Skip to content

btrfs: zoned: write-time activation of metadata block group

Naohiro Aota linux-btrfs 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest10 patches 8 repliesIn review
  2. v210 patches 15 repliesSuperseded
  3. v18 patches 13 repliesSuperseded

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/10btrfs: introduce struct to consolidate extent buffer write contextfs/btrfs/extent_io.c fs/btrfs/extent_io.h+12 -70 replies
2/10btrfs: zoned: introduce block group context to btrfs_eb_write_contextfs/btrfs/extent_io.c fs/btrfs/extent_io.h fs/btrfs/zoned.c +1 more+31 -270 replies
3/10btrfs: zoned: return int from btrfs_check_meta_write_pointerfs/btrfs/extent_io.c fs/btrfs/zoned.c fs/btrfs/zoned.h+30 -210 replies
4/10btrfs: zoned: defer advancing meta_write_pointerfs/btrfs/extent_io.c fs/btrfs/zoned.c fs/btrfs/zoned.h+5 -260 replies
5/10btrfs: zoned: update meta_write_pointer on zone finishfs/btrfs/zoned.c+3 -00 replies
6/10btrfs: zoned: reserve zones for an active metadata/system block groupfs/btrfs/disk-io.c fs/btrfs/zoned.c fs/btrfs/zoned.h+103 -50 replies
7/10btrfs: zoned: activate metadata block group on write timefs/btrfs/block-group.c fs/btrfs/fs.h fs/btrfs/zoned.c+95 -21 reply
8/10btrfs: zoned: no longer count fresh BG region as zone unusablefs/btrfs/free-space-cache.c fs/btrfs/zoned.c+4 -301 reply
9/10btrfs: zoned: don't activate non-DATA BG on allocationfs/btrfs/block-group.c fs/btrfs/extent-tree.c fs/btrfs/space-info.c+8 -300 replies
10/10btrfs: zoned: re-enable metadata over-commit for zoned modefs/btrfs/space-info.c+1 -50 replies

Reviews trailers per patch

7 of 10 patches have a Reviewed-by or Acked-by.

PatchChristoph HellwigJohannes Thumshirn
1/10R-b R-b
2/10R-b R-b
3/10R-b R-b
4/10R-b R-b
5/10R-b R-b
6/10
7/10
8/10
9/10R-b
10/10R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 00/10] btrfs: zoned: write-time activation of metadata block group

In the current implementation, block groups are activated at reservation time to ensure that all reserved bytes can be written to an active metadata block group. However, this approach has proven to be less efficient, as it activates block groups more frequently than necessary, putting pressure on the active zone resource and leading to potential issues such as early ENOSPC or hung_task.

Another drawback of the current method is that it hampers metadata over-commit, and necessitates additional flush operations and block group allocations, resulting in decreased overall performance.

Actually, we don't need so many active metadata block groups because there is only one sequential metadata write stream.

So, this series introduces a write-time activation of metadata and system block group. This involves reserving at least one active block group specifically for a metadata and system block group. When the write goes into a new block group, it should have allocated all the regions in the current active block group. So, we can wait for IOs to fill the space, and then switch to a new block group.

Switching to the write-time activation solves the above issue and will lead to better performance.

* Performance

There is a significant difference with a workload (buffered write without sync) because we re-enable metadata over-commit.

before the patch:  741.00 MB/sec
after the patch:  1430.27 MB/sec (+ 93%)

* Organization

Patches 1-5 are preparation patches involves meta_write_pointer check.

Patches 6 and 7 are the main part of this series, implementing the write-time activation.

Patches 8-10 addresses code for reserve time activation: counting fresh block group as zone_unusable, activating a block group on allocation, and disabling metadata over-commit.

* Changes

- v3
- Rework the reservation patch to fix the over-reservation problem
https://lore.kernel.org/all/xpb5wdmxx5wops26ihulo73oluc64dt4zpxqc7cirp2wvxl3qy@hv7lsvma5hxf/
- Rename btrfs_eb_write_context's block_group to zoned_bg.

- v2
- Introduce a struct to consolidate extent buffer write context (btrfs_eb_write_context)
- Change return type of btrfs_check_meta_write_pointer to int
- Calculate the reservation count only when it sees DUP BG
- Drop unnecessary BG lock

Naohiro Aota (10):
btrfs: introduce struct to consolidate extent buffer write context
btrfs: zoned: introduce block group context to btrfs_eb_write_context
btrfs: zoned: return int from btrfs_check_meta_write_pointer
btrfs: zoned: defer advancing meta_write_pointer
btrfs: zoned: update meta_write_pointer on zone finish
btrfs: zoned: reserve zones for an active metadata/system block group
btrfs: zoned: activate metadata block group on write time
btrfs: zoned: no longer count fresh BG region as zone unusable
btrfs: zoned: don't activate non-DATA BG on allocation
btrfs: zoned: re-enable metadata over-commit for zoned mode

 fs/btrfs/block-group.c      |  13 +-
 fs/btrfs/disk-io.c          |   2 +
 fs/btrfs/extent-tree.c      |   8 +-
 fs/btrfs/extent_io.c        |  44 +++---
 fs/btrfs/extent_io.h        |   7 +
 fs/btrfs/free-space-cache.c |   8 +-
 fs/btrfs/fs.h               |   3 +
 fs/btrfs/space-info.c       |  34 +----
 fs/btrfs/zoned.c            | 259 ++++++++++++++++++++++++++++--------
 fs/btrfs/zoned.h            |  29 ++--
 10 files changed, 273 insertions(+), 134 deletions(-)
Signature · 1 line
2.41.0