]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
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 473450ee0408d4f7a77c86ea8abe1458be1cbcc7..b828e4003552784dc233e7a8f1e7edfbb34f9f58 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 a731c883687dd7cb67023b1a29f88a6dd7cee38d..5154ad390f319ea9c70de024f8af03c4b5ad402f 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 e0ee96cc749ce524f55117f3df3c084c02568a54..212474f4421684e66e4ff0d36e0c22b0a0653841 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 b974e2a84ed7ccfaba9b8d30b7962a3b7116ecf6..10b0d70293cba28f0f2570df58f115c9d0e9a1cc 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);