mbox series

[f2fs-dev,v3,0/7] Add 16K Support for f2fs-tools

Message ID 20230829010536.3044883-1-drosen@google.com (mailing list archive)
Headers show
Series Add 16K Support for f2fs-tools | expand

Message

Daniel Rosenberg Aug. 29, 2023, 1:05 a.m. UTC
This adds support for different block sizes to f2fs-tools.

The first patch redefines all block size based constants to be based on the
block size. After this patch, you should be able to compile a version of
f2fs-tools that works for a given blocksize by just setting F2FS_BLKSIZE_BITS
in f2fs_fs.h. Running fsck on an f2fs filesystem of a different block size will
fail early, and should leave the fs untouched.

I was unsure how to handle things under tools/, so I've left them as is.

The rest of the patches refactor the code to allow it to handle different block
sizes with the same binary. The final patch puts this under a block size
argument in make_f2fs.

The refactor splits apart structs that have components with sizes derived from
the blocksize in the middle. If the component is at the end, it's treated as a
variable length array. This means that sizeof on affected structs will not work
as expected, and should be replaced with F2FS_BLKSIZE where appropriate. The
affected static_asserts are replaced with runtime asserts.

It touches a lot of places, but I think it's probably with it to be able to use
a single binary, particularly if we're ever going to be able to mount different
blocksize f2fs filesystems using the same kernel.

I was unable to get xfstests running on my 16k arm setup, so I wasn't able to
test it as thoroughly as I'd like to have, but it behaved the same on a 4k
x86_64 system, and fsck/mounted successfully on an arm64 system.

---
changes in v3:
Fixed runtime asserts in check_block_struct_sizes
Now calls check_block_struct_sizes in mkfs
Fixed stack corruption in move_one_curseg_info

changes in v2:
Moved some 4096=>Block Size changes up to initial patch
Fixed build error in initial patch

Daniel Rosenberg (7):
  f2fs-tools: Define constants in terms of BLKSIZE
  f2fs-tools: Refactor Orphan Block struct
  f2fs-tools: Refactor f2fs_node struct and friends
  f2fs-tools: Refactor SIT/NAT block structs
  f2fs-tools: Refactor Summary block struct and friends
  f2fs-tools: Refactor f2fs_dentry_block struct
  f2fs-tools: Support different block sizes

 fsck/dir.c               |  46 +++----
 fsck/dump.c              |  28 ++--
 fsck/f2fs.h              |   6 +-
 fsck/fsck.c              |  72 +++++-----
 fsck/fsck.h              |   5 +-
 fsck/main.c              |   1 +
 fsck/mount.c             |  99 ++++++++------
 fsck/node.c              |  12 +-
 fsck/node.h              |  20 +--
 fsck/resize.c            |   2 +-
 include/f2fs_fs.h        | 274 ++++++++++++++++++++++++++++-----------
 lib/libf2fs.c            |   4 +-
 man/sload.f2fs.8         |   2 +-
 mkfs/f2fs_format.c       |  90 ++++++-------
 mkfs/f2fs_format_main.c  |  15 ++-
 mkfs/f2fs_format_utils.c |   2 +-
 16 files changed, 412 insertions(+), 266 deletions(-)


base-commit: b15b6cc56ac7764be17acbdbf96448f388992adc