]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xfs: encode the rtsummary in big endian format
authorDarrick J. Wong <djwong@kernel.org>
Mon, 4 Nov 2024 04:19:24 +0000 (20:19 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 5 Nov 2024 21:38:41 +0000 (13:38 -0800)
Currently, the ondisk realtime summary file counters are 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.  Encode the summary
information in big endian format, like most of the rest of the
filesystem.

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

index cd9457ed5873fe1ddc3ab9866befd4e66caf961b..f56ff9f43c218f1ef94f8d1e8e640ca8ab5b7a10 100644 (file)
@@ -719,10 +719,12 @@ union xfs_rtword_raw {
 
 /*
  * Realtime summary counts are 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_suminfo_raw {
        __u32           old;
+       __be32          rtg;
 };
 
 /*
index f9c0d241590104b3c141cb5a3b1e9d5867ed1232..7be76490a318798b835cb79d66c345c1bfcb6ae6 100644 (file)
@@ -300,6 +300,8 @@ xfs_suminfo_get(
 {
        union xfs_suminfo_raw   *info = xfs_rsumblock_infoptr(args, index);
 
+       if (xfs_has_rtgroups(args->mp))
+               return be32_to_cpu(info->rtg);
        return info->old;
 }
 
@@ -312,6 +314,11 @@ xfs_suminfo_add(
 {
        union xfs_suminfo_raw   *info = xfs_rsumblock_infoptr(args, index);
 
+       if (xfs_has_rtgroups(args->mp)) {
+               be32_add_cpu(&info->rtg, delta);
+               return be32_to_cpu(info->rtg);
+       }
+
        info->old += delta;
        return info->old;
 }
index 8f3f69b26cad0463533cf86ac5556f339f81174b..49fc6250bafcaaaaff1930fd106d70d48d5ee2fb 100644 (file)
@@ -151,6 +151,11 @@ xchk_rtsum_inc(
        struct xfs_mount        *mp,
        union xfs_suminfo_raw   *v)
 {
+       if (xfs_has_rtgroups(mp)) {
+               be32_add_cpu(&v->rtg, 1);
+               return be32_to_cpu(v->rtg);
+       }
+
        v->old += 1;
        return v->old;
 }