From: Marta Rybczynska <mrybczyn@kalray.eu>
To: Christoph Hellwig <hch@lst.de>
Cc: kbusch <kbusch@kernel.org>, axboe <axboe@fb.com>,
Sagi Grimberg <sagi@grimberg.me>,
linux-nvme <linux-nvme@lists.infradead.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
Samuel Jones <sjones@kalray.eu>,
Guillaume Missonnier <gmissonnier@kalray.eu>
Subject: Re: [PATCH v2] nvme: allow 64-bit results in passthru commands
Date: Mon, 26 Aug 2019 13:20:28 +0200 (CEST) [thread overview]
Message-ID: <1678802062.58145473.1566818428010.JavaMail.zimbra@kalray.eu> (raw)
In-Reply-To: <20190822000652.GF9511@lst.de>
----- On 22 Aug, 2019, at 02:06, Christoph Hellwig hch@lst.de wrote:
> On Fri, Aug 16, 2019 at 11:47:21AM +0200, Marta Rybczynska wrote:
>> It is not possible to get 64-bit results from the passthru commands,
>> what prevents from getting for the Capabilities (CAP) property value.
>>
>> As a result, it is not possible to implement IOL's NVMe Conformance
>> test 4.3 Case 1 for Fabrics targets [1] (page 123).
>>
>> This issue has been already discussed [2], but without a solution.
>>
>> This patch solves the problem by adding new ioctls with a new
>> passthru structure, including 64-bit results. The older ioctls stay
>> unchanged.
>
> Ok, with my idea not being suitable I think I'm fine with this approach, a
> little nitpick below:
>
>> +static bool is_admin_cmd(unsigned int cmd)
>> +{
>> + if ((cmd == NVME_IOCTL_ADMIN_CMD) || (cmd == NVME_IOCTL_ADMIN64_CMD))
>> + return true;
>> + return false;
>> +}
>
> No need for the inner braces. But I'm actually not sure the current
> code structure is very suitable for extending it.
>
>> +
>> static int nvme_ioctl(struct block_device *bdev, fmode_t mode,
>> unsigned int cmd, unsigned long arg)
>> {
>> @@ -1418,13 +1473,13 @@ static int nvme_ioctl(struct block_device *bdev, fmode_t
>> mode,
>> * seperately and drop the ns SRCU reference early. This avoids a
>> * deadlock when deleting namespaces using the passthrough interface.
>> */
>> - if (cmd == NVME_IOCTL_ADMIN_CMD || is_sed_ioctl(cmd)) {
>> + if (is_admin_cmd(cmd) || is_sed_ioctl(cmd)) {
>
> So maybe for this check we should have a is_ctrl_iocl() helper instead
> that includes the is_sed_ioctl check.
>
>> struct nvme_ctrl *ctrl = ns->ctrl;
>>
>> nvme_get_ctrl(ns->ctrl);
>> nvme_put_ns_from_disk(head, srcu_idx);
>>
>> - if (cmd == NVME_IOCTL_ADMIN_CMD)
>> + if (is_admin_cmd(cmd))
>> ret = nvme_user_cmd(ctrl, NULL, argp);
>> else
>> ret = sed_ioctl(ctrl->opal_dev, cmd, argp);
>
> And then we can move this whole branch into a helper function,
> which then switches on the ioctl cmd, with sed_ioctl as the fallback.
Do you mean something like this?
+static bool is_ctrl_ioctl(unsigned int cmd)
+{
+ if (cmd == NVME_IOCTL_ADMIN_CMD || cmd == NVME_IOCTL_ADMIN64_CMD)
+ return true;
+ if (is_sed_ioctl(cmd))
+ return true;
+ return false;
+}
+
+static int nvme_handle_ctrl_ioctl(struct nvme_ns *ns, unsigned int cmd,
+ void __user *argp,
+ struct nvme_ns_head *head,
+ int srcu_idx)
+{
+ struct nvme_ctrl *ctrl = ns->ctrl;
+ int ret;
+
+ nvme_get_ctrl(ns->ctrl);
+ nvme_put_ns_from_disk(head, srcu_idx);
+
+ switch (cmd) {
+ case NVME_IOCTL_ADMIN_CMD:
+ ret = nvme_user_cmd(ctrl, NULL, argp);
+ break;
+ case NVME_IOCTL_ADMIN64_CMD:
+ ret = nvme_user_cmd64(ctrl, NULL, argp);
+ break;
+ default:
+ ret = sed_ioctl(ctrl->opal_dev, cmd, argp);
+ break;
+ }
+ nvme_put_ctrl(ctrl);
+ return ret;
+}
+
static int nvme_ioctl(struct block_device *bdev, fmode_t mode,
unsigned int cmd, unsigned long arg)
{
@@ -1418,20 +1501,8 @@ static int nvme_ioctl(struct block_device *bdev, fmode_t mode,
* seperately and drop the ns SRCU reference early. This avoids a
* deadlock when deleting namespaces using the passthrough interface.
*/
- if (cmd == NVME_IOCTL_ADMIN_CMD || is_sed_ioctl(cmd)) {
- struct nvme_ctrl *ctrl = ns->ctrl;
-
- nvme_get_ctrl(ns->ctrl);
- nvme_put_ns_from_disk(head, srcu_idx);
-
- if (cmd == NVME_IOCTL_ADMIN_CMD)
- ret = nvme_user_cmd(ctrl, NULL, argp);
- else
- ret = sed_ioctl(ctrl->opal_dev, cmd, argp);
-
- nvme_put_ctrl(ctrl);
- return ret;
- }
+ if (is_ctrl_ioctl(cmd))
+ return nvme_handle_ctrl_ioctl(ns, cmd, argp, head, srcu_idx);
switch (cmd) {
case NVME_IOCTL_ID:
Regards,
Marta
next prev parent reply other threads:[~2019-08-26 11:20 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-16 9:47 [PATCH v2] nvme: allow 64-bit results in passthru commands Marta Rybczynska
2019-08-16 13:16 ` Christoph Hellwig
2019-08-19 7:06 ` Marta Rybczynska
2019-08-19 14:49 ` Keith Busch
2019-08-19 15:57 ` James Smart
2019-08-19 18:56 ` Sagi Grimberg
2019-08-19 18:57 ` Keith Busch
2019-08-19 21:17 ` Sagi Grimberg
2019-08-19 21:21 ` Keith Busch
2019-08-21 23:59 ` Christoph Hellwig
2019-08-22 0:06 ` Christoph Hellwig
2019-08-26 11:20 ` Marta Rybczynska [this message]
2019-09-02 8:29 ` 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=1678802062.58145473.1566818428010.JavaMail.zimbra@kalray.eu \
--to=mrybczyn@kalray.eu \
--cc=axboe@fb.com \
--cc=gmissonnier@kalray.eu \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
--cc=sjones@kalray.eu \
/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).