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/ioctl.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/ioctl.c')
-rw-r--r-- | fs/btrfs/ioctl.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index ce773fb736a1..0de71feb8e1c 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c | |||
@@ -281,8 +281,9 @@ static noinline int btrfs_ioctl_fitrim(struct file *file, void __user *arg) | |||
281 | if (!capable(CAP_SYS_ADMIN)) | 281 | if (!capable(CAP_SYS_ADMIN)) |
282 | return -EPERM; | 282 | return -EPERM; |
283 | 283 | ||
284 | mutex_lock(&fs_info->fs_devices->device_list_mutex); | 284 | rcu_read_lock(); |
285 | list_for_each_entry(device, &fs_info->fs_devices->devices, dev_list) { | 285 | list_for_each_entry_rcu(device, &fs_info->fs_devices->devices, |
286 | dev_list) { | ||
286 | if (!device->bdev) | 287 | if (!device->bdev) |
287 | continue; | 288 | continue; |
288 | q = bdev_get_queue(device->bdev); | 289 | q = bdev_get_queue(device->bdev); |
@@ -292,7 +293,7 @@ static noinline int btrfs_ioctl_fitrim(struct file *file, void __user *arg) | |||
292 | minlen); | 293 | minlen); |
293 | } | 294 | } |
294 | } | 295 | } |
295 | mutex_unlock(&fs_info->fs_devices->device_list_mutex); | 296 | rcu_read_unlock(); |
296 | if (!num_devices) | 297 | if (!num_devices) |
297 | return -EOPNOTSUPP; | 298 | return -EOPNOTSUPP; |
298 | 299 | ||