Re: [PATCH 1/6] btrfs: do not check for ->num_devices == 0 in rm_device
From: Anand Jain <hidden>
Date: 2021-07-27 22:35:39
On 28/07/2021 03:47, Josef Bacik wrote:
We're specifically prohibited from removing the last device in a file system, so this check is meaningless and the code can be deleted.
Josef, That's not true when removing a seed device from the sprouted filesystem.
quoted hunk ↗ jump to hunk
Signed-off-by: Josef Bacik <josef@toxicpanda.com> --- fs/btrfs/volumes.c | 7 ------- 1 file changed, 7 deletions(-)diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 86846d6e58d0..373be4e54f28 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c@@ -2199,13 +2199,6 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, const char *device_path, btrfs_close_bdev(device); synchronize_rcu(); btrfs_free_device(device); - - if (cur_devices->open_devices == 0) { - list_del_init(&cur_devices->seed_list); - close_fs_devices(cur_devices); - free_fs_devices(cur_devices); - } -
Here the cur_devices will point to the seed devices, and generally, it is the last opened devices in its fs_devices structure. Comments about it is a few lines above from this. 2157 /* 2158 * In normal cases the cur_devices == fs_devices. But in case 2159 * of deleting a seed device, the cur_devices should point to 2160 * its own fs_devices listed under the fs_devices->seed. 2161 */ Thanks, Anand
out: mutex_unlock(&uuid_mutex); return ret;