axmap: clear map->first_free when we reset it
authorJens Axboe <axboe@kernel.dk>
Mon, 21 Jan 2013 16:43:30 +0000 (09:43 -0700)
committerJens Axboe <axboe@kernel.dk>
Mon, 21 Jan 2013 16:43:30 +0000 (09:43 -0700)
Otherwise it could be left at an invalid value. When we clear the map,
we know the first free bit is 0.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
lib/axmap.c

index a44e0ecb35c347ecc74882a0e45f7d94d28d34a4..d9ad30bf5b9d679070b6e1767b4b978dba7c3940 100644 (file)
@@ -67,6 +67,8 @@ void axmap_reset(struct axmap *axmap)
 
                memset(al->map, 0, al->map_size * sizeof(unsigned long));
        }
+
+       axmap->first_free = 0;
 }
 
 void axmap_free(struct axmap *axmap)
@@ -101,7 +103,6 @@ struct axmap *axmap_new(unsigned long nr_bits)
 
        axmap->nr_levels = levels;
        axmap->levels = smalloc(axmap->nr_levels * sizeof(struct axmap_level));
-       axmap->first_free = 0;
 
        for (i = 0; i < axmap->nr_levels; i++) {
                struct axmap_level *al = &axmap->levels[i];