]> git.dujemihanovic.xyz Git - linux.git/commit
btrfs: load block group size class when caching
authorBoris Burkov <boris@bur.io>
Fri, 16 Dec 2022 00:06:34 +0000 (16:06 -0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 13 Feb 2023 16:50:34 +0000 (17:50 +0100)
commitc7eec3d9aa955cbd00470f874f34bdba946bd101
tree059a08ab77e24b56fc5900a435f6dc12d9f67921
parent52bb7a2166af490317ce2cca1865b6630e86aca8
btrfs: load block group size class when caching

Since the size class is an artifact of an arbitrary anti fragmentation
strategy, it doesn't really make sense to persist it. Furthermore, most
of the size class logic assumes fresh block groups. That is of course
not a reasonable assumption -- we will be upgrading kernels with
existing filesystems whose block groups are not classified.

To work around those issues, implement logic to compute the size class
of the block groups as we cache them in. To perfectly assess the state
of a block group, we would have to read the entire extent tree (since
the free space cache mashes together contiguous extent items) which
would be prohibitively expensive for larger file systems with more
extents.

We can do it relatively cheaply by implementing a simple heuristic of
sampling a handful of extents and picking the smallest one we see. In
the happy case where the block group was classified, we will only see
extents of the correct size. In the unhappy case, we will hopefully find
one of the smaller extents, but there is no perfect answer anyway.
Autorelocation will eventually churn up the block group if there is
significant freeing anyway.

There was no regression in mount performance at end state of the fsperf
test suite, and the delay until the block group is marked cached is
minimized by the constant number of extent samples.

Signed-off-by: Boris Burkov <boris@bur.io>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/block-group.c