[PATCHSET v5.8 4/9] mkfs: make protofiles less janky

Darrick J. Wong
2024-12-06T23:27:42Z

Hi all,

Here are some minor improvements to the protofile code in mkfs. First,
we improve the file copy-in code to avoid allocating gigantic heap
buffers by replacing it with a SEEK_{DATA,HOLE} loop and only copying
a fixed size buffer. Next, we add the ability to pull in extended
attributes. Finally, we add a program to generate a protofile from a
directory tree.

Originally this code refactoring was intended to support more efficient
construction of rt bitmap and summary files, but that was subsequently
refactored into libxfs. However, the cleanups still make the protofile
code less disgusting, so they're being submitted anyway.

If you're going to start using this code, I strongly recommend pulling
from my git trees, which are linked below.

This has been running on the djcloud for months with no problems. Enjoy!
Comments and questions are, as always, welcome.

--D

xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=protofiles

fstests git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=protofiles
---
Commits in this patchset:
* libxfs: resync libxfs_alloc_file_space interface with the kernel
* mkfs: support copying in large or sparse files
* mkfs: support copying in xattrs
* mkfs: add a utility to generate protofiles
---
include/libxfs.h | 6 +
libxfs/util.c | 207 +++++++++++++++++++++++++++--------
man/man8/xfs_protofile.8 | 33 ++++++
mkfs/Makefile | 10 ++
mkfs/proto.c | 269 ++++++++++++++++++++++++++++++++++------------
mkfs/xfs_protofile.in | 152 ++++++++++++++++++++++++++
6 files changed, 557 insertions(+), 120 deletions(-)
create mode 100644 man/man8/xfs_protofile.8
create mode 100644 mkfs/xfs_protofile.in