[PATCHv2 3/3] nvme-pci: fix queue_rqs list splitting
Keith Busch
kbusch at kernel.org
Tue Jan 4 11:38:07 PST 2022
On Wed, Dec 29, 2021 at 06:46:02PM +0100, Christoph Hellwig wrote:
> I wonder if a restart label here would be a little cleaner, something
> like:
On second thought, this requires another check that the *rqlist is not
NULL before 'goto restart' since the safe iterator dereferences it. I'm
not sure this is cleaner than the original anymore.
> diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
> index 992ee314e91ba..29b433fd12bdd 100644
> --- a/drivers/nvme/host/pci.c
> +++ b/drivers/nvme/host/pci.c
> @@ -999,9 +999,11 @@ static bool nvme_prep_rq_batch(struct nvme_queue *nvmeq, struct request *req)
>
> static void nvme_queue_rqs(struct request **rqlist)
> {
> - struct request *req, *next, *prev = NULL;
> + struct request *req, *next, *prev;
> struct request *requeue_list = NULL;
>
> +restart:
> + prev = NULL;
> rq_list_for_each_safe(rqlist, req, next) {
> struct nvme_queue *nvmeq = req->mq_hctx->driver_data;
>
> @@ -1009,9 +1011,9 @@ static void nvme_queue_rqs(struct request **rqlist)
> /* detach 'req' and add to remainder list */
> rq_list_move(rqlist, &requeue_list, req, prev, next);
>
> + if (!prev)
> + break;
> req = prev;
> - if (!req)
> - continue;
> }
>
> if (!next || req->mq_hctx != next->mq_hctx) {
> @@ -1019,9 +1021,9 @@ static void nvme_queue_rqs(struct request **rqlist)
> req->rq_next = NULL;
> nvme_submit_cmds(nvmeq, rqlist);
> *rqlist = next;
> - prev = NULL;
> - } else
> - prev = req;
> + goto restart;
> + }
> + prev = req;
> }
>
> *rqlist = requeue_list;
More information about the Linux-nvme
mailing list