From: Christoph Hellwig <hch@lst.de>
To: Logan Gunthorpe <logang@deltatee.com>
Cc: Sagi Grimberg <sagi@grimberg.me>,
Chaitanya Kulkarni <Chaitanya.Kulkarni@wdc.com>,
linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org,
Stephen Bates <sbates@raithlin.com>,
Keith Busch <kbusch@kernel.org>, Max Gurtovoy <maxg@mellanox.com>,
Christoph Hellwig <hch@lst.de>
Subject: Re: [RFC PATCH 3/3] nvme: Introduce nvme_execute_passthru_rq_nowait()
Date: Sun, 27 Oct 2019 16:09:37 +0100 [thread overview]
Message-ID: <20191027150937.GC5843@lst.de> (raw)
In-Reply-To: <20191025202535.12036-4-logang@deltatee.com>
On Fri, Oct 25, 2019 at 02:25:35PM -0600, Logan Gunthorpe wrote:
> This function is similar to nvme_execute_passthru_rq() but does
> not wait and will call a callback when the request is complete.
>
> The new function can also be called in interrupt context, so if there
> are side effects, the request will be executed in a work queue to
> avoid sleeping.
Why would you ever call it from interrupt context? All the target
submission handlers should run in process context.
> +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);
But independent of the target code - I'd much rather leave this to the
caller. Just call nvme_command_effects in the target code, then if
there are not side effects use blk_execute_rq_nowait directly, else
schedule a workqueue in the target code and call
nvme_execute_passthru_rq from it.
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
next prev parent reply other threads:[~2019-10-27 15:10 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-25 20:25 [RFC PATCH 0/3] Passthru Execute Request Interface Logan Gunthorpe
2019-10-25 20:25 ` [RFC PATCH 1/3] nvme: Move nvme_passthru_[start|end]() calls to common code Logan Gunthorpe
2019-10-25 20:25 ` [RFC PATCH 2/3] nvme: Create helper function to obtain command effects Logan Gunthorpe
2019-10-27 15:05 ` Christoph Hellwig
2019-10-25 20:25 ` [RFC PATCH 3/3] nvme: Introduce nvme_execute_passthru_rq_nowait() Logan Gunthorpe
2019-10-25 20:41 ` Sagi Grimberg
2019-10-25 21:12 ` Logan Gunthorpe
2019-10-25 21:40 ` Sagi Grimberg
2019-10-25 21:55 ` Logan Gunthorpe
2019-10-27 15:09 ` Christoph Hellwig [this message]
2019-10-28 16:58 ` Logan Gunthorpe
2019-10-28 21:04 ` Sagi Grimberg
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=20191027150937.GC5843@lst.de \
--to=hch@lst.de \
--cc=Chaitanya.Kulkarni@wdc.com \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=logang@deltatee.com \
--cc=maxg@mellanox.com \
--cc=sagi@grimberg.me \
--cc=sbates@raithlin.com \
/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;
as well as URLs for NNTP newsgroup(s).