Skip to content

Commit a2c2836

Browse files
author
Darrick J. Wong
committed
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 <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]>
1 parent eba42c2 commit a2c2836

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

fs/xfs/libxfs/xfs_format.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,10 +719,12 @@ union xfs_rtword_raw {
719719

720720
/*
721721
* Realtime summary counts are accessed by the word, which is currently
722-
* stored in host-endian format.
722+
* stored in host-endian format. Starting with the realtime groups feature,
723+
* the words are stored in be32 ondisk.
723724
*/
724725
union xfs_suminfo_raw {
725726
__u32 old;
727+
__be32 rtg;
726728
};
727729

728730
/*

fs/xfs/libxfs/xfs_rtbitmap.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,8 @@ xfs_suminfo_get(
300300
{
301301
union xfs_suminfo_raw *info = xfs_rsumblock_infoptr(args, index);
302302

303+
if (xfs_has_rtgroups(args->mp))
304+
return be32_to_cpu(info->rtg);
303305
return info->old;
304306
}
305307

@@ -312,6 +314,11 @@ xfs_suminfo_add(
312314
{
313315
union xfs_suminfo_raw *info = xfs_rsumblock_infoptr(args, index);
314316

317+
if (xfs_has_rtgroups(args->mp)) {
318+
be32_add_cpu(&info->rtg, delta);
319+
return be32_to_cpu(info->rtg);
320+
}
321+
315322
info->old += delta;
316323
return info->old;
317324
}

fs/xfs/scrub/rtsummary.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,11 @@ xchk_rtsum_inc(
151151
struct xfs_mount *mp,
152152
union xfs_suminfo_raw *v)
153153
{
154+
if (xfs_has_rtgroups(mp)) {
155+
be32_add_cpu(&v->rtg, 1);
156+
return be32_to_cpu(v->rtg);
157+
}
158+
154159
v->old += 1;
155160
return v->old;
156161
}

0 commit comments

Comments
 (0)