Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix zettacache allocation cursor on startup (openzfs#17)
On startup, the allocation cursor for each of the buckets within the zettacache appears to be set incorrectly. Rather than the cursor being set to the most free slab in each bucket, we inadvertently set the cursor to the last slab that is loaded from disk, for each bucket. This means that on start up, if the last slab loaded for a bucket happens to be full and at the end of the sorted slab list, a new slab will be converted on the next allocation, rather than satisfying that allocation from a partially allocated slab already in the bucket. Further, it means that if that new slab is filled with new allocations within a single checkpoint, allocation failures will result, even if the bucket has lots of free space available. This error is easy to make, because SlabAllocationBuckets can be in a half-constructed state, where it's SortedSlabs don't have all the slabs, and their last_allocated is bogus The fix implemented here, is to no longer allow a half-constructed SlabAllocationBuckets; instead, its new() method now takes sufficient parameters to get it into a valid state, that accurately represents what's on disk, before the object is returned to the caller.
- Loading branch information