]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit - libxfs/xfs_alloc.c
xfs: set up per-AG free space reservations
authorDarrick J. Wong <darrick.wong@oracle.com>
Tue, 25 Oct 2016 00:46:32 +0000 (11:46 +1100)
committerDave Chinner <david@fromorbit.com>
Tue, 25 Oct 2016 00:46:32 +0000 (11:46 +1100)
commitcf8ce22049582241e3e62515520ab716ed63c5ce
treeca3bc30fc80610cddb461cc0ae2e9df28f207b29
parent0590692ed11e5854656d84e06f84b8f6f5fdcb5d
xfs: set up per-AG free space reservations

Source kernel commit: 3fd129b63fd062a0d8f5d55994a6e98896c20fa7

One unfortunate quirk of the reference count and reverse mapping
btrees -- they can expand in size when blocks are written to *other*
allocation groups if, say, one large extent becomes a lot of tiny
extents.  Since we don't want to start throwing errors in the middle
of CoWing, we need to reserve some blocks to handle future expansion.
The transaction block reservation counters aren't sufficient here
because we have to have a reserve of blocks in every AG, not just
somewhere in the filesystem.

Therefore, create two per-AG block reservation pools.  One feeds the
AGFL so that rmapbt expansion always succeeds, and the other feeds all
other metadata so that refcountbt expansion never fails.

Use the count of how many reserved blocks we need to have on hand to
create a virtual reservation in the AG.  Through selective clamping of
the maximum length of allocation requests and of the length of the
longest free extent, we can make it look like there's less free space
in the AG unless the reservation owner is asking for blocks.

In other words, play some accounting tricks in-core to make sure that
we always have blocks available.  On the plus side, there's nothing to
clean up if we crash, which is contrast to the strategy that the rough
draft used (actually removing extents from the freespace btrees).

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
new file mode 100644
index 000000000000..e3ae0f2b4294
include/xfs_mount.h
include/xfs_trace.h
libxfs/Makefile
libxfs/defer_item.c
libxfs/xfs_ag_resv.c [new file with mode: 0644]
libxfs/xfs_ag_resv.h [new file with mode: 0644]
libxfs/xfs_alloc.c
libxfs/xfs_alloc.h
libxfs/xfs_bmap.c
libxfs/xfs_ialloc_btree.c
repair/phase5.c