Commit 0eff1f1a authored by Pavel Begunkov's avatar Pavel Begunkov Committed by Jens Axboe

sbitmap: simplify wrap check

__sbitmap_get_word() doesn't warp if it's starting from the beginning
(i.e. initial hint is 0). Instead of stashing the original hint just set
@wrap accordingly.
Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent c3250c8d
...@@ -97,9 +97,11 @@ EXPORT_SYMBOL_GPL(sbitmap_resize); ...@@ -97,9 +97,11 @@ EXPORT_SYMBOL_GPL(sbitmap_resize);
static int __sbitmap_get_word(unsigned long *word, unsigned long depth, static int __sbitmap_get_word(unsigned long *word, unsigned long depth,
unsigned int hint, bool wrap) unsigned int hint, bool wrap)
{ {
unsigned int orig_hint = hint;
int nr; int nr;
/* don't wrap if starting from 0 */
wrap = wrap && hint;
while (1) { while (1) {
nr = find_next_zero_bit(word, depth, hint); nr = find_next_zero_bit(word, depth, hint);
if (unlikely(nr >= depth)) { if (unlikely(nr >= depth)) {
...@@ -108,8 +110,8 @@ static int __sbitmap_get_word(unsigned long *word, unsigned long depth, ...@@ -108,8 +110,8 @@ static int __sbitmap_get_word(unsigned long *word, unsigned long depth,
* offset to 0 in a failure case, so start from 0 to * offset to 0 in a failure case, so start from 0 to
* exhaust the map. * exhaust the map.
*/ */
if (orig_hint && hint && wrap) { if (hint && wrap) {
hint = orig_hint = 0; hint = 0;
continue; continue;
} }
return -1; return -1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment