public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Qu Wenruo <wqu@suse.com>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
	Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
	David Sterba <dsterba@suse.com>,
	linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 2/3] btrfs: Fix two misuses of folio_shift()
Date: Tue, 21 Jan 2025 17:10:11 +0100	[thread overview]
Message-ID: <20250121161011.GG5777@suse.cz> (raw)
In-Reply-To: <33fa9947-cead-4f38-a61a-39b053f37a03@suse.com>

On Tue, Jan 21, 2025 at 05:51:40PM +1030, Qu Wenruo wrote:
> 
> 
> 在 2025/1/21 16:10, Matthew Wilcox (Oracle) 写道:
> > It is meaningless to shift a byte count by folio_shift().  The folio index
> > is in units of PAGE_SIZE, not folio_size().  We can use folio_contains()
> > to make this work for arbitrary-order folios, so remove the assertion
> > that the folios are of order 0.
> > 
> > Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> > ---
> >   fs/btrfs/extent_io.c | 8 +++-----
> >   1 file changed, 3 insertions(+), 5 deletions(-)
> > 
> > diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> > index 289ecb8ce217..c9b0ee841501 100644
> > --- a/fs/btrfs/extent_io.c
> > +++ b/fs/btrfs/extent_io.c
> > @@ -523,8 +523,6 @@ static void end_bbio_data_read(struct btrfs_bio *bbio)
> >   		u64 end;
> >   		u32 len;
> >   
> > -		/* For now only order 0 folios are supported for data. */
> > -		ASSERT(folio_order(folio) == 0);
> 
> I'd prefer to keep this ASSERT(), as all the btrfs_folio_*() helpers can 
> only handle page sized folio for now.
> 
> >   		btrfs_debug(fs_info,
> >   			"%s: bi_sector=%llu, err=%d, mirror=%u",
> >   			__func__, bio->bi_iter.bi_sector, bio->bi_status,
> > @@ -552,7 +550,6 @@ static void end_bbio_data_read(struct btrfs_bio *bbio)
> >   
> >   		if (likely(uptodate)) {
> >   			loff_t i_size = i_size_read(inode);
> > -			pgoff_t end_index = i_size >> folio_shift(folio);
> >   
> >   			/*
> >   			 * Zero out the remaining part if this range straddles
> > @@ -563,7 +560,8 @@ static void end_bbio_data_read(struct btrfs_bio *bbio)
> >   			 *
> >   			 * NOTE: i_size is exclusive while end is inclusive.
> >   			 */
> > -			if (folio_index(folio) == end_index && i_size <= end) {
> > +			if (folio_contains(folio, i_size >> PAGE_SHIFT) &&
> 
> Although folio_contains() is already a pretty good improvement, can we 
> have a bytenr/i_sized based solution for fs usages?

Good point, something like folio_contains_offset() that does the correct
shifts.

  reply	other threads:[~2025-01-21 16:10 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-21  5:40 [PATCH 1/3] btrfs: Fix some folio-related comments Matthew Wilcox (Oracle)
2025-01-21  5:40 ` [PATCH 2/3] btrfs: Fix two misuses of folio_shift() Matthew Wilcox (Oracle)
2025-01-21  7:21   ` Qu Wenruo
2025-01-21 16:10     ` David Sterba [this message]
2025-01-21 17:59       ` Matthew Wilcox
2025-01-22 15:24         ` David Sterba
2025-01-24  6:11           ` Qu Wenruo
2025-01-24 21:49             ` David Sterba
2025-01-21  5:40 ` [PATCH 3/3] btrfs: Convert io_ctl_prepare_pages() to work on folios Matthew Wilcox (Oracle)
2025-01-21  7:22   ` Qu Wenruo
2025-01-21  7:14 ` [PATCH 1/3] btrfs: Fix some folio-related comments 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=20250121161011.GG5777@suse.cz \
    --to=dsterba@suse.cz \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=willy@infradead.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