btrfs-progs: there is devid 0 when replace is running
PATCH 1/1 btrfs-progs: there is devid 0 when replace is running
as of now when the replace-er disk is add to dev list with its devid 0. We fail to obtain details of devid 0 since we don't query devid 0 at all as below.
---
btrfs rep start /dev/sdb /dev/sdf /btrfs
btrfs fi show
Label: none uuid: f8fb9819-16c8-47b7-b62f-0ff90f8c56cd
Total devices 3 FS bytes used 1.94GiB
devid 1 size 1.10GiB used 1.10GiB path /dev/sdb
devid 2 size 1.10GiB used 1.08GiB path /dev/sdc
devid 0 size 0.00 used 0.00 path
---
this patch will make it proper by querying dev id 0.
-----
btrfs repl start /dev/sdb /dev/sdf /btrfs btrfs fi show /btrfs
Label: none uuid: f8fb9819-16c8-47b7-b62f-0ff90f8c56cd
Total devices 3 FS bytes used 1.94GiB
devid 0 size 1.10GiB used 1.10GiB path /dev/sdf
devid 1 size 1.10GiB used 1.10GiB path /dev/sdb
devid 2 size 1.10GiB used 1.08GiB path /dev/sdc
-----
Its fine to query dev id 0 when there is no replace activity well because we just skip the error ENODEV
----
btrfs fi show /btrfs
Label: none uuid: f8fb9819-16c8-47b7-b62f-0ff90f8c56cd
Total devices 2 FS bytes used 1.94GiB
devid 1 size 1.10GiB used 1.10GiB path /dev/sdf
devid 2 size 1.10GiB used 1.08GiB path /dev/sdc
----
--- utils.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
utils.c +1 -1
@@ -1696,7 +1696,7 @@ int get_fs_info(char *path, struct btrfs_ioctl_fs_info_args *fi_args, goto out; } -for (; i <= fi_args->max_id; ++i) { +for (i =0 ; i <= fi_args->max_id; ++i) {BUG_ON (ndevs >= fi_args->num_devices); ret =get_device_info (fd, i, &di_args[ndevs]);if (ret == -ENODEV )
Signature · 1 line
1.7.1
PATCH v2 1/1 btrfs-progs: there is devid 0 when replace is running
During disk replacement a new disk is temporarily added to the fs devlist with devid 0 and fs num_device is incremented by 1. However when progs reads the devlist it fail to obtain details of devid 0 because it doesn't query devid 0 at all.
reproducer:
btrfs rep start /dev/sdb /dev/sdf /btrfs
btrfs fi show
Label: none uuid: f8fb9819-16c8-47b7-b62f-0ff90f8c56cd
Total devices 3 FS bytes used 1.94GiB
devid 1 size 1.10GiB used 1.10GiB path /dev/sdb
devid 2 size 1.10GiB used 1.08GiB path /dev/sdc
devid 0 size 0.00 used 0.00 path
this patch will make it proper by querying devid 0.
btrfs repl start /dev/sdb /dev/sdf /btrfs btrfs fi show /btrfs
Label: none uuid: f8fb9819-16c8-47b7-b62f-0ff90f8c56cd
Total devices 3 FS bytes used 1.94GiB
devid 0 size 1.10GiB used 1.10GiB path /dev/sdf
devid 1 size 1.10GiB used 1.10GiB path /dev/sdb
devid 2 size 1.10GiB used 1.08GiB path /dev/sdc
Its fine to query devid 0 when there is no replace activity as well, because we just skip the error ENODEV
btrfs fi show /btrfs
Label: none uuid: f8fb9819-16c8-47b7-b62f-0ff90f8c56cd
Total devices 2 FS bytes used 1.94GiB
devid 1 size 1.10GiB used 1.10GiB path /dev/sdf
devid 2 size 1.10GiB used 1.08GiB path /dev/sdc
---
v2: fix commit message
utils.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
utils.c +1 -1
@@ -1696,7 +1696,7 @@ int get_fs_info(char *path, struct btrfs_ioctl_fs_info_args *fi_args, goto out; } -for (; i <= fi_args->max_id; ++i) { +for (i =0 ; i <= fi_args->max_id; ++i) {BUG_ON (ndevs >= fi_args->num_devices); ret =get_device_info (fd, i, &di_args[ndevs]);if (ret == -ENODEV )
Signature · 1 line
1.7.1
kindly ignore this patch. Though it correct that we need to start from devid 0 to scan. But the individual scan is broken well before this patch. So to fix all together a patch bundle is sent to the mailing list including this
Thanks Anand
Quoted 55 lines · Anand Jain
During disk replacement a new disk is temporarily added to the fs devlist with devid 0 and fs
num_deviceis incremented by 1. However when progs reads the devlist it fail to obtain details of devid 0 because it doesn't query devid 0 at all.reproducer:
btrfs rep start
/dev/sdb/dev/sdf/btrfs
btrfs fi show
Label: none uuid: f8fb9819-16c8-47b7-b62f-0ff90f8c56cd
Total devices 3 FS bytes used 1.94GiB
devid 1 size 1.10GiB used 1.10GiB path/dev/sdb
devid 2 size 1.10GiB used 1.08GiB path/dev/sdc
devid 0 size 0.00 used 0.00 paththis patch will make it proper by querying devid 0.
btrfs repl start
/dev/sdb/dev/sdf/btrfs btrfs fi show /btrfs
Label: none uuid: f8fb9819-16c8-47b7-b62f-0ff90f8c56cd
Total devices 3 FS bytes used 1.94GiB
devid 0 size 1.10GiB used 1.10GiB path/dev/sdf
devid 1 size 1.10GiB used 1.10GiB path/dev/sdb
devid 2 size 1.10GiB used 1.08GiB path/dev/sdcIts fine to query devid 0 when there is no replace activity as well, because we just skip the error ENODEV
btrfs fi show /btrfs
Label: none uuid: f8fb9819-16c8-47b7-b62f-0ff90f8c56cd
Total devices 2 FS bytes used 1.94GiB
devid 1 size 1.10GiB used 1.10GiB path/dev/sdf
devid 2 size 1.10GiB used 1.08GiB path/dev/sdc
---v2: fix commit message
utils.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)utils.c +1
-1@@ -1696,7 +1696,7 @@ int get_fs_info(char *path, struct btrfs_ioctl_fs_info_args *fi_args, goto out; } -for (; i <= fi_args->max_id; ++i) { +for (i =0 ; i <= fi_args->max_id; ++i) {BUG_ON (ndevs >= fi_args->num_devices); ret =get_device_info (fd, i, &di_args[ndevs]);if (ret == -ENODEV )