Fix BITMAP_USE_TREE version of bitmap_ffu().

This fixes an extent searching regression on 32-bit systems, caused by
the initial bitmap_ffu() implementation in
c8021d01f6 (Implement bitmap_ffu(), which
finds the first unset bit.), as first used in
5d33233a5e (Use a bitmap in extents_t to
speed up search.).
This commit is contained in:
Jason Evans
2017-03-24 22:46:56 -07:00
parent e6b074472e
commit 5e12223925
2 changed files with 48 additions and 5 deletions

View File

@@ -112,6 +112,19 @@ bitmap_ffu(const bitmap_t *bitmap, const bitmap_info_t *binfo, size_t min_bit) {
group &= group_mask;
}
if (group == 0LU) {
/*
* If min_bit is not the first bit in its group, try
* again starting at the first bit of the next group.
* This will only recurse at most once, since on
* recursion, min_bit will be the first bit in its
* group.
*/
size_t ceil_min_bit = (min_bit +
BITMAP_GROUP_NBITS_MASK) & ~BITMAP_GROUP_NBITS_MASK;
if (ceil_min_bit != min_bit && ceil_min_bit <
binfo->nbits) {
return bitmap_ffu(bitmap, binfo, ceil_min_bit);
}
return binfo->nbits;
}
bit = (bit << LG_BITMAP_GROUP_NBITS) + (ffs_lu(group) - 1);