allocator: Fix find_free() returning a block past the end when full #125

Merged
vitalif merged 1 commits from koolkhel/vitastor:allocator-full-small into master 2026-11-17 23:37:01 +03:00
Contributor

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 with extra 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 in dequeue_write(), with the fix it gets -ENOSPC.

Contributor Name

Yury Luneff (MIND Software LLC, https://mindsw.io)

CLA

### 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 with `extra 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 in `dequeue_write()`, with the fix it gets -ENOSPC. ### Contributor Name Yury Luneff (MIND Software LLC, https://mindsw.io) ### CLA - [x] I accept Vitastor CLA agreement: https://git.yourcmc.ru/vitalif/vitastor/src/branch/master/CLA-en.md
koolkhel added 1 commit 2026-11-17 21:13:26 +03:00
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.
vitalif merged commit e2d7674cd5 into master 2026-11-17 23:37:01 +03:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vitalif/vitastor#125
No description provided.