]> www.infradead.org Git - users/hch/misc.git/commitdiff
xfs: encode the rtbitmap in big endian format
authorDarrick J. Wong <djwong@kernel.org>
Wed, 29 May 2024 04:11:19 +0000 (21:11 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Wed, 24 Jul 2024 05:33:37 +0000 (22:33 -0700)
Currently, the ondisk realtime bitmap file is accessed in units of
32-bit words.  There's no endian translation of the contents of this
file, which means that the Bad Things Happen(tm) if you go from (say)
x86 to powerpc.  Since we have a new feature flag, let's take the
opportunity to enforce an endianness on the file.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
fs/xfs/libxfs/xfs_format.h
fs/xfs/libxfs/xfs_rtbitmap.h

index 5e916fe8182cb7b64efd5b9028c43a7187e1b562..fcc3a524fc51ed41b9a6efd0cb31fb6574e76974 100644 (file)
@@ -724,10 +724,12 @@ struct xfs_agfl {
 
 /*
  * Realtime bitmap information is accessed by the word, which is currently
- * stored in host-endian format.
+ * stored in host-endian format.  Starting with the realtime groups feature,
+ * the words are stored in be32 ondisk.
  */
 union xfs_rtword_raw {
        __u32           old;
+       __be32          rtg;
 };
 
 /*
index 2cd0c156493d8d025926d089832fff3efc3403f5..c1942321fd149a8b0bbaae8b93da782696fe0a51 100644 (file)
@@ -190,6 +190,8 @@ xfs_rtbitmap_getword(
 {
        union xfs_rtword_raw    *word = xfs_rbmblock_wordptr(args, index);
 
+       if (xfs_has_rtgroups(args->mp))
+               return be32_to_cpu(word->rtg);
        return word->old;
 }
 
@@ -202,7 +204,10 @@ xfs_rtbitmap_setword(
 {
        union xfs_rtword_raw    *word = xfs_rbmblock_wordptr(args, index);
 
-       word->old = value;
+       if (xfs_has_rtgroups(args->mp))
+               word->rtg = cpu_to_be32(value);
+       else
+               word->old = value;
 }
 
 /*