Skip to content

Commit eba42c2

Browse files
author
Darrick J. Wong
committed
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: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de>
1 parent 118895a commit eba42c2

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

fs/xfs/libxfs/xfs_format.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,10 +709,12 @@ struct xfs_agfl {
709709

710710
/*
711711
* Realtime bitmap information is accessed by the word, which is currently
712-
* stored in host-endian format.
712+
* stored in host-endian format. Starting with the realtime groups feature,
713+
* the words are stored in be32 ondisk.
713714
*/
714715
union xfs_rtword_raw {
715716
__u32 old;
717+
__be32 rtg;
716718
};
717719

718720
/*

fs/xfs/libxfs/xfs_rtbitmap.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ xfs_rtbitmap_getword(
210210
{
211211
union xfs_rtword_raw *word = xfs_rbmblock_wordptr(args, index);
212212

213+
if (xfs_has_rtgroups(args->mp))
214+
return be32_to_cpu(word->rtg);
213215
return word->old;
214216
}
215217

@@ -222,7 +224,10 @@ xfs_rtbitmap_setword(
222224
{
223225
union xfs_rtword_raw *word = xfs_rbmblock_wordptr(args, index);
224226

225-
word->old = value;
227+
if (xfs_has_rtgroups(args->mp))
228+
word->rtg = cpu_to_be32(value);
229+
else
230+
word->old = value;
226231
}
227232

228233
/*

0 commit comments

Comments
 (0)