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>
This commit is contained in:
committed by
Chris Mason
parent
4622470565
commit
1f78160ce1
@@ -281,8 +281,9 @@ static noinline int btrfs_ioctl_fitrim(struct file *file, void __user *arg)
|
||||
if (!capable(CAP_SYS_ADMIN))
|
||||
return -EPERM;
|
||||
|
||||
mutex_lock(&fs_info->fs_devices->device_list_mutex);
|
||||
list_for_each_entry(device, &fs_info->fs_devices->devices, dev_list) {
|
||||
rcu_read_lock();
|
||||
list_for_each_entry_rcu(device, &fs_info->fs_devices->devices,
|
||||
dev_list) {
|
||||
if (!device->bdev)
|
||||
continue;
|
||||
q = bdev_get_queue(device->bdev);
|
||||
@@ -292,7 +293,7 @@ static noinline int btrfs_ioctl_fitrim(struct file *file, void __user *arg)
|
||||
minlen);
|
||||
}
|
||||
}
|
||||
mutex_unlock(&fs_info->fs_devices->device_list_mutex);
|
||||
rcu_read_unlock();
|
||||
if (!num_devices)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
|
Reference in New Issue
Block a user