[PATCH 17/22] xfs: encode the rtsummary in big endian format

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Darrick J. Wong <djwong@xxxxxxxxxx>

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@xxxxxxxxxx>
---
 fs/xfs/libxfs/xfs_format.h   |    4 +++-
 fs/xfs/libxfs/xfs_rtbitmap.c |    8 +++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)


diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h
index 47b2e31e2560..7e76bedda688 100644
--- a/fs/xfs/libxfs/xfs_format.h
+++ b/fs/xfs/libxfs/xfs_format.h
@@ -748,10 +748,12 @@ union xfs_rtword_ondisk {
 
 /*
  * 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_ondisk {
 	__u32		raw;
+	__be32		rtg;
 };
 
 /*
diff --git a/fs/xfs/libxfs/xfs_rtbitmap.c b/fs/xfs/libxfs/xfs_rtbitmap.c
index 3d5b14cc0f3a..ccefbfc70f8b 100644
--- a/fs/xfs/libxfs/xfs_rtbitmap.c
+++ b/fs/xfs/libxfs/xfs_rtbitmap.c
@@ -562,6 +562,9 @@ xfs_suminfo_get(
 	struct xfs_mount	*mp,
 	union xfs_suminfo_ondisk *infoptr)
 {
+	if (xfs_has_rtgroups(mp))
+		return be32_to_cpu(infoptr->rtg);
+
 	return infoptr->raw;
 }
 
@@ -571,7 +574,10 @@ xfs_suminfo_add(
 	union xfs_suminfo_ondisk *infoptr,
 	int			delta)
 {
-	infoptr->raw += delta;
+	if (xfs_has_rtgroups(mp))
+		be32_add_cpu(&infoptr->rtg, delta);
+	else
+		infoptr->raw += delta;
 }
 
 /*




[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux