]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xfs: ensure rtx mask/shift are correct after growfs
authorChristoph Hellwig <hch@lst.de>
Fri, 30 Aug 2024 22:37:01 +0000 (15:37 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Sun, 1 Sep 2024 15:58:19 +0000 (08:58 -0700)
When growfs sets an extent size, it doesn't updated the m_rtxblklog and
m_rtxblkmask values, which could lead to incorrect usage of them if they
were set before and can't be used for the new extent size.

Add a xfs_mount_sb_set_rextsize helper that updates the two fields, and
also use it when calculating the new RT geometry instead of disabling
the optimization there.

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

index f9c3045f71e047e48a42a2268e77a81280ff8ee1..a6fa9aedb28b0cd4cc3edd9b89720cae1d6d04e3 100644 (file)
@@ -965,6 +965,15 @@ const struct xfs_buf_ops xfs_sb_quiet_buf_ops = {
        .verify_write = xfs_sb_write_verify,
 };
 
+void
+xfs_mount_sb_set_rextsize(
+       struct xfs_mount        *mp,
+       struct xfs_sb           *sbp)
+{
+       mp->m_rtxblklog = log2_if_power2(sbp->sb_rextsize);
+       mp->m_rtxblkmask = mask64_if_power2(sbp->sb_rextsize);
+}
+
 /*
  * xfs_mount_common
  *
@@ -989,8 +998,7 @@ xfs_sb_mount_common(
        mp->m_blockmask = sbp->sb_blocksize - 1;
        mp->m_blockwsize = sbp->sb_blocksize >> XFS_WORDLOG;
        mp->m_blockwmask = mp->m_blockwsize - 1;
-       mp->m_rtxblklog = log2_if_power2(sbp->sb_rextsize);
-       mp->m_rtxblkmask = mask64_if_power2(sbp->sb_rextsize);
+       xfs_mount_sb_set_rextsize(mp, sbp);
 
        mp->m_alloc_mxr[0] = xfs_allocbt_maxrecs(mp, sbp->sb_blocksize, 1);
        mp->m_alloc_mxr[1] = xfs_allocbt_maxrecs(mp, sbp->sb_blocksize, 0);
index 796f02191dfd2e3800f7c376e6d4465bc279cd99..885c837559914d7257d4b76af427f67f82e1ef4a 100644 (file)
@@ -17,6 +17,8 @@ extern void   xfs_log_sb(struct xfs_trans *tp);
 extern int     xfs_sync_sb(struct xfs_mount *mp, bool wait);
 extern int     xfs_sync_sb_buf(struct xfs_mount *mp);
 extern void    xfs_sb_mount_common(struct xfs_mount *mp, struct xfs_sb *sbp);
+void           xfs_mount_sb_set_rextsize(struct xfs_mount *mp,
+                       struct xfs_sb *sbp);
 extern void    xfs_sb_from_disk(struct xfs_sb *to, struct xfs_dsb *from);
 extern void    xfs_sb_to_disk(struct xfs_dsb *to, struct xfs_sb *from);
 extern void    xfs_sb_quota_from_disk(struct xfs_sb *sbp);
index a9f08d96f1fe8c88fe0074997392f4e57f51199e..4bbb50d5a4b75f0d82fd4120bd2eb52ec4cab08e 100644 (file)
@@ -719,8 +719,8 @@ xfs_growfs_rt_bmblock(
        /*
         * Calculate new sb and mount fields for this round.
         */
-       nmp->m_rtxblklog = -1; /* don't use shift or masking */
        nmp->m_sb.sb_rextsize = rextsize;
+       xfs_mount_sb_set_rextsize(nmp, &nmp->m_sb);
        nmp->m_sb.sb_rbmblocks = bmbno + 1;
        nmp->m_sb.sb_rblocks = min(nrblocks, nrblocks_step);
        nmp->m_sb.sb_rextents = xfs_rtb_to_rtx(nmp, nmp->m_sb.sb_rblocks);
@@ -807,10 +807,11 @@ xfs_growfs_rt_bmblock(
        xfs_trans_mod_sb(args.tp, XFS_TRANS_SB_FREXTENTS, freed_rtx);
 
        /*
-        * Update mp values into the real mp structure.
+        * Update the calculated values in the real mount structure.
         */
        mp->m_rsumlevels = nmp->m_rsumlevels;
        mp->m_rsumsize = nmp->m_rsumsize;
+       xfs_mount_sb_set_rextsize(mp, &mp->m_sb);
 
        /*
         * Recompute the growfsrt reservation from the new rsumsize.