linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nvmet-rdma: Fix using unallocated nvmet_rdma_delete_wq
@ 2018-11-05 16:23 Israel Rukshin
  2018-11-06 22:32 ` Max Gurtovoy
  0 siblings, 1 reply; 5+ messages in thread
From: Israel Rukshin @ 2018-11-05 16:23 UTC (permalink / raw)


nvmet_rdma_ib_client .remove callback is using nvmet_rdma_delete_wq.
Therefore nvmet_rdma_delete_wq must be destroyed only after calling
to ib_unregister_client().
The bug may happens when unloading the module with open connections.

Fixes: 2acf70a ("nvmet-rdma: use a private workqueue for delete")
Signed-off-by: Israel Rukshin <israelr at mellanox.com>
Reviewed-by: Max Gurtovoy <maxg at mellanox.com>
---
 drivers/nvme/target/rdma.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/nvme/target/rdma.c b/drivers/nvme/target/rdma.c
index bd265ac..9d75eb6 100644
--- a/drivers/nvme/target/rdma.c
+++ b/drivers/nvme/target/rdma.c
@@ -1642,35 +1642,33 @@ static int __init nvmet_rdma_init(void)
 {
 	int ret;
 
+	nvmet_rdma_delete_wq = alloc_workqueue("nvmet-rdma-delete-wq",
+			WQ_UNBOUND | WQ_MEM_RECLAIM | WQ_SYSFS, 0);
+	if (!nvmet_rdma_delete_wq)
+		return -ENOMEM;
+
 	ret = ib_register_client(&nvmet_rdma_ib_client);
 	if (ret)
-		return ret;
+		goto err_destroy_workqueue;
 
 	ret = nvmet_register_transport(&nvmet_rdma_ops);
 	if (ret)
 		goto err_ib_client;
 
-	nvmet_rdma_delete_wq = alloc_workqueue("nvmet-rdma-delete-wq",
-			WQ_UNBOUND | WQ_MEM_RECLAIM | WQ_SYSFS, 0);
-	if (!nvmet_rdma_delete_wq) {
-		ret = -ENOMEM;
-		goto err_unreg_transport;
-	}
-
 	return 0;
 
-err_unreg_transport:
-	nvmet_unregister_transport(&nvmet_rdma_ops);
 err_ib_client:
 	ib_unregister_client(&nvmet_rdma_ib_client);
+err_destroy_workqueue:
+	destroy_workqueue(nvmet_rdma_delete_wq);
 	return ret;
 }
 
 static void __exit nvmet_rdma_exit(void)
 {
-	destroy_workqueue(nvmet_rdma_delete_wq);
 	nvmet_unregister_transport(&nvmet_rdma_ops);
 	ib_unregister_client(&nvmet_rdma_ib_client);
+	destroy_workqueue(nvmet_rdma_delete_wq);
 	WARN_ON_ONCE(!list_empty(&nvmet_rdma_queue_list));
 	ida_destroy(&nvmet_rdma_queue_ida);
 }
-- 
1.8.3.1

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

* [PATCH] nvmet-rdma: Fix using unallocated nvmet_rdma_delete_wq
  2018-11-05 16:23 [PATCH] nvmet-rdma: Fix using unallocated nvmet_rdma_delete_wq Israel Rukshin
@ 2018-11-06 22:32 ` Max Gurtovoy
  2018-11-07  3:15   ` Sagi Grimberg
  0 siblings, 1 reply; 5+ messages in thread
From: Max Gurtovoy @ 2018-11-06 22:32 UTC (permalink / raw)


Sagi/Christoph/Keith,

please note that the problematic commit? "nvmet-rdma: use a private 
workqueue for delete" is only merged to nvme-4.20 so this fix can be 
squashed to it IMO.

-Max.

On 11/5/2018 6:23 PM, Israel Rukshin wrote:
> nvmet_rdma_ib_client .remove callback is using nvmet_rdma_delete_wq.
> Therefore nvmet_rdma_delete_wq must be destroyed only after calling
> to ib_unregister_client().
> The bug may happens when unloading the module with open connections.
>
> Fixes: 2acf70a ("nvmet-rdma: use a private workqueue for delete")
> Signed-off-by: Israel Rukshin <israelr at mellanox.com>
> Reviewed-by: Max Gurtovoy <maxg at mellanox.com>
> ---
>   drivers/nvme/target/rdma.c | 20 +++++++++-----------
>   1 file changed, 9 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/nvme/target/rdma.c b/drivers/nvme/target/rdma.c
> index bd265ac..9d75eb6 100644
> --- a/drivers/nvme/target/rdma.c
> +++ b/drivers/nvme/target/rdma.c
> @@ -1642,35 +1642,33 @@ static int __init nvmet_rdma_init(void)
>   {
>   	int ret;
>   
> +	nvmet_rdma_delete_wq = alloc_workqueue("nvmet-rdma-delete-wq",
> +			WQ_UNBOUND | WQ_MEM_RECLAIM | WQ_SYSFS, 0);
> +	if (!nvmet_rdma_delete_wq)
> +		return -ENOMEM;
> +
>   	ret = ib_register_client(&nvmet_rdma_ib_client);
>   	if (ret)
> -		return ret;
> +		goto err_destroy_workqueue;
>   
>   	ret = nvmet_register_transport(&nvmet_rdma_ops);
>   	if (ret)
>   		goto err_ib_client;
>   
> -	nvmet_rdma_delete_wq = alloc_workqueue("nvmet-rdma-delete-wq",
> -			WQ_UNBOUND | WQ_MEM_RECLAIM | WQ_SYSFS, 0);
> -	if (!nvmet_rdma_delete_wq) {
> -		ret = -ENOMEM;
> -		goto err_unreg_transport;
> -	}
> -
>   	return 0;
>   
> -err_unreg_transport:
> -	nvmet_unregister_transport(&nvmet_rdma_ops);
>   err_ib_client:
>   	ib_unregister_client(&nvmet_rdma_ib_client);
> +err_destroy_workqueue:
> +	destroy_workqueue(nvmet_rdma_delete_wq);
>   	return ret;
>   }
>   
>   static void __exit nvmet_rdma_exit(void)
>   {
> -	destroy_workqueue(nvmet_rdma_delete_wq);
>   	nvmet_unregister_transport(&nvmet_rdma_ops);
>   	ib_unregister_client(&nvmet_rdma_ib_client);
> +	destroy_workqueue(nvmet_rdma_delete_wq);
>   	WARN_ON_ONCE(!list_empty(&nvmet_rdma_queue_list));
>   	ida_destroy(&nvmet_rdma_queue_ida);
>   }

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

* [PATCH] nvmet-rdma: Fix using unallocated nvmet_rdma_delete_wq
  2018-11-06 22:32 ` Max Gurtovoy
@ 2018-11-07  3:15   ` Sagi Grimberg
  2018-11-07  8:20     ` Christoph Hellwig
  0 siblings, 1 reply; 5+ messages in thread
From: Sagi Grimberg @ 2018-11-07  3:15 UTC (permalink / raw)



> Sagi/Christoph/Keith,
> 
> please note that the problematic commit? "nvmet-rdma: use a private 
> workqueue for delete" is only merged to nvme-4.20 so this fix can be 
> squashed to it IMO.

I think we need to revert 2acf70a ("nvmet-rdma: use a private workqueue 
for delete") altogether because it never made any difference..

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

* [PATCH] nvmet-rdma: Fix using unallocated nvmet_rdma_delete_wq
  2018-11-07  3:15   ` Sagi Grimberg
@ 2018-11-07  8:20     ` Christoph Hellwig
  2018-11-11 13:39       ` Max Gurtovoy
  0 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2018-11-07  8:20 UTC (permalink / raw)


On Tue, Nov 06, 2018@07:15:31PM -0800, Sagi Grimberg wrote:
>
>> Sagi/Christoph/Keith,
>>
>> please note that the problematic commit? "nvmet-rdma: use a private 
>> workqueue for delete" is only merged to nvme-4.20 so this fix can be 
>> squashed to it IMO.
>
> I think we need to revert 2acf70a ("nvmet-rdma: use a private workqueue for 
> delete") altogether because it never made any difference..

Agreed.  And nvme-4.20 has been merged to mainline already, so we can't
squash anything.  I'll plan to revert it for now.

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

* [PATCH] nvmet-rdma: Fix using unallocated nvmet_rdma_delete_wq
  2018-11-07  8:20     ` Christoph Hellwig
@ 2018-11-11 13:39       ` Max Gurtovoy
  0 siblings, 0 replies; 5+ messages in thread
From: Max Gurtovoy @ 2018-11-11 13:39 UTC (permalink / raw)



On 11/7/2018 10:20 AM, Christoph Hellwig wrote:
> On Tue, Nov 06, 2018@07:15:31PM -0800, Sagi Grimberg wrote:
>>> Sagi/Christoph/Keith,
>>>
>>> please note that the problematic commit? "nvmet-rdma: use a private
>>> workqueue for delete" is only merged to nvme-4.20 so this fix can be
>>> squashed to it IMO.
>> I think we need to revert 2acf70a ("nvmet-rdma: use a private workqueue for
>> delete") altogether because it never made any difference..
> Agreed.  And nvme-4.20 has been merged to mainline already, so we can't
> squash anything.  I'll plan to revert it for now.


so how we overcome the circular lock that was reported by Bart ?

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

end of thread, other threads:[~2018-11-11 13:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-05 16:23 [PATCH] nvmet-rdma: Fix using unallocated nvmet_rdma_delete_wq Israel Rukshin
2018-11-06 22:32 ` Max Gurtovoy
2018-11-07  3:15   ` Sagi Grimberg
2018-11-07  8:20     ` Christoph Hellwig
2018-11-11 13:39       ` Max Gurtovoy

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).