linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added
@ 2015-03-09 22:38 Anand Jain
  2015-03-09 22:38 ` [PATCH 01/26] Btrfs: sysfs: fix, btrfs_release_super_kobj() should to clean up the kobject data Anand Jain
                   ` (26 more replies)
  0 siblings, 27 replies; 31+ messages in thread
From: Anand Jain @ 2015-03-09 22:38 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba

This patch set will provide a framework and help to create attributes
from the structure btrfs_fs_devices which are available even before
fs_info is created. So by moving the parent kobject super_kobj from
fs_info to btrfs_fs_devices, it will help to create attributes
from the btrfs_fs_devices as well.
    
Just to note, this does not change any of the existing btrfs sysfs
external kobject names and its attributes and not even the life
cycle of them. Changes are internal only. And to ensure the same,
this path has been tested with various device operations and,
checking and comparing the sysfs kobjects and attributes with
sysfs kobject and attributes with out this patch, and they remain
same. These test cases are added to the progs as test-btrfs-devmgt.sh,
its patch is below as well.

v3->v4:
  . reorders the patches
  . accepts Dave comment
  . needed stale device clean up, introduced patch..
	520353e Btrfs: free the stale device
  . added cleanups to the patch to support seeding in the patch..
	e311d0a Btrfs: sysfs: support seed devices in the sysfs layout v3
  . added support to show replacing target on the sysfs in the patch..
	e210d55 Btrfs: sysfs: add support to show replacing target in the sysfs

v2->v3:
  . added missing signed-off
  . Dave comment
  . there isn't v2 for individual patch, I marked individual patch v3
    where necessary
v1->v2:
  . adds fresh set of patches from 12 to 24 to support seed fsids
  on btrfs sysfs layout and the related frame work changes
  . the patches 1 to 12 has no changes from the previous submit


Anand Jain (26):
  Btrfs: sysfs: fix, btrfs_release_super_kobj() should to clean up the
    kobject data
  Btrfs: sysfs: fix, fs_info kobject_unregister has init_completion()
    twice
  Btrfs: sysfs: fix, undo sysfs device links
  Btrfs: sysfs: fix, kobject pointer clean up needed after kobject
    release
  Btrfc: sysfs: fix, check if device_dir_kobj is init before destroy
  Btrfs: sysfs: reorder the kobject creations
  Btrfs: sysfs: rename __btrfs_sysfs_remove_one to
    btrfs_sysfs_remove_fsid
  Btrfs: sysfs: introduce function btrfs_sysfs_add_fsid() to create
    sysfs fsid
  Btrfs: sysfs: let default_attrs be separate from the kset
  Btrfs: sysfs: separate device kobject and its attribute creation
  Btrfs: sysfs: move super_kobj and device_dir_kobj from fs_info to
    btrfs_fs_devices
  Btrfs: introduce btrfs_get_fs_uuids to get fs_uuids v2
  Btrfs: sysfs: add pointer to access fs_info from fs_devices v2
  Btrfs: sysfs: provide framework to remove all fsid sysfs kobject v2
  Btrfs: sysfs btrfs_kobj_add_device() pass fs_devices instead of
    fs_info
  Btrfs: sysfs btrfs_kobj_rm_device() pass fs_devices instead of fs_info
  Btrfs: sysfs: make btrfs_sysfs_add_fsid() non static
  Btrfs: sysfs: make btrfs_sysfs_add_device() non static
  Btrfs: sysfs: btrfs_sysfs_remove_fsid() make it non static
  Btrfs: sysfs: separate kobject and attribute creation
  Btrfs: sysfs: add support to add parent for fsid
  Btrfs: sysfs: don't fail seeding for the sake of sysfs kobject issue
    v2
  Btrfs: free the stale device
  Btrfs: sysfs: add support to show replacing target in the sysfs
  Btrfs: sysfs: support seed devices in the sysfs layout v3
  Btrfs: create sys/fs/btrfs/fsid when scanned instead of when mounted

 fs/btrfs/ctree.h       |   7 +-
 fs/btrfs/dev-replace.c |   7 +-
 fs/btrfs/disk-io.c     |  26 ++++-
 fs/btrfs/sysfs.c       | 266 +++++++++++++++++++++++++++++++++++++++----------
 fs/btrfs/sysfs.h       |  15 ++-
 fs/btrfs/volumes.c     |  99 +++++++++++++++---
 fs/btrfs/volumes.h     |   9 ++
 7 files changed, 345 insertions(+), 84 deletions(-)

-- 
2.0.0.153.g79dcccc


^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 01/26] Btrfs: sysfs: fix, btrfs_release_super_kobj() should to clean up the kobject data
  2015-03-09 22:38 [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added Anand Jain
@ 2015-03-09 22:38 ` Anand Jain
  2015-03-09 22:38 ` [PATCH 02/26] Btrfs: sysfs: fix, fs_info kobject_unregister has init_completion() twice Anand Jain
                   ` (25 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Anand Jain @ 2015-03-09 22:38 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba

From: Anand Jain <Anand.Jain@oracle.com>

The following test case fails indicating that, thread tried to init an initialized object.

kernel: [232104.016513] kobject (ffff880006c1c980): tried to init an initialized object, something is seriously wrong.

btrfs_sysfs_remove_one() self test code:

open_tree()
{
 ::
        ret = btrfs_sysfs_add_one(fs_info);
	if (ret) {
              pr_err("BTRFS: failed to init sysfs interface: %d\n", ret);
                goto fail_block_groups;
        }
+       btrfs_sysfs_remove_one(fs_info);
+       ret = btrfs_sysfs_add_one(fs_info);
+       if (ret) {
+               pr_err("BTRFS: failed to init sysfs interface: %d\n", ret);
+               goto fail_block_groups;
+       }

cleaning up the unregistered kobject fixes this.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/sysfs.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 92db3f6..68dcd17 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -439,6 +439,8 @@ static struct attribute *btrfs_attrs[] = {
 static void btrfs_release_super_kobj(struct kobject *kobj)
 {
 	struct btrfs_fs_info *fs_info = to_fs_info(kobj);
+
+	memset(&fs_info->super_kobj, 0, sizeof(struct kobject));
 	complete(&fs_info->kobj_unregister);
 }
 
-- 
2.0.0.153.g79dcccc


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 02/26] Btrfs: sysfs: fix, fs_info kobject_unregister has init_completion() twice
  2015-03-09 22:38 [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added Anand Jain
  2015-03-09 22:38 ` [PATCH 01/26] Btrfs: sysfs: fix, btrfs_release_super_kobj() should to clean up the kobject data Anand Jain
@ 2015-03-09 22:38 ` Anand Jain
  2015-03-09 22:38 ` [PATCH 03/26] Btrfs: sysfs: fix, undo sysfs device links Anand Jain
                   ` (24 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Anand Jain @ 2015-03-09 22:38 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba

From: Anand Jain <Anand.Jain@oracle.com>

kobject_unregister is to handle the release of the kobject,
its completion init is being called in btrfs_sysfs_add_one(),
so we don't have to do the same in the open_ctree() again.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/disk-io.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 8c63419..0cd6550 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -2238,7 +2238,6 @@ int open_ctree(struct super_block *sb,
 	mutex_init(&fs_info->delalloc_root_mutex);
 	seqlock_init(&fs_info->profiles_lock);
 
-	init_completion(&fs_info->kobj_unregister);
 	INIT_LIST_HEAD(&fs_info->dirty_cowonly_roots);
 	INIT_LIST_HEAD(&fs_info->space_info);
 	INIT_LIST_HEAD(&fs_info->tree_mod_seq_list);
-- 
2.0.0.153.g79dcccc


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 03/26] Btrfs: sysfs: fix, undo sysfs device links
  2015-03-09 22:38 [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added Anand Jain
  2015-03-09 22:38 ` [PATCH 01/26] Btrfs: sysfs: fix, btrfs_release_super_kobj() should to clean up the kobject data Anand Jain
  2015-03-09 22:38 ` [PATCH 02/26] Btrfs: sysfs: fix, fs_info kobject_unregister has init_completion() twice Anand Jain
@ 2015-03-09 22:38 ` Anand Jain
  2015-03-09 22:38 ` [PATCH 04/26] Btrfs: sysfs: fix, kobject pointer clean up needed after kobject release Anand Jain
                   ` (23 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Anand Jain @ 2015-03-09 22:38 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba

From: Anand Jain <Anand.Jain@oracle.com>

Theoritically need to remove the device links attributes, but since its entire device
kobject was removed, so there wasn't any issue of about it. Just do it nicely.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/sysfs.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 68dcd17..adfac3e 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -522,6 +522,7 @@ void btrfs_sysfs_remove_one(struct btrfs_fs_info *fs_info)
 		kobject_del(fs_info->space_info_kobj);
 		kobject_put(fs_info->space_info_kobj);
 	}
+	btrfs_kobj_rm_device(fs_info, NULL);
 	kobject_del(fs_info->device_dir_kobj);
 	kobject_put(fs_info->device_dir_kobj);
 	addrm_unknown_feature_attrs(fs_info, false);
@@ -604,6 +605,8 @@ static void init_feature_attrs(void)
 	}
 }
 
+/* when one_device is NULL, it removes all device links */
+
 int btrfs_kobj_rm_device(struct btrfs_fs_info *fs_info,
 		struct btrfs_device *one_device)
 {
@@ -621,6 +624,20 @@ int btrfs_kobj_rm_device(struct btrfs_fs_info *fs_info,
 						disk_kobj->name);
 	}
 
+	if (one_device)
+		return 0;
+
+	list_for_each_entry(one_device,
+			&fs_info->fs_devices->devices, dev_list) {
+		if (!one_device->bdev)
+			continue;
+		disk = one_device->bdev->bd_part;
+		disk_kobj = &part_to_dev(disk)->kobj;
+
+		sysfs_remove_link(fs_info->device_dir_kobj,
+						disk_kobj->name);
+	}
+
 	return 0;
 }
 
