public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Qu Wenruo <quwenruo.btrfs@gmx.com>
Cc: Qu Wenruo <wqu@suse.com>,
	linux-btrfs@vger.kernel.org, David Sterba <dsterba@suse.com>
Subject: Re: [PATCH RFC 2/2] btrfs: defrag: prepare defrag for larger data folio size
Date: Tue, 27 Feb 2024 21:32:45 +0000	[thread overview]
Message-ID: <Zd5U_bSQabhuc4iv@casper.infradead.org> (raw)
In-Reply-To: <fedffe54-abfe-4ef7-a66e-a5a60bb59576@gmx.com>

On Fri, Feb 16, 2024 at 09:37:01AM +1030, Qu Wenruo wrote:
> 在 2024/2/16 06:53, Matthew Wilcox 写道:
> > On Wed, Jan 24, 2024 at 02:29:08PM +1030, Qu Wenruo wrote:
> > > Although we have migrated defrag to use the folio interface, we can
> > > still further enhance it for the future larger data folio size.
> > 
> > This patch is wrong.  Please drop it.
> > 
> > >   {
> > >   	struct btrfs_fs_info *fs_info = inode->root->fs_info;
> > >   	struct extent_changeset *data_reserved = NULL;
> > >   	const u64 start = target->start;
> > >   	const u64 len = target->len;
> > > -	unsigned long last_index = (start + len - 1) >> PAGE_SHIFT;
> > > -	unsigned long start_index = start >> PAGE_SHIFT;
> > > +	unsigned long last_index = (start + len - 1) >> fs_info->folio_shift;
> > > +	unsigned long start_index = start >> fs_info->folio_shift;
> > 
> > indices are always in multiples of PAGE_SIZE.
> 
> So is the fs_info->folio_shift. It would always be >= PAGE_SHIFT.

No, you don't understand.  folio->index * PAGE_SIZE == byte offset of folio
in the file.  What you've done here breaks that.

> > >   	unsigned long first_index = folios[0]->index;
> > 
> > ... so if you've shifted a file position by some "folio_shift" and then
> > subtracted it from folio->index, you have garbage.
> 
> For the future larger folio support, all folio would be in the size of
> sectorsize.

Yes, folios are always an integer multiple of sector size.  But their
_index_ is expressed as a multiple of the page size.


  reply	other threads:[~2024-02-27 21:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-24  3:59 [PATCH RFC 0/2] btrfs: defrag: further preparation for multi-page sector size Qu Wenruo
2024-01-24  3:59 ` [PATCH RFC 1/2] btrfs: introduce cached folio size Qu Wenruo
2024-01-24  3:59 ` [PATCH RFC 2/2] btrfs: defrag: prepare defrag for larger data " Qu Wenruo
2024-02-15 20:23   ` Matthew Wilcox
2024-02-15 23:07     ` Qu Wenruo
2024-02-27 21:32       ` Matthew Wilcox [this message]
2024-02-27 21:42         ` Qu Wenruo
2024-01-24  4:03 ` [PATCH RFC 0/2] btrfs: defrag: further preparation for multi-page sector size Qu Wenruo
2024-01-24  4:48   ` Matthew Wilcox
2024-01-24  5:27     ` Qu Wenruo
2024-01-24  5:43       ` Matthew Wilcox
2024-01-24  5:50         ` 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=Zd5U_bSQabhuc4iv@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=dsterba@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=quwenruo.btrfs@gmx.com \
    --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