]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
xfs: remove conditional building of rt geometry validator functions
authorDarrick J. Wong <djwong@kernel.org>
Wed, 27 Mar 2024 00:12:33 +0000 (17:12 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Apr 2024 13:28:49 +0000 (15:28 +0200)
commit 881f78f472556ed05588172d5b5676b48dc48240 upstream.

[backport: resolve merge conflicts due to refactoring rtbitmap/summary
macros and accessors]

I mistakenly turned off CONFIG_XFS_RT in the Kconfig file for arm64
variant of the djwong-wtf git branch.  Unfortunately, it took me a good
hour to figure out that RT wasn't built because this is what got printed
to dmesg:

XFS (sda2): realtime geometry sanity check failed
XFS (sda2): Metadata corruption detected at xfs_sb_read_verify+0x170/0x190 [xfs], xfs_sb block 0x0

Whereas I would have expected:

XFS (sda2): Not built with CONFIG_XFS_RT
XFS (sda2): RT mount failed

The root cause of these problems is the conditional compilation of the
new functions xfs_validate_rtextents and xfs_compute_rextslog that I
introduced in the two commits listed below.  The !RT versions of these
functions return false and 0, respectively, which causes primary
superblock validation to fail, which explains the first message.

Move the two functions to other parts of libxfs that are not
conditionally defined by CONFIG_XFS_RT and remove the broken stubs so
that validation works again.

Fixes: e14293803f4e ("xfs: don't allow overly small or large realtime volumes")
Fixes: a6a38f309afc ("xfs: make rextslog computation consistent with mkfs")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>
Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
Acked-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/xfs/libxfs/xfs_rtbitmap.c
fs/xfs/libxfs/xfs_rtbitmap.h
fs/xfs/libxfs/xfs_sb.c
fs/xfs/libxfs/xfs_sb.h
fs/xfs/libxfs/xfs_types.h
fs/xfs/scrub/rtbitmap.c
fs/xfs/scrub/rtsummary.c

index 8db1243beacc8f4f0b2ce765c62aa82cbbe356a8..760172a65aff31b1d74a8d01a0b965796163113e 100644 (file)
@@ -1131,17 +1131,3 @@ xfs_rtalloc_extent_is_free(
        return 0;
 }
 
-/*
- * Compute the maximum level number of the realtime summary file, as defined by
- * mkfs.  The historic use of highbit32 on a 64-bit quantity prohibited correct
- * use of rt volumes with more than 2^32 extents.
- */
-uint8_t
-xfs_compute_rextslog(
-       xfs_rtbxlen_t           rtextents)
-{
-       if (!rtextents)
-               return 0;
-       return xfs_highbit64(rtextents);
-}
-
index 4e49aadf0955d77e8ade466eb47e81fad2b18ef8..b89712983347756317bb42287a85993ba7eb12de 100644 (file)
@@ -71,20 +71,6 @@ xfs_rtfree_extent(
 int xfs_rtfree_blocks(struct xfs_trans *tp, xfs_fsblock_t rtbno,
                xfs_filblks_t rtlen);
 
-uint8_t xfs_compute_rextslog(xfs_rtbxlen_t rtextents);
-
-/* Do we support an rt volume having this number of rtextents? */
-static inline bool
-xfs_validate_rtextents(
-       xfs_rtbxlen_t           rtextents)
-{
-       /* No runt rt volumes */
-       if (rtextents == 0)
-               return false;
-
-       return true;
-}
-
 #else /* CONFIG_XFS_RT */
 # define xfs_rtfree_extent(t,b,l)                      (-ENOSYS)
 # define xfs_rtfree_blocks(t,rb,rl)                    (-ENOSYS)
@@ -92,8 +78,6 @@ xfs_validate_rtextents(
 # define xfs_rtalloc_query_all(m,t,f,p)                        (-ENOSYS)
 # define xfs_rtbuf_get(m,t,b,i,p)                      (-ENOSYS)
 # define xfs_rtalloc_extent_is_free(m,t,s,l,i)         (-ENOSYS)
-# define xfs_compute_rextslog(rtx)                     (0)
-# define xfs_validate_rtextents(rtx)                   (false)
 #endif /* CONFIG_XFS_RT */
 
 #endif /* __XFS_RTBITMAP_H__ */
index acba0694abf43907d1fe4d8cbc573027ca1119d6..571bb2a770ac3546dffc06d1315dfad1446cfae3 100644 (file)
@@ -1375,3 +1375,17 @@ xfs_validate_stripe_geometry(
        }
        return true;
 }
+
+/*
+ * Compute the maximum level number of the realtime summary file, as defined by
+ * mkfs.  The historic use of highbit32 on a 64-bit quantity prohibited correct
+ * use of rt volumes with more than 2^32 extents.
+ */
+uint8_t
+xfs_compute_rextslog(
+       xfs_rtbxlen_t           rtextents)
+{
+       if (!rtextents)
+               return 0;
+       return xfs_highbit64(rtextents);
+}
index 19134b23c10be3824de6a7949d6ccf9ebdfa8de0..2e8e8d63d4eb2249d148b8f6d50f2a71726911f5 100644 (file)
@@ -38,4 +38,6 @@ extern int    xfs_sb_get_secondary(struct xfs_mount *mp,
 extern bool    xfs_validate_stripe_geometry(struct xfs_mount *mp,
                __s64 sunit, __s64 swidth, int sectorsize, bool silent);
 
+uint8_t xfs_compute_rextslog(xfs_rtbxlen_t rtextents);
+
 #endif /* __XFS_SB_H__ */
index 6b1a2e9233603370ee254ec8db386869a6e05115..311c5ee677482572bdfc782610c602b7b18c76ad 100644 (file)
@@ -240,4 +240,16 @@ bool xfs_verify_fileoff(struct xfs_mount *mp, xfs_fileoff_t off);
 bool xfs_verify_fileext(struct xfs_mount *mp, xfs_fileoff_t off,
                xfs_fileoff_t len);
 
+/* Do we support an rt volume having this number of rtextents? */
+static inline bool
+xfs_validate_rtextents(
+       xfs_rtbxlen_t           rtextents)
+{
+       /* No runt rt volumes */
+       if (rtextents == 0)
+               return false;
+
+       return true;
+}
+
 #endif /* __XFS_TYPES_H__ */
index 2e5fd52f7af3ab1f93c5f3926612b6aad17b87f4..0f574a1d2cb1ad585ab6a1d2c976649d60f994b4 100644 (file)
@@ -14,6 +14,7 @@
 #include "xfs_rtbitmap.h"
 #include "xfs_inode.h"
 #include "xfs_bmap.h"
+#include "xfs_sb.h"
 #include "scrub/scrub.h"
 #include "scrub/common.h"
 
index f4635a920470e1f944ea2c303852a462ef3ebbeb..7676718dac728785af084654cf526a318b0377a3 100644 (file)
@@ -16,6 +16,7 @@
 #include "xfs_rtbitmap.h"
 #include "xfs_bit.h"
 #include "xfs_bmap.h"
+#include "xfs_sb.h"
 #include "scrub/scrub.h"
 #include "scrub/common.h"
 #include "scrub/trace.h"