Btrfs: do not add replace target to the alloc_list
PATCH 1/1 Btrfs: do not add replace target to the alloc_list
If replace was suspended by the umount, replace target device is added to the fs_devices->alloc_list during a later mount. This is obviously wrong. ->is_tgtdev_for_dev_replace is supposed to guard against that, but ->is_tgtdev_for_dev_replace is (and can only ever be) initialized *after* everything is opened and fs_devices lists are populated. Fix this by checking the devid instead: for replace targets it's always equal to BTRFS_DEV_REPLACE_DEVID.
---
At first I thought this was caused by my btrfs_device rollback patch, but no, it just made it easier to spot -- previously one had to reboot or rmmod/insmod before mounting a suspended replace.
fs/btrfs/volumes.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/volumes.c +2 -1
@@ -793,7 +793,8 @@ static int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices, fs_devices->rotating =1 ; fs_devices->open_devices++; -if (device->writeable && !device->is_tgtdev_for_dev_replace) { +if (device->writeable && + device->devid !=BTRFS_DEV_REPLACE_DEVID ) { fs_devices->rw_devices++;list_add (&device->dev_alloc_list, &fs_devices->alloc_list);
Signature · 1 line
1.7.10.4
Quoted 24 lines · Ilya Dryomov
If replace was suspended by the umount, replace target device is added to the
fs_devices->alloc_listduring a later mount. This is obviously wrong. ->is_tgtdev_for_dev_replace is supposed to guard against that, but ->is_tgtdev_for_dev_replace is (and can only ever be) initialized *after* everything is opened andfs_deviceslists are populated. Fix this by checking the devid instead: for replace targets it's always equal toBTRFS_DEV_REPLACE_DEVID.Cc Stefan Behrens <[email protected]>Signed-off-by Ilya Dryomov <[email protected]>---
At first I thought this was caused by mybtrfs_devicerollback patch, but no, it just made it easier to spot -- previously one had to reboot or rmmod/insmod before mounting a suspended replace.fs/btrfs/volumes.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)fs/btrfs/volumes.c +0
-0
fs/btrfs/volumes.c static int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices, · line 800
Quoted 9 lines
fs/btrfs/volumes.c +2
-1@@ -793,7 +793,8 @@ static int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices, fs_devices->rotating =1 ; fs_devices->open_devices++; -if (device->writeable && !device->is_tgtdev_for_dev_replace) { +if (device->writeable && + device->devid !=BTRFS_DEV_REPLACE_DEVID ) { fs_devices->rw_devices++;list_add (&device->dev_alloc_list, &fs_devices->alloc_list);