All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/8] btrfs: preparatory to make btrfs_rm_dev_replace_srcdev() seed aware
@ 2014-08-13  6:24 Anand Jain
  2014-08-13  6:24 ` [PATCH 2/8] btrfs: replace seed device followed by unmount causes kernel WARNING Anand Jain
                   ` (6 more replies)
  0 siblings, 7 replies; 13+ messages in thread
From: Anand Jain @ 2014-08-13  6:24 UTC (permalink / raw)
  To: linux-btrfs

There is no logical change in this patch, just a preparatory patch,
so that changes can be easily reasoned.

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

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 5f634b6..5fd0132 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1960,19 +1960,23 @@ error_undo:
 void btrfs_rm_dev_replace_srcdev(struct btrfs_fs_info *fs_info,
 				 struct btrfs_device *srcdev)
 {
+	struct btrfs_fs_devices *fs_devices;
+
 	WARN_ON(!mutex_is_locked(&fs_info->fs_devices->device_list_mutex));
 
+	fs_devices = fs_info->fs_devices;
+
 	list_del_rcu(&srcdev->dev_list);
 	list_del_rcu(&srcdev->dev_alloc_list);
-	fs_info->fs_devices->num_devices--;
+	fs_devices->num_devices--;
 	if (srcdev->missing) {
-		fs_info->fs_devices->missing_devices--;
-		fs_info->fs_devices->rw_devices++;
+		fs_devices->missing_devices--;
+		fs_devices->rw_devices++;
 	}
 	if (srcdev->can_discard)
-		fs_info->fs_devices->num_can_discard--;
+		fs_devices->num_can_discard--;
 	if (srcdev->bdev) {
-		fs_info->fs_devices->open_devices--;
+		fs_devices->open_devices--;
 
 		/*
 		 * zero out the old super if it is not writable
-- 
2.0.0.153.g79dcccc


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

* [PATCH 2/8] btrfs: replace seed device followed by unmount causes kernel WARNING
  2014-08-13  6:24 [PATCH 1/8] btrfs: preparatory to make btrfs_rm_dev_replace_srcdev() seed aware Anand Jain
@ 2014-08-13  6:24 ` Anand Jain
  2014-08-19 15:44   ` David Sterba
  2014-08-20  2:56   ` [PATCH 2/8 v2] " Anand Jain
  2014-08-13  6:24 ` [PATCH 3/8] btrfs: fix rw_devices miss match after seed replace Anand Jain
                   ` (5 subsequent siblings)
  6 siblings, 2 replies; 13+ messages in thread
From: Anand Jain @ 2014-08-13  6:24 UTC (permalink / raw)
  To: linux-btrfs

reproducer:
mount /dev/sdb /btrfs
btrfs dev add /dev/sdc /btrfs
btrfs rep start -B /dev/sdb /dev/sdd /btrfs
umount /btrfs

WARNING: CPU: 0 PID: 12661 at fs/btrfs/volumes.c:891 __btrfs_close_devices+0x1b0/0x200 [btrfs]()
::

__btrfs_close_devices()
::
        WARN_ON(fs_devices->open_devices);

After the seed device has been replaced the new target device
is no more a seed device. So we need to update the device
numbers in the fs_devices as pointed by the fs_info.

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

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 5fd0132..f098ae7 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1964,7 +1964,13 @@ void btrfs_rm_dev_replace_srcdev(struct btrfs_fs_info *fs_info,
 
 	WARN_ON(!mutex_is_locked(&fs_info->fs_devices->device_list_mutex));
 
-	fs_devices = fs_info->fs_devices;
+	/*
+	 * in case of fs with no seed, srcdev->fs_devices will point
+	 * to fs_devices of fs_info. However when the dev being replaced is
+	 * a seed dev it will point to the seed's local fs_devices. In short
+	 * srcdev will have its correct fs_devices in both the cases.
+	 */
+	fs_devices = srcdev->fs_devices;
 
 	list_del_rcu(&srcdev->dev_list);
 	list_del_rcu(&srcdev->dev_alloc_list);
-- 
2.0.0.153.g79dcccc


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

* [PATCH 3/8] btrfs: fix rw_devices miss match after seed replace
  2014-08-13  6:24 [PATCH 1/8] btrfs: preparatory to make btrfs_rm_dev_replace_srcdev() seed aware Anand Jain
  2014-08-13  6:24 ` [PATCH 2/8] btrfs: replace seed device followed by unmount causes kernel WARNING Anand Jain
@ 2014-08-13  6:24 ` Anand Jain
  2014-08-13  6:24 ` [PATCH 4/8 v2] btrfs: update sprout seed pointer when seed fs is relinquished Anand Jain
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Anand Jain @ 2014-08-13  6:24 UTC (permalink / raw)
  To: linux-btrfs

reproducer:
    reproducer:
    mount /dev/sdb /btrfs
    btrfs dev add /dev/sdc /btrfs
    btrfs rep start -B /dev/sdb /dev/sdd /btrfs
    umount /btrfs

WARNING: CPU: 0 PID: 3882 at fs/btrfs/volumes.c:892 __btrfs_close_devices+0x1c8/0x200 [btrfs]()

which is

        WARN_ON(fs_devices->rw_devices);

   The problem here is that we did not add one to the rw_devices when
   we replace the seed device with a writable device.

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

diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index eea26e1..fb0a7fa 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -562,6 +562,8 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
 	if (fs_info->fs_devices->latest_bdev == src_device->bdev)
 		fs_info->fs_devices->latest_bdev = tgt_device->bdev;
 	list_add(&tgt_device->dev_alloc_list, &fs_info->fs_devices->alloc_list);
+	if (src_device->fs_devices->seeding)
+		fs_info->fs_devices->rw_devices++;
 
 	/* replace the sysfs entry */
 	btrfs_kobj_rm_device(fs_info, src_device);
-- 
2.0.0.153.g79dcccc


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

* [PATCH 4/8 v2] btrfs: update sprout seed pointer when seed fs is relinquished
  2014-08-13  6:24 [PATCH 1/8] btrfs: preparatory to make btrfs_rm_dev_replace_srcdev() seed aware Anand Jain
  2014-08-13  6:24 ` [PATCH 2/8] btrfs: replace seed device followed by unmount causes kernel WARNING Anand Jain
  2014-08-13  6:24 ` [PATCH 3/8] btrfs: fix rw_devices miss match after seed replace Anand Jain
@ 2014-08-13  6:24 ` Anand Jain
  2014-08-13  6:24 ` [PATCH 5/8] btrfs: fix memory leak when there is no more seed device Anand Jain
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Anand Jain @ 2014-08-13  6:24 UTC (permalink / raw)
  To: linux-btrfs

We are not updating sprout fs seed pointer when all seed device
is replaced. This patch will check if all seed device has been
replaced and then update the sprout pointer accordingly.

Same reproducer as in the previous patch would apply here.
And notice that btrfs_close_device will check if seed fs is
present and spits out the error with out this patch.

int btrfs_close_devices(struct btrfs_fs_devices *fs_devices)
{
::
                seed_devices = fs_devices->seed;
::
        while (seed_devices) {
                fs_devices = seed_devices;
                seed_devices = fs_devices->seed;
                __btrfs_close_devices(fs_devices);
                free_fs_devices(fs_devices);
        }

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 v2: fixes per Miao review. also keep the list pointer update to the last

 fs/btrfs/volumes.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index f098ae7..6716658 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1993,6 +1993,27 @@ void btrfs_rm_dev_replace_srcdev(struct btrfs_fs_info *fs_info,
 	}
 
 	call_rcu(&srcdev->rcu, free_device);
+
+	/*
+	 * unless fs_devices is seed fs, num_devices shouldn't go
+	 * zero
+	 */
+	BUG_ON(!fs_devices->num_devices && !fs_devices->seeding);
+
+	/* if this is no devs we rather delete the fs_devices */
+	if (!fs_devices->num_devices) {
+		struct btrfs_fs_devices *tmp_fs_devices;
+
+		tmp_fs_devices = fs_info->fs_devices;
+		while (tmp_fs_devices) {
+			if (tmp_fs_devices->seed == fs_devices) {
+				tmp_fs_devices->seed = fs_devices->seed;
+				break;
+			}
+			tmp_fs_devices = tmp_fs_devices->seed;
+		}
+		fs_devices->seed = NULL;
+	}
 }
 
 void btrfs_destroy_dev_replace_tgtdev(struct btrfs_fs_info *fs_info,
-- 
2.0.0.153.g79dcccc


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

* [PATCH 5/8] btrfs: fix memory leak when there is no more seed device
  2014-08-13  6:24 [PATCH 1/8] btrfs: preparatory to make btrfs_rm_dev_replace_srcdev() seed aware Anand Jain
                   ` (2 preceding siblings ...)
  2014-08-13  6:24 ` [PATCH 4/8 v2] btrfs: update sprout seed pointer when seed fs is relinquished Anand Jain
@ 2014-08-13  6:24 ` Anand Jain
  2014-08-13  6:24 ` [PATCH 6/8] btrfs: rw_devices shouldn't be incremented for seed fs in btrfs_rm_dev_replace_srcdev() Anand Jain
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Anand Jain @ 2014-08-13  6:24 UTC (permalink / raw)
  To: linux-btrfs

When we replace all the seed device in the system there is
no point in just keeping the btrfs_fs_devices with out
any device

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

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 6716658..314bbbf 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2013,6 +2013,8 @@ void btrfs_rm_dev_replace_srcdev(struct btrfs_fs_info *fs_info,
 			tmp_fs_devices = tmp_fs_devices->seed;
 		}
 		fs_devices->seed = NULL;
+		__btrfs_close_devices(fs_devices);
+		free_fs_devices(fs_devices);
 	}
 }
 
-- 
2.0.0.153.g79dcccc


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

* [PATCH 6/8] btrfs: rw_devices shouldn't be incremented for seed fs in btrfs_rm_dev_replace_srcdev()
  2014-08-13  6:24 [PATCH 1/8] btrfs: preparatory to make btrfs_rm_dev_replace_srcdev() seed aware Anand Jain
                   ` (3 preceding siblings ...)
  2014-08-13  6:24 ` [PATCH 5/8] btrfs: fix memory leak when there is no more seed device Anand Jain
@ 2014-08-13  6:24 ` Anand Jain
  2014-08-13  6:24 ` [PATCH 7/8] btrfs: fix typo in the log message Anand Jain
  2014-08-13  6:24 ` [PATCH 8/8] btrfs: rename total_bytes to avoid confusion Anand Jain
  6 siblings, 0 replies; 13+ messages in thread
From: Anand Jain @ 2014-08-13  6:24 UTC (permalink / raw)
  To: linux-btrfs

seed fs devices don't participate as rw_device, so don't increment
rw_devices when the device being handled belongs to a seed fs.

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

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 314bbbf..bf99e82 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1977,7 +1977,8 @@ void btrfs_rm_dev_replace_srcdev(struct btrfs_fs_info *fs_info,
 	fs_devices->num_devices--;
 	if (srcdev->missing) {
 		fs_devices->missing_devices--;
-		fs_devices->rw_devices++;
+		if (!fs_devices->seeding)
+			fs_devices->rw_devices++;
 	}
 	if (srcdev->can_discard)
 		fs_devices->num_can_discard--;
-- 
2.0.0.153.g79dcccc


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

* [PATCH 7/8] btrfs: fix typo in the log message
  2014-08-13  6:24 [PATCH 1/8] btrfs: preparatory to make btrfs_rm_dev_replace_srcdev() seed aware Anand Jain
                   ` (4 preceding siblings ...)
  2014-08-13  6:24 ` [PATCH 6/8] btrfs: rw_devices shouldn't be incremented for seed fs in btrfs_rm_dev_replace_srcdev() Anand Jain
@ 2014-08-13  6:24 ` Anand Jain
  2014-08-13  6:24 ` [PATCH 8/8] btrfs: rename total_bytes to avoid confusion Anand Jain
  6 siblings, 0 replies; 13+ messages in thread
From: Anand Jain @ 2014-08-13  6:24 UTC (permalink / raw)
  To: linux-btrfs

there is no matching open parenthesis for the closing parenthesis

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

diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index fb0a7fa..64657b3 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -542,7 +542,7 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
 	}
 
 	printk_in_rcu(KERN_INFO
-		      "BTRFS: dev_replace from %s (devid %llu) to %s) finished\n",
+		      "BTRFS: dev_replace from %s (devid %llu) to %s finished\n",
 		      src_device->missing ? "<missing disk>" :
 		        rcu_str_deref(src_device->name),
 		      src_device->devid,
-- 
2.0.0.153.g79dcccc


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

* [PATCH 8/8] btrfs: rename total_bytes to avoid confusion
  2014-08-13  6:24 [PATCH 1/8] btrfs: preparatory to make btrfs_rm_dev_replace_srcdev() seed aware Anand Jain
                   ` (5 preceding siblings ...)
  2014-08-13  6:24 ` [PATCH 7/8] btrfs: fix typo in the log message Anand Jain
@ 2014-08-13  6:24 ` Anand Jain
  2014-08-19 15:37   ` David Sterba
  2014-08-20  2:54   ` [PATCH 8/8 v2] " Anand Jain
  6 siblings, 2 replies; 13+ messages in thread
From: Anand Jain @ 2014-08-13  6:24 UTC (permalink / raw)
  To: linux-btrfs

we are assigning number_devices to the total_bytes,
that's very confusing for a moment

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

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index bf99e82..c0c360a 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2253,7 +2253,7 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
 	struct list_head *devices;
 	struct super_block *sb = root->fs_info->sb;
 	struct rcu_string *name;
-	u64 total_bytes;
+	u64 ret_sz;
 	int seeding_dev = 0;
 	int ret = 0;
 
@@ -2356,13 +2356,13 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
 	if (!blk_queue_nonrot(bdev_get_queue(bdev)))
 		root->fs_info->fs_devices->rotating = 1;
 
-	total_bytes = btrfs_super_total_bytes(root->fs_info->super_copy);
+	ret_sz = btrfs_super_total_bytes(root->fs_info->super_copy);
 	btrfs_set_super_total_bytes(root->fs_info->super_copy,
-				    total_bytes + device->total_bytes);
+				    ret_sz + device->total_bytes);
 
-	total_bytes = btrfs_super_num_devices(root->fs_info->super_copy);
+	ret_sz = btrfs_super_num_devices(root->fs_info->super_copy);
 	btrfs_set_super_num_devices(root->fs_info->super_copy,
-				    total_bytes + 1);
+				    ret_sz + 1);
 
 	/* add sysfs device entry */
 	btrfs_kobj_add_device(root->fs_info, device);
-- 
2.0.0.153.g79dcccc


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

* Re: [PATCH 8/8] btrfs: rename total_bytes to avoid confusion
  2014-08-13  6:24 ` [PATCH 8/8] btrfs: rename total_bytes to avoid confusion Anand Jain
@ 2014-08-19 15:37   ` David Sterba
  2014-08-20  2:54   ` [PATCH 8/8 v2] " Anand Jain
  1 sibling, 0 replies; 13+ messages in thread
From: David Sterba @ 2014-08-19 15:37 UTC (permalink / raw)
  To: Anand Jain; +Cc: linux-btrfs

On Wed, Aug 13, 2014 at 02:24:26PM +0800, Anand Jain wrote:
> we are assigning number_devices to the total_bytes,
> that's very confusing for a moment
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
>  fs/btrfs/volumes.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index bf99e82..c0c360a 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -2253,7 +2253,7 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
>  	struct list_head *devices;
>  	struct super_block *sb = root->fs_info->sb;
>  	struct rcu_string *name;
> -	u64 total_bytes;
> +	u64 ret_sz;

A 'tmp' would do, but whatever

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

* Re: [PATCH 2/8] btrfs: replace seed device followed by unmount causes kernel WARNING
  2014-08-13  6:24 ` [PATCH 2/8] btrfs: replace seed device followed by unmount causes kernel WARNING Anand Jain
@ 2014-08-19 15:44   ` David Sterba
  2014-08-20  2:56   ` [PATCH 2/8 v2] " Anand Jain
  1 sibling, 0 replies; 13+ messages in thread
From: David Sterba @ 2014-08-19 15:44 UTC (permalink / raw)
  To: Anand Jain; +Cc: linux-btrfs

On Wed, Aug 13, 2014 at 02:24:20PM +0800, Anand Jain wrote:
> reproducer:
> mount /dev/sdb /btrfs
> btrfs dev add /dev/sdc /btrfs
> btrfs rep start -B /dev/sdb /dev/sdd /btrfs
> umount /btrfs
> 
> WARNING: CPU: 0 PID: 12661 at fs/btrfs/volumes.c:891 __btrfs_close_devices+0x1b0/0x200 [btrfs]()
> ::
> 
> __btrfs_close_devices()
> ::
>         WARN_ON(fs_devices->open_devices);
> 
> After the seed device has been replaced the new target device
> is no more a seed device. So we need to update the device
> numbers in the fs_devices as pointed by the fs_info.
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>

A formality: if you get a reviewed-by from somebody and the patch does
not change in the next iteration, add the tag to the patch as well. This
will ensure the review credit is not lost.
Otherwise, pinging the maintainer with a forgotten reviewed-by also works.

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

* [PATCH 8/8 v2] btrfs: rename total_bytes to avoid confusion
  2014-08-13  6:24 ` [PATCH 8/8] btrfs: rename total_bytes to avoid confusion Anand Jain
  2014-08-19 15:37   ` David Sterba
@ 2014-08-20  2:54   ` Anand Jain
  2014-08-20 14:29     ` David Sterba
  1 sibling, 1 reply; 13+ messages in thread
From: Anand Jain @ 2014-08-20  2:54 UTC (permalink / raw)
  To: linux-btrfs

we are assigning number_devices to the total_bytes,
that's very confusing for a moment

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v2: accepts David comment renames ret_sz to tmp

 fs/btrfs/volumes.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index bf99e82..718f734 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2253,7 +2253,7 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
 	struct list_head *devices;
 	struct super_block *sb = root->fs_info->sb;
 	struct rcu_string *name;
-	u64 total_bytes;
+	u64 tmp;
 	int seeding_dev = 0;
 	int ret = 0;
 
@@ -2356,13 +2356,13 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
 	if (!blk_queue_nonrot(bdev_get_queue(bdev)))
 		root->fs_info->fs_devices->rotating = 1;
 
-	total_bytes = btrfs_super_total_bytes(root->fs_info->super_copy);
+	tmp = btrfs_super_total_bytes(root->fs_info->super_copy);
 	btrfs_set_super_total_bytes(root->fs_info->super_copy,
-				    total_bytes + device->total_bytes);
+				    tmp + device->total_bytes);
 
-	total_bytes = btrfs_super_num_devices(root->fs_info->super_copy);
+	tmp = btrfs_super_num_devices(root->fs_info->super_copy);
 	btrfs_set_super_num_devices(root->fs_info->super_copy,
-				    total_bytes + 1);
+				    tmp + 1);
 
 	/* add sysfs device entry */
 	btrfs_kobj_add_device(root->fs_info, device);
-- 
2.0.0.153.g79dcccc


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

* [PATCH 2/8 v2] btrfs: replace seed device followed by unmount causes kernel WARNING
  2014-08-13  6:24 ` [PATCH 2/8] btrfs: replace seed device followed by unmount causes kernel WARNING Anand Jain
  2014-08-19 15:44   ` David Sterba
@ 2014-08-20  2:56   ` Anand Jain
  1 sibling, 0 replies; 13+ messages in thread
From: Anand Jain @ 2014-08-20  2:56 UTC (permalink / raw)
  To: linux-btrfs

reproducer:
mount /dev/sdb /btrfs
btrfs dev add /dev/sdc /btrfs
btrfs rep start -B /dev/sdb /dev/sdd /btrfs
umount /btrfs

WARNING: CPU: 0 PID: 12661 at fs/btrfs/volumes.c:891 __btrfs_close_devices+0x1b0/0x200 [btrfs]()
::

__btrfs_close_devices()
::
        WARN_ON(fs_devices->open_devices);

After the seed device has been replaced the new target device
is no more a seed device. So we need to update the device
numbers in the fs_devices as pointed by the fs_info.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Miao Xie <miaox@cn.fujitsu.com>
---
v2: sorry had missed the Reviewed by tag, Thxs David

 fs/btrfs/volumes.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 5fd0132..f098ae7 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1964,7 +1964,13 @@ void btrfs_rm_dev_replace_srcdev(struct btrfs_fs_info *fs_info,
 
 	WARN_ON(!mutex_is_locked(&fs_info->fs_devices->device_list_mutex));
 
-	fs_devices = fs_info->fs_devices;
+	/*
+	 * in case of fs with no seed, srcdev->fs_devices will point
+	 * to fs_devices of fs_info. However when the dev being replaced is
+	 * a seed dev it will point to the seed's local fs_devices. In short
+	 * srcdev will have its correct fs_devices in both the cases.
+	 */
+	fs_devices = srcdev->fs_devices;
 
 	list_del_rcu(&srcdev->dev_list);
 	list_del_rcu(&srcdev->dev_alloc_list);
-- 
2.0.0.153.g79dcccc


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

* Re: [PATCH 8/8 v2] btrfs: rename total_bytes to avoid confusion
  2014-08-20  2:54   ` [PATCH 8/8 v2] " Anand Jain
@ 2014-08-20 14:29     ` David Sterba
  0 siblings, 0 replies; 13+ messages in thread
From: David Sterba @ 2014-08-20 14:29 UTC (permalink / raw)
  To: Anand Jain; +Cc: linux-btrfs

On Wed, Aug 20, 2014 at 10:54:17AM +0800, Anand Jain wrote:
> we are assigning number_devices to the total_bytes,
> that's very confusing for a moment
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>

Thanks.

Reviewed-by: David Sterba <dsterba@suse.cz>

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

end of thread, other threads:[~2014-08-20 14:29 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-13  6:24 [PATCH 1/8] btrfs: preparatory to make btrfs_rm_dev_replace_srcdev() seed aware Anand Jain
2014-08-13  6:24 ` [PATCH 2/8] btrfs: replace seed device followed by unmount causes kernel WARNING Anand Jain
2014-08-19 15:44   ` David Sterba
2014-08-20  2:56   ` [PATCH 2/8 v2] " Anand Jain
2014-08-13  6:24 ` [PATCH 3/8] btrfs: fix rw_devices miss match after seed replace Anand Jain
2014-08-13  6:24 ` [PATCH 4/8 v2] btrfs: update sprout seed pointer when seed fs is relinquished Anand Jain
2014-08-13  6:24 ` [PATCH 5/8] btrfs: fix memory leak when there is no more seed device Anand Jain
2014-08-13  6:24 ` [PATCH 6/8] btrfs: rw_devices shouldn't be incremented for seed fs in btrfs_rm_dev_replace_srcdev() Anand Jain
2014-08-13  6:24 ` [PATCH 7/8] btrfs: fix typo in the log message Anand Jain
2014-08-13  6:24 ` [PATCH 8/8] btrfs: rename total_bytes to avoid confusion Anand Jain
2014-08-19 15:37   ` David Sterba
2014-08-20  2:54   ` [PATCH 8/8 v2] " Anand Jain
2014-08-20 14:29     ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.