From: Darrick J. Wong Date: Mon, 25 Nov 2024 21:14:23 +0000 (-0800) Subject: xfs: encode the rtsummary in big endian format X-Git-Tag: v6.13.0~110 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=af4bcc58f7ea4f0c3c428888ae684fc01868bd11;p=thirdparty%2Fxfsprogs-dev.git xfs: encode the rtsummary in big endian format Source kernel commit: a2c28367396a85f2d9cfb22acfcedcff08dd1c3c 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 Reviewed-by: Christoph Hellwig --- diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h index cd9457ed..f56ff9f4 100644 --- a/libxfs/xfs_format.h +++ b/libxfs/xfs_format.h @@ -719,10 +719,12 @@ union xfs_rtword_raw { /* * 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_raw { __u32 old; + __be32 rtg; }; /* diff --git a/libxfs/xfs_rtbitmap.h b/libxfs/xfs_rtbitmap.h index f9c0d241..7be76490 100644 --- a/libxfs/xfs_rtbitmap.h +++ b/libxfs/xfs_rtbitmap.h @@ -300,6 +300,8 @@ xfs_suminfo_get( { union xfs_suminfo_raw *info = xfs_rsumblock_infoptr(args, index); + if (xfs_has_rtgroups(args->mp)) + return be32_to_cpu(info->rtg); return info->old; } @@ -312,6 +314,11 @@ xfs_suminfo_add( { union xfs_suminfo_raw *info = xfs_rsumblock_infoptr(args, index); + if (xfs_has_rtgroups(args->mp)) { + be32_add_cpu(&info->rtg, delta); + return be32_to_cpu(info->rtg); + } + info->old += delta; return info->old; }