mbox series

[v2,0/3] btrfs: migrate IO path to folios

Message ID cover.1702347666.git.wqu@suse.com (mailing list archive)
Headers show
Series btrfs: migrate IO path to folios | expand

Message

Qu Wenruo Dec. 12, 2023, 2:28 a.m. UTC
[CHANGELOG]
v2:
- Fix a PAGE_SHIFT usage in the 3rd patch on the data read path
  I know this won't be touched any time soon, but considering it's
  really one patch away from enabling higher order folios for metadata,
  let's make the cleanup closer to perfection.


One critical problem I hit the most during my initial higher order
folios tests are, incorrect access to the pages which conflicts with the
page flag policy.

Since folio flags are only set to certain pages according to their
policies (PF_ANY, PF_HEAD, PF_ONLY_HEAD, PF_NO_TAIL, PF_NO_COMPOUND and
the most weird on PF_SECOND), setting page flags violating the policy
would immedate lead to VM_BUG_ON().

Thus no matter if we go compound page or folio, we can not go the
page-by-page iteration helpers that easily.
One of the hot spots which can lead to VM_BUG_ON()s are the endio
helpers.

So this patch would:

- Make metadata set/get helpers to utilize folio interfaces

- Make subpage code to accept folios directly
  This is to avoid btrfs_page_*() helpers to accept page pointers, which
  is another hot spot which uses page pointer a lot.

- Migrate btrfs bio endio functions to utilize bio_for_each_folio_all()
  This completely removes the ability to direct access page pointers.
  Although we still need some extra folio_page(folio, 0) calls to keep
  compatible with existing helpers.

  And since we're here, also fix the choas of btrfs endio functions'
  naming scheme, now it would always be:
    end_bbio_<target>_(read|write)
  The <target> can be:

  - data
    For non-compressed and non-encoeded operations

  - compressed
    For compressed IO and encoded IO.

  - meta

  And since compressed IO path is utilizing unmapped pages (pages
  without an address_space), thus they don't touch the page flags.
  This makes compressed IO path a very good test bed for the initial
  introduction of higher order folio.

Qu Wenruo (3):
  btrfs: migrate get_eb_page_index() and get_eb_offset_in_page() to
    folios
  btrfs: migrate subpage code to folio interfaces
  btrfs: migrate various btrfs end io functions to folios

 fs/btrfs/accessors.c        |  80 ++++----
 fs/btrfs/compression.c      |  15 +-
 fs/btrfs/ctree.c            |  13 +-
 fs/btrfs/defrag.c           |   3 +-
 fs/btrfs/disk-io.c          |   4 +-
 fs/btrfs/extent_io.c        | 363 +++++++++++++++++++-----------------
 fs/btrfs/extent_io.h        |  40 ++--
 fs/btrfs/file.c             |  13 +-
 fs/btrfs/free-space-cache.c |   4 +-
 fs/btrfs/inode.c            |  34 ++--
 fs/btrfs/ordered-data.c     |   5 +-
 fs/btrfs/reflink.c          |   6 +-
 fs/btrfs/relocation.c       |   5 +-
 fs/btrfs/subpage.c          | 304 ++++++++++++++----------------
 fs/btrfs/subpage.h          |  74 ++++----
 15 files changed, 500 insertions(+), 463 deletions(-)

Comments

David Sterba Dec. 13, 2023, 10:27 p.m. UTC | #1
On Tue, Dec 12, 2023 at 12:58:35PM +1030, Qu Wenruo wrote:
> [CHANGELOG]
> v2:
> - Fix a PAGE_SHIFT usage in the 3rd patch on the data read path
>   I know this won't be touched any time soon, but considering it's
>   really one patch away from enabling higher order folios for metadata,
>   let's make the cleanup closer to perfection.
> 
> 
> One critical problem I hit the most during my initial higher order
> folios tests are, incorrect access to the pages which conflicts with the
> page flag policy.
> 
> Since folio flags are only set to certain pages according to their
> policies (PF_ANY, PF_HEAD, PF_ONLY_HEAD, PF_NO_TAIL, PF_NO_COMPOUND and
> the most weird on PF_SECOND), setting page flags violating the policy
> would immedate lead to VM_BUG_ON().
> 
> Thus no matter if we go compound page or folio, we can not go the
> page-by-page iteration helpers that easily.
> One of the hot spots which can lead to VM_BUG_ON()s are the endio
> helpers.
> 
> So this patch would:
> 
> - Make metadata set/get helpers to utilize folio interfaces
> 
> - Make subpage code to accept folios directly
>   This is to avoid btrfs_page_*() helpers to accept page pointers, which
>   is another hot spot which uses page pointer a lot.
> 
> - Migrate btrfs bio endio functions to utilize bio_for_each_folio_all()
>   This completely removes the ability to direct access page pointers.
>   Although we still need some extra folio_page(folio, 0) calls to keep
>   compatible with existing helpers.
> 
>   And since we're here, also fix the choas of btrfs endio functions'
>   naming scheme, now it would always be:
>     end_bbio_<target>_(read|write)
>   The <target> can be:
> 
>   - data
>     For non-compressed and non-encoeded operations
> 
>   - compressed
>     For compressed IO and encoded IO.
> 
>   - meta
> 
>   And since compressed IO path is utilizing unmapped pages (pages
>   without an address_space), thus they don't touch the page flags.
>   This makes compressed IO path a very good test bed for the initial
>   introduction of higher order folio.
> 
> Qu Wenruo (3):
>   btrfs: migrate get_eb_page_index() and get_eb_offset_in_page() to
>     folios
>   btrfs: migrate subpage code to folio interfaces
>   btrfs: migrate various btrfs end io functions to folios

Added to misc-next, thanks.