Skip to contentSkip to conversation

dm-crypt: fix warning in shutdown path

PATCH In review Kent Overstreet 4 participants 5 messages Jun 2, 2018 – Jun 4, 2018 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dm-crypt: fix warning in shutdown path

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.

---
 drivers/md/dm-crypt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/md/dm-crypt.c +4 -4
index eaf6b279ac..9a000aa955 100644
@@ -2221,14 +2221,14 @@ 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);
 
+	if (cc->n_allocated_pages.counters)
+		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);
 
Signature · 1 line
2.17.1
#1 lore raw
Quoted 3 lines · Kent Overstreet

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.

Looks good, but needs a fixes line. I'll add one.

Signature · 1 line
Jens Axboe
Acked-by
#2 lore raw
Quoted 6 lines · Jens Axboe
Quoted 3 lines · Kent Overstreet

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.

Looks good, but needs a fixes line. I'll add one.

Also needs the subject and header updated to reflect that it fixes the crash (Krzysztof please verify):

#3 lore raw
Quoted 8 lines · Mike Snitzer
Quoted 5 lines · Jens Axboe
Quoted 3 lines · Kent Overstreet

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.

Quoted 7 lines
Quoted 1 line

Looks good, but needs a fixes line. I'll add one.

Also needs the subject and header updated to reflect that it fixes the crash (Krzysztof please verify):

Indeed, I have added that. Thanks Mike.

Signature · 1 line
Jens Axboe
#4 lore raw
Quoted 11 lines · Jens Axboe
Quoted 10 lines · Mike Snitzer
Quoted 6 lines · Jens Axboe
Quoted 3 lines · Kent Overstreet

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.

Looks good, but needs a fixes line. I'll add one.

Quoted 7 lines
Quoted 5 lines

Also needs the subject and header updated to reflect that it fixes the crash (Krzysztof please verify):

Indeed, I have added that. Thanks Mike.

Thanks for adding tags!

This fixes reported issue:

Best regards,
Krzysztof