diff options
author | Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> | 2011-04-20 06:09:16 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2011-05-23 13:24:43 -0400 |
commit | 1f78160ce1b1b8e657e2248118c4d91f881763f0 (patch) | |
tree | 98c5496a9ab3e77e4cd682c0487f4c0127198396 /fs/btrfs/disk-io.c | |
parent | 46224705656633466ca7dc71d81b3c0abc76cae4 (diff) |
Btrfs: using rcu lock in the reader side of devices list
fs_devices->devices is only updated on remove and add device paths, so we can
use rcu to protect it in the reader side
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.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 4e53a4fc467f..deba3d9c8853 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -1410,8 +1410,8 @@ 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 | rcu_read_lock(); |
1414 | list_for_each_entry(device, &info->fs_devices->devices, dev_list) { | 1414 | list_for_each_entry_rcu(device, &info->fs_devices->devices, dev_list) { |
1415 | if (!device->bdev) | 1415 | if (!device->bdev) |
1416 | continue; | 1416 | continue; |
1417 | bdi = blk_get_backing_dev_info(device->bdev); | 1417 | bdi = blk_get_backing_dev_info(device->bdev); |
@@ -1420,7 +1420,7 @@ static int btrfs_congested_fn(void *congested_data, int bdi_bits) | |||
1420 | break; | 1420 | break; |
1421 | } | 1421 | } |
1422 | } | 1422 | } |
1423 | mutex_unlock(&info->fs_devices->device_list_mutex); | 1423 | rcu_read_unlock(); |
1424 | return ret; | 1424 | return ret; |
1425 | } | 1425 | } |
1426 | 1426 | ||
@@ -2332,9 +2332,9 @@ int write_all_supers(struct btrfs_root *root, int max_mirrors) | |||
2332 | sb = &root->fs_info->super_for_commit; | 2332 | sb = &root->fs_info->super_for_commit; |
2333 | dev_item = &sb->dev_item; | 2333 | dev_item = &sb->dev_item; |
2334 | 2334 | ||
2335 | mutex_lock(&root->fs_info->fs_devices->device_list_mutex); | 2335 | rcu_read_lock(); |
2336 | head = &root->fs_info->fs_devices->devices; | 2336 | head = &root->fs_info->fs_devices->devices; |
2337 | list_for_each_entry(dev, head, dev_list) { | 2337 | list_for_each_entry_rcu(dev, head, dev_list) { |
2338 | if (!dev->bdev) { | 2338 | if (!dev->bdev) { |
2339 | total_errors++; | 2339 | total_errors++; |
2340 | continue; | 2340 | continue; |
@@ -2367,7 +2367,7 @@ int write_all_supers(struct btrfs_root *root, int max_mirrors) | |||
2367 | } | 2367 | } |
2368 | 2368 | ||
2369 | total_errors = 0; | 2369 | total_errors = 0; |
2370 | list_for_each_entry(dev, head, dev_list) { | 2370 | list_for_each_entry_rcu(dev, head, dev_list) { |
2371 | if (!dev->bdev) | 2371 | if (!dev->bdev) |
2372 | continue; | 2372 | continue; |
2373 | if (!dev->in_fs_metadata || !dev->writeable) | 2373 | if (!dev->in_fs_metadata || !dev->writeable) |
@@ -2377,7 +2377,7 @@ int write_all_supers(struct btrfs_root *root, int max_mirrors) | |||
2377 | if (ret) | 2377 | if (ret) |
2378 | total_errors++; | 2378 | total_errors++; |
2379 | } | 2379 | } |
2380 | mutex_unlock(&root->fs_info->fs_devices->device_list_mutex); | 2380 | rcu_read_unlock(); |
2381 | if (total_errors > max_errors) { | 2381 | if (total_errors > max_errors) { |
2382 | printk(KERN_ERR "btrfs: %d errors while writing supers\n", | 2382 | printk(KERN_ERR "btrfs: %d errors while writing supers\n", |
2383 | total_errors); | 2383 | total_errors); |