]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
xfs: encode the rtsummary in big endian format
authorDarrick J. Wong <djwong@kernel.org>
Mon, 5 Aug 2024 18:07:31 +0000 (11:07 -0700)
committerChristoph Hellwig <hch@lst.de>
Tue, 6 Aug 2024 12:53:49 +0000 (05:53 -0700)
Source kernel commit: 59fc91c095f19228610035ac2e8a86cfed79c855

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>
Signed-off-by: Christoph Hellwig <hch@lst.de>
libxfs/xfs_format.h
libxfs/xfs_rtbitmap.h

index b03e4ac845846b2386ff0a5b6a49105e9d02a923..46621b29d78c2e1b6da47d24ce64f65a2d20bdbe 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 23fc2c3f67b87d7963a8b1524ede610bcb977cdd..fa9fa55a3d223193f7ddba82cd92a029623100aa 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;
 }