From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 03/13] btrfs: save the original bi_iter into btrfs_bio for buffered read
Date: Tue, 3 May 2022 14:49:47 +0800 [thread overview]
Message-ID: <50c90265a7371f0ed1ec9e94c2e4e00a915ec69f.1651559986.git.wqu@suse.com> (raw)
In-Reply-To: <cover.1651559986.git.wqu@suse.com>
Although we have btrfs_bio::iter, it currently have very limited usage:
- RAID56
Which is not needed at all
- btrfs_bio_clone()
This is used mostly for direct IO.
For the incoming read repair patches, we want to grab the original
logical bytenr, and be able to iterate the range of the bio (no matter
if it's cloned).
So this patch will also save btrfs_bio::iter for buffered read bios at
submit_one_bio().
And for the sake of consistency, also save the btrfs_bio::iter for
direct IO at btrfs_submit_dio_bio().
The reason that we didn't save the iter in btrfs_map_bio() is,
btrfs_map_bio() is going to handle various bios, with or without
btrfs_bio bioset.
And we want to keep btrfs_map_bio() to handle and only handle plain bios
without bother the bioset.
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
fs/btrfs/extent_io.c | 12 ++++++++++++
fs/btrfs/inode.c | 2 ++
2 files changed, 14 insertions(+)
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 07888cce3bce..0ae4ee7f344d 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -186,6 +186,18 @@ static void submit_one_bio(struct bio *bio, int mirror_num, unsigned long bio_fl
/* Caller should ensure the bio has at least some range added */
ASSERT(bio->bi_iter.bi_size);
+ /*
+ * Save the original bi_iter for read bios, as read repair wants the
+ * orignial logical bytenr.
+ *
+ * We don't do this in btrfs_map_bio() because that function is
+ * bioset independent.
+ * We can later pass bios without btrfs_bio or with other bioset into
+ * btrfs_map_bio().
+ */
+ if (bio_op(bio) == REQ_OP_READ)
+ btrfs_bio(bio)->iter = bio->bi_iter;
+
if (is_data_inode(tree->private_data))
btrfs_submit_data_bio(tree->private_data, bio, mirror_num,
bio_flags);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 5b1a60a25ef6..f4dfb79fafce 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7926,6 +7926,8 @@ static inline blk_status_t btrfs_submit_dio_bio(struct bio *bio,
ret = btrfs_bio_wq_end_io(fs_info, bio, BTRFS_WQ_ENDIO_DATA);
if (ret)
goto err;
+ /* Check submit_one_bio() for the reason. */
+ btrfs_bio(bio)->iter = bio->bi_iter;
}
if (BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)
--
2.36.0
next prev parent reply other threads:[~2022-05-03 6:52 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-03 6:49 [PATCH 00/13] btrfs: make read repair work in synchronous mode Qu Wenruo
2022-05-03 6:49 ` [PATCH 01/13] btrfs: introduce a pure data checksum checking helper Qu Wenruo
2022-05-03 15:03 ` Christoph Hellwig
2022-05-03 6:49 ` [PATCH 02/13] btrfs: quit early if the fs has no RAID56 support for raid56 related checks Qu Wenruo
2022-05-03 6:49 ` Qu Wenruo [this message]
2022-05-03 6:49 ` [PATCH 04/13] btrfs: remove duplicated parameters from submit_data_read_repair() Qu Wenruo
2022-05-03 6:49 ` [PATCH 05/13] btrfs: add btrfs_read_repair_ctrl to record corrupted sectors Qu Wenruo
2022-05-03 15:06 ` Christoph Hellwig
2022-05-04 1:12 ` Qu Wenruo
2022-05-04 14:05 ` Christoph Hellwig
2022-05-04 22:40 ` Qu Wenruo
2022-05-12 17:16 ` David Sterba
2022-05-13 10:33 ` Christoph Hellwig
2022-05-13 10:53 ` Qu Wenruo
2022-05-13 10:57 ` Christoph Hellwig
2022-05-13 11:21 ` Qu Wenruo
2022-05-13 11:23 ` Christoph Hellwig
2022-05-17 13:32 ` Qu Wenruo
2022-05-03 6:49 ` [PATCH 06/13] btrfs: add a helper to queue a corrupted sector for read repair Qu Wenruo
2022-05-03 15:07 ` Christoph Hellwig
2022-05-04 1:13 ` Qu Wenruo
2022-05-04 14:06 ` Christoph Hellwig
2022-05-12 17:20 ` David Sterba
2022-05-03 6:49 ` [PATCH 07/13] btrfs: introduce a helper to repair from one mirror Qu Wenruo
2022-05-03 6:49 ` [PATCH 08/13] btrfs: allow btrfs read repair to submit writes in asynchronous mode Qu Wenruo
2022-05-03 6:49 ` [PATCH 09/13] btrfs: handle RAID56 read repair differently Qu Wenruo
2022-05-03 6:49 ` [PATCH 10/13] btrfs: switch buffered read to the new read repair routine Qu Wenruo
2022-05-03 6:49 ` [PATCH 11/13] btrfs: switch direct IO routine to use btrfs_read_repair_ctrl Qu Wenruo
2022-05-03 6:49 ` [PATCH 12/13] btrfs: remove io_failure_record infrastructure completely Qu Wenruo
2022-05-03 6:49 ` [PATCH 13/13] btrfs: remove btrfs_inode::io_failure_tree Qu Wenruo
2022-05-03 15:07 ` Christoph Hellwig
2022-05-12 17:08 ` [PATCH 00/13] btrfs: make read repair work in synchronous mode David Sterba
2022-05-12 23:01 ` Qu Wenruo
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=50c90265a7371f0ed1ec9e94c2e4e00a915ec69f.1651559986.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