diff options
| author | David Sterba <dsterba@suse.com> | 2018-06-19 18:01:24 +0200 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-09-15 09:46:56 +0200 |
| commit | 49db06e7f366c26a71dd3589617b43c3110be649 (patch) | |
| tree | dd195354e9a71d6793a3b9bd13d2849699aef73f | |
| parent | 1ef9a3009ba9df130ebf932de96455f357edaed0 (diff) | |
| download | linux-49db06e7f366c26a71dd3589617b43c3110be649.tar.gz linux-49db06e7f366c26a71dd3589617b43c3110be649.tar.bz2 linux-49db06e7f366c26a71dd3589617b43c3110be649.zip | |
btrfs: reorder initialization before the mount locks uuid_mutex
[ Upstream commit 399f7f4c42e8a58c8456264d5112287aefe44cf4 ]
In preparation to take a big lock, move resource initialization before
the critical section. It's not obvious from the diff, the desired order
is:
- initialize mount security options
- allocate temporary fs_info
- allocate superblock buffers
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| -rw-r--r-- | fs/btrfs/super.c | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 5afa3a923cd8..a8f2950b9200 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -1528,14 +1528,6 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type, if (!(flags & SB_RDONLY)) mode |= FMODE_WRITE; - mutex_lock(&uuid_mutex); - error = btrfs_parse_early_options(data, mode, fs_type, - &fs_devices); - mutex_unlock(&uuid_mutex); - if (error) { - return ERR_PTR(error); - } - security_init_mnt_opts(&new_sec_opts); if (data) { error = parse_security_options(data, &new_sec_opts); @@ -1543,12 +1535,6 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type, return ERR_PTR(error); } - mutex_lock(&uuid_mutex); - error = btrfs_scan_one_device(device_name, mode, fs_type, &fs_devices); - mutex_unlock(&uuid_mutex); - if (error) - goto error_sec_opts; - /* * Setup a dummy root and fs_info for test/set super. This is because * we don't actually fill this stuff out until open_ctree, but we need @@ -1561,8 +1547,6 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type, goto error_sec_opts; } - fs_info->fs_devices = fs_devices; - fs_info->super_copy = kzalloc(BTRFS_SUPER_INFO_SIZE, GFP_KERNEL); fs_info->super_for_commit = kzalloc(BTRFS_SUPER_INFO_SIZE, GFP_KERNEL); security_init_mnt_opts(&fs_info->security_opts); @@ -1572,6 +1556,20 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type, } mutex_lock(&uuid_mutex); + error = btrfs_parse_early_options(data, mode, fs_type, &fs_devices); + mutex_unlock(&uuid_mutex); + if (error) + goto error_fs_info; + + mutex_lock(&uuid_mutex); + error = btrfs_scan_one_device(device_name, mode, fs_type, &fs_devices); + mutex_unlock(&uuid_mutex); + if (error) + goto error_fs_info; + + fs_info->fs_devices = fs_devices; + + mutex_lock(&uuid_mutex); error = btrfs_open_devices(fs_devices, mode, fs_type); mutex_unlock(&uuid_mutex); if (error) |
