@@ -192,10 +192,18 @@ static int sbitmap_find_bit(struct sbitmap *sb,
unsigned int alloc_hint,
bool wrap)
{
+ unsigned int map_nr = sb->map_nr;
unsigned int i;
int nr = -1;
- for (i = 0; i < sb->map_nr; i++) {
+ /*
+ * If we have alloc_hint > 0 and don't wrap, we need to
+ * recheck sb->map[index] with hint == 0 to exhaust the map.
+ */
+ if (alloc_hint && !wrap)
+ map_nr += 1;
+
+ for (i = 0; i < map_nr; i++) {
nr = sbitmap_find_bit_in_word(&sb->map[index],
min_t(unsigned int,
__map_depth(sb, index),