Commit 2ef78928 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

btrfs: don't pass a holder for non-exclusive blkdev_get_by_path

Passing a holder to blkdev_get_by_path when FMODE_EXCL isn't set doesn't
make sense, so pass NULL instead and remove the holder argument from the
call chains the only end up in non-FMODE_EXCL blkdev_get_by_path calls.

Exclusive mode for device scanning is not used since commit 50d281fc
("btrfs: scan device in non-exclusive mode")".
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Acked-by: default avatarChristian Brauner <brauner@kernel.org>
Acked-by: default avatarDavid Sterba <dsterba@suse.com>
Link: https://lore.kernel.org/r/20230608110258.189493-15-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 5ee60767
...@@ -849,8 +849,7 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options, ...@@ -849,8 +849,7 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
* All other options will be parsed on much later in the mount process and * All other options will be parsed on much later in the mount process and
* only when we need to allocate a new super block. * only when we need to allocate a new super block.
*/ */
static int btrfs_parse_device_options(const char *options, fmode_t flags, static int btrfs_parse_device_options(const char *options, fmode_t flags)
void *holder)
{ {
substring_t args[MAX_OPT_ARGS]; substring_t args[MAX_OPT_ARGS];
char *device_name, *opts, *orig, *p; char *device_name, *opts, *orig, *p;
...@@ -884,8 +883,7 @@ static int btrfs_parse_device_options(const char *options, fmode_t flags, ...@@ -884,8 +883,7 @@ static int btrfs_parse_device_options(const char *options, fmode_t flags,
error = -ENOMEM; error = -ENOMEM;
goto out; goto out;
} }
device = btrfs_scan_one_device(device_name, flags, device = btrfs_scan_one_device(device_name, flags);
holder);
kfree(device_name); kfree(device_name);
if (IS_ERR(device)) { if (IS_ERR(device)) {
error = PTR_ERR(device); error = PTR_ERR(device);
...@@ -1477,13 +1475,13 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type, ...@@ -1477,13 +1475,13 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type,
} }
mutex_lock(&uuid_mutex); mutex_lock(&uuid_mutex);
error = btrfs_parse_device_options(data, mode, fs_type); error = btrfs_parse_device_options(data, mode);
if (error) { if (error) {
mutex_unlock(&uuid_mutex); mutex_unlock(&uuid_mutex);
goto error_fs_info; goto error_fs_info;
} }
device = btrfs_scan_one_device(device_name, mode, fs_type); device = btrfs_scan_one_device(device_name, mode);
if (IS_ERR(device)) { if (IS_ERR(device)) {
mutex_unlock(&uuid_mutex); mutex_unlock(&uuid_mutex);
error = PTR_ERR(device); error = PTR_ERR(device);
...@@ -2190,8 +2188,7 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd, ...@@ -2190,8 +2188,7 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd,
switch (cmd) { switch (cmd) {
case BTRFS_IOC_SCAN_DEV: case BTRFS_IOC_SCAN_DEV:
mutex_lock(&uuid_mutex); mutex_lock(&uuid_mutex);
device = btrfs_scan_one_device(vol->name, FMODE_READ, device = btrfs_scan_one_device(vol->name, FMODE_READ);
&btrfs_root_fs_type);
ret = PTR_ERR_OR_ZERO(device); ret = PTR_ERR_OR_ZERO(device);
mutex_unlock(&uuid_mutex); mutex_unlock(&uuid_mutex);
break; break;
...@@ -2205,8 +2202,7 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd, ...@@ -2205,8 +2202,7 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd,
break; break;
case BTRFS_IOC_DEVICES_READY: case BTRFS_IOC_DEVICES_READY:
mutex_lock(&uuid_mutex); mutex_lock(&uuid_mutex);
device = btrfs_scan_one_device(vol->name, FMODE_READ, device = btrfs_scan_one_device(vol->name, FMODE_READ);
&btrfs_root_fs_type);
if (IS_ERR(device)) { if (IS_ERR(device)) {
mutex_unlock(&uuid_mutex); mutex_unlock(&uuid_mutex);
ret = PTR_ERR(device); ret = PTR_ERR(device);
......
...@@ -1348,8 +1348,7 @@ int btrfs_forget_devices(dev_t devt) ...@@ -1348,8 +1348,7 @@ int btrfs_forget_devices(dev_t devt)
* and we are not allowed to call set_blocksize during the scan. The superblock * and we are not allowed to call set_blocksize during the scan. The superblock
* is read via pagecache * is read via pagecache
*/ */
struct btrfs_device *btrfs_scan_one_device(const char *path, fmode_t flags, struct btrfs_device *btrfs_scan_one_device(const char *path, fmode_t flags)
void *holder)
{ {
struct btrfs_super_block *disk_super; struct btrfs_super_block *disk_super;
bool new_device_added = false; bool new_device_added = false;
...@@ -1368,16 +1367,16 @@ struct btrfs_device *btrfs_scan_one_device(const char *path, fmode_t flags, ...@@ -1368,16 +1367,16 @@ struct btrfs_device *btrfs_scan_one_device(const char *path, fmode_t flags,
*/ */
/* /*
* Avoid using flag |= FMODE_EXCL here, as the systemd-udev may * Avoid an exclusive open here, as the systemd-udev may initiate the
* initiate the device scan which may race with the user's mount * device scan which may race with the user's mount or mkfs command,
* or mkfs command, resulting in failure. * resulting in failure.
* Since the device scan is solely for reading purposes, there is * Since the device scan is solely for reading purposes, there is no
* no need for FMODE_EXCL. Additionally, the devices are read again * need for an exclusive open. Additionally, the devices are read again
* during the mount process. It is ok to get some inconsistent * during the mount process. It is ok to get some inconsistent
* values temporarily, as the device paths of the fsid are the only * values temporarily, as the device paths of the fsid are the only
* required information for assembling the volume. * required information for assembling the volume.
*/ */
bdev = blkdev_get_by_path(path, flags, holder, NULL); bdev = blkdev_get_by_path(path, flags, NULL, NULL);
if (IS_ERR(bdev)) if (IS_ERR(bdev))
return ERR_CAST(bdev); return ERR_CAST(bdev);
...@@ -2381,7 +2380,7 @@ int btrfs_get_dev_args_from_path(struct btrfs_fs_info *fs_info, ...@@ -2381,7 +2380,7 @@ int btrfs_get_dev_args_from_path(struct btrfs_fs_info *fs_info,
return -ENOMEM; return -ENOMEM;
} }
ret = btrfs_get_bdev_and_sb(path, FMODE_READ, fs_info->bdev_holder, 0, ret = btrfs_get_bdev_and_sb(path, FMODE_READ, NULL, 0,
&bdev, &disk_super); &bdev, &disk_super);
if (ret) { if (ret) {
btrfs_put_dev_args_from_path(args); btrfs_put_dev_args_from_path(args);
......
...@@ -600,8 +600,7 @@ struct btrfs_block_group *btrfs_create_chunk(struct btrfs_trans_handle *trans, ...@@ -600,8 +600,7 @@ struct btrfs_block_group *btrfs_create_chunk(struct btrfs_trans_handle *trans,
void btrfs_mapping_tree_free(struct extent_map_tree *tree); void btrfs_mapping_tree_free(struct extent_map_tree *tree);
int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, int btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
fmode_t flags, void *holder); fmode_t flags, void *holder);
struct btrfs_device *btrfs_scan_one_device(const char *path, struct btrfs_device *btrfs_scan_one_device(const char *path, fmode_t flags);
fmode_t flags, void *holder);
int btrfs_forget_devices(dev_t devt); int btrfs_forget_devices(dev_t devt);
void btrfs_close_devices(struct btrfs_fs_devices *fs_devices); void btrfs_close_devices(struct btrfs_fs_devices *fs_devices);
void btrfs_free_extra_devids(struct btrfs_fs_devices *fs_devices); void btrfs_free_extra_devids(struct btrfs_fs_devices *fs_devices);
......
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