Skip to contentSkip to conversation

Add a parameter for NVME_IOCTL_ID to get Namespaces ID

PATCH New Zou Ming 2 participants 7 messages May 18, 2017 – May 23, 2017 NVMe

lore
Share & tools
lore

Zou Ming

author
#0 lore raw

PATCH 1/1 Add a parameter for NVME_IOCTL_ID to get Namespaces ID

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(-)
drivers/nvme/host/core.c +1 -2
index 3818ff6..886a031 100644
@@ -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:
include/uapi/linux/nvme_ioctl.h +1 -1
index 50ff21f..71eb8fd 100644
@@ -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)
Signature · 1 line
2.6.4.windows.1
#1 lore raw

PATCH 1/1 Add a parameter for NVME_IOCTL_ID to get Namespaces ID

Quoted 11 lines · Zou Ming

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(-)
drivers/nvme/host/core.c +0 -0
index 3818ff6..886a031 100644

drivers/nvme/host/core.c static int nvme_ioctl(struct block_device *bdev, fmode_t mode, · line 772

Quoted 6 lines
drivers/nvme/host/core.c +1 -2
@@ -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..

#2 lore raw

PATCH 1/1 Add a parameter for NVME_IOCTL_ID to get Namespaces ID

Quoted 6 lines

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?

#3 lore raw

PATCH 1/1 Add a parameter for NVME_IOCTL_ID to get Namespaces ID

I can't see how it would fail. But if you're worried about thast case use the nsid sysfs attribute instead.

#4 lore raw

PATCH 1/1 Add a parameter for NVME_IOCTL_ID to get Namespaces ID

In reply to Zouming (IT)
Quoted 6 lines · Zouming (IT)

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..

#5 lore raw

PATCH 1/1 Add a parameter for NVME_IOCTL_ID to get Namespaces ID

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.

Quoted 16 lines · Christoph Hellwig
Quoted 6 lines · Zouming (IT)

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..

.

#6 lore raw

PATCH 1/1 Add a parameter for NVME_IOCTL_ID to get Namespaces ID

Quoted 5 lines · Zouming (IT)

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.