* [PATCH] nbd: add missed destroy_workqueue when nbd_start_device fails
@ 2020-07-25 2:27 Li Heng
2020-07-25 18:42 ` Michael Christie
0 siblings, 1 reply; 3+ messages in thread
From: Li Heng @ 2020-07-25 2:27 UTC (permalink / raw)
To: josef, axboe; +Cc: linux-block, nbd, linux-kernel
destroy_workqueue() should be called to destroy ndev->tx_wq
when nbd_start_device init resources fails.
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Li Heng <liheng40@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 ce7e9f22..45e0a9f4 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -4,7 +4,7 @@
*
* Note that you can not swap over this thing, yet. Seems to work but
* deadlocks sometimes - you can not swap over TCP in general.
- *
+ *
* Copyright 1997-2000, 2008 Pavel Machek <pavel@ucw.cz>
* Parts copyright 2001 Steven Whitehouse <steve@chygwyn.com>
*
@@ -1270,6 +1270,7 @@ static int nbd_start_device(struct nbd_device *nbd)
error = device_create_file(disk_to_dev(nbd->disk), &pid_attr);
if (error) {
dev_err(disk_to_dev(nbd->disk), "device_create_file failed!\n");
+ destroy_workqueue(nbd->recv_workq);
return error;
}
set_bit(NBD_RT_HAS_PID_FILE, &config->runtime_flags);
@@ -1291,6 +1292,7 @@ static int nbd_start_device(struct nbd_device *nbd)
*/
if (i)
flush_workqueue(nbd->recv_workq);
+ destroy_workqueue(nbd->recv_workq);
return -ENOMEM;
}
sk_set_memalloc(config->socks[i]->sock->sk);
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] nbd: add missed destroy_workqueue when nbd_start_device fails
2020-07-25 2:27 [PATCH] nbd: add missed destroy_workqueue when nbd_start_device fails Li Heng
@ 2020-07-25 18:42 ` Michael Christie
0 siblings, 0 replies; 3+ messages in thread
From: Michael Christie @ 2020-07-25 18:42 UTC (permalink / raw)
To: Li Heng; +Cc: josef, axboe, linux-block, nbd, linux-kernel
> On Jul 24, 2020, at 9:27 PM, Li Heng <liheng40@huawei.com> wrote:
>
> destroy_workqueue() should be called to destroy ndev->tx_wq
> when nbd_start_device init resources fails.
>
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Li Heng <liheng40@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 ce7e9f22..45e0a9f4 100644
> --- a/drivers/block/nbd.c
> +++ b/drivers/block/nbd.c
> @@ -4,7 +4,7 @@
> *
> * Note that you can not swap over this thing, yet. Seems to work but
> * deadlocks sometimes - you can not swap over TCP in general.
> - *
> + *
> * Copyright 1997-2000, 2008 Pavel Machek <pavel@ucw.cz>
> * Parts copyright 2001 Steven Whitehouse <steve@chygwyn.com>
> *
> @@ -1270,6 +1270,7 @@ static int nbd_start_device(struct nbd_device *nbd)
> error = device_create_file(disk_to_dev(nbd->disk), &pid_attr);
> if (error) {
> dev_err(disk_to_dev(nbd->disk), "device_create_file failed!\n");
> + destroy_workqueue(nbd->recv_workq);
> return error;
> }
> set_bit(NBD_RT_HAS_PID_FILE, &config->runtime_flags);
> @@ -1291,6 +1292,7 @@ static int nbd_start_device(struct nbd_device *nbd)
> */
> if (i)
> flush_workqueue(nbd->recv_workq);
> + destroy_workqueue(nbd->recv_workq);
> return -ENOMEM;
> }
> sk_set_memalloc(config->socks[i]->sock->sk);
For the netlink error path, we end up cleaning up everything when nbd_config_put is called in the error path.
Are you seeing an issue with the ioctl interface and this code path? I thought normally if the the NBD_DO_IT ioctl fails, then userspace closes the device and that does the nbd_config_put that will clean this up like is done in the netlink path.
If userspace is not closing the device and is trying to maybe retry the NBD_DO_IT ioctl or reuse the device some other way, then I think you need to also NULL nbd->task_recv, remove pid file, NULL recv_workq after you destroy for the cases nbd_config_put is called right after a failure.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] nbd: add missed destroy_workqueue when nbd_start_device fails
@ 2020-07-25 10:50 Markus Elfring
0 siblings, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2020-07-25 10:50 UTC (permalink / raw)
To: Li Heng, linux-block, nbd
Cc: kernel-janitors, linux-kernel, Jens Axboe, Josef Bacik
> destroy_workqueue() should be called to destroy ndev->tx_wq
> when nbd_start_device init resources fails.
* An imperative wording can be preferred for the change description,
can't it?
* Would you like to add the tag “Fixes” to the commit message?
Regards,
Markus
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-07-25 18:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-25 2:27 [PATCH] nbd: add missed destroy_workqueue when nbd_start_device fails Li Heng
2020-07-25 18:42 ` Michael Christie
2020-07-25 10:50 Markus Elfring
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).