2018-06-02 17:47:32

by Kent Overstreet

[permalink] [raw]
Subject: [PATCH] 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.

Signed-off-by: Kent Overstreet <[email protected]>
---
drivers/md/dm-crypt.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index eaf6b279ac..9a000aa955 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -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);

--
2.17.1



2018-06-02 20:06:02

by Jens Axboe

[permalink] [raw]
Subject: Re: [PATCH] dm-crypt: fix warning in shutdown path

On 6/2/18 11:45 AM, Kent Overstreet wrote:
> 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.

--
Jens Axboe


2018-06-02 20:08:07

by Mike Snitzer

[permalink] [raw]
Subject: Re: dm-crypt: fix warning in shutdown path

On Sat, Jun 02 2018 at 4:03pm -0400,
Jens Axboe <[email protected]> wrote:

> On 6/2/18 11:45 AM, Kent Overstreet wrote:
> > 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):

Reported-by: Krzysztof Kozlowski <[email protected]>
Acked-by: Mike Snitzer <[email protected]>

2018-06-02 20:11:07

by Jens Axboe

[permalink] [raw]
Subject: Re: dm-crypt: fix warning in shutdown path

On 6/2/18 2:07 PM, Mike Snitzer wrote:
> On Sat, Jun 02 2018 at 4:03pm -0400,
> Jens Axboe <[email protected]> wrote:
>
>> On 6/2/18 11:45 AM, Kent Overstreet wrote:
>>> 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):
>
> Reported-by: Krzysztof Kozlowski <[email protected]>
> Acked-by: Mike Snitzer <[email protected]>

Indeed, I have added that. Thanks Mike.

--
Jens Axboe


2018-06-04 09:32:30

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: dm-crypt: fix warning in shutdown path

On Sat, Jun 2, 2018 at 10:10 PM, Jens Axboe <[email protected]> wrote:
> On 6/2/18 2:07 PM, Mike Snitzer wrote:
>> On Sat, Jun 02 2018 at 4:03pm -0400,
>> Jens Axboe <[email protected]> wrote:
>>
>>> On 6/2/18 11:45 AM, Kent Overstreet wrote:
>>>> 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):
>>
>> Reported-by: Krzysztof Kozlowski <[email protected]>
>> Acked-by: Mike Snitzer <[email protected]>
>
> Indeed, I have added that. Thanks Mike.

Thanks for adding tags!

This fixes reported issue:
Tested-by: Krzysztof Kozlowski <[email protected]>

Best regards,
Krzysztof