* [PATCH] nvme/ioctl: allow 64-bit results in io-passthru command
@ 2026-02-24 18:51 Tokunori Ikegami
2026-02-25 9:50 ` Maurizio Lombardi
0 siblings, 1 reply; 3+ messages in thread
From: Tokunori Ikegami @ 2026-02-24 18:51 UTC (permalink / raw)
To: linux-nvme; +Cc: Tokunori Ikegami
Deprecated NVME_IOCTL_IO_CMD ioctl on the char device.
But nvme-cli still uses it and NVME_IOCTL_IO64_CMD for now.
So add NVME_IOCTL_IO64_CMD also to allow it.
Note: 32/62-bit ioctl duplicated code should be refactored.
Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
---
drivers/nvme/host/ioctl.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
index 8844bbd39515..ff7df944ef53 100644
--- a/drivers/nvme/host/ioctl.c
+++ b/drivers/nvme/host/ioctl.c
@@ -845,6 +845,43 @@ static int nvme_dev_user_cmd(struct nvme_ctrl *ctrl, void __user *argp,
return ret;
}
+static int nvme_dev_user_cmd64(struct nvme_ctrl *ctrl, void __user *argp,
+ bool open_for_write)
+{
+ struct nvme_ns *ns;
+ int ret, srcu_idx;
+
+ srcu_idx = srcu_read_lock(&ctrl->srcu);
+ if (list_empty(&ctrl->namespaces)) {
+ ret = -ENOTTY;
+ goto out_unlock;
+ }
+
+ ns = list_first_or_null_rcu(&ctrl->namespaces, struct nvme_ns, list);
+ if (ns != list_last_entry(&ctrl->namespaces, struct nvme_ns, list)) {
+ dev_warn(ctrl->device,
+ "NVME_IOCTL_IO64_CMD not supported when multiple namespaces present!\n");
+ ret = -EINVAL;
+ goto out_unlock;
+ }
+
+ dev_warn(ctrl->device,
+ "using deprecated NVME_IOCTL_IO64_CMD ioctl on the char device!\n");
+ if (!nvme_get_ns(ns)) {
+ ret = -ENXIO;
+ goto out_unlock;
+ }
+ srcu_read_unlock(&ctrl->srcu, srcu_idx);
+
+ ret = nvme_user_cmd64(ctrl, ns, argp, 0, open_for_write);
+ nvme_put_ns(ns);
+ return ret;
+
+out_unlock:
+ srcu_read_unlock(&ctrl->srcu, srcu_idx);
+ return ret;
+}
+
long nvme_dev_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
@@ -859,6 +896,8 @@ long nvme_dev_ioctl(struct file *file, unsigned int cmd,
return nvme_user_cmd64(ctrl, NULL, argp, 0, open_for_write);
case NVME_IOCTL_IO_CMD:
return nvme_dev_user_cmd(ctrl, argp, open_for_write);
+ case NVME_IOCTL_IO64_CMD:
+ return nvme_dev_user_cmd64(ctrl, argp, open_for_write);
case NVME_IOCTL_RESET:
if (!capable(CAP_SYS_ADMIN))
return -EACCES;
--
2.51.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] nvme/ioctl: allow 64-bit results in io-passthru command
2026-02-24 18:51 [PATCH] nvme/ioctl: allow 64-bit results in io-passthru command Tokunori Ikegami
@ 2026-02-25 9:50 ` Maurizio Lombardi
2026-03-01 5:14 ` Tokunori Ikegami
0 siblings, 1 reply; 3+ messages in thread
From: Maurizio Lombardi @ 2026-02-25 9:50 UTC (permalink / raw)
To: Tokunori Ikegami, linux-nvme
On Tue Feb 24, 2026 at 7:51 PM CET, Tokunori Ikegami wrote:
> Deprecated NVME_IOCTL_IO_CMD ioctl on the char device.
> But nvme-cli still uses it and NVME_IOCTL_IO64_CMD for now.
> So add NVME_IOCTL_IO64_CMD also to allow it.
> Note: 32/62-bit ioctl duplicated code should be refactored.
Indeed nvme_dev_user_cmd() seems identical.
Wouldn't make sense to add a "bool is64bit" parameter to
nvme_dev_user_cmd() and then just do
if (is64bit)
ret = nvme_user_cmd64(ctrl, ns, argp, 0, open_for_write);
else
ret = nvme_user_cmd(ctrl, ns, argp, 0, open_for_write);
?
Maurizio
>
> Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
> ---
> drivers/nvme/host/ioctl.c | 39 +++++++++++++++++++++++++++++++++++++++
> 1 file changed, 39 insertions(+)
>
> diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
> index 8844bbd39515..ff7df944ef53 100644
> --- a/drivers/nvme/host/ioctl.c
> +++ b/drivers/nvme/host/ioctl.c
> @@ -845,6 +845,43 @@ static int nvme_dev_user_cmd(struct nvme_ctrl *ctrl, void __user *argp,
> return ret;
> }
>
> +static int nvme_dev_user_cmd64(struct nvme_ctrl *ctrl, void __user *argp,
> + bool open_for_write)
> +{
> + struct nvme_ns *ns;
> + int ret, srcu_idx;
> +
> + srcu_idx = srcu_read_lock(&ctrl->srcu);
> + if (list_empty(&ctrl->namespaces)) {
> + ret = -ENOTTY;
> + goto out_unlock;
> + }
> +
> + ns = list_first_or_null_rcu(&ctrl->namespaces, struct nvme_ns, list);
> + if (ns != list_last_entry(&ctrl->namespaces, struct nvme_ns, list)) {
> + dev_warn(ctrl->device,
> + "NVME_IOCTL_IO64_CMD not supported when multiple namespaces present!\n");
> + ret = -EINVAL;
> + goto out_unlock;
> + }
> +
> + dev_warn(ctrl->device,
> + "using deprecated NVME_IOCTL_IO64_CMD ioctl on the char device!\n");
> + if (!nvme_get_ns(ns)) {
> + ret = -ENXIO;
> + goto out_unlock;
> + }
> + srcu_read_unlock(&ctrl->srcu, srcu_idx);
> +
> + ret = nvme_user_cmd64(ctrl, ns, argp, 0, open_for_write);
> + nvme_put_ns(ns);
> + return ret;
> +
> +out_unlock:
> + srcu_read_unlock(&ctrl->srcu, srcu_idx);
> + return ret;
> +}
> +
> long nvme_dev_ioctl(struct file *file, unsigned int cmd,
> unsigned long arg)
> {
> @@ -859,6 +896,8 @@ long nvme_dev_ioctl(struct file *file, unsigned int cmd,
> return nvme_user_cmd64(ctrl, NULL, argp, 0, open_for_write);
> case NVME_IOCTL_IO_CMD:
> return nvme_dev_user_cmd(ctrl, argp, open_for_write);
> + case NVME_IOCTL_IO64_CMD:
> + return nvme_dev_user_cmd64(ctrl, argp, open_for_write);
> case NVME_IOCTL_RESET:
> if (!capable(CAP_SYS_ADMIN))
> return -EACCES;
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] nvme/ioctl: allow 64-bit results in io-passthru command
2026-02-25 9:50 ` Maurizio Lombardi
@ 2026-03-01 5:14 ` Tokunori Ikegami
0 siblings, 0 replies; 3+ messages in thread
From: Tokunori Ikegami @ 2026-03-01 5:14 UTC (permalink / raw)
To: Maurizio Lombardi, linux-nvme
Just sent the v2 patch fixed as adviced. Thanks for your comment.
On 2026/02/25 18:50, Maurizio Lombardi wrote:
> On Tue Feb 24, 2026 at 7:51 PM CET, Tokunori Ikegami wrote:
>> Deprecated NVME_IOCTL_IO_CMD ioctl on the char device.
>> But nvme-cli still uses it and NVME_IOCTL_IO64_CMD for now.
>> So add NVME_IOCTL_IO64_CMD also to allow it.
>> Note: 32/62-bit ioctl duplicated code should be refactored.
> Indeed nvme_dev_user_cmd() seems identical.
>
> Wouldn't make sense to add a "bool is64bit" parameter to
> nvme_dev_user_cmd() and then just do
>
> if (is64bit)
> ret = nvme_user_cmd64(ctrl, ns, argp, 0, open_for_write);
> else
> ret = nvme_user_cmd(ctrl, ns, argp, 0, open_for_write);
>
> ?
>
> Maurizio
>
>> Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
>> ---
>> drivers/nvme/host/ioctl.c | 39 +++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 39 insertions(+)
>>
>> diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
>> index 8844bbd39515..ff7df944ef53 100644
>> --- a/drivers/nvme/host/ioctl.c
>> +++ b/drivers/nvme/host/ioctl.c
>> @@ -845,6 +845,43 @@ static int nvme_dev_user_cmd(struct nvme_ctrl *ctrl, void __user *argp,
>> return ret;
>> }
>>
>> +static int nvme_dev_user_cmd64(struct nvme_ctrl *ctrl, void __user *argp,
>> + bool open_for_write)
>> +{
>> + struct nvme_ns *ns;
>> + int ret, srcu_idx;
>> +
>> + srcu_idx = srcu_read_lock(&ctrl->srcu);
>> + if (list_empty(&ctrl->namespaces)) {
>> + ret = -ENOTTY;
>> + goto out_unlock;
>> + }
>> +
>> + ns = list_first_or_null_rcu(&ctrl->namespaces, struct nvme_ns, list);
>> + if (ns != list_last_entry(&ctrl->namespaces, struct nvme_ns, list)) {
>> + dev_warn(ctrl->device,
>> + "NVME_IOCTL_IO64_CMD not supported when multiple namespaces present!\n");
>> + ret = -EINVAL;
>> + goto out_unlock;
>> + }
>> +
>> + dev_warn(ctrl->device,
>> + "using deprecated NVME_IOCTL_IO64_CMD ioctl on the char device!\n");
>> + if (!nvme_get_ns(ns)) {
>> + ret = -ENXIO;
>> + goto out_unlock;
>> + }
>> + srcu_read_unlock(&ctrl->srcu, srcu_idx);
>> +
>> + ret = nvme_user_cmd64(ctrl, ns, argp, 0, open_for_write);
>> + nvme_put_ns(ns);
>> + return ret;
>> +
>> +out_unlock:
>> + srcu_read_unlock(&ctrl->srcu, srcu_idx);
>> + return ret;
>> +}
>> +
>> long nvme_dev_ioctl(struct file *file, unsigned int cmd,
>> unsigned long arg)
>> {
>> @@ -859,6 +896,8 @@ long nvme_dev_ioctl(struct file *file, unsigned int cmd,
>> return nvme_user_cmd64(ctrl, NULL, argp, 0, open_for_write);
>> case NVME_IOCTL_IO_CMD:
>> return nvme_dev_user_cmd(ctrl, argp, open_for_write);
>> + case NVME_IOCTL_IO64_CMD:
>> + return nvme_dev_user_cmd64(ctrl, argp, open_for_write);
>> case NVME_IOCTL_RESET:
>> if (!capable(CAP_SYS_ADMIN))
>> return -EACCES;
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-01 5:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-24 18:51 [PATCH] nvme/ioctl: allow 64-bit results in io-passthru command Tokunori Ikegami
2026-02-25 9:50 ` Maurizio Lombardi
2026-03-01 5:14 ` Tokunori Ikegami
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox