From: Jens Axboe Date: Wed, 11 Jul 2018 21:16:58 +0000 (-0600) Subject: axmap: fix continued sequential bit setting X-Git-Tag: fio-3.8~5 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=bd71edcedc3dcbce4fe32357523434d8f249b02d axmap: fix continued sequential bit setting We need to remember to clear ->set_bits if we don't set new bits, or the caller will think we re-set the previously set bits. Signed-off-by: Jens Axboe --- diff --git a/lib/axmap.c b/lib/axmap.c index e4e40bf0..4047f236 100644 --- a/lib/axmap.c +++ b/lib/axmap.c @@ -227,15 +227,18 @@ static bool axmap_set_fn(struct axmap_level *al, unsigned long offset, * Mask off any potential overlap, only sets contig regions */ overlap = al->map[offset] & mask; - if (overlap == mask) + if (overlap == mask) { +done: + data->set_bits = 0; return true; + } if (overlap) { const int __bit = ffz(~overlap); nr_bits = __bit - bit; if (!nr_bits) - return true; + goto done; mask = bit_masks[nr_bits] << bit; } @@ -300,7 +303,7 @@ unsigned int axmap_set_nr(struct axmap *axmap, uint64_t bit_nr, unsigned int max_bits, this_set; max_bits = BLOCKS_PER_UNIT - (bit_nr & BLOCKS_PER_UNIT_MASK); - if (max_bits < nr_bits) + if (nr_bits > max_bits) data.nr_bits = max_bits; this_set = data.nr_bits;