diff mbox

btrfs: set device state reappearing missing device

Message ID 1527576609-9347-1-git-send-email-gujx@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Gu Jinxiang May 29, 2018, 6:50 a.m. UTC
From: Gu JinXiang <gujx@cn.fujitsu.com>

patch for commit 921518924084
("btrfs: handle dynamically reappearing missing device").

Since BTRFS_DEV_STATE_IN_FS_METADATA will be clear in
btrfs_open_one_device, and when alloc a new chunk in
__btrfs_alloc_chunk, device with BTRFS_DEV_STATE_IN_FS_METADATA
not be set will be skipped, so it can not alloc chunk correctly.

And from the source logic, BTRFS_DEV_STATE_IN_FS_METADATA should
be also set when reapearing a missing device.

And with this patch, xfstests-dev/tests/btrfs/154 should run
successfully.

Signed-off-by: Gu JinXiang <gujx@cn.fujitsu.com>
---
 fs/btrfs/volumes.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

David Sterba May 29, 2018, 3:48 p.m. UTC | #1
On Tue, May 29, 2018 at 02:50:09PM +0800, Gu Jinxiang wrote:
> From: Gu JinXiang <gujx@cn.fujitsu.com>
> 
> patch for commit 921518924084
> ("btrfs: handle dynamically reappearing missing device").

The commit is not in any of the development branches and I only found
the patch in the mailinglist, so this is for something still in
development and I'll leave it to Anand.
--
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
Anand Jain May 30, 2018, 6:16 a.m. UTC | #2
On 05/29/2018 02:50 PM, Gu Jinxiang wrote:
> From: Gu JinXiang <gujx@cn.fujitsu.com>
> 
> patch for commit 921518924084
> ("btrfs: handle dynamically reappearing missing device").
---
v4:
::
. No need to set in_fs_metadata flag as its already set on missing device
---

 > Since BTRFS_DEV_STATE_IN_FS_METADATA will be clear in
 > btrfs_open_one_device,

  Though v4 change log comment is right. But missed the point that
  btrfs_open_one_device() clears it. My bad. Thanks for the catch.

-Anand

> and when alloc a new chunk in
> __btrfs_alloc_chunk, device with BTRFS_DEV_STATE_IN_FS_METADATA
> not be set will be skipped, so it can not alloc chunk correctly.
> 
> And from the source logic, BTRFS_DEV_STATE_IN_FS_METADATA should
> be also set when reapearing a missing device.
> 
> And with this patch, xfstests-dev/tests/btrfs/154 should run
> successfully.
> 
> Signed-off-by: Gu JinXiang <gujx@cn.fujitsu.com>
> ---
>   fs/btrfs/volumes.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index 8699080ef505..bf8a41b2847e 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -849,6 +849,8 @@ static noinline struct btrfs_device *device_list_add(const char *path,
>   
>   			fs_devices->missing_devices--;
>   			clear_bit(BTRFS_DEV_STATE_MISSING, &device->dev_state);
> +			set_bit(BTRFS_DEV_STATE_IN_FS_METADATA,
> +					&device->dev_state);
>   
>   			if (test_bit(BTRFS_DEV_STATE_WRITEABLE,
>   				     &device->dev_state) &&
> 
--
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
diff mbox

Patch

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 8699080ef505..bf8a41b2847e 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -849,6 +849,8 @@  static noinline struct btrfs_device *device_list_add(const char *path,
 
 			fs_devices->missing_devices--;
 			clear_bit(BTRFS_DEV_STATE_MISSING, &device->dev_state);
+			set_bit(BTRFS_DEV_STATE_IN_FS_METADATA,
+					&device->dev_state);
 
 			if (test_bit(BTRFS_DEV_STATE_WRITEABLE,
 				     &device->dev_state) &&