summaryrefslogtreecommitdiffstats
tag namescrub-detect-mergeable-records_2023-04-11 (050b1f1597530afe002fa19901e20b2a36377083)
tag date2023-04-11 11:20:28 -0700
tagged byDarrick J. Wong <djwong@kernel.org>
tagged objectcommit 5d9fd224ad...
downloadxfs-linux-scrub-detect-mergeable-records_2023-04-11.tar.gz
xfs: detect mergeable and overlapping btree records [v24.0]
While I was doing differential fuzz analysis between xfs_scrub and xfs_repair, I noticed that xfs_repair was only partially effective at detecting btree records that can be merged, and xfs_scrub totally didn't notice at all. For every interval btree type except for the bmbt, there should never exist two adjacent records with adjacent keyspaces because the blockcount field is always large enough to span the entire keyspace of the domain. This is because the free space, rmap, and refcount btrees have a blockcount field large enough to store the maximum AG length, and there can never be an allocation larger than an AG. The bmbt is a different story due to its ondisk encoding where the blockcount is only 21 bits wide. Because AGs can span up to 2^31 blocks and the RT volume can span up to 2^52 blocks, a preallocation of 2^22 blocks will be expressed as two records of 2^21 length. We don't opportunistically combine records when doing bmbt operations, which is why the fsck tools have never complained about this scenario. Offline repair is partially effective at detecting mergeable records because I taught it to do that for the rmap and refcount btrees. This series enhances the free space, rmap, and refcount scrubbers to detect mergeable records. For the bmbt, it will flag the file as being eligible for an optimization to shrink the size of the data structure. The last patch in this set also enhances the rmap scrubber to detect records that overlap incorrectly. This check is done automatically for non-overlapping btree types, but we have to do it separately for the rmapbt because there are constraints on which allocation types are allowed to overlap. Signed-off-by: Darrick J. Wong <djwong@kernel.org> -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQQ2qTKExjcn+O1o2YRKO3ySh0YRpgUCZDWk7AAKCRBKO3ySh0YR pjfmAQDwLOfaOm0RbpPTra8XenJgJdXvYVMqrBOsyHGGGF0vPQD8Chp88QS2AEAp 0C9xkE9VUwKbiiv9jDQirvmElSOBSQg= =nLwv -----END PGP SIGNATURE-----