From: Qu Wenruo <wqu@suse.com>
To: 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 13:16:48 +0800 [thread overview]
Message-ID: <17f04ff8-6591-6057-1607-30ae353b0e0b@suse.com> (raw)
In-Reply-To: <b11499d578ab90258d83ec9be6d46df78c1056bf.1651043617.git.wqu@suse.com>
On 2022/4/27 15:18, 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:
>
> - btrfs_submit_dio_bio()
> - submit_one_bio()
> - submit_compressed_bio()
>
> Signed-off-by: Qu Wenruo <wqu@suse.com>
Cc Christoph, this is definitely going to conflicts with his further
cleanups.
Maybe I can update this patch to only set the iter for read bios?
Thanks,
Qu
> ---
> fs/btrfs/compression.c | 2 ++
> fs/btrfs/extent_io.c | 6 ++++++
> fs/btrfs/inode.c | 2 ++
> 3 files changed, 10 insertions(+)
>
> diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
> index 69c060dc024c..559bf53beaed 100644
> --- a/fs/btrfs/compression.c
> +++ b/fs/btrfs/compression.c
> @@ -428,6 +428,8 @@ static blk_status_t submit_compressed_bio(struct btrfs_fs_info *fs_info,
> blk_status_t ret;
>
> ASSERT(bio->bi_iter.bi_size);
> + /* Check submit_one_bio() for the reason */
> + btrfs_bio(bio)->iter = bio->bi_iter;
> ret = btrfs_bio_wq_end_io(fs_info, bio, BTRFS_WQ_ENDIO_DATA);
> if (ret)
> return ret;
> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> index 07888cce3bce..a3962df30603 100644
> --- a/fs/btrfs/extent_io.c
> +++ b/fs/btrfs/extent_io.c
> @@ -186,6 +186,12 @@ 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 current bi_iter into btrfs_bio::iter, as lower level (including
> + * btrfs chunk mapping) can modify bi_iter, preventing us from using
> + * bi_iter to iterate cloned bio or grab the original logical bytenr.
> + */
> + 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 b4cfd78f50e8..1b596de0c4e9 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -7923,6 +7923,8 @@ static inline blk_status_t btrfs_submit_dio_bio(struct bio *bio,
> bool write = btrfs_op(bio) == BTRFS_MAP_WRITE;
> blk_status_t ret;
>
> + btrfs_bio(bio)->iter = bio->bi_iter;
> +
> /* Check btrfs_submit_bio_hook() for rules about async submit. */
> if (async_submit)
> async_submit = !atomic_read(&BTRFS_I(inode)->sync_writers);
next prev parent reply other threads:[~2022-04-28 5:17 UTC|newest]
Thread overview: 34+ 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 [this message]
2022-04-28 13:32 ` Christoph Hellwig
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 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=17f04ff8-6591-6057-1607-30ae353b0e0b@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