Commit eba42c2c authored by Darrick J. Wong's avatar Darrick J. Wong
Browse files

xfs: encode the rtbitmap in big endian format



Currently, the ondisk realtime bitmap file is 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.

Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
parent 118895aa
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -709,10 +709,12 @@ struct xfs_agfl {

/*
 * Realtime bitmap information is 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_rtword_raw {
	__u32		old;
	__be32		rtg;
};

/*
+6 −1
Original line number Diff line number Diff line
@@ -210,6 +210,8 @@ xfs_rtbitmap_getword(
{
	union xfs_rtword_raw	*word = xfs_rbmblock_wordptr(args, index);

	if (xfs_has_rtgroups(args->mp))
		return be32_to_cpu(word->rtg);
	return word->old;
}

@@ -222,6 +224,9 @@ xfs_rtbitmap_setword(
{
	union xfs_rtword_raw	*word = xfs_rbmblock_wordptr(args, index);

	if (xfs_has_rtgroups(args->mp))
		word->rtg = cpu_to_be32(value);
	else
		word->old = value;
}