linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nbd: add a missed nbd_config_put() in nbd_xmit_timeout()
@ 2019-08-12 12:31 Sun Ke
  2019-08-12 15:34 ` Mike Christie
  2019-08-15  1:27 ` sunke (E)
  0 siblings, 2 replies; 5+ messages in thread
From: Sun Ke @ 2019-08-12 12:31 UTC (permalink / raw)
  To: sunke32, josef, axboe, linux-block, nbd, linux-kernel

When try to get the lock failed, before return, execute the
nbd_config_put() to decrease the nbd->config_refs.

If the nbd->config_refs is added but not decreased. Then will not
execute nbd_clear_sock() in nbd_config_put(). bd->task_setup will
not be cleared away. Finally, print"Device being setup by another
task" in nbd_add_sock() and nbd device can not be reused.

Fixes: 8f3ea35929a0 ("nbd: handle unexpected replies better")
Signed-off-by: Sun Ke <sunke32@huawei.com>
---
 drivers/block/nbd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index e21d2de..a69a90a 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -357,8 +357,10 @@ static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req,
 	}
 	config = nbd->config;
 
-	if (!mutex_trylock(&cmd->lock))
+	if (!mutex_trylock(&cmd->lock)) {
+		nbd_config_put(nbd);
 		return BLK_EH_RESET_TIMER;
+	}
 
 	if (config->num_connections > 1) {
 		dev_err_ratelimited(nbd_to_dev(nbd),
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] nbd: add a missed nbd_config_put() in nbd_xmit_timeout()
  2019-08-12 12:31 [PATCH] nbd: add a missed nbd_config_put() in nbd_xmit_timeout() Sun Ke
@ 2019-08-12 15:34 ` Mike Christie
  2019-08-13  4:28   ` sunke (E)
  2019-08-15  1:27 ` sunke (E)
  1 sibling, 1 reply; 5+ messages in thread
From: Mike Christie @ 2019-08-12 15:34 UTC (permalink / raw)
  To: Sun Ke, josef, axboe, linux-block, nbd, linux-kernel

On 08/12/2019 07:31 AM, Sun Ke wrote:
> When try to get the lock failed, before return, execute the
> nbd_config_put() to decrease the nbd->config_refs.
> 
> If the nbd->config_refs is added but not decreased. Then will not
> execute nbd_clear_sock() in nbd_config_put(). bd->task_setup will
> not be cleared away. Finally, print"Device being setup by another
> task" in nbd_add_sock() and nbd device can not be reused.
> 
> Fixes: 8f3ea35929a0 ("nbd: handle unexpected replies better")
> Signed-off-by: Sun Ke <sunke32@huawei.com>
> ---
>  drivers/block/nbd.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
> index e21d2de..a69a90a 100644
> --- a/drivers/block/nbd.c
> +++ b/drivers/block/nbd.c
> @@ -357,8 +357,10 @@ static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req,
>  	}
>  	config = nbd->config;
>  
> -	if (!mutex_trylock(&cmd->lock))
> +	if (!mutex_trylock(&cmd->lock)) {
> +		nbd_config_put(nbd);
>  		return BLK_EH_RESET_TIMER;
> +	}
>  
>  	if (config->num_connections > 1) {
>  		dev_err_ratelimited(nbd_to_dev(nbd),
> 

I just sent the same patch

https://www.spinics.net/lists/linux-block/msg43718.html

here

https://www.spinics.net/lists/linux-block/msg43715.html

so it looks good to me.

Reviewed-by: Mike Christie <mchristi@redhat.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] nbd: add a missed nbd_config_put() in nbd_xmit_timeout()
  2019-08-12 15:34 ` Mike Christie
@ 2019-08-13  4:28   ` sunke (E)
  0 siblings, 0 replies; 5+ messages in thread
From: sunke (E) @ 2019-08-13  4:28 UTC (permalink / raw)
  To: Mike Christie, josef, axboe, linux-block, nbd, linux-kernel

Thanks for your review.

在 2019/8/12 23:34, Mike Christie 写道:
> On 08/12/2019 07:31 AM, Sun Ke wrote:
>> When try to get the lock failed, before return, execute the
>> nbd_config_put() to decrease the nbd->config_refs.
>>
>> If the nbd->config_refs is added but not decreased. Then will not
>> execute nbd_clear_sock() in nbd_config_put(). bd->task_setup will
>> not be cleared away. Finally, print"Device being setup by another
>> task" in nbd_add_sock() and nbd device can not be reused.
>>
>> Fixes: 8f3ea35929a0 ("nbd: handle unexpected replies better")
>> Signed-off-by: Sun Ke <sunke32@huawei.com>
>> ---
>>   drivers/block/nbd.c | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
>> index e21d2de..a69a90a 100644
>> --- a/drivers/block/nbd.c
>> +++ b/drivers/block/nbd.c
>> @@ -357,8 +357,10 @@ static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req,
>>   	}
>>   	config = nbd->config;
>>   
>> -	if (!mutex_trylock(&cmd->lock))
>> +	if (!mutex_trylock(&cmd->lock)) {
>> +		nbd_config_put(nbd);
>>   		return BLK_EH_RESET_TIMER;
>> +	}
>>   
>>   	if (config->num_connections > 1) {
>>   		dev_err_ratelimited(nbd_to_dev(nbd),
>>
> 
> I just sent the same patch
> 
> https://www.spinics.net/lists/linux-block/msg43718.html
> 
> here
> 
> https://www.spinics.net/lists/linux-block/msg43715.html
> 
> so it looks good to me.
> 
> Reviewed-by: Mike Christie <mchristi@redhat.com>
> 
> .
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] nbd: add a missed nbd_config_put() in nbd_xmit_timeout()
  2019-08-12 12:31 [PATCH] nbd: add a missed nbd_config_put() in nbd_xmit_timeout() Sun Ke
  2019-08-12 15:34 ` Mike Christie
@ 2019-08-15  1:27 ` sunke (E)
  2019-08-15  3:13   ` Mike Christie
  1 sibling, 1 reply; 5+ messages in thread
From: sunke (E) @ 2019-08-15  1:27 UTC (permalink / raw)
  To: josef, axboe, linux-block, nbd, linux-kernel

ping

在 2019/8/12 20:31, Sun Ke 写道:
> When try to get the lock failed, before return, execute the
> nbd_config_put() to decrease the nbd->config_refs.
> 
> If the nbd->config_refs is added but not decreased. Then will not
> execute nbd_clear_sock() in nbd_config_put(). bd->task_setup will
> not be cleared away. Finally, print"Device being setup by another
> task" in nbd_add_sock() and nbd device can not be reused.
> 
> Fixes: 8f3ea35929a0 ("nbd: handle unexpected replies better")
> Signed-off-by: Sun Ke <sunke32@huawei.com>
> ---
>   drivers/block/nbd.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
> index e21d2de..a69a90a 100644
> --- a/drivers/block/nbd.c
> +++ b/drivers/block/nbd.c
> @@ -357,8 +357,10 @@ static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req,
>   	}
>   	config = nbd->config;
>   
> -	if (!mutex_trylock(&cmd->lock))
> +	if (!mutex_trylock(&cmd->lock)) {
> +		nbd_config_put(nbd);
>   		return BLK_EH_RESET_TIMER;
> +	}
>   
>   	if (config->num_connections > 1) {
>   		dev_err_ratelimited(nbd_to_dev(nbd),
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] nbd: add a missed nbd_config_put() in nbd_xmit_timeout()
  2019-08-15  1:27 ` sunke (E)
@ 2019-08-15  3:13   ` Mike Christie
  0 siblings, 0 replies; 5+ messages in thread
From: Mike Christie @ 2019-08-15  3:13 UTC (permalink / raw)
  To: sunke (E), josef, axboe, linux-block, nbd, linux-kernel

Josef had ackd my patch for the same thing here:

https://www.spinics.net/lists/linux-block/msg43800.html

so maybe Jens will pick that up with the rest of the set Josef had acked:

https://www.spinics.net/lists/linux-block/msg43809.html

to make it easier.

On 08/14/2019 08:27 PM, sunke (E) wrote:
> ping
> 
> 在 2019/8/12 20:31, Sun Ke 写道:
>> When try to get the lock failed, before return, execute the
>> nbd_config_put() to decrease the nbd->config_refs.
>>
>> If the nbd->config_refs is added but not decreased. Then will not
>> execute nbd_clear_sock() in nbd_config_put(). bd->task_setup will
>> not be cleared away. Finally, print"Device being setup by another
>> task" in nbd_add_sock() and nbd device can not be reused.
>>
>> Fixes: 8f3ea35929a0 ("nbd: handle unexpected replies better")
>> Signed-off-by: Sun Ke <sunke32@huawei.com>
>> ---
>>   drivers/block/nbd.c | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
>> index e21d2de..a69a90a 100644
>> --- a/drivers/block/nbd.c
>> +++ b/drivers/block/nbd.c
>> @@ -357,8 +357,10 @@ static enum blk_eh_timer_return
>> nbd_xmit_timeout(struct request *req,
>>       }
>>       config = nbd->config;
>>   -    if (!mutex_trylock(&cmd->lock))
>> +    if (!mutex_trylock(&cmd->lock)) {
>> +        nbd_config_put(nbd);
>>           return BLK_EH_RESET_TIMER;
>> +    }
>>         if (config->num_connections > 1) {
>>           dev_err_ratelimited(nbd_to_dev(nbd),
>>
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-08-15  3:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-12 12:31 [PATCH] nbd: add a missed nbd_config_put() in nbd_xmit_timeout() Sun Ke
2019-08-12 15:34 ` Mike Christie
2019-08-13  4:28   ` sunke (E)
2019-08-15  1:27 ` sunke (E)
2019-08-15  3:13   ` Mike Christie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).