]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
btrfs: use fs_holder_ops for all opened devices
authorQu Wenruo <wqu@suse.com>
Thu, 19 Jun 2025 07:18:44 +0000 (16:48 +0930)
committerDavid Sterba <dsterba@suse.com>
Mon, 21 Jul 2025 22:06:20 +0000 (00:06 +0200)
Since we have btrfs_fs_info::sb (struct super_block) as our block device
holder, we can safely use fs_holder_ops for all of our block devices.

This enables freezing/thawing the filesystem from the underlying block
devices.

This may enhance hibernation/suspend support since previously
freezing/thawing a block device managed by btrfs won't do anything btrfs
specific, but only syncing the block device.

Thus before this change, freezing the underlying block devices won't
prevent future writes into the filesystem, thus may cause problems for
hibernation/suspend when btrfs is involved.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/dev-replace.c
fs/btrfs/volumes.c

index b828e4003552784dc233e7a8f1e7edfbb34f9f58..4675bcd5f92efb1f1adf13752cbf23a728d1d6b1 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->sb, NULL);
+                                          fs_info->sb, &fs_holder_ops);
        if (IS_ERR(bdev_file)) {
                btrfs_err(fs_info, "target device %s is invalid!", device_path);
                return PTR_ERR(bdev_file);
index 10b0d70293cba28f0f2570df58f115c9d0e9a1cc..2098129743e7f530edca163521d8a84299cdeadb 100644 (file)
@@ -473,7 +473,7 @@ btrfs_get_bdev_and_sb(const char *device_path, blk_mode_t flags, void *holder,
        struct block_device *bdev;
        int ret;
 
-       *bdev_file = bdev_file_open_by_path(device_path, flags, holder, NULL);
+       *bdev_file = bdev_file_open_by_path(device_path, flags, holder, &fs_holder_ops);
 
        if (IS_ERR(*bdev_file)) {
                ret = PTR_ERR(*bdev_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->sb, NULL);
+                                          fs_info->sb, &fs_holder_ops);
        if (IS_ERR(bdev_file))
                return PTR_ERR(bdev_file);