From: Anand Jain Date: Tue, 3 Jul 2018 09:07:23 +0000 (+0800) Subject: btrfs: fix in-memory value of total_devices after seed device deletion X-Git-Tag: 4.19-rc-smb3~133^2~95 X-Git-Url: http://git.samba.org/samba.git/?p=sfrench%2Fcifs-2.6.git;a=commitdiff_plain;h=b4993e64f78a9605b45252fa9ba385c88a1f4ce9;ds=sidebyside btrfs: fix in-memory value of total_devices after seed device deletion In case of deleting the seed device the %cur_devices (seed) and the %fs_devices (parent) are different. Now, as the parent fs_devices::total_devices also maintains the total number of devices including the seed device, so decrement its in-memory value for the successful seed delete. We are already updating its corresponding on-disk btrfs_super_block::number_devices value. Signed-off-by: Anand Jain Signed-off-by: David Sterba --- diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 211fb2161487..f532e855b507 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -2026,6 +2026,9 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, const char *device_path, cur_devices->num_devices--; cur_devices->total_devices--; + /* Update total_devices of the parent fs_devices if it's seed */ + if (cur_devices != fs_devices) + fs_devices->total_devices--; if (test_bit(BTRFS_DEV_STATE_MISSING, &device->dev_state)) cur_devices->missing_devices--;