mbox series

[v3,0/2] btrfs: migrate extent_buffer::pages[] to folio and more cleanups

Message ID cover.1701902977.git.wqu@suse.com (mailing list archive)
Headers show
Series btrfs: migrate extent_buffer::pages[] to folio and more cleanups | expand

Message

Qu Wenruo Dec. 6, 2023, 11:09 p.m. UTC
[CHANGELOG]
v2:
- Add a new patch to do more cleanups for metadata page pointers usage

v3:
- Fix a bug in alloc_eb_folio_array() which accesses uninitialized stack
  It turns out that I have CONFIG_INIT_STACK_ALL_ZERO, which prevents me
  from exposing the bug. Now changed to CONFIG_INIT_STACK_ALL_PATTERN.

This patchset would migrate extent_buffer::pages[] to folios[], then
cleanup the existing metadata page pointer usage to proper folios ones.

This cleanup would help future higher order folios usage for metadata in
the following aspects:

- No more need to iterate through the remaining pages for page flags
  We just call folio_set/mark/start_*() helpers, for the single folio.
  The helper would only set the flag (mostly for the leading page).

- Single bio_add_folio() call for the whole eb

- Better filio helpers naming
  PageUptodate() compared to folio_test_uptodate().

The first patch would do a very simple conversion, then the 2nd patch do
the prepartion for the higher order folio situation.

There are two locations which won't be converted to folios yet:

- Subpage code
  There is no meaning to support higher order folio for subpage.
  The two conditions are just conflicting with each other.

- Data page pointers
  That would be more useful in the future, before we going to support
  multi-page sectorsize.

However the 2nd one would also add a new corner case:

- Order mismatch in filemap and eb folios
  Unforatunately I don't have a better plan other than re-allocate the
  folios to the same order.
  Maybe in the future we would have better ways to handle it? Like
  migrating the pages to the higher order one?


Qu Wenruo (2):
  btrfs: migrate extent_buffer::pages[] to folio
  btrfs: cleanup metadata page pointer usage

 fs/btrfs/accessors.c             |  20 +-
 fs/btrfs/accessors.h             |   4 +-
 fs/btrfs/ctree.c                 |   2 +-
 fs/btrfs/disk-io.c               |  25 +-
 fs/btrfs/extent_io.c             | 402 ++++++++++++++++++-------------
 fs/btrfs/extent_io.h             |  21 +-
 fs/btrfs/inode.c                 |   2 +-
 fs/btrfs/subpage.c               |  60 ++---
 fs/btrfs/subpage.h               |  11 +-
 fs/btrfs/tests/extent-io-tests.c |   4 +-
 10 files changed, 322 insertions(+), 229 deletions(-)

Comments

David Sterba Dec. 7, 2023, 12:42 p.m. UTC | #1
On Thu, Dec 07, 2023 at 09:39:26AM +1030, Qu Wenruo wrote:
> [CHANGELOG]
> v2:
> - Add a new patch to do more cleanups for metadata page pointers usage
> 
> v3:
> - Fix a bug in alloc_eb_folio_array() which accesses uninitialized stack
>   It turns out that I have CONFIG_INIT_STACK_ALL_ZERO, which prevents me
>   from exposing the bug. Now changed to CONFIG_INIT_STACK_ALL_PATTERN.

Seems to be fixed, thanks. I had CONFIG_INIT_STACK_NONE=y so it got
caught due to random data on the stack but with
CONFIG_INIT_STACK_ALL_PATTERN the pattern makes it clear that it's due
to that.

Added to misc-next, thanks.