Skip to content

btrfs: support more pages sizes for the subpage support

Qu Wenruo linux-btrfs 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest3 patches 4 repliesIn review
  2. v23 patches 1 replySuperseded
  3. v12 patches 2 repliesSuperseded

Changes in v3 from the cover letter

- Fix the wrong page boundary check for nodesize >= PAGE_SIZE And update the commit message for the 1st path.

- Add an artificial limit to only support 4K and PAGE_SIZE as sectorsizes
There is no problem supporting any sectorsize < PAGE_SIZE, e.g. support 16K seectorsize with 64K page size works pretty fine.

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3btrfs: use dummy extent buffer for super block sys chunk array readfs/btrfs/volumes.c+5 -200 replies
2/3btrfs: make nodesize >= PAGE_SIZE case to reuse the non-subpage routinefs/btrfs/disk-io.c fs/btrfs/extent_io.c fs/btrfs/inode.c +2 more+110 -533 replies
3/3btrfs: expand subpage support to any PAGE_SIZE > 4Kfs/btrfs/disk-io.c fs/btrfs/sysfs.c+10 -90 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH v3 0/3] btrfs: support more pages sizes for the subpage support

The series can be fetched from github:
https://github.com/adam900710/linux/tree/metadata_subpage_switch

Previously we only support 64K page size with 4K sector size for subpage support.

There are two reasons for such requirement:

- Make sure no matter what the nodesize is, metadata can be fit into one page
This is to avoid multi-page metadata handling.

- We use u16 as bitmap
That means we will waste extra memory for smaller page sizes.

The 2nd problem is already solved by compacting all bitmap into one large bitmap, in commit 72a69cd03082 ("btrfs: subpage: pack all subpage bitmaps into a larger bitmap").

And this patchset will address the first problem by going to non-subpage routine if nodesize >= PAGE_SIZE.

This will still leave a small limitation, that for nodesize >= PAGE_SIZE and sectorsize < PAGE_SIZE case, the tree block must be page aligned.

Thankfully we have btrfs-check to detect such problem, and mkfs and kernel chunk allocator have already ensured all our metadata will not cross such page boundaries.

The following combinations has been tested:
(p: page_size s: sectorsize, n: nodesize)

- p=64K s=4K n=64K (aarch64, RK3399/CM4)
To cover the new metadata path

- p=64K s=4K n=16K (aarch64, RK3399/CM4)
- p=4k s=4k n=16k (x86_64)
The make sure no new bugs in the old path

- p=16K s=4K n=16K (aarch64, M1)
- p=16K s=4K n=64K (aarch64, M1)
Special thanks to Su Yue. He contributes his VM on M1 to me to do extra tests, and exposed a bug in the btrfs_read_sys_array() affecting 16K page size cases.

Changelog:
RFC->v1:
- Remove one ASSERT() which is causing false alert
As we have no way to distinguish unmapped extent buffer with anonymous page used by DIO/compression.

- Expand the subpage support to any PAGE_SIZE > 4K
There is still a limitation on not allowing metadata block crossing page boundaries, but that should already be rare nowadays.

Another limit is we still don't support 256K page size due to it's beyond max compressed extent size.

v2:
- Add extra supported sectorsizes in sysfs interface Now for page size > 4K, all sector sizes up to page size will be supported.

- Fix a bug in btrfs_read_sys_array() that would cause false alert Now btrfs_read_sys_array() will use dummy eb, and set/clear_extent_buffer_uptodate() will handle both dummy and subpage cases properly.

- Fix a bug in check_eb_alignment() that would cause false alert Since we handle nodesize >= PAGE_SIZE cases with the same page based metadata routine, we need to make sure metadata is page aligned for that case.

v3:
- Fix the wrong page boundary check for nodesize >= PAGE_SIZE And update the commit message for the 1st path.

- Add an artificial limit to only support 4K and PAGE_SIZE as sectorsizes
There is no problem supporting any sectorsize < PAGE_SIZE, e.g. support 16K seectorsize with 64K page size works pretty fine.

But that combination will not be supported by x86_64 anyway, and the extra combination will slow down the already slow testing on weaker ARM boards.

We will push 4k as default sectorsize.

Qu Wenruo (3):
btrfs: use dummy extent buffer for super block sys chunk array read
btrfs: make nodesize >= PAGE_SIZE case to reuse the non-subpage
routine
btrfs: expand subpage support to any PAGE_SIZE > 4K

 fs/btrfs/disk-io.c   |  17 +++++---
 fs/btrfs/extent_io.c | 102 ++++++++++++++++++++++++++++---------------
 fs/btrfs/inode.c     |   2 +-
 fs/btrfs/subpage.c   |  30 ++++++-------
 fs/btrfs/subpage.h   |  25 +++++++++++
 fs/btrfs/sysfs.c     |   6 +--
 fs/btrfs/volumes.c   |  25 +++--------
 7 files changed, 125 insertions(+), 82 deletions(-)
Signature · 1 line
2.34.1