bcache: Send a uevent with a cached device's UUID
authorGabriel de Perthuis <g2p.code@gmail.com>
Fri, 7 Jun 2013 21:27:01 +0000 (23:27 +0200)
committerKent Overstreet <koverstreet@google.com>
Thu, 27 Jun 2013 04:58:05 +0000 (21:58 -0700)
Signed-off-by: Gabriel de Perthuis <g2p.code@gmail.com>
drivers/md/bcache/super.c

index 8c73f0c7f28a041a595fabf80703db68b8b6aed1..a104dad2c7fac7ce442d2006d72ecb6424087b8a 100644 (file)
@@ -825,6 +825,11 @@ static void calc_cached_dev_sectors(struct cache_set *c)
 void bch_cached_dev_run(struct cached_dev *dc)
 {
        struct bcache_device *d = &dc->disk;
+       char *env[] = {
+               "DRIVER=bcache",
+               kasprintf(GFP_KERNEL, "CACHED_UUID=%pU", dc->sb.uuid),
+               NULL
+       };
 
        if (atomic_xchg(&dc->running, 1))
                return;
@@ -841,10 +846,11 @@ void bch_cached_dev_run(struct cached_dev *dc)
 
        add_disk(d->disk);
        bd_link_disk_holder(dc->bdev, dc->disk.disk);
-#if 0
-       char *env[] = { "SYMLINK=label" , NULL };
+       /* won't show up in the uevent file, use udevadm monitor -e instead
+        * only class / kset properties are persistent */
        kobject_uevent_env(&disk_to_dev(d->disk)->kobj, KOBJ_CHANGE, env);
-#endif
+       kfree(env[1]);
+
        if (sysfs_create_link(&d->kobj, &disk_to_dev(d->disk)->kobj, "dev") ||
            sysfs_create_link(&disk_to_dev(d->disk)->kobj, &d->kobj, "bcache"))
                pr_debug("error creating sysfs link");