xfs: don't deplete the reserve pool when trying to shrink the fs
PATCH 1/1 xfs: don't deplete the reserve pool when trying to shrink the fs
From: Darrick J. Wong <[email protected]>
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.
--- fs/xfs/xfs_fsops.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
fs/xfs/xfs_fsops.c +7 -3
@@ -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;
Quoted 11 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
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 atxfs_ag_shrink_space+0x23c/0x3b0[xfs] (fs/xfs/libxfs/xfs_ag.c:1007). Shutting down filesystem.
Quoted 4 lines
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")
[ These months I have no more slots for XFS, will go back later
after some ongoing feature development is done. ]
Thanks,
Gao Xiang
Quoted 26 lines
Signed-off-by Darrick J. Wong <[email protected]>--- fs/xfs/xfs_fsops.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)fs/xfs/xfs_fsops.c +7
-3@@ -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;