Skip to content

Commit 2c5058c

Browse files
kdaveasj
authored andcommitted
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. Signed-off-by: David Sterba <[email protected]> Reviewed-by: Anand Jain <[email protected]>
1 parent 8ffc96e commit 2c5058c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fs/btrfs/super.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,8 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags,
890890
char *device_name, *opts, *orig, *p;
891891
int error = 0;
892892

893+
lockdep_assert_held(&uuid_mutex);
894+
893895
if (!options)
894896
return 0;
895897

@@ -915,10 +917,8 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags,
915917
error = -ENOMEM;
916918
goto out;
917919
}
918-
mutex_lock(&uuid_mutex);
919920
error = btrfs_scan_one_device(device_name,
920921
flags, holder, fs_devices);
921-
mutex_unlock(&uuid_mutex);
922922
kfree(device_name);
923923
if (error)
924924
goto out;
@@ -1526,8 +1526,10 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type,
15261526
if (!(flags & SB_RDONLY))
15271527
mode |= FMODE_WRITE;
15281528

1529+
mutex_lock(&uuid_mutex);
15291530
error = btrfs_parse_early_options(data, mode, fs_type,
15301531
&fs_devices);
1532+
mutex_unlock(&uuid_mutex);
15311533
if (error) {
15321534
return ERR_PTR(error);
15331535
}

0 commit comments

Comments
 (0)