From: Josef Bacik <josef@toxicpanda.com>
To: Qu Wenruo <wqu@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v2 2/2] btrfs: pass disk_bytenr directly for check_data_csum()
Date: Tue, 10 Nov 2020 10:30:36 -0500 [thread overview]
Message-ID: <19a1507a-2a9e-805d-3b0d-66609f07decb@toxicpanda.com> (raw)
In-Reply-To: <20201110020909.23438-3-wqu@suse.com>
On 11/9/20 9:09 PM, Qu Wenruo wrote:
> Parameter @icsum for check_data_csum() is a little hard to understand.
> So is the @phy_offset for btrfs_verify_data_csum().
>
> Both parameters are calculated values for csum lookup.
>
> Instead of some calculated value, just pass @disk_bytenr and let the
> final and only user, check_data_csum(), to calculate whatever it needs.
>
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
> fs/btrfs/extent_io.c | 14 ++++++++------
> fs/btrfs/inode.c | 26 +++++++++++++++++---------
> 2 files changed, 25 insertions(+), 15 deletions(-)
>
> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> index bd5a22bfee68..f8b5d3d4e5b0 100644
> --- a/fs/btrfs/extent_io.c
> +++ b/fs/btrfs/extent_io.c
> @@ -2878,7 +2878,7 @@ static void end_bio_extent_readpage(struct bio *bio)
> struct btrfs_io_bio *io_bio = btrfs_io_bio(bio);
> struct extent_io_tree *tree, *failure_tree;
> struct processed_extent processed = { 0 };
> - u64 offset = 0;
> + u64 disk_bytenr = (bio->bi_iter.bi_sector << 9);
This doesn't work, bi_sector can be remapped based on the underlying device, and
thus can be different between submit and endio. To illustrate this point, make
2 partitions on a single device, mkfs the second partition, and then run
xfstests with this patch applied, all sorts of fun will happen.
In fact we should probably add such a test to xfstests to catch anybody relying
on bi_sector to stay the same. Thanks,
Josef
next prev parent reply other threads:[~2020-11-10 15:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-10 2:09 [PATCH v2 0/2] btrfs: paramater refactors for data and metadata endio call backs Qu Wenruo
2020-11-10 2:09 ` [PATCH v2 1/2] btrfs: remove the phy_offset parameter for btrfs_validate_metadata_buffer() Qu Wenruo
2020-11-10 2:09 ` [PATCH v2 2/2] btrfs: pass disk_bytenr directly for check_data_csum() Qu Wenruo
2020-11-10 15:30 ` Josef Bacik [this message]
2020-11-11 0:05 ` 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=19a1507a-2a9e-805d-3b0d-66609f07decb@toxicpanda.com \
--to=josef@toxicpanda.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox