Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 50d281fc434c
("btrfs: scan device in non-exclusive mode")".

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Acked-by: Christian Brauner <brauner@kernel.org>
Acked-by: David Sterba <dsterba@suse.com>
Link: https://lore.kernel.org/r/20230608110258.189493-15-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Christoph Hellwig and committed by
Jens Axboe
2ef78928 5ee60767

+15 -21
+6 -10
fs/btrfs/super.c
··· 849 849 * All other options will be parsed on much later in the mount process and 850 850 * only when we need to allocate a new super block. 851 851 */ 852 - static int btrfs_parse_device_options(const char *options, fmode_t flags, 853 - void *holder) 852 + static int btrfs_parse_device_options(const char *options, fmode_t flags) 854 853 { 855 854 substring_t args[MAX_OPT_ARGS]; 856 855 char *device_name, *opts, *orig, *p; ··· 883 884 error = -ENOMEM; 884 885 goto out; 885 886 } 886 - device = btrfs_scan_one_device(device_name, flags, 887 - holder); 887 + device = btrfs_scan_one_device(device_name, flags); 888 888 kfree(device_name); 889 889 if (IS_ERR(device)) { 890 890 error = PTR_ERR(device); ··· 1475 1477 } 1476 1478 1477 1479 mutex_lock(&uuid_mutex); 1478 - error = btrfs_parse_device_options(data, mode, fs_type); 1480 + error = btrfs_parse_device_options(data, mode); 1479 1481 if (error) { 1480 1482 mutex_unlock(&uuid_mutex); 1481 1483 goto error_fs_info; 1482 1484 } 1483 1485 1484 - device = btrfs_scan_one_device(device_name, mode, fs_type); 1486 + device = btrfs_scan_one_device(device_name, mode); 1485 1487 if (IS_ERR(device)) { 1486 1488 mutex_unlock(&uuid_mutex); 1487 1489 error = PTR_ERR(device); ··· 2188 2190 switch (cmd) { 2189 2191 case BTRFS_IOC_SCAN_DEV: 2190 2192 mutex_lock(&uuid_mutex); 2191 - device = btrfs_scan_one_device(vol->name, FMODE_READ, 2192 - &btrfs_root_fs_type); 2193 + device = btrfs_scan_one_device(vol->name, FMODE_READ); 2193 2194 ret = PTR_ERR_OR_ZERO(device); 2194 2195 mutex_unlock(&uuid_mutex); 2195 2196 break; ··· 2202 2205 break; 2203 2206 case BTRFS_IOC_DEVICES_READY: 2204 2207 mutex_lock(&uuid_mutex); 2205 - device = btrfs_scan_one_device(vol->name, FMODE_READ, 2206 - &btrfs_root_fs_type); 2208 + device = btrfs_scan_one_device(vol->name, FMODE_READ); 2207 2209 if (IS_ERR(device)) { 2208 2210 mutex_unlock(&uuid_mutex); 2209 2211 ret = PTR_ERR(device);
+8 -9
fs/btrfs/volumes.c
··· 1348 1348 * and we are not allowed to call set_blocksize during the scan. The superblock 1349 1349 * is read via pagecache 1350 1350 */ 1351 - struct btrfs_device *btrfs_scan_one_device(const char *path, fmode_t flags, 1352 - void *holder) 1351 + struct btrfs_device *btrfs_scan_one_device(const char *path, fmode_t flags) 1353 1352 { 1354 1353 struct btrfs_super_block *disk_super; 1355 1354 bool new_device_added = false; ··· 1367 1368 */ 1368 1369 1369 1370 /* 1370 - * Avoid using flag |= FMODE_EXCL here, as the systemd-udev may 1371 - * initiate the device scan which may race with the user's mount 1372 - * or mkfs command, resulting in failure. 1373 - * Since the device scan is solely for reading purposes, there is 1374 - * no need for FMODE_EXCL. Additionally, the devices are read again 1371 + * Avoid an exclusive open here, as the systemd-udev may initiate the 1372 + * device scan which may race with the user's mount or mkfs command, 1373 + * resulting in failure. 1374 + * Since the device scan is solely for reading purposes, there is no 1375 + * need for an exclusive open. Additionally, the devices are read again 1375 1376 * during the mount process. It is ok to get some inconsistent 1376 1377 * values temporarily, as the device paths of the fsid are the only 1377 1378 * required information for assembling the volume. 1378 1379 */ 1379 - bdev = blkdev_get_by_path(path, flags, holder, NULL); 1380 + bdev = blkdev_get_by_path(path, flags, NULL, NULL); 1380 1381 if (IS_ERR(bdev)) 1381 1382 return ERR_CAST(bdev); 1382 1383 ··· 2380 2381 return -ENOMEM; 2381 2382 } 2382 2383 2383 - ret = btrfs_get_bdev_and_sb(path, FMODE_READ, fs_info->bdev_holder, 0, 2384 + ret = btrfs_get_bdev_and_sb(path, FMODE_READ, NULL, 0, 2384 2385 &bdev, &disk_super); 2385 2386 if (ret) { 2386 2387 btrfs_put_dev_args_from_path(args);
+1 -2
fs/btrfs/volumes.h
··· 600 600 void btrfs_mapping_tree_free(struct extent_map_tree *tree); 601 601 int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, 602 602 fmode_t flags, void *holder); 603 - struct btrfs_device *btrfs_scan_one_device(const char *path, 604 - fmode_t flags, void *holder); 603 + struct btrfs_device *btrfs_scan_one_device(const char *path, fmode_t flags); 605 604 int btrfs_forget_devices(dev_t devt); 606 605 void btrfs_close_devices(struct btrfs_fs_devices *fs_devices); 607 606 void btrfs_free_extra_devids(struct btrfs_fs_devices *fs_devices);