[PATCH 16/52] 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>
---
 db/check.c            |    7 ++++++-
 libxfs/xfs_format.h   |    4 +++-
 libxfs/xfs_rtbitmap.h |    7 +++++++
 repair/rt.c           |    5 ++++-
 4 files changed, 20 insertions(+), 3 deletions(-)


diff --git a/db/check.c b/db/check.c
index 190565074b6..20de9c74d4a 100644
--- a/db/check.c
+++ b/db/check.c
@@ -1709,6 +1709,8 @@ get_suminfo(
 	struct xfs_mount	*mp,
 	union xfs_suminfo_raw	*raw)
 {
+	if (xfs_has_rtgroups(mp))
+		return be32_to_cpu(raw->rtg);
 	return raw->old;
 }
 
@@ -3625,7 +3627,10 @@ inc_sumcount(
 {
 	union xfs_suminfo_raw	*p = info + index;
 
-	p->old++;
+	if (xfs_has_rtgroups(mp))
+		be32_add_cpu(&p->rtg, 1);
+	else
+		p->old++;
 }
 
 static void
diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h
index f2c70e1027e..59ba13db53e 100644
--- a/libxfs/xfs_format.h
+++ b/libxfs/xfs_format.h
@@ -759,10 +759,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;
 };
 
 /*
diff --git a/libxfs/xfs_rtbitmap.h b/libxfs/xfs_rtbitmap.h
index e8558db14b9..0bb63f77ede 100644
--- a/libxfs/xfs_rtbitmap.h
+++ b/libxfs/xfs_rtbitmap.h
@@ -298,6 +298,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;
 }
 
@@ -310,6 +312,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;
 }
diff --git a/repair/rt.c b/repair/rt.c
index c2b2c25ff79..ded968b7d82 100644
--- a/repair/rt.c
+++ b/repair/rt.c
@@ -63,7 +63,10 @@ inc_sumcount(
 {
 	union xfs_suminfo_raw	*p = info + index;
 
-	p->old++;
+	if (xfs_has_rtgroups(mp))
+		be32_add_cpu(&p->rtg, 1);
+	else
+		p->old++;
 }
 
 /*





[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