Re: [PATCH v5] xfs: validate log record version against superblock log version
From: Christoph Hellwig
Date: Tue Nov 25 2025 - 01:31:37 EST
> Hrmm maybe we ought to reserve XLOG_VERSION==0x3 so that whenever we do
> log v3 we don't accidentally write logs with bits that won't be
> validated quite right on old kernels?
Why do we need to reserve that? The code checks for either 1 or 2
right now based on the log feature flag. If we add a v3 log we'll
have to ammend this, but reservations won't help with that.
> > + if (xfs_has_logv2(mp)) {
> > + if (XFS_IS_CORRUPT(mp, h_version != XLOG_VERSION_2))
>
> Being pedantic here, but the kernel cpu_to_be32 wrappers are magic in
> that they compile to byteswapped constants so you can avoid the runtime
> overhead of byteswapping rhead->h_version by doing:
>
> if (XFS_IS_CORRUPT(mp,
> rhead->h_version != cpu_to_be32(XLOG_VERSION_2)))
> return -EFSCORRUPTED;
>
> But seeing as this is log validation for recovery, I think the
> performance implications are vanishingly small.
Yes.