Changeset View
Changeset View
Standalone View
Standalone View
subr_blist.c
Show First 20 Lines • Show All 633 Lines • ▼ Show 20 Lines | for (blk = start; blk - start < maxcount; blk += BLIST_BMAP_RADIX) { | ||||
if (~scan->bm_bitmap != 0) { | if (~scan->bm_bitmap != 0) { | ||||
/* | /* | ||||
* Either there is no next leaf with any free blocks, | * Either there is no next leaf with any free blocks, | ||||
* or we've reached the next leaf and found that some | * or we've reached the next leaf and found that some | ||||
* of its blocks are not free. In the first case, | * of its blocks are not free. In the first case, | ||||
* bitpos() returns zero here. | * bitpos() returns zero here. | ||||
*/ | */ | ||||
avail = blk - start + bitpos(~scan->bm_bitmap); | avail = blk - start + bitpos(~scan->bm_bitmap); | ||||
if (avail < count) { | if (avail < count || avail == 0) { | ||||
alc: Can you please explain why the avail == 0 test is needed, given the avail < count test? (I… | |||||
dougmAuthorUnsubmitted Done Inline ActionsIf *count == 5 and maxcount ==10 in blst_leaf_alloc, and the first free group of 5 or more free blocks is 6 blocks at the end of leaf 0, then blst_next_leaf_alloc will be called with count==-1 and maxcount == 4 because, while we would like to have 4 more for this allocation, we don't need them in order to complete the allocation successfully. If leaf 1 starts with an allocated block, we should return 0 from blst_next_leaf_alloc and NOT set about marking any blocks of leaf 1 as freed. dougm: If *count == 5 and maxcount ==10 in blst_leaf_alloc, and the first free group of 5 or more free… | |||||
/* | /* | ||||
* There isn't a next leaf with enough free | * There isn't a next leaf with enough free | ||||
* blocks at its beginning to complete the | * blocks at its beginning to bother | ||||
* spanning allocation. | * allocating. | ||||
*/ | */ | ||||
return (avail); | return (avail); | ||||
} | } | ||||
maxcount = imin(avail, maxcount); | maxcount = imin(avail, maxcount); | ||||
if (maxcount % BLIST_BMAP_RADIX == 0) { | |||||
/* | |||||
* There was no next leaf. Back scan up to | |||||
* last leaf. | |||||
*/ | |||||
--scan; | |||||
while (radix != BLIST_BMAP_RADIX) { | |||||
radix /= BLIST_META_RADIX; | |||||
--scan; | |||||
} | |||||
blk -= BLIST_BMAP_RADIX; | |||||
} | |||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* 'scan' is the last leaf that provides blocks. Clear from 1 to | * 'scan' is the last leaf that provides blocks. Clear from 1 to | ||||
* BLIST_BMAP_RADIX bits to represent the allocation of those last | * BLIST_BMAP_RADIX bits to represent the allocation of those last | ||||
* blocks. | * blocks. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 559 Lines • Show Last 20 Lines |
Can you please explain why the avail == 0 test is needed, given the avail < count test? (I didn't think that count would be negative.)