This patch will be useful when we have to change the context in which we create and destroy sysfs fsid and device kobjects. But this is a good change to have it, as it just does the right thing in general.
Signed-off-by: Anand Jain <anand.j...@oracle.com> --- v2->v3: add missing signed-off, update commit v1->v2: when kobject is already created return EEXIST, not sent to ML fs/btrfs/sysfs.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index f8358d2..6ebbe6c 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -750,10 +750,14 @@ int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs, int error = 0; while (fs_devs) { - init_completion(&fs_devs->kobj_unregister); - fs_devs->super_kobj.kset = btrfs_kset; - error = kobject_init_and_add(&fs_devs->super_kobj, + if (!fs_devs->super_kobj.state_initialized) { + init_completion(&fs_devs->kobj_unregister); + fs_devs->super_kobj.kset = btrfs_kset; + error = kobject_init_and_add(&fs_devs->super_kobj, &btrfs_ktype, parent, "%pU", fs_devs->fsid); + } else { + error = -EEXIST; + } if (!follow_seed) return error; parent = &fs_devs->super_kobj; -- 2.0.0.153.g79dcccc -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html