btrfs: use the super_block as holder when mounting file systems

The file system type is not a very useful holder as it doesn't allow us
to go back to the actual file system instance.  Pass the super_block
instead which is useful when passed back to the file system driver.

This matches what is done for all other block device based file systems,
and allows us to remove btrfs_fs_info::bdev_holder completely.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Christoph Hellwig 2025-06-11 12:03:03 +02:00 committed by David Sterba
parent bddf57a707
commit 40426dd147
4 changed files with 4 additions and 7 deletions

View File

@ -250,7 +250,7 @@ static int btrfs_init_dev_replace_tgtdev(struct btrfs_fs_info *fs_info,
}
bdev_file = bdev_file_open_by_path(device_path, BLK_OPEN_WRITE,
fs_info->bdev_holder, NULL);
fs_info->sb, NULL);
if (IS_ERR(bdev_file)) {
btrfs_err(fs_info, "target device %s is invalid!", device_path);
return PTR_ERR(bdev_file);

View File

@ -715,8 +715,6 @@ struct btrfs_fs_info {
u32 data_chunk_allocations;
u32 metadata_ratio;
void *bdev_holder;
/* Private scrub information */
struct mutex scrub_lock;
atomic_t scrubs_running;

View File

@ -1925,7 +1925,7 @@ static int btrfs_get_tree_super(struct fs_context *fc)
mutex_lock(&uuid_mutex);
btrfs_fs_devices_dec_holding(fs_devices);
ret = btrfs_open_devices(fs_devices, mode, &btrfs_fs_type);
ret = btrfs_open_devices(fs_devices, mode, sb);
if (ret < 0)
fs_info->fs_devices = NULL;
mutex_unlock(&uuid_mutex);
@ -1940,7 +1940,6 @@ static int btrfs_get_tree_super(struct fs_context *fc)
bdev = fs_devices->latest_dev->bdev;
snprintf(sb->s_id, sizeof(sb->s_id), "%pg", bdev);
shrinker_debugfs_rename(sb->s_shrink, "sb-btrfs:%s", sb->s_id);
btrfs_sb(sb)->bdev_holder = &btrfs_fs_type;
ret = btrfs_fill_super(sb, fs_devices);
if (ret) {
deactivate_locked_super(sb);

View File

@ -2705,7 +2705,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
return -EROFS;
bdev_file = bdev_file_open_by_path(device_path, BLK_OPEN_WRITE,
fs_info->bdev_holder, NULL);
fs_info->sb, NULL);
if (IS_ERR(bdev_file))
return PTR_ERR(bdev_file);
@ -7174,7 +7174,7 @@ static struct btrfs_fs_devices *open_seed_devices(struct btrfs_fs_info *fs_info,
if (IS_ERR(fs_devices))
return fs_devices;
ret = open_fs_devices(fs_devices, BLK_OPEN_READ, fs_info->bdev_holder);
ret = open_fs_devices(fs_devices, BLK_OPEN_READ, fs_info->sb);
if (ret) {
free_fs_devices(fs_devices);
return ERR_PTR(ret);