Re: [PATCH v3 4/4] xfs: support shrinking unused space in the last AG
From: Gao Xiang <hidden>
Date: 2021-01-09 00:49:36
Hi Darrick, On Fri, Jan 08, 2021 at 01:19:42PM -0800, Darrick J. Wong wrote:
On Sat, Jan 09, 2021 at 03:09:19AM +0800, Gao Xiang wrote:
...
quoted
delta = nb; /* use delta as a temporary here */Yikes, can this become a separate variable please?
Ok.
quoted
nb_mod = do_div(delta, mp->m_sb.sb_agblocks);@@ -99,10 +102,18 @@ xfs_growfs_data_private( if (nb_mod && nb_mod < XFS_MIN_AG_BLOCKS) { nagcount--; nb = (xfs_rfsblock_t)nagcount * mp->m_sb.sb_agblocks; - if (nb < mp->m_sb.sb_dblocks) + if (nagcount < 2) return -EINVAL; } - delta = nb - mp->m_sb.sb_dblocks; + + if (nb > mp->m_sb.sb_dblocks) { + delta = nb - mp->m_sb.sb_dblocks; + extend = true; + } else { + delta = mp->m_sb.sb_dblocks - nb; + extend = false;/me wonders why delta isn't simply int64_t, and then you can do things like: if (delta > 0) growfs else if (delta < 0) shrinkfs ?
Yeah, delta changed into a signed variable in mycurrent experimental shrinking entire AG hack as well. Will update this here in advance. Thanks, Gao Xiang