On Tue, Nov 28, 2023 at 10:34:09PM -0800, Christoph Hellwig wrote: > On Wed, Nov 29, 2023 at 10:15:52AM +1100, Dave Chinner wrote: > > > + /* > > > + * Update the moved block's blkno if it's a dir3 leaf block > > > + */ > > > + if (dead_info->magic == cpu_to_be16(XFS_DIR3_LEAF1_MAGIC) || > > > + dead_info->magic == cpu_to_be16(XFS_DIR3_LEAFN_MAGIC) || > > > + dead_info->magic == cpu_to_be16(XFS_ATTR3_LEAF_MAGIC)) { > > > > a.k.a. > > > > if (xfs_has_crc(mp)) { > > > > i.e. this is not specific to the buffer type being processed, it's > > specific to v4 vs v5 on-disk format. Hence it's a fs-feature check, > > not a block magic number check. > > We have these magic based checks in quite a few places right now, > so I'm not surprised that Jiachen picked it up from there.. Yes, but that doesn't mean the magic number check has been used correctly here. That is, we use the magic number check when the code has a conditional on the type of buffer being processed (i.e. what block type are we operating on? e.g. DANODE vs LEAFN as is checked a few lines further down in this code). When the conditional is "what on-disk format are we operating on?" such as when we are decoding headers or running verifiers, we use xfs_has_crc() because we can't trust magic numbers to be correct prior to validation. Hence we use xfs_has_crc() to determine how to decode/encode/verify the structure header, not the magic number in the block. Cheers, Dave. -- Dave Chinner david@xxxxxxxxxxxxx