From: Jens Axboe Date: Tue, 10 Jul 2018 22:52:16 +0000 (-0600) Subject: axmap: ensure that overlaps are handled strictly sequential X-Git-Tag: fio-3.8~17 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=8cd5a2fdad69fcc7acc85863b69cc9ded97edceb axmap: ensure that overlaps are handled strictly sequential We must terminate at the first overlapping bit, we can't just mask off non-sequential ranges. Signed-off-by: Jens Axboe --- diff --git a/lib/axmap.c b/lib/axmap.c index 3c65308c..c29597f8 100644 --- a/lib/axmap.c +++ b/lib/axmap.c @@ -234,17 +234,18 @@ static bool axmap_set_fn(struct axmap_level *al, unsigned long offset, if (overlap == mask) return true; - while (overlap) { - unsigned long clear_mask = ~(1UL << ffz(~overlap)); + if (overlap) { + const int __bit = ffz(~overlap); - mask &= clear_mask; - overlap &= clear_mask; - nr_bits--; + if (__bit == bit) + return true; + + nr_bits = __bit - bit; + mask = bit_masks[nr_bits] << bit; } assert(mask); assert(!(al->map[offset] & mask)); - al->map[offset] |= mask; if (!al->level)