diff options
| author | David Sterba <dsterba@suse.com> | 2018-06-19 17:50:25 +0200 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-09-15 09:46:56 +0200 |
| commit | 1ef9a3009ba9df130ebf932de96455f357edaed0 (patch) | |
| tree | e9ceba5cb6fb46aa1956344bb643765913350941 | |
| parent | 71ddab54bee5c571647fd5ed9bb9be9db305f7c1 (diff) | |
| download | linux-1ef9a3009ba9df130ebf932de96455f357edaed0.tar.gz linux-1ef9a3009ba9df130ebf932de96455f357edaed0.tar.bz2 linux-1ef9a3009ba9df130ebf932de96455f357edaed0.zip | |
btrfs: lift uuid_mutex to callers of btrfs_parse_early_options
[ Upstream commit 5139cff598d42b1e531f40c84691a7e945f04553 ]
Prepartory work to fix race between mount and device scan.
btrfs_parse_early_options calls the device scan from mount and we'll
need to let mount completely manage the critical section.
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 | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index b00e88f746cb..5afa3a923cd8 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -892,6 +892,8 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags, char *device_name, *opts, *orig, *p; int error = 0; + lockdep_assert_held(&uuid_mutex); + if (!options) return 0; @@ -917,10 +919,8 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags, error = -ENOMEM; goto out; } - mutex_lock(&uuid_mutex); error = btrfs_scan_one_device(device_name, flags, holder, fs_devices); - mutex_unlock(&uuid_mutex); kfree(device_name); if (error) goto out; @@ -1528,8 +1528,10 @@ 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); } |
