btrfs: lift uuid_mutex to callers of btrfs_parse_early_options
[sfrench/cifs-2.6.git] / fs / btrfs / super.c
index 81107ad49f3a9c75eccf2c95f9dad8d7d0a0a6f6..de87b7b0367d719e1adb4ce91937b509e28ee7f9 100644 (file)
@@ -5,7 +5,6 @@
 
 #include <linux/blkdev.h>
 #include <linux/module.h>
-#include <linux/buffer_head.h>
 #include <linux/fs.h>
 #include <linux/pagemap.h>
 #include <linux/highmem.h>
@@ -15,8 +14,6 @@
 #include <linux/string.h>
 #include <linux/backing-dev.h>
 #include <linux/mount.h>
-#include <linux/mpage.h>
-#include <linux/swap.h>
 #include <linux/writeback.h>
 #include <linux/statfs.h>
 #include <linux/compat.h>
@@ -760,6 +757,7 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
                case Opt_recovery:
                        btrfs_warn(info,
                                   "'recovery' is deprecated, use 'usebackuproot' instead");
+                       /* fall through */
                case Opt_usebackuproot:
                        btrfs_info(info,
                                   "trying to use backup root at mount time");
@@ -892,6 +890,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;
 
@@ -935,8 +935,8 @@ out:
  *
  * The value is later passed to mount_subvol()
  */
-static int btrfs_parse_subvol_options(const char *options, fmode_t flags,
-               char **subvol_name, u64 *subvol_objectid)
+static int btrfs_parse_subvol_options(const char *options, char **subvol_name,
+               u64 *subvol_objectid)
 {
        substring_t args[MAX_OPT_ARGS];
        char *opts, *orig, *p;
@@ -1526,8 +1526,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);
        }
@@ -1539,7 +1541,9 @@ 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;
 
@@ -1565,7 +1569,9 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type,
                goto error_fs_info;
        }
 
+       mutex_lock(&uuid_mutex);
        error = btrfs_open_devices(fs_devices, mode, fs_type);
+       mutex_unlock(&uuid_mutex);
        if (error)
                goto error_fs_info;
 
@@ -1650,8 +1656,8 @@ static struct dentry *btrfs_mount(struct file_system_type *fs_type, int flags,
        if (!(flags & SB_RDONLY))
                mode |= FMODE_WRITE;
 
-       error = btrfs_parse_subvol_options(data, mode,
-                                         &subvol_name, &subvol_objectid);
+       error = btrfs_parse_subvol_options(data, &subvol_name,
+                                       &subvol_objectid);
        if (error) {
                kfree(subvol_name);
                return ERR_PTR(error);
@@ -2234,15 +2240,21 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd,
 
        switch (cmd) {
        case BTRFS_IOC_SCAN_DEV:
+               mutex_lock(&uuid_mutex);
                ret = btrfs_scan_one_device(vol->name, FMODE_READ,
                                            &btrfs_root_fs_type, &fs_devices);
+               mutex_unlock(&uuid_mutex);
                break;
        case BTRFS_IOC_DEVICES_READY:
+               mutex_lock(&uuid_mutex);
                ret = btrfs_scan_one_device(vol->name, FMODE_READ,
                                            &btrfs_root_fs_type, &fs_devices);
-               if (ret)
+               if (ret) {
+                       mutex_unlock(&uuid_mutex);
                        break;
+               }
                ret = !(fs_devices->num_devices == fs_devices->total_devices);
+               mutex_unlock(&uuid_mutex);
                break;
        case BTRFS_IOC_GET_SUPPORTED_FEATURES:
                ret = btrfs_ioctl_get_supported_features((void __user*)arg);
@@ -2369,7 +2381,7 @@ static __cold void btrfs_interface_exit(void)
 
 static void __init btrfs_print_mod_info(void)
 {
-       pr_info("Btrfs loaded, crc32c=%s"
+       static const char options[] = ""
 #ifdef CONFIG_BTRFS_DEBUG
                        ", debug=on"
 #endif
@@ -2382,8 +2394,8 @@ static void __init btrfs_print_mod_info(void)
 #ifdef CONFIG_BTRFS_FS_REF_VERIFY
                        ", ref-verify=on"
 #endif
-                       "\n",
-                       crc32c_impl());
+                       ;
+       pr_info("Btrfs loaded, crc32c=%s%s\n", crc32c_impl(), options);
 }
 
 static int __init init_btrfs_fs(void)