* [PATCH] Add a parameter for NVME_IOCTL_ID to get Namespaces ID
@ 2017-05-18 4:17 Zou Ming
2017-05-18 6:38 ` Christoph Hellwig
0 siblings, 1 reply; 7+ messages in thread
From: Zou Ming @ 2017-05-18 4:17 UTC (permalink / raw)
For distinguish return value,add a parameter for NVME_IOCTL_ID to get Namespaces ID.
---
drivers/nvme/host/core.c | 3 +--
include/uapi/linux/nvme_ioctl.h | 2 +-
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 3818ff6..886a031 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -769,8 +769,7 @@ static int nvme_ioctl(struct block_device *bdev, fmode_t mode,
switch (cmd) {
case NVME_IOCTL_ID:
- force_successful_syscall_return();
- return ns->ns_id;
+ return put_user(ns->ns_id, (__u32 __user *)arg);
case NVME_IOCTL_ADMIN_CMD:
return nvme_user_cmd(ns->ctrl, NULL, (void __user *)arg);
case NVME_IOCTL_IO_CMD:
diff --git a/include/uapi/linux/nvme_ioctl.h b/include/uapi/linux/nvme_ioctl.h
index 50ff21f..71eb8fd 100644
--- a/include/uapi/linux/nvme_ioctl.h
+++ b/include/uapi/linux/nvme_ioctl.h
@@ -55,7 +55,7 @@ struct nvme_passthru_cmd {
#define nvme_admin_cmd nvme_passthru_cmd
-#define NVME_IOCTL_ID _IO('N', 0x40)
+#define NVME_IOCTL_ID _IO('N', 0x40, __u32)
#define NVME_IOCTL_ADMIN_CMD _IOWR('N', 0x41, struct nvme_admin_cmd)
#define NVME_IOCTL_SUBMIT_IO _IOW('N', 0x42, struct nvme_user_io)
#define NVME_IOCTL_IO_CMD _IOWR('N', 0x43, struct nvme_passthru_cmd)
--
2.6.4.windows.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH] Add a parameter for NVME_IOCTL_ID to get Namespaces ID
2017-05-18 4:17 [PATCH] Add a parameter for NVME_IOCTL_ID to get Namespaces ID Zou Ming
@ 2017-05-18 6:38 ` Christoph Hellwig
2017-05-18 7:14 ` Zouming (IT)
0 siblings, 1 reply; 7+ messages in thread
From: Christoph Hellwig @ 2017-05-18 6:38 UTC (permalink / raw)
On Thu, May 18, 2017@04:17:41AM +0000, Zou Ming wrote:
> For distinguish return value,add a parameter for NVME_IOCTL_ID to get Namespaces ID.
> ---
> drivers/nvme/host/core.c | 3 +--
> include/uapi/linux/nvme_ioctl.h | 2 +-
> 2 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 3818ff6..886a031 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -769,8 +769,7 @@ static int nvme_ioctl(struct block_device *bdev, fmode_t mode,
>
> switch (cmd) {
> case NVME_IOCTL_ID:
> - force_successful_syscall_return();
> - return ns->ns_id;
> + return put_user(ns->ns_id, (__u32 __user *)arg);
This break any existing user. I also don't really understand the
problem you're trying to solve..
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] Add a parameter for NVME_IOCTL_ID to get Namespaces ID
2017-05-18 6:38 ` Christoph Hellwig
@ 2017-05-18 7:14 ` Zouming (IT)
2017-05-18 13:39 ` Christoph Hellwig
2017-05-21 8:34 ` Christoph Hellwig
0 siblings, 2 replies; 7+ messages in thread
From: Zouming (IT) @ 2017-05-18 7:14 UTC (permalink / raw)
> This break any existing user. I also don't really understand the
> problem you're trying to solve..
>
> .
>
The problem trying to solve is below:
1?According to nvme spec, the possible range of Namespaces ID is form 1 to FFFFFFFe
2?When use NVME_IOCTL_ID IOCTL cmd to get namespaces ID?if return error before function nvme_ioctl?
How can user distinguish the return value is valid namespaces ID or error value?
Do you think this situation exsits or there will never fail when use NVME_IOCTL_ID cmd?
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] Add a parameter for NVME_IOCTL_ID to get Namespaces ID
2017-05-18 7:14 ` Zouming (IT)
@ 2017-05-18 13:39 ` Christoph Hellwig
2017-05-21 8:34 ` Christoph Hellwig
1 sibling, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2017-05-18 13:39 UTC (permalink / raw)
I can't see how it would fail. But if you're worried about thast case
use the nsid sysfs attribute instead.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] Add a parameter for NVME_IOCTL_ID to get Namespaces ID
2017-05-18 7:14 ` Zouming (IT)
2017-05-18 13:39 ` Christoph Hellwig
@ 2017-05-21 8:34 ` Christoph Hellwig
2017-05-22 7:51 ` Zouming (IT)
1 sibling, 1 reply; 7+ messages in thread
From: Christoph Hellwig @ 2017-05-21 8:34 UTC (permalink / raw)
On Thu, May 18, 2017@03:14:23PM +0800, Zouming (IT) wrote:
> The problem trying to solve is below:
> 1?According to nvme spec, the possible range of Namespaces ID is form 1 to FFFFFFFe
> 2?When use NVME_IOCTL_ID IOCTL cmd to get namespaces ID?if return error before function nvme_ioctl?
> How can user distinguish the return value is valid namespaces ID or error value?
>
> Do you think this situation exsits or there will never fail when use NVME_IOCTL_ID cmd?
NVME_IOCTL_ID can't fail in the NVMe driver itself, but it can fail
because the device isn't a NVMe device or a security module rejected it.
So you'd have to add a new ioctl additional ioctl that copies it out.
Or just use the sysfs file..
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] Add a parameter for NVME_IOCTL_ID to get Namespaces ID
2017-05-21 8:34 ` Christoph Hellwig
@ 2017-05-22 7:51 ` Zouming (IT)
2017-05-23 7:29 ` Christoph Hellwig
0 siblings, 1 reply; 7+ messages in thread
From: Zouming (IT) @ 2017-05-22 7:51 UTC (permalink / raw)
Hi,Christoph
Thank you for your detailed response to the fail scenario.
Using the ioctl method to get namespace id is easier than using the sysfs file method when only the nvme device's handle is available.
So I want to add a new ioctl name called NVME_IOCTL_NS_ID,Is that OK?
Best regards,
Zou Ming.
On 2017/5/21 16:34, Christoph Hellwig wrote:
> On Thu, May 18, 2017@03:14:23PM +0800, Zouming (IT) wrote:
>> The problem trying to solve is below:
>> 1?According to nvme spec, the possible range of Namespaces ID is form 1 to FFFFFFFe
>> 2?When use NVME_IOCTL_ID IOCTL cmd to get namespaces ID?if return error before function nvme_ioctl?
>> How can user distinguish the return value is valid namespaces ID or error value?
>>
>> Do you think this situation exsits or there will never fail when use NVME_IOCTL_ID cmd?
>
> NVME_IOCTL_ID can't fail in the NVMe driver itself, but it can fail
> because the device isn't a NVMe device or a security module rejected it.
>
> So you'd have to add a new ioctl additional ioctl that copies it out.
> Or just use the sysfs file..
>
> .
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] Add a parameter for NVME_IOCTL_ID to get Namespaces ID
2017-05-22 7:51 ` Zouming (IT)
@ 2017-05-23 7:29 ` Christoph Hellwig
0 siblings, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2017-05-23 7:29 UTC (permalink / raw)
On Mon, May 22, 2017@03:51:43PM +0800, Zouming (IT) wrote:
> Hi,Christoph
>
> Thank you for your detailed response to the fail scenario.
> Using the ioctl method to get namespace id is easier than using the sysfs file method when only the nvme device's handle is available.
> So I want to add a new ioctl name called NVME_IOCTL_NS_ID,Is that OK?
I'm still not sold too much on adding a new ioctl, but IFF we do it that
would be the way.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-05-23 7:29 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-18 4:17 [PATCH] Add a parameter for NVME_IOCTL_ID to get Namespaces ID Zou Ming
2017-05-18 6:38 ` Christoph Hellwig
2017-05-18 7:14 ` Zouming (IT)
2017-05-18 13:39 ` Christoph Hellwig
2017-05-21 8:34 ` Christoph Hellwig
2017-05-22 7:51 ` Zouming (IT)
2017-05-23 7:29 ` Christoph Hellwig
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).