提交 7bcb8164 编写于 作者: A Anand Jain 提交者: David Sterba

btrfs: use device_list_mutex when removing stale devices

btrfs_free_stale_devices() finds a stale (not opened) device matching
path in the fs_uuid list. We are already under uuid_mutex so when we
check for each fs_devices, hold the device_list_mutex too.
Signed-off-by: NAnand Jain <anand.jain@oracle.com>
Reviewed-by: NDavid Sterba <dsterba@suse.com>
Signed-off-by: NDavid Sterba <dsterba@suse.com>
上级 fa6d2ae5
...@@ -637,8 +637,11 @@ static void btrfs_free_stale_devices(const char *path, ...@@ -637,8 +637,11 @@ static void btrfs_free_stale_devices(const char *path,
struct btrfs_device *device, *tmp_device; struct btrfs_device *device, *tmp_device;
list_for_each_entry_safe(fs_devices, tmp_fs_devices, &fs_uuids, fs_list) { list_for_each_entry_safe(fs_devices, tmp_fs_devices, &fs_uuids, fs_list) {
if (fs_devices->opened) mutex_lock(&fs_devices->device_list_mutex);
if (fs_devices->opened) {
mutex_unlock(&fs_devices->device_list_mutex);
continue; continue;
}
list_for_each_entry_safe(device, tmp_device, list_for_each_entry_safe(device, tmp_device,
&fs_devices->devices, dev_list) { &fs_devices->devices, dev_list) {
...@@ -658,16 +661,18 @@ static void btrfs_free_stale_devices(const char *path, ...@@ -658,16 +661,18 @@ static void btrfs_free_stale_devices(const char *path,
continue; continue;
/* delete the stale device */ /* delete the stale device */
if (fs_devices->num_devices == 1) { fs_devices->num_devices--;
btrfs_sysfs_remove_fsid(fs_devices); list_del(&device->dev_list);
list_del(&fs_devices->fs_list); btrfs_free_device(device);
free_fs_devices(fs_devices);
if (fs_devices->num_devices == 0)
break; break;
} else { }
fs_devices->num_devices--; mutex_unlock(&fs_devices->device_list_mutex);
list_del(&device->dev_list); if (fs_devices->num_devices == 0) {
btrfs_free_device(device); btrfs_sysfs_remove_fsid(fs_devices);
} list_del(&fs_devices->fs_list);
free_fs_devices(fs_devices);
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册