Skip to content

Commit bd97a59

Browse files
kawasakiChristoph Hellwig
authored andcommitted
nvme-auth: use workqueue dedicated to authentication
NVMe In-Band authentication uses two kinds of works: chap->auth_work and ctrl->dhchap_auth_work. The latter work flushes or cancels the former work. However, the both works are queued to the same workqueue nvme-wq. It results in the lockdep WARNING as follows: WARNING: possible recursive locking detected 6.2.0-rc4+ #1 Not tainted -------------------------------------------- kworker/u16:7/69 is trying to acquire lock: ffff902d52e65548 ((wq_completion)nvme-wq){+.+.}-{0:0}, at: start_flush_work+0x2c5/0x380 but task is already holding lock: ffff902d52e65548 ((wq_completion)nvme-wq){+.+.}-{0:0}, at: process_one_work+0x210/0x410 To avoid the WARNING, introduce a new workqueue nvme-auth-wq dedicated to chap->auth_work. Reported-by: Daniel Wagner <[email protected]> Link: https://lore.kernel.org/linux-nvme/[email protected]/ Fixes: f50fff7 ("nvme: implement In-Band authentication") Signed-off-by: Shin'ichiro Kawasaki <[email protected]> Tested-by: Daniel Wagner <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 6fbf13c commit bd97a59

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

drivers/nvme/host/auth.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ struct nvme_dhchap_queue_context {
4545
int sess_key_len;
4646
};
4747

48+
struct workqueue_struct *nvme_auth_wq;
49+
4850
#define nvme_auth_flags_from_qid(qid) \
4951
(qid == 0) ? 0 : BLK_MQ_REQ_NOWAIT | BLK_MQ_REQ_RESERVED
5052
#define nvme_auth_queue_from_qid(ctrl, qid) \
@@ -866,7 +868,7 @@ int nvme_auth_negotiate(struct nvme_ctrl *ctrl, int qid)
866868

867869
chap = &ctrl->dhchap_ctxs[qid];
868870
cancel_work_sync(&chap->auth_work);
869-
queue_work(nvme_wq, &chap->auth_work);
871+
queue_work(nvme_auth_wq, &chap->auth_work);
870872
return 0;
871873
}
872874
EXPORT_SYMBOL_GPL(nvme_auth_negotiate);
@@ -1008,10 +1010,15 @@ EXPORT_SYMBOL_GPL(nvme_auth_free);
10081010

10091011
int __init nvme_init_auth(void)
10101012
{
1013+
nvme_auth_wq = alloc_workqueue("nvme-auth-wq",
1014+
WQ_UNBOUND | WQ_MEM_RECLAIM | WQ_SYSFS, 0);
1015+
if (!nvme_auth_wq)
1016+
return -ENOMEM;
1017+
10111018
nvme_chap_buf_cache = kmem_cache_create("nvme-chap-buf-cache",
10121019
CHAP_BUF_SIZE, 0, SLAB_HWCACHE_ALIGN, NULL);
10131020
if (!nvme_chap_buf_cache)
1014-
return -ENOMEM;
1021+
goto err_destroy_workqueue;
10151022

10161023
nvme_chap_buf_pool = mempool_create(16, mempool_alloc_slab,
10171024
mempool_free_slab, nvme_chap_buf_cache);
@@ -1021,11 +1028,14 @@ int __init nvme_init_auth(void)
10211028
return 0;
10221029
err_destroy_chap_buf_cache:
10231030
kmem_cache_destroy(nvme_chap_buf_cache);
1031+
err_destroy_workqueue:
1032+
destroy_workqueue(nvme_auth_wq);
10241033
return -ENOMEM;
10251034
}
10261035

10271036
void __exit nvme_exit_auth(void)
10281037
{
10291038
mempool_destroy(nvme_chap_buf_pool);
10301039
kmem_cache_destroy(nvme_chap_buf_cache);
1040+
destroy_workqueue(nvme_auth_wq);
10311041
}

0 commit comments

Comments
 (0)