btrfs: use the super_block as holder when mounting file systems
authorChristoph Hellwig <hch@lst.de>
Wed, 11 Jun 2025 10:03:03 +0000 (12:03 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 21 Jul 2025 22:06:19 +0000 (00:06 +0200)
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>
fs/btrfs/dev-replace.c
fs/btrfs/fs.h
fs/btrfs/super.c
fs/btrfs/volumes.c

index 473450e..b828e40 100644 (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);
index a731c88..5154ad3 100644 (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;
index e0ee96c..212474f 100644 (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);
index b974e2a..10b0d70 100644 (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);