]> www.infradead.org Git - users/hch/misc.git/commitdiff
xfs: encode the rtsummary in big endian format
authorDarrick J. Wong <djwong@kernel.org>
Wed, 29 May 2024 04:11:21 +0000 (21:11 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Wed, 24 Jul 2024 05:33:38 +0000 (22:33 -0700)
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>
fs/xfs/libxfs/xfs_format.h
fs/xfs/libxfs/xfs_rtbitmap.h
fs/xfs/scrub/rtsummary.c

index e7fb96277c245e02112702c004a20c829f8ec711..385e191569d3447ed9efbb10559e37a17c2dad40 100644 (file)
@@ -734,10 +734,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 aa3206c22ad6f4ffe4f1c6295db798998647157e..f5bb1ef7df7cce8885de5709b857bc3f05f8ec97 100644 (file)
@@ -280,6 +280,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;
 }
 
@@ -292,6 +294,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 f8ec63462e0b77aa27b9d46127f0ed500da4d542..c7f5659ab32ccf82924698f18831da33c31af1f8 100644 (file)
@@ -143,6 +143,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;
 }