]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit
xfs: allow inode-based btrees to reserve space in the data device
authorDarrick J. Wong <djwong@kernel.org>
Mon, 24 Feb 2025 18:21:47 +0000 (10:21 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 25 Feb 2025 17:15:57 +0000 (09:15 -0800)
commit2711590ccdf1230ee521fe9fd99a8c0bd13ade80
tree0243bed04949417ec6fd0b0cc0f78c6ba6ba2420
parentab1b3de74ded0fbbe2838e715915d692e5cdc286
xfs: allow inode-based btrees to reserve space in the data device

Source kernel commit: 05290bd5c6236b8ad659157edb36bd2d38f46d3e

Create a new space reservation scheme so that btree metadata for the
realtime volume can reserve space in the data device to avoid space
underruns.

Back when we were testing the rmap and refcount btrees for the data
device, people observed occasional shutdowns when xfs_btree_split was
called for either of those two btrees.  This happened when certain
operations (mostly writeback ioends) created new rmap or refcount
records, which would expand the size of the btree.  If there were no
free blocks available the allocation would fail and the split would shut
down the filesystem.

I considered pre-reserving blocks for btree expansion at the time of a
write() call, but there wasn't any good way to attach the reservations
to an inode and keep them there all the way to ioend processing.  Unlike
delalloc reservations which have that indlen mechanism, there's no way
to do that for mapped extents; and indlen blocks are given back during
the delalloc -> unwritten transition.

The solution was to reserve sufficient blocks for rmap/refcount btree
expansion at mount time.  This is what the XFS_AG_RESV_* flags provide;
any expansion of those two btrees can come from the pre-reserved space.

This patch brings that pre-reservation ability to inode-rooted btrees so
that the rt rmap and refcount btrees can also save room for future
expansion.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
include/xfs_inode.h
include/xfs_mount.h
include/xfs_trace.h
io/inject.c
libxfs/libxfs_priv.h
libxfs/xfs_ag_resv.c
libxfs/xfs_errortag.h
libxfs/xfs_metadir.c
libxfs/xfs_metafile.c
libxfs/xfs_metafile.h
libxfs/xfs_types.h