summaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorBrian Foster2019-06-29 04:30:20 +0200
committerDarrick J. Wong2019-06-29 04:30:20 +0200
commit6691cd9267c1c588d1f8e097c175d7c9670c7fc1 (patch)
tree6ddefbe142c1e4a2f1db2336317bcbe0ab6e9118 /fs/xfs
parentxfs: move small allocation helper (diff)
downloadkernel-qcow2-linux-6691cd9267c1c588d1f8e097c175d7c9670c7fc1.tar.gz
kernel-qcow2-linux-6691cd9267c1c588d1f8e097c175d7c9670c7fc1.tar.xz
kernel-qcow2-linux-6691cd9267c1c588d1f8e097c175d7c9670c7fc1.zip
xfs: skip small alloc cntbt logic on NULL cursor
The small allocation helper is implemented in a way that is fairly tightly integrated to the existing allocation algorithms. It expects a cntbt cursor beyond the end of the tree, attempts to locate the last record in the tree and only attempts an AGFL allocation if the cntbt is empty. The upcoming generic algorithm doesn't rely on the cntbt processing of this function. It will only call this function when the cntbt doesn't have a big enough extent or is empty and thus AGFL allocation is the only remaining option. Tweak xfs_alloc_ag_vextent_small() to handle a NULL cntbt cursor and skip the cntbt logic. This facilitates use by the existing allocation code and new code that only requires an AGFL allocation attempt. Signed-off-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/libxfs/xfs_alloc.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index 15850ca99155..5b0fadc34b83 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -713,9 +713,16 @@ xfs_alloc_ag_vextent_small(
int error = 0;
xfs_agblock_t fbno = NULLAGBLOCK;
xfs_extlen_t flen = 0;
- int i;
+ int i = 0;
- error = xfs_btree_decrement(ccur, 0, &i);
+ /*
+ * If a cntbt cursor is provided, try to allocate the largest record in
+ * the tree. Try the AGFL if the cntbt is empty, otherwise fail the
+ * allocation. Make sure to respect minleft even when pulling from the
+ * freelist.
+ */
+ if (ccur)
+ error = xfs_btree_decrement(ccur, 0, &i);
if (error)
goto error;
if (i) {