mbox series

[v4,00/10] btrfs-progs: zoned: proper "mkfs.btrfs -b" support

Message ID 20240529071325.940910-1-naohiro.aota@wdc.com (mailing list archive)
Headers show
Series btrfs-progs: zoned: proper "mkfs.btrfs -b" support | expand

Message

Naohiro Aota May 29, 2024, 7:13 a.m. UTC
mkfs.btrfs -b <byte_count> on a zoned device has several issues listed
below.

- The FS size needs to be larger than minimal size that can host a btrfs,
  but its calculation does not consider non-SINGLE profile
- The calculation also does not ensure tree-log BG and data relocation BG
- It allows creating a FS not aligned to the zone boundary
- It resets all device zones beyond the specified length

This series fixes the issues with some cleanups.

This one passed CI workflow here:

Patches 1 to 3 are clean up patches, so they should not change the behavior.

Patches 4 to 6 address the issues.

Patches 7 to 10 add/modify the test cases. First, patch 7 adds nullb
functions to use in later patches. Patch 8 adds a new test for
zone resetting. And, patches 9 and 10 rewrites existing tests with the
nullb helper.

Changes:
- v4:
  -  Fix source directory size alignment.
- v3: https://lore.kernel.org/linux-btrfs/dfd8887b-a2cb-425f-8705-0d6a94cefb9c@gmx.com/
  - Tweak minimum FS size calculation style.
  - Round down the specified byte_count towards sectorsize and zone
    size, instead of banning unaligned byte_count.
  - Add active zone description in the commit log of patch 6.
  - Add nullb test functions and use them in tests.
- v2: https://lore.kernel.org/linux-btrfs/20240514182227.1197664-1-naohiro.aota@wdc.com/
  - fix function declaration on older distro (non-ZONED setup)
  - fix mkfs test failure
- v1: https://lore.kernel.org/linux-btrfs/20240514005133.44786-1-naohiro.aota@wdc.com/

Naohiro Aota (10):
  btrfs-progs: rename block_count to byte_count
  btrfs-progs: mkfs: remove duplicated device size check
  btrfs-progs: mkfs: unify zoned mode minimum size calc into
    btrfs_min_dev_size()
  btrfs-progs: mkfs: fix minimum size calculation for zoned mode
  btrfs-progs: mkfs: align byte_count with sectorsize and zone size
  btrfs-progs: support byte length for zone resetting
  btrfs-progs: test: add nullb setup functions
  btrfs-progs: test: add test for zone resetting
  btrfs-progs: test: use nullb helper and smaller zone size
  btrfs-progs: test: use nullb helpers in 031-zoned-bgt

 common/device-utils.c                    | 45 +++++++-----
 kernel-shared/zoned.c                    | 23 +++++-
 kernel-shared/zoned.h                    |  7 +-
 mkfs/common.c                            | 62 ++++++++++++++---
 mkfs/common.h                            |  2 +-
 mkfs/main.c                              | 89 ++++++++++--------------
 tests/common                             | 63 +++++++++++++++++
 tests/mkfs-tests/030-zoned-rst/test.sh   | 14 ++--
 tests/mkfs-tests/031-zoned-bgt/test.sh   | 30 ++------
 tests/mkfs-tests/032-zoned-reset/test.sh | 43 ++++++++++++
 10 files changed, 260 insertions(+), 118 deletions(-)
 create mode 100755 tests/mkfs-tests/032-zoned-reset/test.sh

--
2.45.1

Comments

David Sterba June 3, 2024, 7:36 p.m. UTC | #1
On Wed, May 29, 2024 at 04:13:15PM +0900, Naohiro Aota wrote:
> mkfs.btrfs -b <byte_count> on a zoned device has several issues listed
> below.
> 
> - The FS size needs to be larger than minimal size that can host a btrfs,
>   but its calculation does not consider non-SINGLE profile
> - The calculation also does not ensure tree-log BG and data relocation BG
> - It allows creating a FS not aligned to the zone boundary
> - It resets all device zones beyond the specified length
> 
> This series fixes the issues with some cleanups.
> 
> This one passed CI workflow here:
> 
> Patches 1 to 3 are clean up patches, so they should not change the behavior.
> 
> Patches 4 to 6 address the issues.
> 
> Patches 7 to 10 add/modify the test cases. First, patch 7 adds nullb
> functions to use in later patches. Patch 8 adds a new test for
> zone resetting. And, patches 9 and 10 rewrites existing tests with the
> nullb helper.
> 
> Changes:
> - v4:
>   -  Fix source directory size alignment.
> - v3: https://lore.kernel.org/linux-btrfs/dfd8887b-a2cb-425f-8705-0d6a94cefb9c@gmx.com/
>   - Tweak minimum FS size calculation style.
>   - Round down the specified byte_count towards sectorsize and zone
>     size, instead of banning unaligned byte_count.
>   - Add active zone description in the commit log of patch 6.
>   - Add nullb test functions and use them in tests.
> - v2: https://lore.kernel.org/linux-btrfs/20240514182227.1197664-1-naohiro.aota@wdc.com/
>   - fix function declaration on older distro (non-ZONED setup)
>   - fix mkfs test failure
> - v1: https://lore.kernel.org/linux-btrfs/20240514005133.44786-1-naohiro.aota@wdc.com/
> 
> Naohiro Aota (10):
>   btrfs-progs: rename block_count to byte_count
>   btrfs-progs: mkfs: remove duplicated device size check
>   btrfs-progs: mkfs: unify zoned mode minimum size calc into
>     btrfs_min_dev_size()
>   btrfs-progs: mkfs: fix minimum size calculation for zoned mode
>   btrfs-progs: mkfs: align byte_count with sectorsize and zone size
>   btrfs-progs: support byte length for zone resetting
>   btrfs-progs: test: add nullb setup functions
>   btrfs-progs: test: add test for zone resetting
>   btrfs-progs: test: use nullb helper and smaller zone size
>   btrfs-progs: test: use nullb helpers in 031-zoned-bgt

Added to devel, thanks.

One thing that may be worth adding to the documentation is behaviour
regarding the active zones outside of the fs range. The error messages
are clear if this happens, for troubleshooting it may be useful to say
what to do or check if this happens.