diff options
author | Anand Jain <anand.jain@oracle.com> | 2018-04-12 10:29:24 +0800 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2018-05-28 18:23:12 +0200 |
commit | b6ed73bcb1c4c8c742452a4cc03868ce4e7455c8 (patch) | |
tree | 46ef1107f98b0441ea3825515ac0089e60926872 /fs/btrfs/volumes.c | |
parent | 20a68004022d5b894efdf5959ebd538b8e91ec73 (diff) | |
download | lwn-b6ed73bcb1c4c8c742452a4cc03868ce4e7455c8.tar.gz lwn-b6ed73bcb1c4c8c742452a4cc03868ce4e7455c8.zip |
btrfs: reduce uuid_mutex critical section while scanning devices
The generic block device lookup or cleanup does not need the uuid mutex,
that's only for the device_list_add.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
[ update changelog ]
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/volumes.c')
-rw-r--r-- | fs/btrfs/volumes.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index ebc81766fc86..c1d09da40d73 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1232,31 +1232,29 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder, */ bytenr = btrfs_sb_offset(0); flags |= FMODE_EXCL; - mutex_lock(&uuid_mutex); bdev = blkdev_get_by_path(path, flags, holder); - if (IS_ERR(bdev)) { - ret = PTR_ERR(bdev); - goto error; - } + if (IS_ERR(bdev)) + return PTR_ERR(bdev); if (btrfs_read_disk_super(bdev, bytenr, &page, &disk_super)) { ret = -EINVAL; goto error_bdev_put; } + mutex_lock(&uuid_mutex); device = device_list_add(path, disk_super); if (IS_ERR(device)) ret = PTR_ERR(device); else *fs_devices_ret = device->fs_devices; + mutex_unlock(&uuid_mutex); btrfs_release_disk_super(page); error_bdev_put: blkdev_put(bdev, flags); -error: - mutex_unlock(&uuid_mutex); + return ret; } |