]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
xfs: don't use xfs_trans_reserve in xfs_trans_reserve_more
authorChristoph Hellwig <hch@lst.de>
Wed, 16 Jul 2025 12:43:12 +0000 (14:43 +0200)
committerCarlos Maiolino <cem@kernel.org>
Thu, 24 Jul 2025 15:30:13 +0000 (17:30 +0200)
xfs_trans_reserve_more just tries to allocate additional blocks and/or
rtextents and is otherwise unrelated to the transaction reservation
logic.  Open code the block and rtextent reservation in
xfs_trans_reserve_more to prepare for simplifying xfs_trans_reserve.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
fs/xfs/xfs_trans.c

index 8b15bfe68774d3e8a839d5171ace06cba5a04de4..2213cb2278d29f055b1b69a6a428f7ebe0050047 100644 (file)
@@ -1146,9 +1146,18 @@ xfs_trans_reserve_more(
        unsigned int            blocks,
        unsigned int            rtextents)
 {
-       struct xfs_trans_res    resv = { };
-
-       return xfs_trans_reserve(tp, &resv, blocks, rtextents);
+       bool                    rsvd = tp->t_flags & XFS_TRANS_RESERVE;
+
+       if (blocks && xfs_dec_fdblocks(tp->t_mountp, blocks, rsvd))
+               return -ENOSPC;
+       if (rtextents && xfs_dec_frextents(tp->t_mountp, rtextents)) {
+               if (blocks)
+                       xfs_add_fdblocks(tp->t_mountp, blocks);
+               return -ENOSPC;
+       }
+       tp->t_blk_res += blocks;
+       tp->t_rtx_res += rtextents;
+       return 0;
 }
 
 /*