[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <28b40ab8-c695-784e-3f52-03a18b891d25@grimberg.me>
Date: Fri, 25 Oct 2019 13:41:03 -0700
From: Sagi Grimberg <sagi@...mberg.me>
To: Logan Gunthorpe <logang@...tatee.com>,
linux-kernel@...r.kernel.org, linux-nvme@...ts.infradead.org
Cc: Chaitanya Kulkarni <Chaitanya.Kulkarni@....com>,
Stephen Bates <sbates@...thlin.com>,
Keith Busch <kbusch@...nel.org>,
Max Gurtovoy <maxg@...lanox.com>,
Christoph Hellwig <hch@....de>
Subject: Re: [RFC PATCH 3/3] nvme: Introduce nvme_execute_passthru_rq_nowait()
> +#ifdef CONFIG_NVME_TARGET_PASSTHRU
> +static void nvme_execute_passthru_rq_work(struct work_struct *w)
> +{
> + struct nvme_request *req = container_of(w, struct nvme_request, work);
> + struct request *rq = blk_mq_rq_from_pdu(req);
> + rq_end_io_fn *done = rq->end_io;
> + void *end_io_data = rq->end_io_data;
Why is end_io_data stored to a local variable here? where is it set?
> +
> + nvme_execute_passthru_rq(rq);
> +
> + if (done) {
> + rq->end_io_data = end_io_data;
> + done(rq, 0);
> + }
> +}
> +
> +void nvme_execute_passthru_rq_nowait(struct request *rq, rq_end_io_fn *done)
> +{
> + struct nvme_command *cmd = nvme_req(rq)->cmd;
> + struct nvme_ctrl *ctrl = nvme_req(rq)->ctrl;
> + struct nvme_ns *ns = rq->q->queuedata;
> + struct gendisk *disk = ns ? ns->disk : NULL;
> + u32 effects;
> +
> + /*
> + * This function may be called in interrupt context, so we cannot sleep
> + * but nvme_passthru_[start|end]() may sleep so we need to execute
> + * the command in a work queue.
> + */
> + effects = nvme_command_effects(ctrl, ns, cmd->common.opcode);
> + if (effects) {
> + rq->end_io = done;
> + INIT_WORK(&nvme_req(rq)->work, nvme_execute_passthru_rq_work);
> + queue_work(nvme_wq, &nvme_req(rq)->work);
This work will need to be flushed when in nvme_stop_ctrl. That is
assuming that it will fail-fast and not hang (which it should given
that its a passthru command that is allocated via nvme_alloc_request).
Powered by blists - more mailing lists