tag name | scrub-detect-mergeable-records_2022-10-14 (ec725500c288292903c0d97f689567d605d927f0) |
tag date | 2022-10-14 14:18:29 -0700 |
tagged by | Darrick J. Wong <djwong@kernel.org> |
tagged object | commit d625c0c5ad... |
xfs: detect mergeable and overlapping btree records
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-----
iQIzBAABCgAdFiEEUzaAxoMeQq6m2jMV+H93GTRKtOsFAmNJ0iUACgkQ+H93GTRK
tOtWMA//aLZUyQ6/h0DWHnFbYH7wlh8kj+11jb9hE1h7HncNJReBgKq2lBqNHpUY
v8v94WujZvTHBbDlRaH+mdPEKIm+Ruxb3ZW3UiUOy95ZBC2nKvFtwNzRjEAgxj1b
B2XQwPeVYN/ufXSy23eNPA1nXdnFGEWL91FyNtUP2dTJ2st4IauUjhqdy3aCqM0v
/QFbRucZXKsons3+puFWTU8YLVj7tmzLduM3Pfrrj2gPvS+iiRoUb9TAf/ODaXLb
OSaZNKxYM4zkSa0OJsLhIStgyoWrP43ExnhUGs1EavbL7sX28XE85HK1XEbluZI3
cyNoLdxGYTeDWOqxai60EJKc+HqEw+N7R9B+vD70eYBlnAW0zb4Y4EXMq4SsGW+i
Z4ffwKS29D9zmHzn+EANE/wJLFotoDZSbq4m/oVDgzP5gFQYvC+64dCTGHTPSyAZ
rNxIbhUkM4A7TrjRZAFGIRdwGGRUTEGCuol7A+yNWGHDwBx/koNh92YTa5WPJQHM
VpUXSfYUKGtS9IghWTyp74ahFg33MwIPtKeiBe+jIQ7dV3G4UD7d89XVyywgNgEa
6JuM33FokuhHKin8MDzMBXrWoGc5w6YSYHXrLQsiUqaIZZrEM4ZZ67qVfTg8MxVl
Z4H2Yn4oNaw5wiXyG2UVKwtircVK+QzoWoqPOJ2BYD64P69nRAA=
=8Iy9
-----END PGP SIGNATURE-----