summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2022-09-21 14:17:04 -0700
committerDarrick J. Wong <djwong@kernel.org>2022-10-14 14:17:11 -0700
commit15b2cf0b5809c3b6664e0de55ea1371ebb219ef8 (patch)
treeaacba7776a845560e06bf0becfd71cf6acd9b4ce /fs
parent2ddb5be2447ed5db8e4ffc0d0482c22dac97c4d2 (diff)
xfs: encode the rtsummary in big endian format
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>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/libxfs/xfs_format.h4
-rw-r--r--fs/xfs/libxfs/xfs_rtbitmap.c8
2 files changed, 10 insertions, 2 deletions
diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h
index 92f4bf0ce047..474bd4ea0bc2 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;
}
/*