aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/disk-io.c
diff options
context:
space:
mode:
authorXiao Guangrong <xiaoguangrong@cn.fujitsu.com>2011-04-20 06:07:30 -0400
committerChris Mason <chris.mason@oracle.com>2011-05-23 13:24:42 -0400
commitc9513edb0079f97749c2ac00c887a22c4ba44792 (patch)
tree6b34bd7cdf5dcd882e61bf4912ae10b4de3b87dd /fs/btrfs/disk-io.c
parent4f6c9328c6c0d8558907f16579a9d47815abef80 (diff)
Btrfs: fix the race between reading and updating devices
On btrfs_congested_fn and __unplug_io_fn paths, we should hold device_list_mutex to avoid remove/add device path to update fs_devices->devices On __btrfs_close_devices and btrfs_prepare_sprout paths, the devices in fs_devices->devices or fs_devices->devices is updated, so we should hold the mutex to avoid the reader side to reach them Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r--fs/btrfs/disk-io.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 64b289690f9d..4e53a4fc467f 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1410,6 +1410,7 @@ static int btrfs_congested_fn(void *congested_data, int bdi_bits)
1410 struct btrfs_device *device; 1410 struct btrfs_device *device;
1411 struct backing_dev_info *bdi; 1411 struct backing_dev_info *bdi;
1412 1412
1413 mutex_lock(&info->fs_devices->device_list_mutex);
1413 list_for_each_entry(device, &info->fs_devices->devices, dev_list) { 1414 list_for_each_entry(device, &info->fs_devices->devices, dev_list) {
1414 if (!device->bdev) 1415 if (!device->bdev)
1415 continue; 1416 continue;
@@ -1419,6 +1420,7 @@ static int btrfs_congested_fn(void *congested_data, int bdi_bits)
1419 break; 1420 break;
1420 } 1421 }
1421 } 1422 }
1423 mutex_unlock(&info->fs_devices->device_list_mutex);
1422 return ret; 1424 return ret;
1423} 1425}
1424 1426