allocator: Fix find_free() returning a block past the end when full #125
Reference in New Issue
Block a user
No description provided.
Delete Branch "koolkhel/vitastor:allocator-full-small"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
An allocator of 2-63 blocks has a single-level mask with no parent bit to mark it full, and the mask bits past the end are always zero. So find_free() on a full allocator returned the first index past the end instead of UINT64_MAX. Store v1 then submitted a big write past the end of its data area (the bounds assert in dequeue_write() fires) instead of failing it with ENOSPC. Store v2 and vitastor-disk raw-resize use the same call.
Check the leaf index against the allocator size, and cover sizes 2, 63 and 64 in test_allocator.
Tested:
test_allocator(the new cases fail on master withextra free space found: 3f (63)),test_blockstore_v1,test_blockstore_chaos --seeds 1-240. A Store v1 store with a 32-block data area: on master the 33rd big write trips the bounds assert indequeue_write(), with the fix it gets -ENOSPC.Contributor Name
Yury Luneff (MIND Software LLC, https://mindsw.io)
CLA