summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2021-09-01 11:24:40 -0700
committerDarrick J. Wong <djwong@kernel.org>2021-09-17 18:55:27 -0700
commit1724bf5a47f9ecad13ce57f10b36c0760730d666 (patch)
tree66c05d5f84e41970ba77a4fef53b0d445fb16b21
parentd632735644f2658067bd38384ae151f6d60cfa48 (diff)
xfs: fix rt growfs quota accounting
When growing the realtime bitmap or summary inodes, use xfs_trans_alloc_inode to reserve quota for the blocks that could be allocated to the file. Although we never enforce limits against the root dquot, making a reservation means that the bmap code will update the quota block count, which is necessary for correct accounting. Found by running xfs/521. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
-rw-r--r--fs/xfs/xfs_rtalloc.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index 06f69f62e85d..88aafa2da45e 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -27,6 +27,7 @@
#include "xfs_error.h"
#include "xfs_rtrmap_btree.h"
#include "xfs_rtrefcount_btree.h"
+#include "xfs_quota.h"
/*
* Read and return the summary information for a given extent size,
@@ -802,15 +803,10 @@ xfs_growfs_rt_alloc(
/*
* Reserve space & log for one extent added to the file.
*/
- error = xfs_trans_alloc(mp, &M_RES(mp)->tr_growrtalloc, resblks,
- 0, 0, &tp);
+ error = xfs_trans_alloc_inode(ip, &M_RES(mp)->tr_growrtalloc,
+ resblks, 0, false, &tp);
if (error)
return error;
- /*
- * Lock the inode.
- */
- xfs_ilock(ip, XFS_ILOCK_EXCL);
- xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
error = xfs_iext_count_may_overflow(ip, XFS_DATA_FORK,
XFS_IEXT_ADD_NOSPLIT_CNT);
@@ -831,6 +827,7 @@ xfs_growfs_rt_alloc(
* Free any blocks freed up in the transaction, then commit.
*/
error = xfs_trans_commit(tp);
+ xfs_iunlock(ip, XFS_ILOCK_EXCL);
if (error)
return error;
/*
@@ -843,15 +840,12 @@ xfs_growfs_rt_alloc(
/*
* Reserve log for one block zeroing.
*/
- error = xfs_trans_alloc(mp, &M_RES(mp)->tr_growrtzero,
- 0, 0, 0, &tp);
+ error = xfs_trans_alloc_inode(ip,
+ &M_RES(mp)->tr_growrtzero, 0, 0, false,
+ &tp);
if (error)
return error;
- /*
- * Lock the bitmap inode.
- */
- xfs_ilock(ip, XFS_ILOCK_EXCL);
- xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
+
/*
* Get a buffer for the block.
*/
@@ -869,6 +863,7 @@ xfs_growfs_rt_alloc(
* Commit the transaction.
*/
error = xfs_trans_commit(tp);
+ xfs_iunlock(ip, XFS_ILOCK_EXCL);
if (error)
return error;
}
@@ -882,6 +877,7 @@ xfs_growfs_rt_alloc(
out_trans_cancel:
xfs_trans_cancel(tp);
+ xfs_iunlock(ip, XFS_ILOCK_EXCL);
return error;
}