Commit ab9e1400 authored by Gabriel de Perthuis's avatar Gabriel de Perthuis Committed by Kent Overstreet

bcache: Send label uevents

Signed-off-by: default avatarGabriel de Perthuis <g2p.code@gmail.com>
Signed-off-by: default avatarKent Overstreet <koverstreet@google.com>
parent a25c32be
...@@ -825,12 +825,18 @@ static void calc_cached_dev_sectors(struct cache_set *c) ...@@ -825,12 +825,18 @@ static void calc_cached_dev_sectors(struct cache_set *c)
void bch_cached_dev_run(struct cached_dev *dc) void bch_cached_dev_run(struct cached_dev *dc)
{ {
struct bcache_device *d = &dc->disk; struct bcache_device *d = &dc->disk;
char buf[SB_LABEL_SIZE + 1];
char *env[] = { char *env[] = {
"DRIVER=bcache", "DRIVER=bcache",
kasprintf(GFP_KERNEL, "CACHED_UUID=%pU", dc->sb.uuid), kasprintf(GFP_KERNEL, "CACHED_UUID=%pU", dc->sb.uuid),
NULL NULL,
NULL,
}; };
memcpy(buf, dc->sb.label, SB_LABEL_SIZE);
buf[SB_LABEL_SIZE] = '\0';
env[2] = kasprintf(GFP_KERNEL, "CACHED_LABEL=%s", buf);
if (atomic_xchg(&dc->running, 1)) if (atomic_xchg(&dc->running, 1))
return; return;
...@@ -850,6 +856,7 @@ void bch_cached_dev_run(struct cached_dev *dc) ...@@ -850,6 +856,7 @@ void bch_cached_dev_run(struct cached_dev *dc)
* only class / kset properties are persistent */ * only class / kset properties are persistent */
kobject_uevent_env(&disk_to_dev(d->disk)->kobj, KOBJ_CHANGE, env); kobject_uevent_env(&disk_to_dev(d->disk)->kobj, KOBJ_CHANGE, env);
kfree(env[1]); kfree(env[1]);
kfree(env[2]);
if (sysfs_create_link(&d->kobj, &disk_to_dev(d->disk)->kobj, "dev") || 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")) sysfs_create_link(&disk_to_dev(d->disk)->kobj, &d->kobj, "bcache"))
......
...@@ -178,6 +178,7 @@ STORE(__cached_dev) ...@@ -178,6 +178,7 @@ STORE(__cached_dev)
disk.kobj); disk.kobj);
unsigned v = size; unsigned v = size;
struct cache_set *c; struct cache_set *c;
struct kobj_uevent_env *env;
#define d_strtoul(var) sysfs_strtoul(var, dc->var) #define d_strtoul(var) sysfs_strtoul(var, dc->var)
#define d_strtoi_h(var) sysfs_hatoi(var, dc->var) #define d_strtoi_h(var) sysfs_hatoi(var, dc->var)
...@@ -222,6 +223,7 @@ STORE(__cached_dev) ...@@ -222,6 +223,7 @@ STORE(__cached_dev)
} }
if (attr == &sysfs_label) { if (attr == &sysfs_label) {
/* note: endlines are preserved */
memcpy(dc->sb.label, buf, SB_LABEL_SIZE); memcpy(dc->sb.label, buf, SB_LABEL_SIZE);
bch_write_bdev_super(dc, NULL); bch_write_bdev_super(dc, NULL);
if (dc->disk.c) { if (dc->disk.c) {
...@@ -229,6 +231,13 @@ STORE(__cached_dev) ...@@ -229,6 +231,13 @@ STORE(__cached_dev)
buf, SB_LABEL_SIZE); buf, SB_LABEL_SIZE);
bch_uuid_write(dc->disk.c); bch_uuid_write(dc->disk.c);
} }
env = kzalloc(sizeof(struct kobj_uevent_env), GFP_KERNEL);
add_uevent_var(env, "DRIVER=bcache");
add_uevent_var(env, "CACHED_UUID=%pU", dc->sb.uuid),
add_uevent_var(env, "CACHED_LABEL=%s", buf);
kobject_uevent_env(
&disk_to_dev(dc->disk.disk)->kobj, KOBJ_CHANGE, env->envp);
kfree(env);
} }
if (attr == &sysfs_attach) { if (attr == &sysfs_attach) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment