From: Christoph Hellwig <hch@infradead.org>
To: Qu Wenruo <wqu@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH RFC v2 02/12] btrfs: always save bio::bi_iter into btrfs_bio::iter before submitting
Date: Thu, 28 Apr 2022 06:32:23 -0700 [thread overview]
Message-ID: <YmqXZ1Oa8UX3n2ZP@infradead.org> (raw)
In-Reply-To: <b11499d578ab90258d83ec9be6d46df78c1056bf.1651043617.git.wqu@suse.com>
On Wed, Apr 27, 2022 at 03:18:48PM +0800, Qu Wenruo wrote:
> Lower level bio mapping, from driver to dm, even btrfs chunk mapping
> can modify bio::bi_iter.
>
> This prevents us from doing two things:
>
> - Iterate the bio range of a cloned bio
> This is only utilized by direct IO, thus it's already using
> btrfs_bio::iter, which is populated in btrfs_bio_clone_partial().
>
> - Grab the original logical bytenr of a bio
> This will be utilized by incoming read repair patches.
>
> So to make sure all btrfs_bio submitted to own a proper iter, this patch
> will assigned btrfs_bio::iter in the following call sites:
Independent of what we want to do with the saved iter in the future
I don't think this is an improvement. The place where we can start
advancing the iter is after the bio is submit by btrfs_map_bio, so that
is the one central place where it should be saved. I actually had
a patch like that in one my my wip branches:
---
From: Christoph Hellwig <hch@lst.de>
Subject: btrfs: centralize stashing away ->bi_iter in btrfs_map_bio
Once a bio is submitted to a driver, the driver can advance bi_iter.
Save to the copy in the btrfs_bio just before that can happen rather
than in random places high up in the stack.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/btrfs/extent_io.c | 7 +------
fs/btrfs/volumes.c | 3 +++
2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 07888cce3bce6..002b1ea92e398 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2683,7 +2683,6 @@ int btrfs_repair_one_sector(struct inode *inode,
}
bio_add_page(repair_bio, page, failrec->len, pgoff);
- repair_bbio->iter = repair_bio->bi_iter;
btrfs_debug(btrfs_sb(inode->i_sb),
"repair read error: submitting new read to mirror %d",
@@ -3209,14 +3208,11 @@ struct bio *btrfs_bio_alloc(unsigned int nr_iovecs)
struct bio *btrfs_bio_clone(struct block_device *bdev, struct bio *bio)
{
- struct btrfs_bio *bbio;
struct bio *new;
/* Bio allocation backed by a bioset does not fail */
new = bio_alloc_clone(bdev, bio, GFP_NOFS, &btrfs_bioset);
- bbio = btrfs_bio(new);
- btrfs_bio_init(bbio);
- bbio->iter = bio->bi_iter;
+ btrfs_bio_init(btrfs_bio(new));
return new;
}
@@ -3235,7 +3231,6 @@ struct bio *btrfs_bio_clone_partial(struct bio *orig, u64 offset, u64 size)
btrfs_bio_init(bbio);
bio_trim(bio, offset >> 9, size >> 9);
- bbio->iter = bio->bi_iter;
return bio;
}
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 748614b00ffa2..f282a58a12344 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -6750,6 +6750,9 @@ blk_status_t btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio,
int total_devs;
struct btrfs_io_context *bioc = NULL;
+ /* stash away the iter as the low-level processing can advance it */
+ btrfs_bio(bio)->iter = bio->bi_iter;
+
length = bio->bi_iter.bi_size;
map_length = length;
--
2.30.2
next prev parent reply other threads:[~2022-04-28 13:32 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1651043617.git.wqu@suse.com>
2022-04-27 7:18 ` [PATCH RFC v2 01/12] btrfs: introduce a pure data checksum checking helper Qu Wenruo
2022-04-28 13:26 ` Christoph Hellwig
2022-04-27 7:18 ` [PATCH RFC v2 02/12] btrfs: always save bio::bi_iter into btrfs_bio::iter before submitting Qu Wenruo
2022-04-28 5:16 ` Qu Wenruo
2022-04-28 13:32 ` Christoph Hellwig [this message]
2022-04-28 22:41 ` Qu Wenruo
2022-04-29 15:09 ` Christoph Hellwig
2022-04-29 23:04 ` Qu Wenruo
2022-04-27 7:18 ` [PATCH RFC v2 03/12] btrfs: remove duplicated parameters from submit_data_read_repair() Qu Wenruo
2022-04-28 13:32 ` Christoph Hellwig
2022-04-27 7:18 ` [PATCH RFC v2 04/12] btrfs: add btrfs_read_repair_ctrl to record corrupted sectors Qu Wenruo
2022-04-28 13:37 ` Christoph Hellwig
2022-04-28 22:51 ` Qu Wenruo
2022-04-29 0:09 ` Qu Wenruo
2022-04-29 15:12 ` Christoph Hellwig
2022-04-29 15:11 ` Christoph Hellwig
2022-04-27 7:18 ` [PATCH RFC v2 05/12] btrfs: add a helper to queue a corrupted sector for read repair Qu Wenruo
2022-04-28 5:20 ` Qu Wenruo
2022-04-28 13:44 ` Christoph Hellwig
2022-04-28 22:55 ` Qu Wenruo
2022-04-29 7:11 ` Qu Wenruo
2022-04-29 15:14 ` Christoph Hellwig
2022-04-29 23:08 ` Qu Wenruo
2022-05-01 23:59 ` Qu Wenruo
2022-05-02 16:45 ` Christoph Hellwig
2022-05-02 23:00 ` Qu Wenruo
2022-04-27 7:18 ` [PATCH RFC v2 06/12] btrfs: introduce a helper to repair from one mirror Qu Wenruo
2022-04-27 7:18 ` [PATCH RFC v2 07/12] btrfs: allow btrfs read repair to submit all writes in one go Qu Wenruo
2022-04-27 7:18 ` [PATCH RFC v2 08/12] btrfs: switch buffered read to the new btrfs_read_repair_* based repair routine Qu Wenruo
2022-04-27 13:59 ` kernel test robot
2022-04-28 10:08 ` kernel test robot
2022-04-28 10:51 ` Qu Wenruo
2022-04-28 10:51 ` Qu Wenruo
2022-04-27 7:18 ` [PATCH RFC v2 09/12] btrfs: switch direct IO routine to use btrfs_read_repair_ctrl Qu Wenruo
2022-04-27 7:18 ` [PATCH RFC v2 10/12] btrfs: cleanup btrfs_repair_one_sector() Qu Wenruo
2022-04-28 13:45 ` Christoph Hellwig
2022-04-27 7:18 ` [PATCH RFC v2 11/12] btrfs: remove io_failure_record infrastructure completely Qu Wenruo
2022-04-27 7:18 ` [PATCH RFC v2 12/12] btrfs: remove btrfs_inode::io_failure_tree 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=YmqXZ1Oa8UX3n2ZP@infradead.org \
--to=hch@infradead.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=wqu@suse.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.