diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c index 15850ca99155ba725bc86de9b89ff148cfe10216..5b0fadc34b8350d430d03150a0e2eb5cbe4a7cc0 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) {