Commit 5139cff5 authored by David Sterba's avatar David Sterba

btrfs: lift uuid_mutex to callers of btrfs_parse_early_options

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: default avatarAnand Jain <anand.jain@oracle.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent f5194e34
...@@ -890,6 +890,8 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags, ...@@ -890,6 +890,8 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags,
char *device_name, *opts, *orig, *p; char *device_name, *opts, *orig, *p;
int error = 0; int error = 0;
lockdep_assert_held(&uuid_mutex);
if (!options) if (!options)
return 0; return 0;
...@@ -915,10 +917,8 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags, ...@@ -915,10 +917,8 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags,
error = -ENOMEM; error = -ENOMEM;
goto out; goto out;
} }
mutex_lock(&uuid_mutex);
error = btrfs_scan_one_device(device_name, error = btrfs_scan_one_device(device_name,
flags, holder, fs_devices); flags, holder, fs_devices);
mutex_unlock(&uuid_mutex);
kfree(device_name); kfree(device_name);
if (error) if (error)
goto out; goto out;
...@@ -1526,8 +1526,10 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type, ...@@ -1526,8 +1526,10 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type,
if (!(flags & SB_RDONLY)) if (!(flags & SB_RDONLY))
mode |= FMODE_WRITE; mode |= FMODE_WRITE;
mutex_lock(&uuid_mutex);
error = btrfs_parse_early_options(data, mode, fs_type, error = btrfs_parse_early_options(data, mode, fs_type,
&fs_devices); &fs_devices);
mutex_unlock(&uuid_mutex);
if (error) { if (error) {
return ERR_PTR(error); return ERR_PTR(error);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment