xfs: generalize the freespace and reserved blocks handling
authorChristoph Hellwig <hch@lst.de>
Sun, 9 Feb 2025 04:43:50 +0000 (05:43 +0100)
committerChristoph Hellwig <hch@lst.de>
Mon, 3 Mar 2025 15:16:37 +0000 (08:16 -0700)
commit712bae96631852c1a1822ee4f57a08ccd843358b
tree633ae9b57de8b64bd8dafa5f899c4108e4b9f95b
parentcc3d2f55c43affde7195867afb7b0ee45dd8019b
xfs: generalize the freespace and reserved blocks handling

xfs_{add,dec}_freecounter already handles the block and RT extent
percpu counters, but it currently hardcodes the passed in counter.

Add a freecounter abstraction that uses an enum to designate the counter
and add wrappers that hide the actual percpu_counters.  This will allow
expanding the reserved block handling to the RT extent counter in the
next step, and also prepares for adding yet another such counter that
can share the code.  Both these additions will be needed for the zoned
allocator.

Also switch the flooring of the frextents counter to 0 in statfs for the
rthinherit case to a manual min_t call to match the handling of the
fdblocks counter for normal file systems.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
16 files changed:
fs/xfs/libxfs/xfs_ialloc.c
fs/xfs/libxfs/xfs_metafile.c
fs/xfs/libxfs/xfs_sb.c
fs/xfs/libxfs/xfs_types.h
fs/xfs/scrub/fscounters.c
fs/xfs/scrub/fscounters_repair.c
fs/xfs/scrub/newbt.c
fs/xfs/xfs_fsops.c
fs/xfs/xfs_icache.c
fs/xfs/xfs_ioctl.c
fs/xfs/xfs_iomap.c
fs/xfs/xfs_mount.c
fs/xfs/xfs_mount.h
fs/xfs/xfs_rtalloc.c
fs/xfs/xfs_super.c
fs/xfs/xfs_trace.h