nvme: support I/O passthrough for multipath
cover nvme: support I/O passthrough for multipath
Hello,
This series is to support I/O passthrough for multipath I/O.
Currently driver exposes block device for the head namespace. Also, the path will be decided by the driver with the I/O policy defined to the actual hidden device based on ANA state. This means that userspace is not allowed to I/O passthrough to a specified namespace target which is hidden by the driver.
This series is to support passthrough to the namespace attached to a controller regardless to ANA state (e.g., inaccessible) and decided path by the driver.
Please review.
Thanks,
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
PATCH 1/1 nvme: introduce passthrough ioctl for multipath
We don't allow NVME_IOCTL_IO_CMD ioctl in case that a controller has multiple namespaces attached. Also, I/O request to the controller character device has not been recommended and deprecated because we have block device to I/O with where the multipath consideration is taken.
Once kernel decided a path to I/O for a namespace based on the I/O policy of a NVMe subsystem, userspace is not allowed to choose a path to I/O. If a path is broken(inaccessible state in ANA), then it will not try to I/O to that path.
This patch introduced NVME_IOCTL_MPATH_IO command for controller device(e.g., /dev/nvme0) to support multipath I/O passthrough for userspace. Regardless driver's path decision, userspace can target a namespace to I/O. In this case, cmd.nsid will be used to find out the namespace instance target which is hidden(e.g., nvmeXcYnZ).
--- drivers/nvme/host/core.c | 31 +++++++++++++++++++++++++++++++ include/uapi/linux/nvme_ioctl.h | 1 + 2 files changed, 32 insertions(+)
drivers/nvme/host/core.c +31 -0
@@ -1707,6 +1707,35 @@ static int nvme_user_cmd64(struct nvme_ctrl *ctrl, struct nvme_ns *ns,return status; } +#ifdef CONFIG_NVME_MULTIPATH +static int nvme_dev_mpath_cmd (struct nvme_ctrl *ctrl, +struct nvme_passthru_cmd __user *ucmd) +{ +struct nvme_passthru_cmd cmd; +struct nvme_ns *ns; + +if (!capable (CAP_SYS_ADMIN )) +return -EACCES ; +if (copy_from_user (&cmd, ucmd,sizeof (cmd))) +return -EFAULT ; + + ns =nvme_find_get_ns (ctrl, cmd.nsid); +if (unlikely (!ns)) +return -EINVAL ; +if (WARN_ON_ONCE (!(ns->disk->flags &GENHD_FL_HIDDEN ))) +return -EINVAL ; + +return nvme_user_cmd (ctrl, ns, ucmd); +} +#else +static int nvme_dev_mpath_cmd (struct nvme_ctrl *ctrl, +struct nvme_passthru_cmd __user *ucmd) +{ +dev_warn (ctrl->device,"CONFIG_NVME_MULTIPATH should be enabled\n" ); +return -EINVAL ; +} +#endif +/* * Issue ioctl requests on the first available path. Note that unlike normal * block layer requests we will not retry failed request on another controller.
@@ -3329,6 +3358,8 @@ static long nvme_dev_ioctl(struct file *file, unsigned int cmd,return nvme_user_cmd64 (ctrl,NULL , argp);case NVME_IOCTL_IO_CMD :return nvme_dev_user_cmd (ctrl, argp); +case NVME_IOCTL_MPATH_IO : +return nvme_dev_mpath_cmd (ctrl, argp);case NVME_IOCTL_RESET :dev_warn (ctrl->device,"resetting controller\n" );return nvme_reset_ctrl_sync (ctrl);
include/uapi/linux/nvme_ioctl.h +1 -0
@@ -78,5 +78,6 @@ struct nvme_passthru_cmd64 {#define NVME_IOCTL_RESCAN _IO('N', 0x46)#define NVME_IOCTL_ADMIN64_CMD _IOWR('N', 0x47, struct nvme_passthru_cmd64)#define NVME_IOCTL_IO64_CMD _IOWR('N', 0x48, struct nvme_passthru_cmd64) +#define NVME_IOCTL_MPATH_IO _IOWR('N', 0x49, struct nvme_passthru_cmd)#endif /* _UAPI_LINUX_NVME_IOCTL_H */
Signature · 7 lines
2.17.1 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
PATCH 1/1 nvme: add [--mpath|-M] option to io-passthru
In reply to Minwoo Imio-passthru command is to submit a I/O command to controller with a namespace specified. Kernel driver does not allow userspace to I/O passthrough in case that controller has multiple namespaces attached. NVME_IOCTL_IO_CMD will return -EINVAL error from the kernel driver.
This patch added an option --mpath|-M option to the io-passthru command to support specifying device namespace id to I/O. This option will make --namespace-id option to be used to find out the namespae instance to the kernel side even it's a hidden blkdev (e.g., /dev/nvmeXcYnZ).
This feature can be used to debug or test the broken path for ANA case by specifying the target namespace of a controller to I/O.
nvme io-passthru /dev/nvme0 --namespace-id=123 --opcode=0x2 --data-len=512 --read --mpath
--- linux/nvme_ioctl.h | 1 + nvme.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+)
linux/nvme_ioctl.h +1 -0
@@ -87,5 +87,6 @@ struct nvme_passthru_cmd64 {#define NVME_IOCTL_RESCAN _IO('N', 0x46)#define NVME_IOCTL_ADMIN64_CMD _IOWR('N', 0x47, struct nvme_passthru_cmd64)#define NVME_IOCTL_IO64_CMD _IOWR('N', 0x48, struct nvme_passthru_cmd64) +#define NVME_IOCTL_MPATH_IO _IOWR('N', 0x49, struct nvme_passthru_cmd)#endif /* _UAPI_LINUX_NVME_IOCTL_H */
nvme.c +20 -0
@@ -5109,6 +5109,7 @@ static int passthru(int argc, char **argv, int ioctl_cmd, const char *desc, struint read;int write;__u8 prefill; +bool mpath; };struct config cfg = {
@@ -5129,6 +5130,7 @@ static int passthru(int argc, char **argv, int ioctl_cmd, const char *desc, stru .cdw15 = 0, .input_file = "", .prefill = 0, + .mpath = false, };const char *opcode ="opcode (required)" ;
@@ -5153,6 +5155,7 @@ static int passthru(int argc, char **argv, int ioctl_cmd, const char *desc, struconst char *re ="set dataflow direction to receive" ;const char *wr ="set dataflow direction to send" ;const char *prefill ="prefill buffers with known byte-value, default 0" ; +const char *mpath ="multipath I/O (valid only if io-passthru)" ;OPT_ARGS (opts) = {OPT_BYTE ("opcode" ,'o' , &cfg.opcode, opcode),
@@ -5177,6 +5180,7 @@ static int passthru(int argc, char **argv, int ioctl_cmd, const char *desc, struOPT_FLAG ("dry-run" ,'d' , &cfg.dry_run, dry),OPT_FLAG ("read" ,'r' , &cfg.read, re),OPT_FLAG ("write" ,'w' , &cfg.write, wr), +OPT_FLAG ("mpath" ,'M' , &cfg.mpath, mpath), OPT_END() };
@@ -5184,6 +5188,22 @@ static int passthru(int argc, char **argv, int ioctl_cmd, const char *desc, struif (fd <0 ) goto ret; +if (cfg.mpath) { +if (!cfg.namespace_id) { +fprintf (stderr,"mpath should be with --namespace-id\n" ); + err = -EINVAL ; + goto close_fd; + } + +if (!is_chardev ()) { +fprintf (stderr,"mpath should be with chardev (e.g., /dev/nvme0)\n" ); + err = -EINVAL ; + goto close_fd; + } + + ioctl_cmd =NVME_IOCTL_MPATH_IO ; + } +if (strlen (cfg.input_file)){ wfd =open (cfg.input_file,O_RDONLY ,S_IRUSR |S_IRGRP |S_IROTH );
Signature · 7 lines
2.17.1 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Keith Busch
maintainerRe: [PATCH] nvme: introduce passthrough ioctl for multipath
In reply to Minwoo ImQuoted 10 lines · Minwoo Im
We don't allow
NVME_IOCTL_IO_CMDioctl in case that a controller has multiple namespaces attached. Also, I/O request to the controller character device has not been recommended and deprecated because we have block device to I/O with where the multipath consideration is taken.Once kernel decided a path to I/O for a namespace based on the I/O policy of a NVMe subsystem, userspace is not allowed to choose a path to I/O. If a path is broken(inaccessible state in ANA), then it will not try to I/O to that path.
Quoted 5 lines
This patch introduced
NVME_IOCTL_MPATH_IOcommand for controllerdevice(e.g., /dev/nvme0)to support multipath I/O passthrough for userspace. Regardless driver's path decision, userspace can target a namespace to I/O. In this case,cmd.nsidwill be used to find out the namespace instance target which ishidden(e.g., nvmeXcYnZ).
IO commands are not allowed through the character handle with the existing ioctls. A new ioctl doesn't make it okay. If it was okay, then we could just remove the limitation in the current ones.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Re: [PATCH] nvme: introduce passthrough ioctl for multipath
Quoted 17 lines · Keith Busch
Quoted 10 lines · Minwoo Im
We don't allow
NVME_IOCTL_IO_CMDioctl in case that a controller has multiple namespaces attached. Also, I/O request to the controller character device has not been recommended and deprecated because we have block device to I/O with where the multipath consideration is taken.Once kernel decided a path to I/O for a namespace based on the I/O policy of a NVMe subsystem, userspace is not allowed to choose a path to I/O. If a path is broken(inaccessible state in ANA), then it will not try to I/O to that path.
Quoted 5 lines
This patch introduced
NVME_IOCTL_MPATH_IOcommand for controllerdevice(e.g., /dev/nvme0)to support multipath I/O passthrough for userspace. Regardless driver's path decision, userspace can target a namespace to I/O. In this case,cmd.nsidwill be used to find out the namespace instance target which ishidden(e.g., nvmeXcYnZ).
Quoted 3 lines
IO commands are not allowed through the character handle with the existing ioctls. A new ioctl doesn't make it okay. If it was okay, then we could just remove the limitation in the current ones.
Thanks for your feedback, Keith. If you don't mind, may I ask why it's been entirely unsafe and deprecated in the exsiting ioctl(NVME_IOCTL_IO_CMD)? I've seen a patch bfd8947194b2 ("nvme: fixes for NVME_IOCTL_IO_CMD on the char device), but have no idea why it's been really depreacted :)
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Keith Busch
maintainerRe: [PATCH] nvme: introduce passthrough ioctl for multipath
Quoted 22 lines · Minwoo Im
Quoted 17 lines · Keith Busch
Quoted 10 lines · Minwoo Im
We don't allow
NVME_IOCTL_IO_CMDioctl in case that a controller has multiple namespaces attached. Also, I/O request to the controller character device has not been recommended and deprecated because we have block device to I/O with where the multipath consideration is taken.Once kernel decided a path to I/O for a namespace based on the I/O policy of a NVMe subsystem, userspace is not allowed to choose a path to I/O. If a path is broken(inaccessible state in ANA), then it will not try to I/O to that path.
Quoted 5 lines
This patch introduced
NVME_IOCTL_MPATH_IOcommand for controllerdevice(e.g., /dev/nvme0)to support multipath I/O passthrough for userspace. Regardless driver's path decision, userspace can target a namespace to I/O. In this case,cmd.nsidwill be used to find out the namespace instance target which ishidden(e.g., nvmeXcYnZ).Quoted 3 lines
IO commands are not allowed through the character handle with the existing ioctls. A new ioctl doesn't make it okay. If it was okay, then we could just remove the limitation in the current ones.
Quoted 5 lines
Thanks for your feedback, Keith. If you don't mind, may I ask why it's been entirely unsafe and deprecated in the exsiting
ioctl(NVME_IOCTL_IO_CMD)? I've seen a patchbfd8947194b2("nvme: fixes forNVME_IOCTL_IO_CMDon the char device), but have no idea why it's been really depreacted :)
A container could read data from namespaces assigned to a different container.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Re: [PATCH] nvme: introduce passthrough ioctl for multipath
Quoted 23 lines · Keith Busch
Quoted 22 lines · Minwoo Im
Quoted 20 lines · Keith Busch
Quoted 10 lines · Minwoo Im
We don't allow
NVME_IOCTL_IO_CMDioctl in case that a controller has multiple namespaces attached. Also, I/O request to the controller character device has not been recommended and deprecated because we have block device to I/O with where the multipath consideration is taken.Once kernel decided a path to I/O for a namespace based on the I/O policy of a NVMe subsystem, userspace is not allowed to choose a path to I/O. If a path is broken(inaccessible state in ANA), then it will not try to I/O to that path.
Quoted 5 lines
This patch introduced
NVME_IOCTL_MPATH_IOcommand for controllerdevice(e.g., /dev/nvme0)to support multipath I/O passthrough for userspace. Regardless driver's path decision, userspace can target a namespace to I/O. In this case,cmd.nsidwill be used to find out the namespace instance target which ishidden(e.g., nvmeXcYnZ).IO commands are not allowed through the character handle with the existing ioctls. A new ioctl doesn't make it okay. If it was okay, then we could just remove the limitation in the current ones.
Quoted 8 lines
Quoted 5 lines
Thanks for your feedback, Keith. If you don't mind, may I ask why it's been entirely unsafe and deprecated in the exsiting
ioctl(NVME_IOCTL_IO_CMD)? I've seen a patchbfd8947194b2("nvme: fixes forNVME_IOCTL_IO_CMDon the char device), but have no idea why it's been really depreacted :)A container could read data from namespaces assigned to a different container.
Now I got your point! Thanks Keith, please ignore this patch :)
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerRe: [PATCH] nvme: introduce passthrough ioctl for multipath
Quoted 4 lines · Minwoo Im
Quoted 2 lines
A container could read data from namespaces assigned to a different container.
Now I got your point! Thanks Keith, please ignore this patch :)
Note that Javier has been working on exposing access to namespaces with unsupported command sets for ioctls. If that is what you are looking for.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Re: [PATCH] nvme: introduce passthrough ioctl for multipath
Quoted 9 lines · Christoph Hellwig
Quoted 4 lines · Minwoo Im
Quoted 2 lines
A container could read data from namespaces assigned to a different container.
Now I got your point! Thanks Keith, please ignore this patch :)
Note that Javier has been working on exposing access to namespaces with unsupported command sets for ioctls. If that is what you are looking for.
Minwoo, I think this would apply good on top of the char device patches I posted a while ago. I have a multipath version working on top, but I am still working out a good way to expose in sysfs.
We can try to merge these and send the char device with multipath in the following days. This has been hanging on me more than I wanted it to...
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Re: [PATCH] nvme: introduce passthrough ioctl for multipath
In reply to Christoph HellwigQuoted 9 lines · Christoph Hellwig
Quoted 4 lines · Minwoo Im
Quoted 2 lines
A container could read data from namespaces assigned to a different container.
Now I got your point! Thanks Keith, please ignore this patch :)
Note that Javier has been working on exposing access to namespaces with unsupported command sets for ioctls. If that is what you are looking for.
Thank you for the information!
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Re: [PATCH] nvme: introduce passthrough ioctl for multipath
In reply to Javier GonzálezQuoted 11 lines · Javier González
Quoted 9 lines · Christoph Hellwig
Quoted 4 lines · Minwoo Im
Quoted 2 lines
A container could read data from namespaces assigned to a different container.
Now I got your point! Thanks Keith, please ignore this patch :)
Note that Javier has been working on exposing access to namespaces with unsupported command sets for ioctls. If that is what you are looking for.
Quoted 6 lines
Minwoo, I think this would apply good on top of the char device patches I posted a while ago. I have a multipath version working on top, but I am still working out a good way to expose in sysfs.
We can try to merge these and send the char device with multipath in the following days. This has been hanging on me more than I wanted it to...
Thanks Javier, That sounds cool. will have a look at your patch first!
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme