From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH v4 8/8] btrfs: use fs_holder_ops for all opened devices
Date: Mon, 23 Jun 2025 20:16:52 +0930 [thread overview]
Message-ID: <0d52a7384a1beb3c96b704451e63d504ba1a8404.1750674924.git.wqu@suse.com> (raw)
In-Reply-To: <cover.1750674924.git.wqu@suse.com>
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 btrfs from the underlying block
devices.
This may enhance hibernation/suspension 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 btrfs, thus may cause problems for
hibernation/suspension when btrfs is involved.
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
fs/btrfs/dev-replace.c | 2 +-
fs/btrfs/volumes.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index c23847de4e99..79529c36ca6c 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->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);
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 8c91511ed433..083b0041cb3c 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -474,7 +474,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);
@@ -2706,7 +2706,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);
--
2.49.0
prev parent reply other threads:[~2025-06-23 10:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-23 10:46 [PATCH v4 0/8] btrfs: use fs_holder_ops for btrfs Qu Wenruo
2025-06-23 10:46 ` [PATCH v4 1/8] btrfs: always open the device read-only in btrfs_scan_one_device Qu Wenruo
2025-06-23 10:46 ` [PATCH v4 2/8] btrfs: get rid of the re-entry of btrfs_get_tree() Qu Wenruo
2025-06-23 10:46 ` [PATCH v4 3/8] btrfs: add comments to make super block creation more clear Qu Wenruo
2025-06-23 15:10 ` David Sterba
2025-06-23 21:23 ` Qu Wenruo
2025-06-23 21:56 ` Qu Wenruo
2025-06-23 10:46 ` [PATCH v4 4/8] btrfs: call btrfs_close_devices from ->kill_sb Qu Wenruo
2025-06-23 10:46 ` [PATCH v4 5/8] btrfs: call bdev_fput() to reclaim the blk_holder immediately Qu Wenruo
2025-06-23 10:46 ` [PATCH v4 6/8] btrfs: delay btrfs_open_devices() until super block is created Qu Wenruo
2025-06-23 10:46 ` [PATCH v4 7/8] btrfs: use the super_block as holder when mounting file systems Qu Wenruo
2025-06-23 10:46 ` Qu Wenruo [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0d52a7384a1beb3c96b704451e63d504ba1a8404.1750674924.git.wqu@suse.com \
--to=wqu@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).