Skip to content

Commit 710c69d

Browse files
igawkeithbusch
authored andcommitted
nvmet-fc: avoid deadlock on delete association path
When deleting an association the shutdown path is deadlocking because we try to flush the nvmet_wq nested. Avoid this by deadlock by deferring the put work into its own work item. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Daniel Wagner <dwagner@suse.de> Signed-off-by: Keith Busch <kbusch@kernel.org>
1 parent 3146345 commit 710c69d

File tree

1 file changed

+13
-3
lines changed
  • drivers/nvme/target

1 file changed

+13
-3
lines changed

drivers/nvme/target/fc.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ struct nvmet_fc_tgtport {
111111
struct nvmet_fc_port_entry *pe;
112112
struct kref ref;
113113
u32 max_sg_cnt;
114+
115+
struct work_struct put_work;
114116
};
115117

116118
struct nvmet_fc_port_entry {
@@ -247,6 +249,13 @@ static int nvmet_fc_tgt_a_get(struct nvmet_fc_tgt_assoc *assoc);
247249
static void nvmet_fc_tgt_q_put(struct nvmet_fc_tgt_queue *queue);
248250
static int nvmet_fc_tgt_q_get(struct nvmet_fc_tgt_queue *queue);
249251
static void nvmet_fc_tgtport_put(struct nvmet_fc_tgtport *tgtport);
252+
static void nvmet_fc_put_tgtport_work(struct work_struct *work)
253+
{
254+
struct nvmet_fc_tgtport *tgtport =
255+
container_of(work, struct nvmet_fc_tgtport, put_work);
256+
257+
nvmet_fc_tgtport_put(tgtport);
258+
}
250259
static int nvmet_fc_tgtport_get(struct nvmet_fc_tgtport *tgtport);
251260
static void nvmet_fc_handle_fcp_rqst(struct nvmet_fc_tgtport *tgtport,
252261
struct nvmet_fc_fcp_iod *fod);
@@ -358,7 +367,7 @@ __nvmet_fc_finish_ls_req(struct nvmet_fc_ls_req_op *lsop)
358367

359368
if (!lsop->req_queued) {
360369
spin_unlock_irqrestore(&tgtport->lock, flags);
361-
goto out_puttgtport;
370+
goto out_putwork;
362371
}
363372

364373
list_del(&lsop->lsreq_list);
@@ -371,8 +380,8 @@ __nvmet_fc_finish_ls_req(struct nvmet_fc_ls_req_op *lsop)
371380
(lsreq->rqstlen + lsreq->rsplen),
372381
DMA_BIDIRECTIONAL);
373382

374-
out_puttgtport:
375-
nvmet_fc_tgtport_put(tgtport);
383+
out_putwork:
384+
queue_work(nvmet_wq, &tgtport->put_work);
376385
}
377386

378387
static int
@@ -1396,6 +1405,7 @@ nvmet_fc_register_targetport(struct nvmet_fc_port_info *pinfo,
13961405
kref_init(&newrec->ref);
13971406
ida_init(&newrec->assoc_cnt);
13981407
newrec->max_sg_cnt = template->max_sgl_segments;
1408+
INIT_WORK(&newrec->put_work, nvmet_fc_put_tgtport_work);
13991409

14001410
ret = nvmet_fc_alloc_ls_iodlist(newrec);
14011411
if (ret) {

0 commit comments

Comments
 (0)