Commit 2fca0db0 authored by Anand Jain's avatar Anand Jain Committed by David Sterba

btrfs: reada: lock all seed/sprout devices in __reada_start_machine

On an fs mounted using a sprout device, the seed fs_devices are
maintained in a linked list under fs_info->fs_devices. Each seeds
fs_devices also has device_list_mutex initialized to protect against the
potential race with delete threads. But the delete thread (at
btrfs_rm_device()) is holding the fs_info::fs_devices::device_list_mutex
mutex which belongs to sprout device_list_mutex instead of seed
device_list_mutex. Moreover, there aren't any significient benefits in
using the seed::device_list_mutex instead of sprout::device_list_mutex.

So this patch converts them of using the seed::device_list_mutex to
sprout::device_list_mutex.
Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
Signed-off-by: default avatarAnand Jain <anand.jain@oracle.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 7ad3912a
...@@ -776,13 +776,11 @@ static int reada_start_for_fsdevs(struct btrfs_fs_devices *fs_devices) ...@@ -776,13 +776,11 @@ static int reada_start_for_fsdevs(struct btrfs_fs_devices *fs_devices)
do { do {
enqueued = 0; enqueued = 0;
mutex_lock(&fs_devices->device_list_mutex);
list_for_each_entry(device, &fs_devices->devices, dev_list) { list_for_each_entry(device, &fs_devices->devices, dev_list) {
if (atomic_read(&device->reada_in_flight) < if (atomic_read(&device->reada_in_flight) <
MAX_IN_FLIGHT) MAX_IN_FLIGHT)
enqueued += reada_start_machine_dev(device); enqueued += reada_start_machine_dev(device);
} }
mutex_unlock(&fs_devices->device_list_mutex);
total += enqueued; total += enqueued;
} while (enqueued && total < 10000); } while (enqueued && total < 10000);
...@@ -795,10 +793,13 @@ static void __reada_start_machine(struct btrfs_fs_info *fs_info) ...@@ -795,10 +793,13 @@ static void __reada_start_machine(struct btrfs_fs_info *fs_info)
int i; int i;
u64 enqueued = 0; u64 enqueued = 0;
mutex_lock(&fs_devices->device_list_mutex);
enqueued += reada_start_for_fsdevs(fs_devices); enqueued += reada_start_for_fsdevs(fs_devices);
list_for_each_entry(seed_devs, &fs_devices->seed_list, seed_list) list_for_each_entry(seed_devs, &fs_devices->seed_list, seed_list)
enqueued += reada_start_for_fsdevs(seed_devs); enqueued += reada_start_for_fsdevs(seed_devs);
mutex_unlock(&fs_devices->device_list_mutex);
if (enqueued == 0) if (enqueued == 0)
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment