dm-crypt: fix warning in shutdown path
authorKent Overstreet <[email protected]>
Sat, 2 Jun 2018 17:45:04 +0000 (13:45 -0400)
committerJens Axboe <[email protected]>
Sun, 3 Jun 2018 02:35:00 +0000 (20:35 -0600)
The counter for the number of allocated pages includes pages in the
mempool's reserve, so checking that the number of allocated pages is 0
needs to happen after we exit the mempool.

Fixes: 6f1c819c219f ("dm: convert to bioset_init()/mempool_init()")
Signed-off-by: Kent Overstreet <[email protected]>
Reported-by: Krzysztof Kozlowski <[email protected]>
Acked-by: Mike Snitzer <[email protected]>
Fixed to always just use percpu_counter_sum()

Signed-off-by: Jens Axboe <[email protected]>
drivers/md/dm-crypt.c

index eaf6b279accbaf3f187d9d281ceba250e1275e11..da02f4d8e4b95b4eefa7c7146ce28e65653e974e 100644 (file)
@@ -2221,14 +2221,13 @@ static void crypt_dtr(struct dm_target *ti)
 
        bioset_exit(&cc->bs);
 
-       if (mempool_initialized(&cc->page_pool))
-               WARN_ON(percpu_counter_sum(&cc->n_allocated_pages) != 0);
-       percpu_counter_destroy(&cc->n_allocated_pages);
-
        mempool_exit(&cc->page_pool);
        mempool_exit(&cc->req_pool);
        mempool_exit(&cc->tag_pool);
 
+       WARN_ON(percpu_counter_sum(&cc->n_allocated_pages) != 0);
+       percpu_counter_destroy(&cc->n_allocated_pages);
+
        if (cc->iv_gen_ops && cc->iv_gen_ops->dtr)
                cc->iv_gen_ops->dtr(cc);