-- 
2.0.0.153.g79dcccc


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 04/26] Btrfs: sysfs: fix, kobject pointer clean up needed after kobject release
  2015-03-09 22:38 [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added Anand Jain
                   ` (2 preceding siblings ...)
  2015-03-09 22:38 ` [PATCH 03/26] Btrfs: sysfs: fix, undo sysfs device links Anand Jain
@ 2015-03-09 22:38 ` Anand Jain
  2015-03-09 22:38 ` [PATCH 05/26] Btrfc: sysfs: fix, check if device_dir_kobj is init before destroy Anand Jain
                   ` (22 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Anand Jain @ 2015-03-09 22:38 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba

From: Anand Jain <Anand.Jain@oracle.com>

The sysfs clean up self test like in the below code fails, since
fs_info->device_dir_kobject still points to its stale kobject.
Reseting this pointer will help to fix this.

open_ctree()
{

ret = btrfs_sysfs_add_one(fs_info);
::
+       btrfs_sysfs_remove_one(fs_info);
+       ret = btrfs_sysfs_add_one(fs_info);
+       if (ret) {
+               pr_err("BTRFS: failed to init sysfs interface: %d\n", ret);
+               goto fail_block_groups;
+       }

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/sysfs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index adfac3e..15fead2 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -525,6 +525,7 @@ void btrfs_sysfs_remove_one(struct btrfs_fs_info *fs_info)
 	btrfs_kobj_rm_device(fs_info, NULL);
 	kobject_del(fs_info->device_dir_kobj);
 	kobject_put(fs_info->device_dir_kobj);
+	fs_info->device_dir_kobj = NULL;
 	addrm_unknown_feature_attrs(fs_info, false);
 	sysfs_remove_group(&fs_info->super_kobj, &btrfs_feature_attr_group);
 	__btrfs_sysfs_remove_one(fs_info);
-- 
2.0.0.153.g79dcccc


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 05/26] Btrfc: sysfs: fix, check if device_dir_kobj is init before destroy
  2015-03-09 22:38 [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added Anand Jain
                   ` (3 preceding siblings ...)
  2015-03-09 22:38 ` [PATCH 04/26] Btrfs: sysfs: fix, kobject pointer clean up needed after kobject release Anand Jain
@ 2015-03-09 22:38 ` Anand Jain
  2015-03-09 22:38 ` [PATCH 06/26] Btrfs: sysfs: reorder the kobject creations Anand Jain
                   ` (21 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Anand Jain @ 2015-03-09 22:38 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba

From: Anand Jain <Anand.Jain@oracle.com>

Since the failure code in the btrfs_sysfs_add_one() can
call btrfs_sysfs_remove_one() even before device_dir_kobj
has been created we need to check if its null.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/sysfs.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 15fead2..506f7e4 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -522,10 +522,12 @@ void btrfs_sysfs_remove_one(struct btrfs_fs_info *fs_info)
 		kobject_del(fs_info->space_info_kobj);
 		kobject_put(fs_info->space_info_kobj);
 	}
-	btrfs_kobj_rm_device(fs_info, NULL);
-	kobject_del(fs_info->device_dir_kobj);
-	kobject_put(fs_info->device_dir_kobj);
-	fs_info->device_dir_kobj = NULL;
+	if (fs_info->device_dir_kobj) {
+		btrfs_kobj_rm_device(fs_info, NULL);
+		kobject_del(fs_info->device_dir_kobj);
+		kobject_put(fs_info->device_dir_kobj);
+		fs_info->device_dir_kobj = NULL;
+	}
 	addrm_unknown_feature_attrs(fs_info, false);
 	sysfs_remove_group(&fs_info->super_kobj, &btrfs_feature_attr_group);
 	__btrfs_sysfs_remove_one(fs_info);
-- 
2.0.0.153.g79dcccc


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 06/26] Btrfs: sysfs: reorder the kobject creations
  2015-03-09 22:38 [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added Anand Jain
                   ` (4 preceding siblings ...)
  2015-03-09 22:38 ` [PATCH 05/26] Btrfc: sysfs: fix, check if device_dir_kobj is init before destroy Anand Jain
@ 2015-03-09 22:38 ` Anand Jain
  2015-03-09 22:38 ` [PATCH 07/26] Btrfs: sysfs: rename __btrfs_sysfs_remove_one to btrfs_sysfs_remove_fsid Anand Jain
                   ` (20 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Anand Jain @ 2015-03-09 22:38 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba

From: Anand Jain <Anand.Jain@oracle.com>

As of now the order in which the kobjects are created
at btrfs_sysfs_add_one() is..
 fsid
 features
 unknown features (dynamic features)
 devices.

Since we would move fsid and device kobject to fs_devices
from fs_info structure, this patch will reorder in which
the kobjects are created as below.
 fsid
 devices
 features
 unknown features (dynamic features)

And hence the btrfs_sysfs_remove_one() will follow the same
in reverse order. and the device kobject destroy now can
be moved into the function __btrfs_sysfs_remove_one()

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/sysfs.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 506f7e4..c3e7f06 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -510,6 +510,13 @@ static int addrm_unknown_feature_attrs(struct btrfs_fs_info *fs_info, bool add)
 
 static void __btrfs_sysfs_remove_one(struct btrfs_fs_info *fs_info)
 {
+	if (fs_info->device_dir_kobj) {
+		btrfs_kobj_rm_device(fs_info, NULL);
+		kobject_del(fs_info->device_dir_kobj);
+		kobject_put(fs_info->device_dir_kobj);
+		fs_info->device_dir_kobj = NULL;
+	}
+
 	kobject_del(&fs_info->super_kobj);
 	kobject_put(&fs_info->super_kobj);
 	wait_for_completion(&fs_info->kobj_unregister);
@@ -522,12 +529,6 @@ void btrfs_sysfs_remove_one(struct btrfs_fs_info *fs_info)
 		kobject_del(fs_info->space_info_kobj);
 		kobject_put(fs_info->space_info_kobj);
 	}
-	if (fs_info->device_dir_kobj) {
-		btrfs_kobj_rm_device(fs_info, NULL);
-		kobject_del(fs_info->device_dir_kobj);
-		kobject_put(fs_info->device_dir_kobj);
-		fs_info->device_dir_kobj = NULL;
-	}
 	addrm_unknown_feature_attrs(fs_info, false);
 	sysfs_remove_group(&fs_info->super_kobj, &btrfs_feature_attr_group);
 	__btrfs_sysfs_remove_one(fs_info);
@@ -700,6 +701,12 @@ int btrfs_sysfs_add_one(struct btrfs_fs_info *fs_info)
 	if (error)
 		return error;
 
+	error = btrfs_kobj_add_device(fs_info, NULL);
+	if (error) {
+		__btrfs_sysfs_remove_one(fs_info);
+		return error;
+	}
+
 	error = sysfs_create_group(&fs_info->super_kobj,
 				   &btrfs_feature_attr_group);
 	if (error) {
@@ -711,10 +718,6 @@ int btrfs_sysfs_add_one(struct btrfs_fs_info *fs_info)
 	if (error)
 		goto failure;
 
-	error = btrfs_kobj_add_device(fs_info, NULL);
-	if (error)
-		goto failure;
-
 	fs_info->space_info_kobj = kobject_create_and_add("allocation",
 						  &fs_info->super_kobj);
 	if (!fs_info->space_info_kobj) {
-- 
2.0.0.153.g79dcccc


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 07/26] Btrfs: sysfs: rename __btrfs_sysfs_remove_one to btrfs_sysfs_remove_fsid
  2015-03-09 22:38 [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added Anand Jain
                   ` (5 preceding siblings ...)
  2015-03-09 22:38 ` [PATCH 06/26] Btrfs: sysfs: reorder the kobject creations Anand Jain
@ 2015-03-09 22:38 ` Anand Jain
  2015-03-09 22:38 ` [PATCH 08/26] Btrfs: sysfs: introduce function btrfs_sysfs_add_fsid() to create sysfs fsid Anand Jain
                   ` (19 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Anand Jain @ 2015-03-09 22:38 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba

From: Anand Jain <Anand.Jain@oracle.com>

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/sysfs.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index c3e7f06..c923e8b 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -508,7 +508,7 @@ static int addrm_unknown_feature_attrs(struct btrfs_fs_info *fs_info, bool add)
 	return 0;
 }
 
-static void __btrfs_sysfs_remove_one(struct btrfs_fs_info *fs_info)
+static void btrfs_sysfs_remove_fsid(struct btrfs_fs_info *fs_info)
 {
 	if (fs_info->device_dir_kobj) {
 		btrfs_kobj_rm_device(fs_info, NULL);
@@ -531,7 +531,7 @@ void btrfs_sysfs_remove_one(struct btrfs_fs_info *fs_info)
 	}
 	addrm_unknown_feature_attrs(fs_info, false);
 	sysfs_remove_group(&fs_info->super_kobj, &btrfs_feature_attr_group);
-	__btrfs_sysfs_remove_one(fs_info);
+	btrfs_sysfs_remove_fsid(fs_info);
 }
 
 const char * const btrfs_feature_set_names[3] = {
@@ -703,14 +703,14 @@ int btrfs_sysfs_add_one(struct btrfs_fs_info *fs_info)
 
 	error = btrfs_kobj_add_device(fs_info, NULL);
 	if (error) {
-		__btrfs_sysfs_remove_one(fs_info);
+		btrfs_sysfs_remove_fsid(fs_info);
 		return error;
 	}
 
 	error = sysfs_create_group(&fs_info->super_kobj,
 				   &btrfs_feature_attr_group);
 	if (error) {
-		__btrfs_sysfs_remove_one(fs_info);
+		btrfs_sysfs_remove_fsid(fs_info);
 		return error;
 	}
 
-- 
2.0.0.153.g79dcccc


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 08/26] Btrfs: sysfs: introduce function btrfs_sysfs_add_fsid() to create sysfs fsid
  2015-03-09 22:38 [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added Anand Jain
                   ` (6 preceding siblings ...)
  2015-03-09 22:38 ` [PATCH 07/26] Btrfs: sysfs: rename __btrfs_sysfs_remove_one to btrfs_sysfs_remove_fsid Anand Jain
@ 2015-03-09 22:38 ` Anand Jain
  2015-03-09 22:38 ` [PATCH 09/26] Btrfs: sysfs: let default_attrs be separate from the kset Anand Jain
                   ` (18 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Anand Jain @ 2015-03-09 22:38 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba

From: Anand Jain <Anand.Jain@oracle.com>

We need it in a seperate function so that it can be called from the
device discovery thread as well.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/sysfs.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index c923e8b..f42d8fd 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -690,7 +690,12 @@ static struct dentry *btrfs_debugfs_root_dentry;
 /* Debugging tunables and exported data */
 u64 btrfs_debugfs_test;
 
-int btrfs_sysfs_add_one(struct btrfs_fs_info *fs_info)
+/*
+ * Can be called by the device discovery thread.
+ * And parent can be specified for seed device
+ */
+int btrfs_sysfs_add_fsid(struct btrfs_fs_info *fs_info,
+				struct kobject *parent)
 {
 	int error;
 
@@ -698,6 +703,14 @@ int btrfs_sysfs_add_one(struct btrfs_fs_info *fs_info)
 	fs_info->super_kobj.kset = btrfs_kset;
 	error = kobject_init_and_add(&fs_info->super_kobj, &btrfs_ktype, NULL,
 				     "%pU", fs_info->fsid);
+	return error;
+}
+
+int btrfs_sysfs_add_one(struct btrfs_fs_info *fs_info)
+{
+	int error;
+
+	error = btrfs_sysfs_add_fsid(fs_info, NULL);
 	if (error)
 		return error;
 
-- 
2.0.0.153.g79dcccc


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 09/26] Btrfs: sysfs: let default_attrs be separate from the kset
  2015-03-09 22:38 [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added Anand Jain
                   ` (7 preceding siblings ...)
  2015-03-09 22:38 ` [PATCH 08/26] Btrfs: sysfs: introduce function btrfs_sysfs_add_fsid() to create sysfs fsid Anand Jain
@ 2015-03-09 22:38 ` Anand Jain
  2015-03-09 22:38 ` [PATCH 10/26] Btrfs: sysfs: separate device kobject and its attribute creation Anand Jain
                   ` (17 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Anand Jain @ 2015-03-09 22:38 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba

From: Anand Jain <Anand.Jain@oracle.com>

As of now btrfs_attrs are provided using the default_attrs through
the kset. Separate them and create the default_attrs using the
sysfs_create_files instead. By doing this we will have the
flexibility that device discovery thread could create fsid
kobject.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/sysfs.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index f42d8fd..5208a49 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -428,7 +428,7 @@ static ssize_t btrfs_clone_alignment_show(struct kobject *kobj,
 
 BTRFS_ATTR(clone_alignment, btrfs_clone_alignment_show);
 
-static struct attribute *btrfs_attrs[] = {
+static const struct attribute *btrfs_attrs[] = {
 	BTRFS_ATTR_PTR(label),
 	BTRFS_ATTR_PTR(nodesize),
 	BTRFS_ATTR_PTR(sectorsize),
@@ -447,7 +447,6 @@ static void btrfs_release_super_kobj(struct kobject *kobj)
 static struct kobj_type btrfs_ktype = {
 	.sysfs_ops	= &kobj_sysfs_ops,
 	.release	= btrfs_release_super_kobj,
-	.default_attrs	= btrfs_attrs,
 };
 
 static inline struct btrfs_fs_info *to_fs_info(struct kobject *kobj)
@@ -531,6 +530,7 @@ void btrfs_sysfs_remove_one(struct btrfs_fs_info *fs_info)
 	}
 	addrm_unknown_feature_attrs(fs_info, false);
 	sysfs_remove_group(&fs_info->super_kobj, &btrfs_feature_attr_group);
+	sysfs_remove_files(&fs_info->super_kobj, btrfs_attrs);
 	btrfs_sysfs_remove_fsid(fs_info);
 }
 
@@ -720,13 +720,17 @@ int btrfs_sysfs_add_one(struct btrfs_fs_info *fs_info)
 		return error;
 	}
 
-	error = sysfs_create_group(&fs_info->super_kobj,
-				   &btrfs_feature_attr_group);
+	error = sysfs_create_files(&fs_info->super_kobj, btrfs_attrs);
 	if (error) {
 		btrfs_sysfs_remove_fsid(fs_info);
 		return error;
 	}
 
+	error = sysfs_create_group(&fs_info->super_kobj,
+				   &btrfs_feature_attr_group);
+	if (error)
+		goto failure;
+
 	error = addrm_unknown_feature_attrs(fs_info, true);
 	if (error)
 		goto failure;
-- 
2.0.0.153.g79dcccc


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 10/26] Btrfs: sysfs: separate device kobject and its attribute creation
  2015-03-09 22:38 [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added Anand Jain
                   ` (8 preceding siblings ...)
  2015-03-09 22:38 ` [PATCH 09/26] Btrfs: sysfs: let default_attrs be separate from the kset Anand Jain
@ 2015-03-09 22:38 ` Anand Jain
  2015-03-09 22:38 ` [PATCH 11/26] Btrfs: sysfs: move super_kobj and device_dir_kobj from fs_info to btrfs_fs_devices Anand Jain
                   ` (16 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Anand Jain @ 2015-03-09 22:38 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba

From: Anand Jain <Anand.Jain@oracle.com>

Separate device kobject and its attribute creation so that device
kobject can be created from the device discovery thread.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/sysfs.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 5208a49..2cb4c69 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -645,13 +645,8 @@ int btrfs_kobj_rm_device(struct btrfs_fs_info *fs_info,
 	return 0;
 }
 
-int btrfs_kobj_add_device(struct btrfs_fs_info *fs_info,
-		struct btrfs_device *one_device)
+int btrfs_sysfs_add_device(struct btrfs_fs_info *fs_info)
 {
-	int error = 0;
-	struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
-	struct btrfs_device *dev;
-
 	if (!fs_info->device_dir_kobj)
 		fs_info->device_dir_kobj = kobject_create_and_add("devices",
 						&fs_info->super_kobj);
@@ -659,6 +654,20 @@ int btrfs_kobj_add_device(struct btrfs_fs_info *fs_info,
 	if (!fs_info->device_dir_kobj)
 		return -ENOMEM;
 
+	return 0;
+}
+
+int btrfs_kobj_add_device(struct btrfs_fs_info *fs_info,
+		struct btrfs_device *one_device)
+{
+	int error = 0;
+	struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
+	struct btrfs_device *dev;
+
+	error = btrfs_sysfs_add_device(fs_info);
+	if (error)
+		return error;
+
 	list_for_each_entry(dev, &fs_devices->devices, dev_list) {
 		struct hd_struct *disk;
 		struct kobject *disk_kobj;
-- 
2.0.0.153.g79dcccc


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 11/26] Btrfs: sysfs: move super_kobj and device_dir_kobj from fs_info to btrfs_fs_devices
  2015-03-09 22:38 [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added Anand Jain
                   ` (9 preceding siblings ...)
  2015-03-09 22:38 ` [PATCH 10/26] Btrfs: sysfs: separate device kobject and its attribute creation Anand Jain
@ 2015-03-09 22:38 ` Anand Jain
  2015-03-09 22:38 ` [PATCH 12/26] Btrfs: introduce btrfs_get_fs_uuids to get fs_uuids v2 Anand Jain
                   ` (15 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Anand Jain @ 2015-03-09 22:38 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba

From: Anand Jain <Anand.Jain@oracle.com>

This patch will provide a framework and help to create attributes
from the structure btrfs_fs_devices which are available even before
fs_info is created. So by moving the parent kobject super_kobj from
fs_info to btrfs_fs_devices, it will help to create attributes
from the btrfs_fs_devices as well.

Patches on top of this patch now will be able to create the
sys/fs/btrfs/fsid kobject and attributes from btrfs_fs_devices
when devices are scanned and registered to the kernel.

Just to note, this does not change any of the existing btrfs sysfs
external kobject names and its attributes and not even the life
cycle of them. Changes are internal only. And to ensure the same,
this path has been tested with various device operations and,
checking and comparing the sysfs kobjects and attributes with
sysfs kobject and attributes with out this patch, and they remain
same.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/ctree.h   |  3 --
 fs/btrfs/sysfs.c   | 88 ++++++++++++++++++++++++++++++------------------------
 fs/btrfs/volumes.c |  3 +-
 fs/btrfs/volumes.h |  5 ++++
 4 files changed, 56 insertions(+), 43 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 7e60741..9493b91 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -1580,10 +1580,7 @@ struct btrfs_fs_info {
 	struct task_struct *cleaner_kthread;
 	int thread_pool_size;
 
-	struct kobject super_kobj;
 	struct kobject *space_info_kobj;
-	struct kobject *device_dir_kobj;
-	struct completion kobj_unregister;
 	int do_barriers;
 	int closing;
 	int log_root_recovering;
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 2cb4c69..ac15fbb 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -33,6 +33,7 @@
 #include "volumes.h"
 
 static inline struct btrfs_fs_info *to_fs_info(struct kobject *kobj);
+static inline struct btrfs_fs_devices *to_fs_devs(struct kobject *kobj);
 
 static u64 get_features(struct btrfs_fs_info *fs_info,
 			enum btrfs_feature_set set)
@@ -438,10 +439,10 @@ static const struct attribute *btrfs_attrs[] = {
 
 static void btrfs_release_super_kobj(struct kobject *kobj)
 {
-	struct btrfs_fs_info *fs_info = to_fs_info(kobj);
+	struct btrfs_fs_devices *fs_devs = to_fs_devs(kobj);
 
-	memset(&fs_info->super_kobj, 0, sizeof(struct kobject));
-	complete(&fs_info->kobj_unregister);
+	memset(&fs_devs->super_kobj, 0, sizeof(struct kobject));
+	complete(&fs_devs->kobj_unregister);
 }
 
 static struct kobj_type btrfs_ktype = {
@@ -449,11 +450,18 @@ static struct kobj_type btrfs_ktype = {
 	.release	= btrfs_release_super_kobj,
 };
 
+static inline struct btrfs_fs_devices *to_fs_devs(struct kobject *kobj)
+{
+	if (kobj->ktype != &btrfs_ktype)
+		return NULL;
+	return container_of(kobj, struct btrfs_fs_devices, super_kobj);
+}
+
 static inline struct btrfs_fs_info *to_fs_info(struct kobject *kobj)
 {
 	if (kobj->ktype != &btrfs_ktype)
 		return NULL;
-	return container_of(kobj, struct btrfs_fs_info, super_kobj);
+	return to_fs_devs(kobj)->fs_info;
 }
 
 #define NUM_FEATURE_BITS 64
@@ -494,12 +502,12 @@ static int addrm_unknown_feature_attrs(struct btrfs_fs_info *fs_info, bool add)
 			attrs[0] = &fa->kobj_attr.attr;
 			if (add) {
 				int ret;
-				ret = sysfs_merge_group(&fs_info->super_kobj,
+				ret = sysfs_merge_group(&fs_info->fs_devices->super_kobj,
 							&agroup);
 				if (ret)
 					return ret;
 			} else
-				sysfs_unmerge_group(&fs_info->super_kobj,
+				sysfs_unmerge_group(&fs_info->fs_devices->super_kobj,
 						    &agroup);
 		}
 
@@ -507,18 +515,17 @@ static int addrm_unknown_feature_attrs(struct btrfs_fs_info *fs_info, bool add)
 	return 0;
 }
 
-static void btrfs_sysfs_remove_fsid(struct btrfs_fs_info *fs_info)
+static void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs)
 {
-	if (fs_info->device_dir_kobj) {
-		btrfs_kobj_rm_device(fs_info, NULL);
-		kobject_del(fs_info->device_dir_kobj);
-		kobject_put(fs_info->device_dir_kobj);
-		fs_info->device_dir_kobj = NULL;
+	if (fs_devs->device_dir_kobj) {
+		kobject_del(fs_devs->device_dir_kobj);
+		kobject_put(fs_devs->device_dir_kobj);
+		fs_devs->device_dir_kobj = NULL;
 	}
 
-	kobject_del(&fs_info->super_kobj);
-	kobject_put(&fs_info->super_kobj);
-	wait_for_completion(&fs_info->kobj_unregister);
+	kobject_del(&fs_devs->super_kobj);
+	kobject_put(&fs_devs->super_kobj);
+	wait_for_completion(&fs_devs->kobj_unregister);
 }
 
 void btrfs_sysfs_remove_one(struct btrfs_fs_info *fs_info)
@@ -529,9 +536,10 @@ void btrfs_sysfs_remove_one(struct btrfs_fs_info *fs_info)
 		kobject_put(fs_info->space_info_kobj);
 	}
 	addrm_unknown_feature_attrs(fs_info, false);
-	sysfs_remove_group(&fs_info->super_kobj, &btrfs_feature_attr_group);
-	sysfs_remove_files(&fs_info->super_kobj, btrfs_attrs);
-	btrfs_sysfs_remove_fsid(fs_info);
+	sysfs_remove_group(&fs_info->fs_devices->super_kobj, &btrfs_feature_attr_group);
+	sysfs_remove_files(&fs_info->fs_devices->super_kobj, btrfs_attrs);
+	btrfs_kobj_rm_device(fs_info, NULL);
+	btrfs_sysfs_remove_fsid(fs_info->fs_devices);
 }
 
 const char * const btrfs_feature_set_names[3] = {
@@ -617,14 +625,14 @@ int btrfs_kobj_rm_device(struct btrfs_fs_info *fs_info,
 	struct hd_struct *disk;
 	struct kobject *disk_kobj;
 
-	if (!fs_info->device_dir_kobj)
+	if (!fs_info->fs_devices->device_dir_kobj)
 		return -EINVAL;
 
 	if (one_device && one_device->bdev) {
 		disk = one_device->bdev->bd_part;
 		disk_kobj = &part_to_dev(disk)->kobj;
 
-		sysfs_remove_link(fs_info->device_dir_kobj,
+		sysfs_remove_link(fs_info->fs_devices->device_dir_kobj,
 						disk_kobj->name);
 	}
 
@@ -638,20 +646,20 @@ int btrfs_kobj_rm_device(struct btrfs_fs_info *fs_info,
 		disk = one_device->bdev->bd_part;
 		disk_kobj = &part_to_dev(disk)->kobj;
 
-		sysfs_remove_link(fs_info->device_dir_kobj,
+		sysfs_remove_link(fs_info->fs_devices->device_dir_kobj,
 						disk_kobj->name);
 	}
 
 	return 0;
 }
 
-int btrfs_sysfs_add_device(struct btrfs_fs_info *fs_info)
+int btrfs_sysfs_add_device(struct btrfs_fs_devices *fs_devs)
 {
-	if (!fs_info->device_dir_kobj)
-		fs_info->device_dir_kobj = kobject_create_and_add("devices",
-						&fs_info->super_kobj);
+	if (!fs_devs->device_dir_kobj)
+		fs_devs->device_dir_kobj = kobject_create_and_add("devices",
+						&fs_devs->super_kobj);
 
-	if (!fs_info->device_dir_kobj)
+	if (!fs_devs->device_dir_kobj)
 		return -ENOMEM;
 
 	return 0;
@@ -664,7 +672,7 @@ int btrfs_kobj_add_device(struct btrfs_fs_info *fs_info,
 	struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
 	struct btrfs_device *dev;
 
-	error = btrfs_sysfs_add_device(fs_info);
+	error = btrfs_sysfs_add_device(fs_devices);
 	if (error)
 		return error;
 
@@ -681,7 +689,7 @@ int btrfs_kobj_add_device(struct btrfs_fs_info *fs_info,
 		disk = dev->bdev->bd_part;
 		disk_kobj = &part_to_dev(disk)->kobj;
 
-		error = sysfs_create_link(fs_info->device_dir_kobj,
+		error = sysfs_create_link(fs_devices->device_dir_kobj,
 					  disk_kobj, disk_kobj->name);
 		if (error)
 			break;
@@ -703,39 +711,41 @@ u64 btrfs_debugfs_test;
  * Can be called by the device discovery thread.
  * And parent can be specified for seed device
  */
-int btrfs_sysfs_add_fsid(struct btrfs_fs_info *fs_info,
+static int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs,
 				struct kobject *parent)
 {
 	int error;
 
-	init_completion(&fs_info->kobj_unregister);
-	fs_info->super_kobj.kset = btrfs_kset;
-	error = kobject_init_and_add(&fs_info->super_kobj, &btrfs_ktype, NULL,
-				     "%pU", fs_info->fsid);
+	init_completion(&fs_devs->kobj_unregister);
+	fs_devs->super_kobj.kset = btrfs_kset;
+	error = kobject_init_and_add(&fs_devs->super_kobj, &btrfs_ktype, NULL,
+				     "%pU", fs_devs->fsid);
 	return error;
 }
 
 int btrfs_sysfs_add_one(struct btrfs_fs_info *fs_info)
 {
 	int error;
+	struct btrfs_fs_devices *fs_devs = fs_info->fs_devices;
+	struct kobject *super_kobj = &fs_devs->super_kobj;
 
-	error = btrfs_sysfs_add_fsid(fs_info, NULL);
+	error = btrfs_sysfs_add_fsid(fs_devs, NULL);
 	if (error)
 		return error;
 
 	error = btrfs_kobj_add_device(fs_info, NULL);
 	if (error) {
-		btrfs_sysfs_remove_fsid(fs_info);
+		btrfs_sysfs_remove_fsid(fs_devs);
 		return error;
 	}
 
-	error = sysfs_create_files(&fs_info->super_kobj, btrfs_attrs);
+	error = sysfs_create_files(super_kobj, btrfs_attrs);
 	if (error) {
-		btrfs_sysfs_remove_fsid(fs_info);
+		btrfs_sysfs_remove_fsid(fs_devs);
 		return error;
 	}
 
-	error = sysfs_create_group(&fs_info->super_kobj,
+	error = sysfs_create_group(super_kobj,
 				   &btrfs_feature_attr_group);
 	if (error)
 		goto failure;
@@ -745,7 +755,7 @@ int btrfs_sysfs_add_one(struct btrfs_fs_info *fs_info)
 		goto failure;
 
 	fs_info->space_info_kobj = kobject_create_and_add("allocation",
-						  &fs_info->super_kobj);
+						  super_kobj);
 	if (!fs_info->space_info_kobj) {
 		error = -ENOMEM;
 		goto failure;
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 0144790..218a14a 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2243,7 +2243,8 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
 		 */
 		snprintf(fsid_buf, BTRFS_UUID_UNPARSED_SIZE, "%pU",
 						root->fs_info->fsid);
-		if (kobject_rename(&root->fs_info->super_kobj, fsid_buf))
+		if (kobject_rename(&root->fs_info->fs_devices->super_kobj,
+								fsid_buf))
 			goto error_trans;
 	}
 
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
index d6fe73c..c2e5bd0 100644
--- a/fs/btrfs/volumes.h
+++ b/fs/btrfs/volumes.h
@@ -253,6 +253,11 @@ struct btrfs_fs_devices {
 	 * nonrot flag set
 	 */
 	int rotating;
+
+	/* sysfs kobjects */
+	struct kobject super_kobj;
+	struct kobject *device_dir_kobj;
+	struct completion kobj_unregister;
 };
 
 #define BTRFS_BIO_INLINE_CSUM_SIZE	64
-- 
2.0.0.153.g79dcccc


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 12/26] Btrfs: introduce btrfs_get_fs_uuids to get fs_uuids v2
  2015-03-09 22:38 [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added Anand Jain
                   ` (10 preceding siblings ...)
  2015-03-09 22:38 ` [PATCH 11/26] Btrfs: sysfs: move super_kobj and device_dir_kobj from fs_info to btrfs_fs_devices Anand Jain
@ 2015-03-09 22:38 ` Anand Jain
  2015-03-09 22:38 ` [PATCH 13/26] Btrfs: sysfs: add pointer to access fs_info from fs_devices v2 Anand Jain
                   ` (14 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Anand Jain @ 2015-03-09 22:38 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba

v2: commit update
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/volumes.c | 4 ++++
 fs/btrfs/volumes.h | 1 +
 2 files changed, 5 insertions(+)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 218a14a..c1b1038 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -52,6 +52,10 @@ static void btrfs_dev_stat_print_on_load(struct btrfs_device *device);
 
 DEFINE_MUTEX(uuid_mutex);
 static LIST_HEAD(fs_uuids);
+struct list_head *btrfs_get_fs_uuids(void)
+{
+	return &fs_uuids;
+}
 
 static struct btrfs_fs_devices *__alloc_fs_devices(void)
 {
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
index c2e5bd0..d4586ac 100644
--- a/fs/btrfs/volumes.h
+++ b/fs/btrfs/volumes.h
@@ -539,5 +539,6 @@ static inline void unlock_chunks(struct btrfs_root *root)
 	mutex_unlock(&root->fs_info->chunk_mutex);
 }
 
+struct list_head *btrfs_get_fs_uuids(void);
 
 #endif
-- 
2.0.0.153.g79dcccc


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 13/26] Btrfs: sysfs: add pointer to access fs_info from fs_devices v2
  2015-03-09 22:38 [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added Anand Jain
                   ` (11 preceding siblings ...)
  2015-03-09 22:38 ` [PATCH 12/26] Btrfs: introduce btrfs_get_fs_uuids to get fs_uuids v2 Anand Jain
@ 2015-03-09 22:38 ` Anand Jain
  2015-03-09 22:38 ` [PATCH 14/26] Btrfs: sysfs: provide framework to remove all fsid sysfs kobject v2 Anand Jain
                   ` (13 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Anand Jain @ 2015-03-09 22:38 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba

From: Anand Jain <Anand.Jain@oracle.com>

adds fs_info pointer with struct btrfs_fs_devices.

v2: Fix a bug:d update fs_info pointer in open_seed_devices()

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/sysfs.c   |  4 ++++
 fs/btrfs/volumes.c | 18 ++++++++++++++++++
 fs/btrfs/volumes.h |  3 +++
 3 files changed, 25 insertions(+)

diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index ac15fbb..95d6257 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -530,6 +530,8 @@ static void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs)
 
 void btrfs_sysfs_remove_one(struct btrfs_fs_info *fs_info)
 {
+	btrfs_reset_fs_info_ptr(fs_info);
+
 	if (fs_info->space_info_kobj) {
 		sysfs_remove_files(fs_info->space_info_kobj, allocation_attrs);
 		kobject_del(fs_info->space_info_kobj);
@@ -729,6 +731,8 @@ int btrfs_sysfs_add_one(struct btrfs_fs_info *fs_info)
 	struct btrfs_fs_devices *fs_devs = fs_info->fs_devices;
 	struct kobject *super_kobj = &fs_devs->super_kobj;
 
+	btrfs_set_fs_info_ptr(fs_info);
+
 	error = btrfs_sysfs_add_fsid(fs_devs, NULL);
 	if (error)
 		return error;
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index c1b1038..033e56a 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -6688,3 +6688,21 @@ void btrfs_update_commit_device_bytes_used(struct btrfs_root *root,
 	}
 	unlock_chunks(root);
 }
+
+void btrfs_set_fs_info_ptr(struct btrfs_fs_info *fs_info)
+{
+	struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
+	while (fs_devices) {
+		fs_devices->fs_info = fs_info;
+		fs_devices = fs_devices->seed;
+	}
+}
+
+void btrfs_reset_fs_info_ptr(struct btrfs_fs_info *fs_info)
+{
+	struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
+	while (fs_devices) {
+		fs_devices->fs_info = NULL;
+		fs_devices = fs_devices->seed;
+	}
+}
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
index d4586ac..e6514c7 100644
--- a/fs/btrfs/volumes.h
+++ b/fs/btrfs/volumes.h
@@ -254,6 +254,7 @@ struct btrfs_fs_devices {
 	 */
 	int rotating;
 
+	struct btrfs_fs_info *fs_info;
 	/* sysfs kobjects */
 	struct kobject super_kobj;
 	struct kobject *device_dir_kobj;
@@ -540,5 +541,7 @@ static inline void unlock_chunks(struct btrfs_root *root)
 }
 
 struct list_head *btrfs_get_fs_uuids(void);
+void btrfs_set_fs_info_ptr(struct btrfs_fs_info *fs_info);
+void btrfs_reset_fs_info_ptr(struct btrfs_fs_info *fs_info);
 
 #endif
-- 
2.0.0.153.g79dcccc


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 14/26] Btrfs: sysfs: provide framework to remove all fsid sysfs kobject v2
  2015-03-09 22:38 [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added Anand Jain
                   ` (12 preceding siblings ...)
  2015-03-09 22:38 ` [PATCH 13/26] Btrfs: sysfs: add pointer to access fs_info from fs_devices v2 Anand Jain
@ 2015-03-09 22:38 ` Anand Jain
  2015-03-09 22:38 ` [PATCH 15/26] Btrfs: sysfs btrfs_kobj_add_device() pass fs_devices instead of fs_info Anand Jain
                   ` (12 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Anand Jain @ 2015-03-09 22:38 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba

just a helper function to clean up the sysfs fsid kobjects

v2: update commit
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/sysfs.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 95d6257..a8ee136 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -515,7 +515,7 @@ static int addrm_unknown_feature_attrs(struct btrfs_fs_info *fs_info, bool add)
 	return 0;
 }
 
-static void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs)
+static void __btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs)
 {
 	if (fs_devs->device_dir_kobj) {
 		kobject_del(fs_devs->device_dir_kobj);
@@ -528,6 +528,21 @@ static void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs)
 	wait_for_completion(&fs_devs->kobj_unregister);
 }
 
+/* when fs_devs is NULL it will remove all fsid kobject */
+static void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs)
+{
+	struct list_head *fs_uuids = btrfs_get_fs_uuids();
+
+	if (fs_devs) {
+		__btrfs_sysfs_remove_fsid(fs_devs);
+		return;
+	}
+
+	list_for_each_entry(fs_devs, fs_uuids, list) {
+		__btrfs_sysfs_remove_fsid(fs_devs);
+	}
+}
+
 void btrfs_sysfs_remove_one(struct btrfs_fs_info *fs_info)
 {
 	btrfs_reset_fs_info_ptr(fs_info);
-- 
2.0.0.153.g79dcccc


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 15/26] Btrfs: sysfs btrfs_kobj_add_device() pass fs_devices instead of fs_info
  2015-03-09 22:38 [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added Anand Jain
                   ` (13 preceding siblings ...)
  2015-03-09 22:38 ` [PATCH 14/26] Btrfs: sysfs: provide framework to remove all fsid sysfs kobject v2 Anand Jain
@ 2015-03-09 22:38 ` Anand Jain
  2015-03-09 22:38 ` [PATCH 16/26] Btrfs: sysfs btrfs_kobj_rm_device() " Anand Jain
                   ` (11 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Anand Jain @ 2015-03-09 22:38 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba

btrfs_kobj_add_device() does not need fs_info any more.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/dev-replace.c | 2 +-
 fs/btrfs/sysfs.c       | 7 +++----
 fs/btrfs/sysfs.h       | 2 +-
 fs/btrfs/volumes.c     | 2 +-
 4 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index ca6a3a3..2acc0aa 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -593,7 +593,7 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
 
 	/* replace the sysfs entry */
 	btrfs_kobj_rm_device(fs_info, src_device);
-	btrfs_kobj_add_device(fs_info, tgt_device);
+	btrfs_kobj_add_device(fs_info->fs_devices, tgt_device);
 	btrfs_rm_dev_replace_free_srcdev(fs_info, src_device);
 
 	/* write back the superblocks */
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index a8ee136..76afc96 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -682,11 +682,10 @@ int btrfs_sysfs_add_device(struct btrfs_fs_devices *fs_devs)
 	return 0;
 }
 
-int btrfs_kobj_add_device(struct btrfs_fs_info *fs_info,
-		struct btrfs_device *one_device)
+int btrfs_kobj_add_device(struct btrfs_fs_devices *fs_devices,
+				struct btrfs_device *one_device)
 {
 	int error = 0;
-	struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
 	struct btrfs_device *dev;
 
 	error = btrfs_sysfs_add_device(fs_devices);
@@ -752,7 +751,7 @@ int btrfs_sysfs_add_one(struct btrfs_fs_info *fs_info)
 	if (error)
 		return error;
 
-	error = btrfs_kobj_add_device(fs_info, NULL);
+	error = btrfs_kobj_add_device(fs_devs, NULL);
 	if (error) {
 		btrfs_sysfs_remove_fsid(fs_devs);
 		return error;
diff --git a/fs/btrfs/sysfs.h b/fs/btrfs/sysfs.h
index f7dd298..eeb86a8 100644
--- a/fs/btrfs/sysfs.h
+++ b/fs/btrfs/sysfs.h
@@ -70,7 +70,7 @@ char *btrfs_printable_features(enum btrfs_feature_set set, u64 flags);
 extern const char * const btrfs_feature_set_names[3];
 extern struct kobj_type space_info_ktype;
 extern struct kobj_type btrfs_raid_ktype;
-int btrfs_kobj_add_device(struct btrfs_fs_info *fs_info,
+int btrfs_kobj_add_device(struct btrfs_fs_devices *fs_devices,
 		struct btrfs_device *one_device);
 int btrfs_kobj_rm_device(struct btrfs_fs_info *fs_info,
                 struct btrfs_device *one_device);
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 033e56a..ee318af 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2206,7 +2206,7 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
 				    tmp + 1);
 
 	/* add sysfs device entry */
-	btrfs_kobj_add_device(root->fs_info, device);
+	btrfs_kobj_add_device(root->fs_info->fs_devices, device);
 
 	/*
 	 * we've got more storage, clear any full flags on the space
-- 
2.0.0.153.g79dcccc


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 16/26] Btrfs: sysfs btrfs_kobj_rm_device() pass fs_devices instead of fs_info
  2015-03-09 22:38 [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added Anand Jain
                   ` (14 preceding siblings ...)
  2015-03-09 22:38 ` [PATCH 15/26] Btrfs: sysfs btrfs_kobj_add_device() pass fs_devices instead of fs_info Anand Jain
@ 2015-03-09 22:38 ` Anand Jain
  2015-03-09 22:38 ` [PATCH 17/26] Btrfs: sysfs: make btrfs_sysfs_add_fsid() non static Anand Jain
                   ` (10 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Anand Jain @ 2015-03-09 22:38 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba

since btrfs_kobj_rm_device() does nothing with fs_info

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/dev-replace.c |  2 +-
 fs/btrfs/sysfs.c       | 12 ++++++------
 fs/btrfs/sysfs.h       |  2 +-
 fs/btrfs/volumes.c     |  4 ++--
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index 2acc0aa..124b60f 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -592,7 +592,7 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
 	mutex_unlock(&uuid_mutex);
 
 	/* replace the sysfs entry */
-	btrfs_kobj_rm_device(fs_info, src_device);
+	btrfs_kobj_rm_device(fs_info->fs_devices, src_device);
 	btrfs_kobj_add_device(fs_info->fs_devices, tgt_device);
 	btrfs_rm_dev_replace_free_srcdev(fs_info, src_device);
 
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 76afc96..5055809 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -555,7 +555,7 @@ void btrfs_sysfs_remove_one(struct btrfs_fs_info *fs_info)
 	addrm_unknown_feature_attrs(fs_info, false);
 	sysfs_remove_group(&fs_info->fs_devices->super_kobj, &btrfs_feature_attr_group);
 	sysfs_remove_files(&fs_info->fs_devices->super_kobj, btrfs_attrs);
-	btrfs_kobj_rm_device(fs_info, NULL);
+	btrfs_kobj_rm_device(fs_info->fs_devices, NULL);
 	btrfs_sysfs_remove_fsid(fs_info->fs_devices);
 }
 
@@ -636,20 +636,20 @@ static void init_feature_attrs(void)
 
 /* when one_device is NULL, it removes all device links */
 
-int btrfs_kobj_rm_device(struct btrfs_fs_info *fs_info,
+int btrfs_kobj_rm_device(struct btrfs_fs_devices *fs_devices,
 		struct btrfs_device *one_device)
 {
 	struct hd_struct *disk;
 	struct kobject *disk_kobj;
 
-	if (!fs_info->fs_devices->device_dir_kobj)
+	if (!fs_devices->device_dir_kobj)
 		return -EINVAL;
 
 	if (one_device && one_device->bdev) {
 		disk = one_device->bdev->bd_part;
 		disk_kobj = &part_to_dev(disk)->kobj;
 
-		sysfs_remove_link(fs_info->fs_devices->device_dir_kobj,
+		sysfs_remove_link(fs_devices->device_dir_kobj,
 						disk_kobj->name);
 	}
 
@@ -657,13 +657,13 @@ int btrfs_kobj_rm_device(struct btrfs_fs_info *fs_info,
 		return 0;
 
 	list_for_each_entry(one_device,
-			&fs_info->fs_devices->devices, dev_list) {
+			&fs_devices->devices, dev_list) {
 		if (!one_device->bdev)
 			continue;
 		disk = one_device->bdev->bd_part;
 		disk_kobj = &part_to_dev(disk)->kobj;
 
-		sysfs_remove_link(fs_info->fs_devices->device_dir_kobj,
+		sysfs_remove_link(fs_devices->device_dir_kobj,
 						disk_kobj->name);
 	}
 
diff --git a/fs/btrfs/sysfs.h b/fs/btrfs/sysfs.h
index eeb86a8..3938ac1 100644
--- a/fs/btrfs/sysfs.h
+++ b/fs/btrfs/sysfs.h
@@ -72,6 +72,6 @@ extern struct kobj_type space_info_ktype;
 extern struct kobj_type btrfs_raid_ktype;
 int btrfs_kobj_add_device(struct btrfs_fs_devices *fs_devices,
 		struct btrfs_device *one_device);
-int btrfs_kobj_rm_device(struct btrfs_fs_info *fs_info,
+int btrfs_kobj_rm_device(struct btrfs_fs_devices *fs_devices,
                 struct btrfs_device *one_device);
 #endif /* _BTRFS_SYSFS_H_ */
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index ee318af..549f978 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1701,7 +1701,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
 	if (device->bdev) {
 		device->fs_devices->open_devices--;
 		/* remove sysfs entry */
-		btrfs_kobj_rm_device(root->fs_info, device);
+		btrfs_kobj_rm_device(root->fs_info->fs_devices, device);
 	}
 
 	call_rcu(&device->rcu, free_device);
@@ -2285,7 +2285,7 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
 error_trans:
 	btrfs_end_transaction(trans, root);
 	rcu_string_free(device->name);
-	btrfs_kobj_rm_device(root->fs_info, device);
+	btrfs_kobj_rm_device(root->fs_info->fs_devices, device);
 	kfree(device);
 error:
 	blkdev_put(bdev, FMODE_EXCL);
-- 
2.0.0.153.g79dcccc


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 17/26] Btrfs: sysfs: make btrfs_sysfs_add_fsid() non static
  2015-03-09 22:38 [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added Anand Jain
                   ` (15 preceding siblings ...)
  2015-03-09 22:38 ` [PATCH 16/26] Btrfs: sysfs btrfs_kobj_rm_device() " Anand Jain
@ 2015-03-09 22:38 ` Anand Jain
  2015-03-09 22:38 ` [PATCH 18/26] Btrfs: sysfs: make btrfs_sysfs_add_device() " Anand Jain
                   ` (9 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Anand Jain @ 2015-03-09 22:38 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/sysfs.c | 2 +-
 fs/btrfs/sysfs.h | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 5055809..42ed7a7 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -727,7 +727,7 @@ u64 btrfs_debugfs_test;
  * Can be called by the device discovery thread.
  * And parent can be specified for seed device
  */
-static int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs,
+int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs,
 				struct kobject *parent)
 {
 	int error;
diff --git a/fs/btrfs/sysfs.h b/fs/btrfs/sysfs.h
index 3938ac1..aaff124 100644
--- a/fs/btrfs/sysfs.h
+++ b/fs/btrfs/sysfs.h
@@ -74,4 +74,6 @@ int btrfs_kobj_add_device(struct btrfs_fs_devices *fs_devices,
 		struct btrfs_device *one_device);
 int btrfs_kobj_rm_device(struct btrfs_fs_devices *fs_devices,
                 struct btrfs_device *one_device);
+int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs,
+				struct kobject *parent);
 #endif /* _BTRFS_SYSFS_H_ */
-- 
2.0.0.153.g79dcccc


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 18/26] Btrfs: sysfs: make btrfs_sysfs_add_device() non static
  2015-03-09 22:38 [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added Anand Jain
                   ` (16 preceding siblings ...)
  2015-03-09 22:38 ` [PATCH 17/26] Btrfs: sysfs: make btrfs_sysfs_add_fsid() non static Anand Jain
@ 2015-03-09 22:38 ` Anand Jain
  2015-03-09 22:38 ` [PATCH 19/26] Btrfs: sysfs: btrfs_sysfs_remove_fsid() make it " Anand Jain
                   ` (8 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Anand Jain @ 2015-03-09 22:38 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/sysfs.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/btrfs/sysfs.h b/fs/btrfs/sysfs.h
index aaff124..ac06b5c 100644
--- a/fs/btrfs/sysfs.h
+++ b/fs/btrfs/sysfs.h
@@ -76,4 +76,5 @@ int btrfs_kobj_rm_device(struct btrfs_fs_devices *fs_devices,
                 struct btrfs_device *one_device);
 int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs,
 				struct kobject *parent);
+int btrfs_sysfs_add_device(struct btrfs_fs_devices *fs_devs);
 #endif /* _BTRFS_SYSFS_H_ */
-- 
2.0.0.153.g79dcccc


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 19/26] Btrfs: sysfs: btrfs_sysfs_remove_fsid() make it non static
  2015-03-09 22:38 [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added Anand Jain
                   ` (17 preceding siblings ...)
  2015-03-09 22:38 ` [PATCH 18/26] Btrfs: sysfs: make btrfs_sysfs_add_device() " Anand Jain
@ 2015-03-09 22:38 ` Anand Jain
  2015-03-09 22:38 ` [PATCH 20/26] Btrfs: sysfs: separate kobject and attribute creation Anand Jain
                   ` (7 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Anand Jain @ 2015-03-09 22:38 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/sysfs.c | 2 +-
 fs/btrfs/sysfs.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 42ed7a7..1d34538 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -529,7 +529,7 @@ static void __btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs)
 }
 
 /* when fs_devs is NULL it will remove all fsid kobject */
-static void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs)
+void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs)
 {
 	struct list_head *fs_uuids = btrfs_get_fs_uuids();
 
diff --git a/fs/btrfs/sysfs.h b/fs/btrfs/sysfs.h
index ac06b5c..2b31f6f 100644
--- a/fs/btrfs/sysfs.h
+++ b/fs/btrfs/sysfs.h
@@ -77,4 +77,5 @@ int btrfs_kobj_rm_device(struct btrfs_fs_devices *fs_devices,
 int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs,
 				struct kobject *parent);
 int btrfs_sysfs_add_device(struct btrfs_fs_devices *fs_devs);
+void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs);
 #endif /* _BTRFS_SYSFS_H_ */
-- 
2.0.0.153.g79dcccc


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 20/26] Btrfs: sysfs: separate kobject and attribute creation
  2015-03-09 22:38 [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added Anand Jain
                   ` (18 preceding siblings ...)
  2015-03-09 22:38 ` [PATCH 19/26] Btrfs: sysfs: btrfs_sysfs_remove_fsid() make it " Anand Jain
@ 2015-03-09 22:38 ` Anand Jain
  2015-03-09 22:38 ` [PATCH 21/26] Btrfs: sysfs: add support to add parent for fsid Anand Jain
                   ` (6 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Anand Jain @ 2015-03-09 22:38 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/disk-io.c | 18 +++++++++++++++++-
 fs/btrfs/sysfs.c   | 15 ++-------------
 2 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 0cd6550..4b7f3b8 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -2785,10 +2785,22 @@ retry_root_backup:
 
 	btrfs_close_extra_devices(fs_info, fs_devices, 1);
 
+	ret = btrfs_sysfs_add_fsid(fs_devices, NULL);
+	if (ret) {
+		pr_err("BTRFS: failed to init sysfs fsid interface: %d\n", ret);
+		goto fail_block_groups;
+	}
+
+	ret = btrfs_sysfs_add_device(fs_devices);
+	if (ret) {
+		pr_err("BTRFS: failed to init sysfs device interface: %d\n", ret);
+		goto fail_fsdev_sysfs;
+	}
+
 	ret = btrfs_sysfs_add_one(fs_info);
 	if (ret) {
 		pr_err("BTRFS: failed to init sysfs interface: %d\n", ret);
-		goto fail_block_groups;
+		goto fail_fsdev_sysfs;
 	}
 
 	ret = btrfs_init_space_info(fs_info);
@@ -3002,6 +3014,9 @@ fail_cleaner:
 fail_sysfs:
 	btrfs_sysfs_remove_one(fs_info);
 
+fail_fsdev_sysfs:
+	btrfs_sysfs_remove_fsid(fs_info->fs_devices);
+
 fail_block_groups:
 	btrfs_put_block_group_cache(fs_info);
 	btrfs_free_block_groups(fs_info);
@@ -3679,6 +3694,7 @@ void close_ctree(struct btrfs_root *root)
 	}
 
 	btrfs_sysfs_remove_one(fs_info);
+	btrfs_sysfs_remove_fsid(fs_info->fs_devices);
 
 	btrfs_free_fs_roots(fs_info);
 
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 1d34538..be5342f 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -556,7 +556,6 @@ void btrfs_sysfs_remove_one(struct btrfs_fs_info *fs_info)
 	sysfs_remove_group(&fs_info->fs_devices->super_kobj, &btrfs_feature_attr_group);
 	sysfs_remove_files(&fs_info->fs_devices->super_kobj, btrfs_attrs);
 	btrfs_kobj_rm_device(fs_info->fs_devices, NULL);
-	btrfs_sysfs_remove_fsid(fs_info->fs_devices);
 }
 
 const char * const btrfs_feature_set_names[3] = {
@@ -688,10 +687,6 @@ int btrfs_kobj_add_device(struct btrfs_fs_devices *fs_devices,
 	int error = 0;
 	struct btrfs_device *dev;
 
-	error = btrfs_sysfs_add_device(fs_devices);
-	if (error)
-		return error;
-
 	list_for_each_entry(dev, &fs_devices->devices, dev_list) {
 		struct hd_struct *disk;
 		struct kobject *disk_kobj;
@@ -747,19 +742,13 @@ int btrfs_sysfs_add_one(struct btrfs_fs_info *fs_info)
 
 	btrfs_set_fs_info_ptr(fs_info);
 
-	error = btrfs_sysfs_add_fsid(fs_devs, NULL);
-	if (error)
-		return error;
-
 	error = btrfs_kobj_add_device(fs_devs, NULL);
-	if (error) {
-		btrfs_sysfs_remove_fsid(fs_devs);
+	if (error)
 		return error;
-	}
 
 	error = sysfs_create_files(super_kobj, btrfs_attrs);
 	if (error) {
-		btrfs_sysfs_remove_fsid(fs_devs);
+		btrfs_kobj_rm_device(fs_devs, NULL);
 		return error;
 	}
 
-- 
2.0.0.153.g79dcccc


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 21/26] Btrfs: sysfs: add support to add parent for fsid
  2015-03-09 22:38 [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added Anand Jain
                   ` (19 preceding siblings ...)
  2015-03-09 22:38 ` [PATCH 20/26] Btrfs: sysfs: separate kobject and attribute creation Anand Jain
@ 2015-03-09 22:38 ` Anand Jain
  2015-03-09 22:38 ` [PATCH 22/26] Btrfs: sysfs: don't fail seeding for the sake of sysfs kobject issue v2 Anand Jain
                   ` (5 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Anand Jain @ 2015-03-09 22:38 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba

To support seed sysfs layout and represent seed fsid under
the sprout we need the facility to create fsid under the
specified parent.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/sysfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index be5342f..51e2fae 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -729,8 +729,8 @@ int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs,
 
 	init_completion(&fs_devs->kobj_unregister);
 	fs_devs->super_kobj.kset = btrfs_kset;
-	error = kobject_init_and_add(&fs_devs->super_kobj, &btrfs_ktype, NULL,
-				     "%pU", fs_devs->fsid);
+	error = kobject_init_and_add(&fs_devs->super_kobj,
+				&btrfs_ktype, parent, "%pU", fs_devs->fsid);
 	return error;
 }
 
-- 
2.0.0.153.g79dcccc


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 22/26] Btrfs: sysfs: don't fail seeding for the sake of sysfs kobject issue v2
  2015-03-09 22:38 [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added Anand Jain
                   ` (20 preceding siblings ...)
  2015-03-09 22:38 ` [PATCH 21/26] Btrfs: sysfs: add support to add parent for fsid Anand Jain
@ 2015-03-09 22:38 ` Anand Jain
  2015-03-09 22:38 ` [PATCH 23/26] Btrfs: free the stale device Anand Jain
                   ` (4 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Anand Jain @ 2015-03-09 22:38 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba

v2: accept David comment

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/volumes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 549f978..58232bc 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2249,7 +2249,7 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
 						root->fs_info->fsid);
 		if (kobject_rename(&root->fs_info->fs_devices->super_kobj,
 								fsid_buf))
-			goto error_trans;
+			pr_warn("BTRFS: sysfs: failed to create fsid for sprout\n");
 	}
 
 	root->fs_info->num_tolerated_disk_barrier_failures =
-- 
2.0.0.153.g79dcccc


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 23/26] Btrfs: free the stale device
  2015-03-09 22:38 [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added Anand Jain
                   ` (21 preceding siblings ...)
  2015-03-09 22:38 ` [PATCH 22/26] Btrfs: sysfs: don't fail seeding for the sake of sysfs kobject issue v2 Anand Jain
@ 2015-03-09 22:38 ` Anand Jain
  2015-03-09 22:38 ` [PATCH 24/26] Btrfs: sysfs: add support to show replacing target in the sysfs Anand Jain
                   ` (3 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Anand Jain @ 2015-03-09 22:38 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/volumes.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 58232bc..452abb3 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -446,6 +446,55 @@ static void pending_bios_fn(struct btrfs_work *work)
 	run_scheduled_bios(device);
 }
 
+
+void btrfs_free_stale_device(struct btrfs_device *cur_dev)
+{
+	int del = 0;
+	struct btrfs_fs_devices *fs_devs;
+	struct btrfs_device *dev;
+
+	list_for_each_entry(fs_devs, &fs_uuids, list) {
+		if (fs_devs->opened)
+			continue;
+		if (fs_devs->seeding)
+			continue;
+		list_for_each_entry(dev, &fs_devs->devices, dev_list) {
+			if (dev == cur_dev)
+				continue;
+
+			/*
+			 * Todo: This won't be enough. What if same device
+			 * comes back with new uuid and with its mapper path?
+			 * But for now, this does helps as mostly an admin will
+			 * use either mapper or non mapper path throughout.
+			 */
+
+			if (!strcmp(rcu_str_deref(dev->name),
+						rcu_str_deref(cur_dev->name))) {
+				del = 1;
+				break;
+			}
+		}
+		if (del) {
+			/* delete the stale */
+			if (fs_devs->num_devices == 1) {
+				btrfs_kobj_rm_device(fs_devs, dev);
+				btrfs_sysfs_remove_fsid(fs_devs);
+				list_del(&fs_devs->list);
+				free_fs_devices(fs_devs);
+			} else {
+				fs_devs->num_devices--;
+				btrfs_kobj_rm_device(fs_devs, dev);
+				list_del(&dev->dev_list);
+				rcu_string_free(dev->name);
+				kfree(dev);
+			}
+			break;
+		}
+	}
+	return;
+}
+
 /*
  * Add new device to list of registered devices
  *
@@ -561,6 +610,8 @@ static noinline int device_list_add(const char *path,
 	if (!fs_devices->opened)
 		device->generation = found_transid;
 
+	btrfs_free_stale_device(device);
+
 	*fs_devices_ret = fs_devices;
 
 	return ret;
-- 
2.0.0.153.g79dcccc


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 24/26] Btrfs: sysfs: add support to show replacing target in the sysfs
  2015-03-09 22:38 [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added Anand Jain
                   ` (22 preceding siblings ...)
  2015-03-09 22:38 ` [PATCH 23/26] Btrfs: free the stale device Anand Jain
@ 2015-03-09 22:38 ` Anand Jain
  2015-03-09 22:38 ` [PATCH 25/26] Btrfs: sysfs: support seed devices in the sysfs layout v3 Anand Jain
                   ` (2 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Anand Jain @ 2015-03-09 22:38 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba

This patch will add support to show the replacing target in sysfs
during the process of replacement.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/dev-replace.c | 5 ++++-
 fs/btrfs/volumes.c     | 3 +++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index 124b60f..f06390b 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -376,6 +376,10 @@ int btrfs_dev_replace_start(struct btrfs_root *root,
 	WARN_ON(!tgt_device);
 	dev_replace->tgtdev = tgt_device;
 
+	ret = btrfs_kobj_add_device(tgt_device->fs_devices, tgt_device);
+	if (ret)
+		btrfs_error(root->fs_info, ret, "kobj add dev failed");
+
 	printk_in_rcu(KERN_INFO
 		      "BTRFS: dev_replace from %s (devid %llu) to %s started\n",
 		      src_device->missing ? "<missing disk>" :
@@ -593,7 +597,6 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
 
 	/* replace the sysfs entry */
 	btrfs_kobj_rm_device(fs_info->fs_devices, src_device);
-	btrfs_kobj_add_device(fs_info->fs_devices, tgt_device);
 	btrfs_rm_dev_replace_free_srcdev(fs_info, src_device);
 
 	/* write back the superblocks */
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 452abb3..f51f5ba 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1921,6 +1921,9 @@ void btrfs_destroy_dev_replace_tgtdev(struct btrfs_fs_info *fs_info,
 	mutex_lock(&uuid_mutex);
 	WARN_ON(!tgtdev);
 	mutex_lock(&fs_info->fs_devices->device_list_mutex);
+
+	btrfs_kobj_rm_device(fs_info->fs_devices, tgtdev);
+
 	if (tgtdev->bdev) {
 		btrfs_scratch_superblock(tgtdev);
 		fs_info->fs_devices->open_devices--;
-- 
2.0.0.153.g79dcccc


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 25/26] Btrfs: sysfs: support seed devices in the sysfs layout v3
  2015-03-09 22:38 [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added Anand Jain
                   ` (23 preceding siblings ...)
  2015-03-09 22:38 ` [PATCH 24/26] Btrfs: sysfs: add support to show replacing target in the sysfs Anand Jain
@ 2015-03-09 22:38 ` Anand Jain
  2015-03-19 18:55   ` David Sterba
  2015-03-09 22:38 ` [PATCH 26/26] Btrfs: create sys/fs/btrfs/fsid when scanned instead of when mounted Anand Jain
  2015-03-19 18:58 ` [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added David Sterba
  26 siblings, 1 reply; 31+ messages in thread
From: Anand Jain @ 2015-03-09 22:38 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba

This adds an enhancement to show the seed fsid and devices.

The way sprouting handles fs_devices:
      clone seed fs_devices and add to the fs_uuids
      mem copy seed fs_devices and assign to fs_devices->seed (move dev_list)
      evacuate seed fs_devices contents to hold sprout fs devices contents

  So to be inline with this fs_devices changes during seeding,
  represent seed fsid under the sprout fsid, this is achieved
  by using the kobject_move()
  The end result will be,
    /sys/fs/btrfs/sprout-fsid/level-1-seed-fsid/(if)level-2-seed-fsid

eg: showing two levels of seeding.

find /sys/fs/btrfs/ -type d -name devices -exec ls {} \; -print

sde
/sys/fs/btrfs/8c2772d4-6951-43c3-89b6-3ab3c70a13f8/f7ef2904-ce89-4421-bfb0-49fd999e9a0b/devices
sdd
/sys/fs/btrfs/8c2772d4-6951-43c3-89b6-3ab3c70a13f8/f7ef2904-ce89-4421-bfb0-49fd999e9a0b/53ac3265-0c34-4afd-9453-cc0d1a07be64/devices
sdf
/sys/fs/btrfs/8c2772d4-6951-43c3-89b6-3ab3c70a13f8/devices

Signed-off-by: Anand Jain <anand.jain@oracle.com>

Btrfs: sysfs: add check if super kobject is already initialized

v2: when kobject is already created return EEXIST
v3: squash with patch 25

Signed-off-by: Anand Jain <anand.jain@oracle.com>

Btrfs: rename btrfs_kobj_add/rm_device

rename btrfs_kobj_add_device to btrfs_sysfs_add_device_link
rename btrfs_kobj_rm_device to btrfs_sysfs_rm_device_link

Signed-off-by: Anand Jain <anand.jain@oracle.com>

Btrfs: rearrange code for easy readability

no logical change

Signed-off-by: Anand Jain <anand.jain@oracle.com>

Btrfs: rename btrfs_sysfs_add_one to btrfs_sysfs_add_mounted

rename btrfs_sysfs_add_one to btrfs_sysfs_add_mounted

rename btrfs_sysfs_remove_one to btrfs_sysfs_remove_mounted

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/ctree.h       |   4 +-
 fs/btrfs/dev-replace.c |   4 +-
 fs/btrfs/disk-io.c     |  12 +--
 fs/btrfs/sysfs.c       | 207 ++++++++++++++++++++++++++++++++++---------------
 fs/btrfs/sysfs.h       |  14 ++--
 fs/btrfs/volumes.c     |  26 +++----
 6 files changed, 172 insertions(+), 95 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 9493b91..5f25607 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -3976,8 +3976,8 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
 /* sysfs.c */
 int btrfs_init_sysfs(void);
 void btrfs_exit_sysfs(void);
-int btrfs_sysfs_add_one(struct btrfs_fs_info *fs_info);
-void btrfs_sysfs_remove_one(struct btrfs_fs_info *fs_info);
+int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info);
+void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info);
 
 /* xattr.c */
 ssize_t btrfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index f06390b..61d183b 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -376,7 +376,7 @@ int btrfs_dev_replace_start(struct btrfs_root *root,
 	WARN_ON(!tgt_device);
 	dev_replace->tgtdev = tgt_device;
 
-	ret = btrfs_kobj_add_device(tgt_device->fs_devices, tgt_device);
+	ret = btrfs_sysfs_add_device_link(tgt_device->fs_devices, tgt_device, 0);
 	if (ret)
 		btrfs_error(root->fs_info, ret, "kobj add dev failed");
 
@@ -596,7 +596,7 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
 	mutex_unlock(&uuid_mutex);
 
 	/* replace the sysfs entry */
-	btrfs_kobj_rm_device(fs_info->fs_devices, src_device);
+	btrfs_sysfs_rm_device_link(fs_info->fs_devices, src_device, 0);
 	btrfs_rm_dev_replace_free_srcdev(fs_info, src_device);
 
 	/* write back the superblocks */
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 4b7f3b8..4b19e41 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -2785,19 +2785,19 @@ retry_root_backup:
 
 	btrfs_close_extra_devices(fs_info, fs_devices, 1);
 
-	ret = btrfs_sysfs_add_fsid(fs_devices, NULL);
-	if (ret) {
+	ret = btrfs_sysfs_add_fsid(fs_devices, NULL, 1);
+	if (ret && ret != -EEXIST) {
 		pr_err("BTRFS: failed to init sysfs fsid interface: %d\n", ret);
 		goto fail_block_groups;
 	}
 
-	ret = btrfs_sysfs_add_device(fs_devices);
+	ret = btrfs_sysfs_add_device(fs_devices, 1);
 	if (ret) {
 		pr_err("BTRFS: failed to init sysfs device interface: %d\n", ret);
 		goto fail_fsdev_sysfs;
 	}
 
-	ret = btrfs_sysfs_add_one(fs_info);
+	ret = btrfs_sysfs_add_mounted(fs_info);
 	if (ret) {
 		pr_err("BTRFS: failed to init sysfs interface: %d\n", ret);
 		goto fail_fsdev_sysfs;
@@ -3012,7 +3012,7 @@ fail_cleaner:
 	filemap_write_and_wait(fs_info->btree_inode->i_mapping);
 
 fail_sysfs:
-	btrfs_sysfs_remove_one(fs_info);
+	btrfs_sysfs_remove_mounted(fs_info);
 
 fail_fsdev_sysfs:
 	btrfs_sysfs_remove_fsid(fs_info->fs_devices);
@@ -3693,7 +3693,7 @@ void close_ctree(struct btrfs_root *root)
 		       percpu_counter_sum(&fs_info->delalloc_bytes));
 	}
 
-	btrfs_sysfs_remove_one(fs_info);
+	btrfs_sysfs_remove_mounted(fs_info);
 	btrfs_sysfs_remove_fsid(fs_info->fs_devices);
 
 	btrfs_free_fs_roots(fs_info);
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 51e2fae..e1b4f95 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -515,49 +515,6 @@ static int addrm_unknown_feature_attrs(struct btrfs_fs_info *fs_info, bool add)
 	return 0;
 }
 
-static void __btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs)
-{
-	if (fs_devs->device_dir_kobj) {
-		kobject_del(fs_devs->device_dir_kobj);
-		kobject_put(fs_devs->device_dir_kobj);
-		fs_devs->device_dir_kobj = NULL;
-	}
-
-	kobject_del(&fs_devs->super_kobj);
-	kobject_put(&fs_devs->super_kobj);
-	wait_for_completion(&fs_devs->kobj_unregister);
-}
-
-/* when fs_devs is NULL it will remove all fsid kobject */
-void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs)
-{
-	struct list_head *fs_uuids = btrfs_get_fs_uuids();
-
-	if (fs_devs) {
-		__btrfs_sysfs_remove_fsid(fs_devs);
-		return;
-	}
-
-	list_for_each_entry(fs_devs, fs_uuids, list) {
-		__btrfs_sysfs_remove_fsid(fs_devs);
-	}
-}
-
-void btrfs_sysfs_remove_one(struct btrfs_fs_info *fs_info)
-{
-	btrfs_reset_fs_info_ptr(fs_info);
-
-	if (fs_info->space_info_kobj) {
-		sysfs_remove_files(fs_info->space_info_kobj, allocation_attrs);
-		kobject_del(fs_info->space_info_kobj);
-		kobject_put(fs_info->space_info_kobj);
-	}
-	addrm_unknown_feature_attrs(fs_info, false);
-	sysfs_remove_group(&fs_info->fs_devices->super_kobj, &btrfs_feature_attr_group);
-	sysfs_remove_files(&fs_info->fs_devices->super_kobj, btrfs_attrs);
-	btrfs_kobj_rm_device(fs_info->fs_devices, NULL);
-}
-
 const char * const btrfs_feature_set_names[3] = {
 	[FEAT_COMPAT]	 = "compat",
 	[FEAT_COMPAT_RO] = "compat_ro",
@@ -633,10 +590,59 @@ static void init_feature_attrs(void)
 	}
 }
 
+static void __btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs)
+{
+	if (fs_devs->seed)
+		__btrfs_sysfs_remove_fsid(fs_devs->seed);
+
+	if (fs_devs->device_dir_kobj) {
+		kobject_del(fs_devs->device_dir_kobj);
+		kobject_put(fs_devs->device_dir_kobj);
+		fs_devs->device_dir_kobj = NULL;
+	}
+
+	if (fs_devs->super_kobj.state_initialized) {
+		kobject_del(&fs_devs->super_kobj);
+		kobject_put(&fs_devs->super_kobj);
+		wait_for_completion(&fs_devs->kobj_unregister);
+	}
+}
+
+/* when fs_devs is NULL it will remove all fsid kobject */
+void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs)
+{
+	struct list_head *fs_uuids = btrfs_get_fs_uuids();
+
+	if (fs_devs) {
+		__btrfs_sysfs_remove_fsid(fs_devs);
+		return;
+	}
+
+	list_for_each_entry(fs_devs, fs_uuids, list) {
+		__btrfs_sysfs_remove_fsid(fs_devs);
+	}
+}
+
+void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info)
+{
+	btrfs_reset_fs_info_ptr(fs_info);
+
+	if (fs_info->space_info_kobj) {
+		sysfs_remove_files(fs_info->space_info_kobj, allocation_attrs);
+		kobject_del(fs_info->space_info_kobj);
+		kobject_put(fs_info->space_info_kobj);
+	}
+	addrm_unknown_feature_attrs(fs_info, false);
+	sysfs_remove_group(&fs_info->fs_devices->super_kobj, &btrfs_feature_attr_group);
+	sysfs_remove_files(&fs_info->fs_devices->super_kobj, btrfs_attrs);
+	btrfs_sysfs_rm_device_link(fs_info->fs_devices, NULL, 1);
+}
+
+
 /* when one_device is NULL, it removes all device links */
 
-int btrfs_kobj_rm_device(struct btrfs_fs_devices *fs_devices,
-		struct btrfs_device *one_device)
+int btrfs_sysfs_rm_device_link(struct btrfs_fs_devices *fs_devices,
+		struct btrfs_device *one_device, int follow_seed)
 {
 	struct hd_struct *disk;
 	struct kobject *disk_kobj;
@@ -666,27 +672,39 @@ int btrfs_kobj_rm_device(struct btrfs_fs_devices *fs_devices,
 						disk_kobj->name);
 	}
 
+	if (follow_seed && fs_devices->seed)
+		btrfs_sysfs_rm_device_link(fs_devices->seed, NULL, follow_seed);
+
 	return 0;
 }
 
-int btrfs_sysfs_add_device(struct btrfs_fs_devices *fs_devs)
+int btrfs_sysfs_add_device(struct btrfs_fs_devices *fs_devs, int follow_seed)
 {
-	if (!fs_devs->device_dir_kobj)
-		fs_devs->device_dir_kobj = kobject_create_and_add("devices",
-						&fs_devs->super_kobj);
 
-	if (!fs_devs->device_dir_kobj)
-		return -ENOMEM;
+	while (fs_devs) {
+		if (!fs_devs->device_dir_kobj)
+			fs_devs->device_dir_kobj = kobject_create_and_add(
+					"devices", &fs_devs->super_kobj);
+
+		if (!fs_devs->device_dir_kobj)
+			return -ENOMEM;
+
+		if (!follow_seed)
+			return 0;
+
+		fs_devs = fs_devs->seed;
+	}
 
 	return 0;
 }
 
-int btrfs_kobj_add_device(struct btrfs_fs_devices *fs_devices,
-				struct btrfs_device *one_device)
+int btrfs_sysfs_add_device_link(struct btrfs_fs_devices *fs_devices,
+			struct btrfs_device *one_device, int follow_seed)
 {
 	int error = 0;
 	struct btrfs_device *dev;
 
+again:
 	list_for_each_entry(dev, &fs_devices->devices, dev_list) {
 		struct hd_struct *disk;
 		struct kobject *disk_kobj;
@@ -706,6 +724,11 @@ int btrfs_kobj_add_device(struct btrfs_fs_devices *fs_devices,
 			break;
 	}
 
+	if (follow_seed && fs_devices->seed) {
+		fs_devices = fs_devices->seed;
+		goto again;
+	}
+
 	return error;
 }
 
@@ -723,18 +746,28 @@ u64 btrfs_debugfs_test;
  * And parent can be specified for seed device
  */
 int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs,
-				struct kobject *parent)
+				struct kobject *parent, int follow_seed)
 {
-	int error;
+	int error = 0;
 
-	init_completion(&fs_devs->kobj_unregister);
-	fs_devs->super_kobj.kset = btrfs_kset;
-	error = kobject_init_and_add(&fs_devs->super_kobj,
+	while (fs_devs) {
+		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;
+		fs_devs = fs_devs->seed;
+	}
 	return error;
 }
 
-int btrfs_sysfs_add_one(struct btrfs_fs_info *fs_info)
+int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info)
 {
 	int error;
 	struct btrfs_fs_devices *fs_devs = fs_info->fs_devices;
@@ -742,13 +775,13 @@ int btrfs_sysfs_add_one(struct btrfs_fs_info *fs_info)
 
 	btrfs_set_fs_info_ptr(fs_info);
 
-	error = btrfs_kobj_add_device(fs_devs, NULL);
+	error = btrfs_sysfs_add_device_link(fs_devs, NULL, 1);
 	if (error)
 		return error;
 
 	error = sysfs_create_files(super_kobj, btrfs_attrs);
 	if (error) {
-		btrfs_kobj_rm_device(fs_devs, NULL);
+		btrfs_sysfs_rm_device_link(fs_devs, NULL, 0);
 		return error;
 	}
 
@@ -774,7 +807,7 @@ int btrfs_sysfs_add_one(struct btrfs_fs_info *fs_info)
 
 	return 0;
 failure:
-	btrfs_sysfs_remove_one(fs_info);
+	btrfs_sysfs_remove_mounted(fs_info);
 	return error;
 }
 
@@ -816,3 +849,53 @@ void btrfs_exit_sysfs(void)
 	debugfs_remove_recursive(btrfs_debugfs_root_dentry);
 }
 
+void btrfs_sysfs_prepare_sprout_reset(void)
+{
+	/* close call would anyway cleanup */
+}
+
+void btrfs_sysfs_prepare_sprout(struct btrfs_fs_devices *fs_devices,
+				struct btrfs_fs_devices *seed_devices)
+{
+	char fsid_buf[BTRFS_UUID_UNPARSED_SIZE];
+
+	/*
+	 * Sprouting has changed fsid of the mounted root,
+	 * so rename the fsid on the sysfs
+	 */
+	snprintf(fsid_buf, BTRFS_UUID_UNPARSED_SIZE, "%pU", fs_devices->fsid);
+	if (kobject_rename(&fs_devices->super_kobj, fsid_buf)) {
+		pr_warn("Btrfs: sysfs: kobject move failed\n");
+		return;
+	}
+
+	/*
+	 * Create the seed fsid inside the sprout fsid
+	 * but should not create devices dir, instead
+	 * move it from the original fs_devices
+	 */
+	memset(&seed_devices->super_kobj, 0, sizeof(struct kobject));
+	seed_devices->device_dir_kobj = NULL;
+	memset(&seed_devices->kobj_unregister, 0,
+					sizeof(struct completion));
+	btrfs_sysfs_add_fsid(seed_devices, &fs_devices->super_kobj, 0);
+	if (kobject_move(fs_devices->device_dir_kobj,
+					&seed_devices->super_kobj))
+		pr_warn("Btrfs: sysfs: dev kobject move failed\n");
+
+	seed_devices->device_dir_kobj = fs_devices->device_dir_kobj;
+	fs_devices->device_dir_kobj = NULL;
+	btrfs_sysfs_add_device(fs_devices, 0);
+
+	/*
+	 * the kobj dev and devices attribute will be created
+	 * in the main function as part of the init_new_device
+	 * If this is a nested seed, that is if there is seed's
+	 * seed device then move that one level deep.
+	 */
+	if (seed_devices->seed) {
+		if (kobject_move(&seed_devices->seed->super_kobj,
+					&seed_devices->super_kobj))
+			pr_warn("Btrfs: sysfs: kobject move failed\n");
+	}
+}
diff --git a/fs/btrfs/sysfs.h b/fs/btrfs/sysfs.h
index 2b31f6f..b23e94c 100644
--- a/fs/btrfs/sysfs.h
+++ b/fs/btrfs/sysfs.h
@@ -70,12 +70,14 @@ char *btrfs_printable_features(enum btrfs_feature_set set, u64 flags);
 extern const char * const btrfs_feature_set_names[3];
 extern struct kobj_type space_info_ktype;
 extern struct kobj_type btrfs_raid_ktype;
-int btrfs_kobj_add_device(struct btrfs_fs_devices *fs_devices,
-		struct btrfs_device *one_device);
-int btrfs_kobj_rm_device(struct btrfs_fs_devices *fs_devices,
-                struct btrfs_device *one_device);
+int btrfs_sysfs_add_device_link(struct btrfs_fs_devices *fs_devices,
+		struct btrfs_device *one_device, int follow_seed);
+int btrfs_sysfs_rm_device_link(struct btrfs_fs_devices *fs_devices,
+                struct btrfs_device *one_device, int follow_seed);
 int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs,
-				struct kobject *parent);
-int btrfs_sysfs_add_device(struct btrfs_fs_devices *fs_devs);
+				struct kobject *parent, int follow_seed);
+int btrfs_sysfs_add_device(struct btrfs_fs_devices *fs_devs, int follow_seed);
 void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs);
+void btrfs_sysfs_prepare_sprout(struct btrfs_fs_devices *fs_devices,
+				struct btrfs_fs_devices *seed_devices);
 #endif /* _BTRFS_SYSFS_H_ */
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index f51f5ba..bf59224 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -27,6 +27,7 @@
 #include <linux/kthread.h>
 #include <linux/raid/pq.h>
 #include <linux/semaphore.h>
+#include <linux/kobject.h>
 #include <asm/div64.h>
 #include "ctree.h"
 #include "extent_map.h"
@@ -478,13 +479,13 @@ void btrfs_free_stale_device(struct btrfs_device *cur_dev)
 		if (del) {
 			/* delete the stale */
 			if (fs_devs->num_devices == 1) {
-				btrfs_kobj_rm_device(fs_devs, dev);
+				btrfs_sysfs_rm_device_link(fs_devs, dev, 0);
 				btrfs_sysfs_remove_fsid(fs_devs);
 				list_del(&fs_devs->list);
 				free_fs_devices(fs_devs);
 			} else {
 				fs_devs->num_devices--;
-				btrfs_kobj_rm_device(fs_devs, dev);
+				btrfs_sysfs_rm_device_link(fs_devs, dev, 0);
 				list_del(&dev->dev_list);
 				rcu_string_free(dev->name);
 				kfree(dev);
@@ -1752,7 +1753,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
 	if (device->bdev) {
 		device->fs_devices->open_devices--;
 		/* remove sysfs entry */
-		btrfs_kobj_rm_device(root->fs_info->fs_devices, device);
+		btrfs_sysfs_rm_device_link(root->fs_info->fs_devices, device, 0);
 	}
 
 	call_rcu(&device->rcu, free_device);
@@ -1922,7 +1923,7 @@ void btrfs_destroy_dev_replace_tgtdev(struct btrfs_fs_info *fs_info,
 	WARN_ON(!tgtdev);
 	mutex_lock(&fs_info->fs_devices->device_list_mutex);
 
-	btrfs_kobj_rm_device(fs_info->fs_devices, tgtdev);
+	btrfs_sysfs_rm_device_link(fs_info->fs_devices, tgtdev, 0);
 
 	if (tgtdev->bdev) {
 		btrfs_scratch_superblock(tgtdev);
@@ -2063,6 +2064,8 @@ static int btrfs_prepare_sprout(struct btrfs_root *root)
 		      ~BTRFS_SUPER_FLAG_SEEDING;
 	btrfs_set_super_flags(disk_super, super_flags);
 
+	btrfs_sysfs_prepare_sprout(fs_devices, seed_devices);
+
 	return 0;
 }
 
@@ -2260,7 +2263,7 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
 				    tmp + 1);
 
 	/* add sysfs device entry */
-	btrfs_kobj_add_device(root->fs_info->fs_devices, device);
+	btrfs_sysfs_add_device_link(root->fs_info->fs_devices, device, 0);
 
 	/*
 	 * we've got more storage, clear any full flags on the space
@@ -2288,22 +2291,11 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
 	}
 
 	if (seeding_dev) {
-		char fsid_buf[BTRFS_UUID_UNPARSED_SIZE];
-
 		ret = btrfs_finish_sprout(trans, root);
 		if (ret) {
 			btrfs_abort_transaction(trans, root, ret);
 			goto error_trans;
 		}
-
-		/* Sprouting would change fsid of the mounted root,
-		 * so rename the fsid on the sysfs
-		 */
-		snprintf(fsid_buf, BTRFS_UUID_UNPARSED_SIZE, "%pU",
-						root->fs_info->fsid);
-		if (kobject_rename(&root->fs_info->fs_devices->super_kobj,
-								fsid_buf))
-			pr_warn("BTRFS: sysfs: failed to create fsid for sprout\n");
 	}
 
 	root->fs_info->num_tolerated_disk_barrier_failures =
@@ -2339,7 +2331,7 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
 error_trans:
 	btrfs_end_transaction(trans, root);
 	rcu_string_free(device->name);
-	btrfs_kobj_rm_device(root->fs_info->fs_devices, device);
+	btrfs_sysfs_rm_device_link(root->fs_info->fs_devices, device, 0);
 	kfree(device);
 error:
 	blkdev_put(bdev, FMODE_EXCL);
-- 
2.0.0.153.g79dcccc


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 26/26] Btrfs: create sys/fs/btrfs/fsid when scanned instead of when mounted
  2015-03-09 22:38 [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added Anand Jain
                   ` (24 preceding siblings ...)
  2015-03-09 22:38 ` [PATCH 25/26] Btrfs: sysfs: support seed devices in the sysfs layout v3 Anand Jain
@ 2015-03-09 22:38 ` Anand Jain
  2015-03-19 18:58 ` [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added David Sterba
  26 siblings, 0 replies; 31+ messages in thread
From: Anand Jain @ 2015-03-09 22:38 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba

This patch changes the life cycle of the exisiting sysfs kobjects
/sys/fs/btrfs/<fsid> and /sys/fs/btrfs/<fsid>/devices,
from that they are created and destroyed by mount and unmount event
respectively, to created and destroyed by scanned-registered and
module-unload respectively.

So that information from the btrfs_fs_devices can be added.

This does not change life cycle of any attributes from the fs_info.

The changes here are very simple, thanks to the sysfs framework
modifictions patchset which was sent before.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/disk-io.c | 3 ++-
 fs/btrfs/sysfs.c   | 7 ++++++-
 fs/btrfs/sysfs.h   | 3 ++-
 fs/btrfs/volumes.c | 6 +++++-
 4 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 4b19e41..0155ce8 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3694,7 +3694,8 @@ void close_ctree(struct btrfs_root *root)
 	}
 
 	btrfs_sysfs_remove_mounted(fs_info);
-	btrfs_sysfs_remove_fsid(fs_info->fs_devices);
+	if (fs_info->fs_devices->seed)
+		btrfs_sysfs_remove_fsid(fs_info->fs_devices->seed);
 
 	btrfs_free_fs_roots(fs_info);
 
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index e1b4f95..253e57e 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -845,6 +845,7 @@ int btrfs_init_sysfs(void)
 void btrfs_exit_sysfs(void)
 {
 	sysfs_remove_group(&btrfs_kset->kobj, &btrfs_feature_attr_group);
+	btrfs_sysfs_remove_fsid(NULL);
 	kset_unregister(btrfs_kset);
 	debugfs_remove_recursive(btrfs_debugfs_root_dentry);
 }
@@ -855,7 +856,8 @@ void btrfs_sysfs_prepare_sprout_reset(void)
 }
 
 void btrfs_sysfs_prepare_sprout(struct btrfs_fs_devices *fs_devices,
-				struct btrfs_fs_devices *seed_devices)
+				struct btrfs_fs_devices *seed_devices,
+				struct btrfs_fs_devices *old_devices)
 {
 	char fsid_buf[BTRFS_UUID_UNPARSED_SIZE];
 
@@ -898,4 +900,7 @@ void btrfs_sysfs_prepare_sprout(struct btrfs_fs_devices *fs_devices,
 					&seed_devices->super_kobj))
 			pr_warn("Btrfs: sysfs: kobject move failed\n");
 	}
+
+	btrfs_sysfs_add_fsid(old_devices, NULL, 0);
+	btrfs_sysfs_add_device(old_devices, 0);
 }
diff --git a/fs/btrfs/sysfs.h b/fs/btrfs/sysfs.h
index b23e94c..34b9864 100644
--- a/fs/btrfs/sysfs.h
+++ b/fs/btrfs/sysfs.h
@@ -79,5 +79,6 @@ int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs,
 int btrfs_sysfs_add_device(struct btrfs_fs_devices *fs_devs, int follow_seed);
 void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs);
 void btrfs_sysfs_prepare_sprout(struct btrfs_fs_devices *fs_devices,
-				struct btrfs_fs_devices *seed_devices);
+				struct btrfs_fs_devices *seed_devices,
+				struct btrfs_fs_devices *old_devices);
 #endif /* _BTRFS_SYSFS_H_ */
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index bf59224..dfb5062 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -523,6 +523,10 @@ static noinline int device_list_add(const char *path,
 		list_add(&fs_devices->list, &fs_uuids);
 
 		device = NULL;
+		if (btrfs_sysfs_add_fsid(fs_devices, NULL, 0))
+			printk(KERN_WARNING "Btrfs: sysfs add fsid failed\n");
+		if (btrfs_sysfs_add_device(fs_devices, 0))
+			printk(KERN_WARNING "Btrfs: sysfs add device failed\n");
 	} else {
 		device = __find_device(&fs_devices->devices, devid,
 				       disk_super->dev_item.uuid);
@@ -2064,7 +2068,7 @@ static int btrfs_prepare_sprout(struct btrfs_root *root)
 		      ~BTRFS_SUPER_FLAG_SEEDING;
 	btrfs_set_super_flags(disk_super, super_flags);
 
-	btrfs_sysfs_prepare_sprout(fs_devices, seed_devices);
+	btrfs_sysfs_prepare_sprout(fs_devices, seed_devices, old_devices);
 
 	return 0;
 }
-- 
2.0.0.153.g79dcccc


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [PATCH 25/26] Btrfs: sysfs: support seed devices in the sysfs layout v3
  2015-03-09 22:38 ` [PATCH 25/26] Btrfs: sysfs: support seed devices in the sysfs layout v3 Anand Jain
@ 2015-03-19 18:55   ` David Sterba
  2015-03-20  1:58     ` Anand Jain
  0 siblings, 1 reply; 31+ messages in thread
From: David Sterba @ 2015-03-19 18:55 UTC (permalink / raw)
  To: Anand Jain; +Cc: linux-btrfs, dsterba

On Tue, Mar 10, 2015 at 06:38:43AM +0800, Anand Jain wrote:
>   by using the kobject_move()

Then you should add the kobject_move patch to this patchset as well,
with Greg's ack.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added
  2015-03-09 22:38 [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added Anand Jain
                   ` (25 preceding siblings ...)
  2015-03-09 22:38 ` [PATCH 26/26] Btrfs: create sys/fs/btrfs/fsid when scanned instead of when mounted Anand Jain
@ 2015-03-19 18:58 ` David Sterba
  2015-03-20 10:03   ` Anand Jain
  26 siblings, 1 reply; 31+ messages in thread
From: David Sterba @ 2015-03-19 18:58 UTC (permalink / raw)
  To: Anand Jain; +Cc: linux-btrfs, dsterba

On Tue, Mar 10, 2015 at 06:38:18AM +0800, Anand Jain wrote:
> This patch set will provide a framework and help to create attributes
> from the structure btrfs_fs_devices which are available even before
> fs_info is created. So by moving the parent kobject super_kobj from
> fs_info to btrfs_fs_devices, it will help to create attributes
> from the btrfs_fs_devices as well.

FYI, I'm going to test this patchset and prepare a pull for Chris if
everything goes fine.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 25/26] Btrfs: sysfs: support seed devices in the sysfs layout v3
  2015-03-19 18:55   ` David Sterba
@ 2015-03-20  1:58     ` Anand Jain
  0 siblings, 0 replies; 31+ messages in thread
From: Anand Jain @ 2015-03-20  1:58 UTC (permalink / raw)
  To: dsterba, linux-btrfs


    OK will do.

Thanks, Anand


On 03/20/2015 02:55 AM, David Sterba wrote:
> On Tue, Mar 10, 2015 at 06:38:43AM +0800, Anand Jain wrote:
>>    by using the kobject_move()
>
> Then you should add the kobject_move patch to this patchset as well,
> with Greg's ack.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added
  2015-03-19 18:58 ` [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added David Sterba
@ 2015-03-20 10:03   ` Anand Jain
  0 siblings, 0 replies; 31+ messages in thread
From: Anand Jain @ 2015-03-20 10:03 UTC (permalink / raw)
  To: dsterba, linux-btrfs



V5 has been sent out with the kobject_move patch,
kindly use v5.

Thanks, Anand

On 03/20/2015 02:58 AM, David Sterba wrote:
> On Tue, Mar 10, 2015 at 06:38:18AM +0800, Anand Jain wrote:
>> This patch set will provide a framework and help to create attributes
>> from the structure btrfs_fs_devices which are available even before
>> fs_info is created. So by moving the parent kobject super_kobj from
>> fs_info to btrfs_fs_devices, it will help to create attributes
>> from the btrfs_fs_devices as well.
>
> FYI, I'm going to test this patchset and prepare a pull for Chris if
> everything goes fine.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2015-03-20 10:05 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-09 22:38 [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added Anand Jain
2015-03-09 22:38 ` [PATCH 01/26] Btrfs: sysfs: fix, btrfs_release_super_kobj() should to clean up the kobject data Anand Jain
2015-03-09 22:38 ` [PATCH 02/26] Btrfs: sysfs: fix, fs_info kobject_unregister has init_completion() twice Anand Jain
2015-03-09 22:38 ` [PATCH 03/26] Btrfs: sysfs: fix, undo sysfs device links Anand Jain
2015-03-09 22:38 ` [PATCH 04/26] Btrfs: sysfs: fix, kobject pointer clean up needed after kobject release Anand Jain
2015-03-09 22:38 ` [PATCH 05/26] Btrfc: sysfs: fix, check if device_dir_kobj is init before destroy Anand Jain
2015-03-09 22:38 ` [PATCH 06/26] Btrfs: sysfs: reorder the kobject creations Anand Jain
2015-03-09 22:38 ` [PATCH 07/26] Btrfs: sysfs: rename __btrfs_sysfs_remove_one to btrfs_sysfs_remove_fsid Anand Jain
2015-03-09 22:38 ` [PATCH 08/26] Btrfs: sysfs: introduce function btrfs_sysfs_add_fsid() to create sysfs fsid Anand Jain
2015-03-09 22:38 ` [PATCH 09/26] Btrfs: sysfs: let default_attrs be separate from the kset Anand Jain
2015-03-09 22:38 ` [PATCH 10/26] Btrfs: sysfs: separate device kobject and its attribute creation Anand Jain
2015-03-09 22:38 ` [PATCH 11/26] Btrfs: sysfs: move super_kobj and device_dir_kobj from fs_info to btrfs_fs_devices Anand Jain
2015-03-09 22:38 ` [PATCH 12/26] Btrfs: introduce btrfs_get_fs_uuids to get fs_uuids v2 Anand Jain
2015-03-09 22:38 ` [PATCH 13/26] Btrfs: sysfs: add pointer to access fs_info from fs_devices v2 Anand Jain
2015-03-09 22:38 ` [PATCH 14/26] Btrfs: sysfs: provide framework to remove all fsid sysfs kobject v2 Anand Jain
2015-03-09 22:38 ` [PATCH 15/26] Btrfs: sysfs btrfs_kobj_add_device() pass fs_devices instead of fs_info Anand Jain
2015-03-09 22:38 ` [PATCH 16/26] Btrfs: sysfs btrfs_kobj_rm_device() " Anand Jain
2015-03-09 22:38 ` [PATCH 17/26] Btrfs: sysfs: make btrfs_sysfs_add_fsid() non static Anand Jain
2015-03-09 22:38 ` [PATCH 18/26] Btrfs: sysfs: make btrfs_sysfs_add_device() " Anand Jain
2015-03-09 22:38 ` [PATCH 19/26] Btrfs: sysfs: btrfs_sysfs_remove_fsid() make it " Anand Jain
2015-03-09 22:38 ` [PATCH 20/26] Btrfs: sysfs: separate kobject and attribute creation Anand Jain
2015-03-09 22:38 ` [PATCH 21/26] Btrfs: sysfs: add support to add parent for fsid Anand Jain
2015-03-09 22:38 ` [PATCH 22/26] Btrfs: sysfs: don't fail seeding for the sake of sysfs kobject issue v2 Anand Jain
2015-03-09 22:38 ` [PATCH 23/26] Btrfs: free the stale device Anand Jain
2015-03-09 22:38 ` [PATCH 24/26] Btrfs: sysfs: add support to show replacing target in the sysfs Anand Jain
2015-03-09 22:38 ` [PATCH 25/26] Btrfs: sysfs: support seed devices in the sysfs layout v3 Anand Jain
2015-03-19 18:55   ` David Sterba
2015-03-20  1:58     ` Anand Jain
2015-03-09 22:38 ` [PATCH 26/26] Btrfs: create sys/fs/btrfs/fsid when scanned instead of when mounted Anand Jain
2015-03-19 18:58 ` [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added David Sterba
2015-03-20 10:03   ` Anand Jain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).