From: Keith Busch <kbusch@kernel.org>
To: linux-nvme@lists.infradead.org, axboe@kernel.dk
Cc: hch@lst.de, sagi@grimberg.me, Keith Busch <kbusch@kernel.org>
Subject: [PATCH] nvme/pci: fix queue_rqs list splitting
Date: Wed, 22 Dec 2021 13:41:59 -0800 [thread overview]
Message-ID: <20211222214159.1767965-1-kbusch@kernel.org> (raw)
If command prep fails, current handling will orphan subsequent requests
in the list. Consider a simple example:
rqlist = [ 1 -> 2 ]
When prep for request '1' fails, it will be appended to the
'requeue_list', leaving request '2' disconnected from the original
rqlist and no longer tracked. Meanwhile, rqlist is still pointing to the
failed 'req' and will attempt to submit the unprepped command.
Fix this by updating the rqlist accordingly.
Fixes: d62cbcf62f2f ("nvme: add support for mq_ops->queue_rqs()")
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
Just IMO, the rq list manipulation looks a bit fragile for the lld. If
more drivers want to subscribe to the new .queue_rqs() interface, I have
another patch set ready for consideration with helper macros to make
this sort of error handling a little easier for re-use.
drivers/nvme/host/pci.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 50deb8b69c40..36398fee66c1 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -1007,20 +1007,33 @@ static void nvme_queue_rqs(struct request **rqlist)
if (!nvme_prep_rq_batch(nvmeq, req)) {
/* detach 'req' and add to remainder list */
+ struct request *next = rq_list_next(req);
+
if (prev)
- prev->rq_next = req->rq_next;
+ prev->rq_next = next;
+ else
+ *rqlist = next;
+
rq_list_add(&requeue_list, req);
- } else {
+
+ if (prev)
+ req = prev;
+ else
+ req = next;
+ }
+
+ if (req) {
prev = req;
+ req = rq_list_next(req);
}
- req = rq_list_next(req);
if (!req || (prev && req->mq_hctx != prev->mq_hctx)) {
/* detach rest of list, and submit */
if (prev)
prev->rq_next = NULL;
nvme_submit_cmds(nvmeq, rqlist);
*rqlist = req;
+ prev = NULL;
}
} while (req);
--
2.25.4
next reply other threads:[~2021-12-22 21:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-22 21:41 Keith Busch [this message]
2021-12-23 0:04 ` [PATCH] nvme/pci: fix queue_rqs list splitting Jens Axboe
2021-12-23 6:20 ` Christoph Hellwig
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=20211222214159.1767965-1-kbusch@kernel.org \
--to=kbusch@kernel.org \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.