From 40426dd147ffde7087dc29c263b87e1a2a36ca38 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 11 Jun 2025 12:03:03 +0200 Subject: [PATCH] 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 Signed-off-by: Qu Wenruo Signed-off-by: David Sterba --- fs/btrfs/dev-replace.c | 2 +- fs/btrfs/fs.h | 2 -- fs/btrfs/super.c | 3 +-- fs/btrfs/volumes.c | 4 ++-- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c index 473450ee0408d..b828e40035527 100644 --- a/fs/btrfs/dev-replace.c +++ b/fs/btrfs/dev-replace.c @@ -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); diff --git a/fs/btrfs/fs.h b/fs/btrfs/fs.h index a731c883687dd..5154ad390f319 100644 --- a/fs/btrfs/fs.h +++ b/fs/btrfs/fs.h @@ -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; diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index e0ee96cc749ce..212474f442168 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -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); diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index b974e2a84ed7c..10b0d70293cba 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -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); -- 2.47.2