summaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_fsops.c
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2023-06-12 18:09:04 -0700
committerDarrick J. Wong <djwong@kernel.org>2023-06-12 18:09:04 -0700
commit06f3ef6e1705612b88aa0b6991e2ac3b8ed3f8ec (patch)
tree1adcc43460eed64372604661834d300aa560f496 /fs/xfs/xfs_fsops.c
parent858fd168a95c5b9669aac8db6c14a9aeab446375 (diff)
downloadlinux-stable-06f3ef6e1705612b88aa0b6991e2ac3b8ed3f8ec.tar.gz
linux-stable-06f3ef6e1705612b88aa0b6991e2ac3b8ed3f8ec.tar.bz2
linux-stable-06f3ef6e1705612b88aa0b6991e2ac3b8ed3f8ec.zip
xfs: don't deplete the reserve pool when trying to shrink the fs
Every now and then, xfs/168 fails with this logged in dmesg: Reserve blocks depleted! Consider increasing reserve pool size. EXPERIMENTAL online shrink feature in use. Use at your own risk! Per-AG reservation for AG 1 failed. Filesystem may run out of space. Per-AG reservation for AG 1 failed. Filesystem may run out of space. Error -28 reserving per-AG metadata reserve pool. Corruption of in-memory data (0x8) detected at xfs_ag_shrink_space+0x23c/0x3b0 [xfs] (fs/xfs/libxfs/xfs_ag.c:1007). Shutting down filesystem. It's silly to deplete the reserved blocks pool just to shrink the filesystem, particularly since the fs goes down after that. Fixes: fb2fc1720185 ("xfs: support shrinking unused space in the last AG") Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Diffstat (limited to 'fs/xfs/xfs_fsops.c')
-rw-r--r--fs/xfs/xfs_fsops.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index 13851c0d640b..5f00527b8065 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -140,9 +140,13 @@ xfs_growfs_data_private(
return -EINVAL;
}
- error = xfs_trans_alloc(mp, &M_RES(mp)->tr_growdata,
- (delta > 0 ? XFS_GROWFS_SPACE_RES(mp) : -delta), 0,
- XFS_TRANS_RESERVE, &tp);
+ if (delta > 0)
+ error = xfs_trans_alloc(mp, &M_RES(mp)->tr_growdata,
+ XFS_GROWFS_SPACE_RES(mp), 0, XFS_TRANS_RESERVE,
+ &tp);
+ else
+ error = xfs_trans_alloc(mp, &M_RES(mp)->tr_growdata, -delta, 0,
+ 0, &tp);
if (error)
return error;