]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
xfs: ensure rtx mask/shift are correct after growfs
authorChristoph Hellwig <hch@lst.de>
Mon, 5 Aug 2024 18:50:51 +0000 (11:50 -0700)
committerChristoph Hellwig <hch@lst.de>
Mon, 5 Aug 2024 18:52:43 +0000 (11:52 -0700)
Source kernel commit: 101587dd747fd4fa4df9688892e3ad86dcebc63b

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>
libxfs/xfs_sb.c
libxfs/xfs_sb.h

index 9d922e902c301c7916fc1edb11e0856b520f7d90..f9566d71596f822f21dd39273b9e67d9a6a63d9e 100644 (file)
@@ -972,6 +972,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
  *
@@ -996,8 +1005,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);