xfs: recompute growfsrtfree transaction reservation while growing rt volume
authorDarrick J. Wong <djwong@kernel.org>
Mon, 11 Dec 2023 18:41:51 +0000 (10:41 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Wed, 13 Dec 2023 22:16:27 +0000 (14:16 -0800)
While playing with growfs to create a 20TB realtime section on a
filesystem that didn't previously have an rt section, I noticed that
growfs would occasionally shut down the log due to a transaction
reservation overflow.

xfs_calc_growrtfree_reservation uses the current size of the realtime
summary file (m_rsumsize) to compute the transaction reservation for a
growrtfree transaction.  The reservations are computed at mount time,
which means that m_rsumsize is zero when growfs starts "freeing" the new
realtime extents into the rt volume.  As a result, the transaction is
undersized and fails.

Fix this by recomputing the transaction reservations every time we
change m_rsumsize.

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

index 8feb58c6241ce4b965b0bf7d1aa7afae03cfa9e3..0c9893b9f2a99af614e5486641faae760974c1ca 100644 (file)
@@ -1038,6 +1038,9 @@ xfs_growfs_rt(
                nrsumblocks = xfs_rtsummary_blockcount(mp, nrsumlevels,
                                nsbp->sb_rbmblocks);
                nmp->m_rsumsize = nrsumsize = XFS_FSB_TO_B(mp, nrsumblocks);
+               /* recompute growfsrt reservation from new rsumsize */
+               xfs_trans_resv_calc(nmp, &nmp->m_resv);
+
                /*
                 * Start a transaction, get the log reservation.
                 */
@@ -1124,6 +1127,8 @@ error_cancel:
                 */
                mp->m_rsumlevels = nrsumlevels;
                mp->m_rsumsize = nrsumsize;
+               /* recompute growfsrt reservation from new rsumsize */
+               xfs_trans_resv_calc(mp, &mp->m_resv);
 
                error = xfs_trans_commit(tp);
                if (error)