If the map is completely full, we could return an invalid value
for the first free bit. So check if we actually found a match,
return failure if we didn't.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
uint64_t index)
{
unsigned long j;
uint64_t index)
{
unsigned long j;
/*
* Start at the bottom, then converge towards first free bit at the top
/*
* Start at the bottom, then converge towards first free bit at the top
* free bit at the next higher level
*/
index = (j << UNIT_SHIFT) + ffz(al->map[j]);
* free bit at the next higher level
*/
index = (j << UNIT_SHIFT) + ffz(al->map[j]);
+ return found ? index : (uint64_t) -1ULL;
}
uint64_t axmap_first_free(struct axmap *axmap)
}
uint64_t axmap_first_free(struct axmap *axmap)