@@ -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;
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.jain@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(-)