From: Hannes Reinecke <hare@suse.de>
To: Christoph Hellwig <hch@lst.de>
Cc: Chaitanya Kulkarni <Chaitanya.Kulkarni@wdc.com>,
Keith Busch <keith.busch@wdc.com>,
James Smart <james.smart@broadcom.com>,
linux-nvme@lists.infradead.org, Hannes Reinecke <hare@suse.de>,
Sagi Grimberg <sagi@grimberg.me>
Subject: [PATCH 2/3] nvme/fcloop: short-circuit LS requests if no association is present
Date: Fri, 6 Mar 2020 14:04:39 +0100 [thread overview]
Message-ID: <20200306130440.16864-3-hare@suse.de> (raw)
In-Reply-To: <20200306130440.16864-1-hare@suse.de>
If no association or targetport is present shifting LS processing
to a workqueue is a bad idea as the targetport itself is about
to be removed, and we would deadlock with targetport deletion.
So instead return an error directly and treat it as a send error,
avoiding the deadlock.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
drivers/nvme/target/fcloop.c | 36 +++++++++---------------------------
1 file changed, 9 insertions(+), 27 deletions(-)
diff --git a/drivers/nvme/target/fcloop.c b/drivers/nvme/target/fcloop.c
index 3610b0bd12da..4f9435d9fa61 100644
--- a/drivers/nvme/target/fcloop.c
+++ b/drivers/nvme/target/fcloop.c
@@ -332,26 +332,17 @@ fcloop_h2t_ls_req(struct nvme_fc_local_port *localport,
{
struct fcloop_lsreq *tls_req = lsreq->private;
struct fcloop_rport *rport = remoteport->private;
- int ret = 0;
+
+ if (!rport->targetport)
+ return -ECONNREFUSED;
tls_req->lsreq = lsreq;
INIT_LIST_HEAD(&tls_req->ls_list);
- if (!rport->targetport) {
- tls_req->status = -ECONNREFUSED;
- spin_lock(&rport->lock);
- list_add_tail(&rport->ls_list, &tls_req->ls_list);
- spin_unlock(&rport->lock);
- schedule_work(&rport->ls_work);
- return ret;
- }
-
tls_req->status = 0;
- ret = nvmet_fc_rcv_ls_req(rport->targetport, rport,
+ return nvmet_fc_rcv_ls_req(rport->targetport, rport,
&tls_req->ls_rsp,
lsreq->rqstaddr, lsreq->rqstlen);
-
- return ret;
}
static int
@@ -415,7 +406,9 @@ fcloop_t2h_ls_req(struct nvmet_fc_target_port *targetport, void *hosthandle,
{
struct fcloop_lsreq *tls_req = lsreq->private;
struct fcloop_tport *tport = targetport->private;
- int ret = 0;
+
+ if (!tport->remoteport)
+ return -ECONNREFUSED;
/*
* hosthandle should be the dst.rport value.
@@ -425,20 +418,9 @@ fcloop_t2h_ls_req(struct nvmet_fc_target_port *targetport, void *hosthandle,
tls_req->lsreq = lsreq;
INIT_LIST_HEAD(&tls_req->ls_list);
- if (!tport->remoteport) {
- tls_req->status = -ECONNREFUSED;
- spin_lock(&tport->lock);
- list_add_tail(&tport->ls_list, &tls_req->ls_list);
- spin_unlock(&tport->lock);
- schedule_work(&tport->ls_work);
- return ret;
- }
-
tls_req->status = 0;
- ret = nvme_fc_rcv_ls_req(tport->remoteport, &tls_req->ls_rsp,
- lsreq->rqstaddr, lsreq->rqstlen);
-
- return ret;
+ return nvme_fc_rcv_ls_req(tport->remoteport, &tls_req->ls_rsp,
+ lsreq->rqstaddr, lsreq->rqstlen);
}
static int
--
2.16.4
_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
next prev parent reply other threads:[~2020-03-06 13:05 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-06 13:04 [PATCH 0/3] nvmet/fcloop fixes Hannes Reinecke
2020-03-06 13:04 ` [PATCH 1/3] nvmet/fc: Sanitize tgtport reference counting for LS requests Hannes Reinecke
2020-03-06 22:11 ` Sagi Grimberg
2020-03-07 1:00 ` James Smart
2020-03-10 16:52 ` Christoph Hellwig
2020-03-06 13:04 ` Hannes Reinecke [this message]
2020-03-06 22:12 ` [PATCH 2/3] nvme/fcloop: short-circuit LS requests if no association is present Sagi Grimberg
2020-03-07 1:11 ` James Smart
2020-03-07 8:39 ` Hannes Reinecke
2020-03-06 13:04 ` [PATCH 3/3] nvme/fcloop: flush workqueue before calling nvme_fc_unregister_remoteport() Hannes Reinecke
2020-03-06 22:12 ` Sagi Grimberg
2020-03-07 1:12 ` James Smart
2020-03-07 8:41 ` Hannes Reinecke
2020-03-31 14:24 ` [PATCH 0/3] nvmet/fcloop fixes Christoph Hellwig
2020-04-16 10:37 ` Hannes Reinecke
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200306130440.16864-3-hare@suse.de \
--to=hare@suse.de \
--cc=Chaitanya.Kulkarni@wdc.com \
--cc=hch@lst.de \
--cc=james.smart@broadcom.com \
--cc=keith.busch@wdc.com \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox