diff options
author | Darrick J. Wong <djwong@kernel.org> | 2022-09-21 14:17:04 -0700 |
---|---|---|
committer | Darrick J. Wong <djwong@kernel.org> | 2022-11-09 19:07:58 -0800 |
commit | 2a012e558a6c94bbab7655bdeb6eb7239b846111 (patch) | |
tree | 3a005cf67f3f8931ca64fbcc0a5343811c1513dc | |
parent | 02b2e1c3c564577199b7888c4208471da66eebff (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>
-rw-r--r-- | fs/xfs/libxfs/xfs_format.h | 4 | ||||
-rw-r--r-- | 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 97707f5fe200..a1b903d8f6ff 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; } /* |