nvme ioctl refactor and generic per-namespace char device
Christoph Hellwig
maintainerHi all,
this series picks up the generic per-namespace character device from Minwoo and Javier with a few small fixed, but rebases them on an ioctl refactoring I had pending, which cleans up a lot of the lower level code.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerPATCH 1/13 nvme: add a nvme_ns_head_multipath helper
From: Minwoo Im <[email protected]>
Move the multipath gendisk out of #ifdef CONFIG_NVME_MULTIPATH and add a new nvme_ns_head_multipath that uses it to check if a ns_head has a multipath device associated with it.
--- drivers/nvme/host/core.c | 8 ++------ drivers/nvme/host/nvme.h | 7 ++++++- 2 files changed, 8 insertions(+), 7 deletions(-)
drivers/nvme/host/core.c +2 -6
@@ -1873,11 +1873,9 @@ static int nvme_open(struct block_device *bdev, fmode_t mode) {struct nvme_ns *ns = bdev->bd_disk->private_data; -#ifdef CONFIG_NVME_MULTIPATH /* should never be called due to GENHD_FL_HIDDEN */ -if (WARN_ON_ONCE (ns->head->disk)) +if (WARN_ON_ONCE (nvme_ns_head_multipath (ns->head))) goto fail; -#endif if (!kref_get_unless_zero (&ns->kref)) goto fail;if (!try_module_get (ns->ctrl->ops->module))
@@ -2215,8 +2213,7 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id)return ret; } -#ifdef CONFIG_NVME_MULTIPATH -if (ns->head->disk) { +if (nvme_ns_head_multipath (ns->head)) {blk_mq_freeze_queue (ns->head->disk->queue);nvme_update_disk_info (ns->head->disk, ns, id); blk_stack_limits(&ns->head->disk->queue->limits,
@@ -2224,7 +2221,6 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id)blk_queue_update_readahead (ns->head->disk->queue);blk_mq_unfreeze_queue (ns->head->disk->queue); } -#endif return 0 ; out_unfreeze:
drivers/nvme/host/nvme.h +6 -1
@@ -413,8 +413,8 @@ struct nvme_ns_head {bool shared;int instance;struct nvme_effects_log *effects; -#ifdef CONFIG_NVME_MULTIPATH struct gendisk *disk; +#ifdef CONFIG_NVME_MULTIPATH struct bio_list requeue_list;spinlock_t requeue_lock;struct work_struct requeue_work;
@@ -425,6 +425,11 @@ struct nvme_ns_head {#endif }; +static inline bool nvme_ns_head_multipath (struct nvme_ns_head *head) +{ +return IS_ENABLED (CONFIG_NVME_MULTIPATH ) && head->disk; +} +enum nvme_ns_features {NVME_NS_EXT_LBAS =1 <<0 ,/* support extended LBA format */ NVME_NS_METADATA_SUPPORTED =1 <<1 ,/* support getting generated md */
Signature · 7 lines
2.30.1 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Re: [PATCH 01/13] nvme: add a nvme_ns_head_multipath helper
Quoted 9 lines · Christoph Hellwig
From: Minwoo Im <[email protected]>
Move the multipath gendisk out of #ifdef
CONFIG_NVME_MULTIPATHand add a newnvme_ns_head_multipaththat uses it to check if ans_headhas a multipath device associated with it.Signed-off-by Minwoo Im <[email protected]>[hch: added the IS_ENABLED, converted a few existing users]Signed-off-by Christoph Hellwig <[email protected]>
Looks good.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerPATCH 2/13 nvme: cleanup setting the disk name
In reply to Christoph HellwigReturn false from nvme_set_disk_name and let the caller set the non-multipath name instead of duplicating the naming information in two places. Also remove the pointless local variables for the disk name and flags and the not needed ctrl argument.
--- drivers/nvme/host/core.c | 17 +++++++++++------ drivers/nvme/host/multipath.c | 24 ++++++++++++------------ drivers/nvme/host/nvme.h | 14 ++++---------- 3 files changed, 27 insertions(+), 28 deletions(-)
drivers/nvme/host/core.c +11 -6
@@ -3998,8 +3998,7 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid,struct nvme_ns *ns;struct gendisk *disk;struct nvme_id_ns *id; -char disk_name[DISK_NAME_LEN ]; -int node = ctrl->numa_node, flags =GENHD_FL_EXT_DEVT ; +int node = ctrl->numa_node;if (nvme_identify_ns (ctrl, nsid, ids, &id))return ;
@@ -4025,7 +4024,6 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid,if (nvme_init_ns_head (ns, nsid, ids, id->nmic &NVME_NS_NMIC_SHARED )) goto out_free_queue; -nvme_set_disk_name (disk_name, ns, ctrl, &flags); disk =alloc_disk_node (0 , node);if (!disk)
@@ -4034,15 +4032,22 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid, disk->fops = &nvme_bdev_ops; disk->private_data = ns; disk->queue = ns->queue; - disk->flags = flags; -memcpy (disk->disk_name, disk_name,DISK_NAME_LEN ); + disk->flags =GENHD_FL_EXT_DEVT ; +/* +* Without the multipath code enabled, multiple controller per +* subsystems are visible as devices and thus we cannot use the +* subsystem instance. +*/ +if (!nvme_mpath_set_disk_name (ns, disk->disk_name, &disk->flags)) +sprintf (disk->disk_name,"nvme%dn%d" , ctrl->instance, + ns->head->instance); ns->disk = disk;if (nvme_update_ns_info (ns, id)) goto out_put_disk;if ((ctrl->quirks &NVME_QUIRK_LIGHTNVM ) && id->vs[0 ] ==0x1 ) { -if (nvme_nvm_register (ns, disk_name, node)) { +if (nvme_nvm_register (ns, disk->disk_name, node)) {dev_warn (ctrl->device,"LightNVM init failure\n" ); goto out_put_disk; }
drivers/nvme/host/multipath.c +12 -12
@@ -50,19 +50,19 @@ void nvme_mpath_start_freeze(struct nvme_subsystem *subsys)* and those that have a single controller and use the controller node * directly. */ -void nvme_set_disk_name (char *disk_name,struct nvme_ns *ns, -struct nvme_ctrl *ctrl,int *flags) -{ -if (!multipath) { -sprintf (disk_name,"nvme%dn%d" , ctrl->instance, ns->head->instance); - }else if (ns->head->disk) { -sprintf (disk_name,"nvme%dc%dn%d" , ctrl->subsys->instance, - ctrl->instance, ns->head->instance); - *flags =GENHD_FL_HIDDEN ; - }else { -sprintf (disk_name,"nvme%dn%d" , ctrl->subsys->instance, - ns->head->instance); +bool nvme_mpath_set_disk_name (struct nvme_ns *ns,char *disk_name,int *flags) +{ +if (!multipath) +return false; +if (!ns->head->disk) { +sprintf (disk_name,"nvme%dn%d" , ns->ctrl->subsys->instance, + ns->head->instance); +return true; } +sprintf (disk_name,"nvme%dc%dn%d" , ns->ctrl->subsys->instance, + ns->ctrl->instance, ns->head->instance); + *flags =GENHD_FL_HIDDEN ; +return true; }void nvme_failover_req (struct request *req)
drivers/nvme/host/nvme.h +4 -10
@@ -668,8 +668,7 @@ static inline bool nvme_ctrl_use_ana(struct nvme_ctrl *ctrl)void nvme_mpath_unfreeze (struct nvme_subsystem *subsys);void nvme_mpath_wait_freeze (struct nvme_subsystem *subsys);void nvme_mpath_start_freeze (struct nvme_subsystem *subsys); -void nvme_set_disk_name (char *disk_name,struct nvme_ns *ns, -struct nvme_ctrl *ctrl,int *flags); +bool nvme_mpath_set_disk_name (struct nvme_ns *ns,char *disk_name,int *flags);void nvme_failover_req (struct request *req);void nvme_kick_requeue_lists (struct nvme_ctrl *ctrl);int nvme_mpath_alloc_disk (struct nvme_ctrl *ctrl,struct nvme_ns_head *head);
@@ -708,16 +707,11 @@ static inline bool nvme_ctrl_use_ana(struct nvme_ctrl *ctrl) {return false; } -/* -* Without the multipath code enabled, multiple controller per subsystems are -* visible as devices and thus we cannot use the subsystem instance. -*/ -static inline void nvme_set_disk_name (char *disk_name,struct nvme_ns *ns, -struct nvme_ctrl *ctrl,int *flags) +static inline bool nvme_mpath_set_disk_name (struct nvme_ns *ns,char *disk_name, +int *flags) { -sprintf (disk_name,"nvme%dn%d" , ctrl->instance, ns->head->instance); +return false; } -static inline void nvme_failover_req (struct request *req) { }
Signature · 7 lines
2.30.1 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerPATCH 3/13 nvme: pass a user pointer to nvme_nvm_ioctl
In reply to Christoph HellwigPass the proper user pointer instead of the not all that useful integer representation.
--- drivers/nvme/host/core.c | 2 +- drivers/nvme/host/lightnvm.c | 8 ++++---- drivers/nvme/host/nvme.h | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-)
drivers/nvme/host/core.c +1 -1
@@ -1819,7 +1819,7 @@ static int nvme_ioctl(struct block_device *bdev, fmode_t mode,break ;default :if (ns->ndev) - ret =nvme_nvm_ioctl (ns, cmd, arg); + ret =nvme_nvm_ioctl (ns, cmd, argp);else ret = -ENOTTY ; }
drivers/nvme/host/lightnvm.c +4 -4
@@ -930,15 +930,15 @@ static int nvme_nvm_user_vcmd(struct nvme_ns *ns, int admin,return ret; } -int nvme_nvm_ioctl (struct nvme_ns *ns,unsigned int cmd,unsigned long arg) +int nvme_nvm_ioctl (struct nvme_ns *ns,unsigned int cmd,void __user *argp) {switch (cmd) {case NVME_NVM_IOCTL_ADMIN_VIO : -return nvme_nvm_user_vcmd (ns,1 , (void __user *)arg); +return nvme_nvm_user_vcmd (ns,1 , argp);case NVME_NVM_IOCTL_IO_VIO : -return nvme_nvm_user_vcmd (ns,0 , (void __user *)arg); +return nvme_nvm_user_vcmd (ns,0 , argp);case NVME_NVM_IOCTL_SUBMIT_VIO : -return nvme_nvm_submit_vio (ns, (void __user *)arg); +return nvme_nvm_submit_vio (ns, argp);default :return -ENOTTY ; }
drivers/nvme/host/nvme.h +2 -2
@@ -799,7 +799,7 @@ static inline int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf)int nvme_nvm_register (struct nvme_ns *ns,char *disk_name,int node);void nvme_nvm_unregister (struct nvme_ns *ns);extern const struct attribute_group nvme_nvm_attr_group; -int nvme_nvm_ioctl (struct nvme_ns *ns,unsigned int cmd,unsigned long arg); +int nvme_nvm_ioctl (struct nvme_ns *ns,unsigned int cmd,void __user *argp);#else static inline int nvme_nvm_register (struct nvme_ns *ns,char *disk_name,int node)
@@ -809,7 +809,7 @@ static inline int nvme_nvm_register(struct nvme_ns *ns, char *disk_name,static inline void nvme_nvm_unregister (struct nvme_ns *ns) {};static inline int nvme_nvm_ioctl (struct nvme_ns *ns,unsigned int cmd, -unsigned long arg) +void __user *argp) {return -ENOTTY ; }
Signature · 7 lines
2.30.1 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerPATCH 4/13 nvme: factor out a nvme_ns_ioctl helper
In reply to Christoph HellwigFactor out a helper for the namespace based ioctls.
--- drivers/nvme/host/core.c | 42 ++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 21 deletions(-)
drivers/nvme/host/core.c +21 -21
@@ -1783,6 +1783,26 @@ static int nvme_handle_ctrl_ioctl(struct nvme_ns *ns, unsigned int cmd,return ret; } +static int nvme_ns_ioctl (struct nvme_ns *ns,unsigned int cmd, +void __user *argp) +{ +switch (cmd) { +case NVME_IOCTL_ID : +force_successful_syscall_return (); +return ns->head->ns_id; +case NVME_IOCTL_IO_CMD : +return nvme_user_cmd (ns->ctrl, ns, argp); +case NVME_IOCTL_SUBMIT_IO : +return nvme_submit_io (ns, argp); +case NVME_IOCTL_IO64_CMD : +return nvme_user_cmd64 (ns->ctrl, ns, argp); +default : +if (!ns->ndev) +return -ENOTTY ; +return nvme_nvm_ioctl (ns, cmd, argp); + } +} +static int nvme_ioctl (struct block_device *bdev,fmode_t mode,unsigned int cmd,unsigned long arg) {
@@ -1803,27 +1823,7 @@ static int nvme_ioctl(struct block_device *bdev, fmode_t mode,if (is_ctrl_ioctl (cmd))return nvme_handle_ctrl_ioctl (ns, cmd, argp, head, srcu_idx); -switch (cmd) { -case NVME_IOCTL_ID : -force_successful_syscall_return (); - ret = ns->head->ns_id; -break ; -case NVME_IOCTL_IO_CMD : - ret =nvme_user_cmd (ns->ctrl, ns, argp); -break ; -case NVME_IOCTL_SUBMIT_IO : - ret =nvme_submit_io (ns, argp); -break ; -case NVME_IOCTL_IO64_CMD : - ret =nvme_user_cmd64 (ns->ctrl, ns, argp); -break ; -default : -if (ns->ndev) - ret =nvme_nvm_ioctl (ns, cmd, argp); -else - ret = -ENOTTY ; - } - + ret =nvme_ns_ioctl (ns, cmd, argp);nvme_put_ns_from_disk (head, srcu_idx);return ret; }
Signature · 7 lines
2.30.1 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Re: [PATCH 04/13] nvme: factor out a nvme_ns_ioctl helper
Quoted 3 lines · Christoph Hellwig
Factor out a helper for the namespace based ioctls.
Signed-off-by Christoph Hellwig <[email protected]>
Looks good.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerPATCH 5/13 nvme: simplify the compat ioctl handling
In reply to Christoph HellwigDon't bother defining a separate compat_ioctl handler, and just handle the NVME_IOCTL_SUBMIT_IO32 case inline. Also only defined it for those ABIs (currently just i386 vs x86_64) that are affected.
--- drivers/nvme/host/core.c | 69 +++++++++++++++------------------------- 1 file changed, 26 insertions(+), 43 deletions(-)
drivers/nvme/host/core.c +26 -43
@@ -1783,6 +1783,24 @@ static int nvme_handle_ctrl_ioctl(struct nvme_ns *ns, unsigned int cmd,return ret; } +#ifdef COMPAT_FOR_U64_ALIGNMENT +struct nvme_user_io32 { +__u8 opcode; +__u8 flags; +__u16 control; +__u16 nblocks; +__u16 rsvd; +__u64 metadata; +__u64 addr; +__u64 slba; +__u32 dsmgmt; +__u32 reftag; +__u16 apptag; +__u16 appmask; +} __attribute__((__packed__ )); +#define NVME_IOCTL_SUBMIT_IO32 _IOW('N', 0x42, struct nvme_user_io32) +#endif /* COMPAT_FOR_U64_ALIGNMENT */ +static int nvme_ns_ioctl (struct nvme_ns *ns,unsigned int cmd,void __user *argp) {
@@ -1792,6 +1810,14 @@ static int nvme_ns_ioctl(struct nvme_ns *ns, unsigned int cmd,return ns->head->ns_id;case NVME_IOCTL_IO_CMD :return nvme_user_cmd (ns->ctrl, ns, argp); +/* +* struct nvme_user_io can has different padding on some 32-bit ABIs. +* Just accept the compat version as all fields that are used are the +* same size and at the same offset. +*/ +#ifdef COMPAT_FOR_U64_ALIGNMENT +case NVME_IOCTL_SUBMIT_IO32 : +#endif case NVME_IOCTL_SUBMIT_IO :return nvme_submit_io (ns, argp);case NVME_IOCTL_IO64_CMD :
@@ -1828,47 +1854,6 @@ static int nvme_ioctl(struct block_device *bdev, fmode_t mode,return ret; } -#ifdef CONFIG_COMPAT -struct nvme_user_io32 { -__u8 opcode; -__u8 flags; -__u16 control; -__u16 nblocks; -__u16 rsvd; -__u64 metadata; -__u64 addr; -__u64 slba; -__u32 dsmgmt; -__u32 reftag; -__u16 apptag; -__u16 appmask; -} __attribute__((__packed__ )); - -#define NVME_IOCTL_SUBMIT_IO32 _IOW('N', 0x42, struct nvme_user_io32) - -static int nvme_compat_ioctl (struct block_device *bdev,fmode_t mode, -unsigned int cmd,unsigned long arg) -{ -/* -* Corresponds to the difference of NVME_IOCTL_SUBMIT_IO -* between 32 bit programs and 64 bit kernel. -* The cause is that the results of sizeof(struct nvme_user_io), -* which is used to define NVME_IOCTL_SUBMIT_IO, -* are not same between 32 bit compiler and 64 bit compiler. -* NVME_IOCTL_SUBMIT_IO32 is for 64 bit kernel handling -* NVME_IOCTL_SUBMIT_IO issued from 32 bit programs. -* Other IOCTL numbers are same between 32 bit and 64 bit. -* So there is nothing to do regarding to other IOCTL numbers. -*/ -if (cmd ==NVME_IOCTL_SUBMIT_IO32 ) -return nvme_ioctl (bdev, mode,NVME_IOCTL_SUBMIT_IO , arg); - -return nvme_ioctl (bdev, mode, cmd, arg); -} -#else -#define nvme_compat_ioctl NULL -#endif /* CONFIG_COMPAT */ -static int nvme_open (struct block_device *bdev,fmode_t mode) {struct nvme_ns *ns = bdev->bd_disk->private_data;
@@ -2356,7 +2341,6 @@ EXPORT_SYMBOL_GPL(nvme_sec_submit);static const struct block_device_operations nvme_bdev_ops = { .owner =THIS_MODULE , .ioctl = nvme_ioctl, - .compat_ioctl = nvme_compat_ioctl, .open = nvme_open, .release = nvme_release, .getgeo = nvme_getgeo,
@@ -2385,7 +2369,6 @@ const struct block_device_operations nvme_ns_head_ops = { .open = nvme_ns_head_open, .release = nvme_ns_head_release, .ioctl = nvme_ioctl, - .compat_ioctl = nvme_compat_ioctl, .getgeo = nvme_getgeo, .report_zones = nvme_report_zones, .pr_ops = &nvme_pr_ops,
Signature · 7 lines
2.30.1 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Re: [PATCH 05/13] nvme: simplify the compat ioctl handling
drivers/nvme/host/core.c static int nvme_ns_ioctl(struct nvme_ns *ns, unsigned int cmd, · line 1814
Quoted 1 line · Christoph Hellwig
drivers/nvme/host/core.c +1
-0+* struct nvme_user_io can has different padding on some 32-bit ABIs.
s/can has/can have/ ?
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerRe: [PATCH 05/13] nvme: simplify the compat ioctl handling
Quoted 4 lines · Chaitanya Kulkarni
drivers/nvme/host/core.c static int nvme_ns_ioctl(struct nvme_ns *ns, unsigned int cmd, · line 1814
Quoted 1 line · Christoph Hellwig
drivers/nvme/host/core.c +1
-0+* struct nvme_user_io can has different padding on some 32-bit ABIs. s/can has/can have/ ?
Yes.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerPATCH 6/13 nvme: simplify block device ioctl handling for the !multipath case
In reply to Christoph HellwigOnly use the existing ioctl handler for the multipath case, and add a simpler one that reverts to the pre-multipath case for not shared use case.
--- drivers/nvme/host/core.c | 83 +++++++++++++++++++++++----------------- 1 file changed, 47 insertions(+), 36 deletions(-)
drivers/nvme/host/core.c +47 -36
@@ -1757,30 +1757,17 @@ static bool is_ctrl_ioctl(unsigned int cmd)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) +static int nvme_ctrl_ioctl (struct nvme_ctrl *ctrl,unsigned int cmd, +void __user *argp) { -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 ; +return nvme_user_cmd (ctrl,NULL , argp);case NVME_IOCTL_ADMIN64_CMD : - ret =nvme_user_cmd64 (ctrl,NULL , argp); -break ; +return nvme_user_cmd64 (ctrl,NULL , argp);default : - ret =sed_ioctl (ctrl->opal_dev, cmd, argp); -break ; +return sed_ioctl (ctrl->opal_dev, cmd, argp); } -nvme_put_ctrl (ctrl); -return ret; }#ifdef COMPAT_FOR_U64_ALIGNMENT
@@ -1832,26 +1819,12 @@ static int nvme_ns_ioctl(struct nvme_ns *ns, unsigned int cmd,static int nvme_ioctl (struct block_device *bdev,fmode_t mode,unsigned int cmd,unsigned long arg) { -struct nvme_ns_head *head =NULL ; +struct nvme_ns *ns = bdev->bd_disk->private_data;void __user *argp = (void __user *)arg; -struct nvme_ns *ns; -int srcu_idx, ret; - - ns =nvme_get_ns_from_disk (bdev->bd_disk, &head, &srcu_idx); -if (unlikely (!ns)) -return -EWOULDBLOCK ; -/* -* Handle ioctls that apply to the controller instead of the namespace -* seperately and drop the ns SRCU reference early. This avoids a -* deadlock when deleting namespaces using the passthrough interface. -*/ if (is_ctrl_ioctl (cmd)) -return nvme_handle_ctrl_ioctl (ns, cmd, argp, head, srcu_idx); - - ret =nvme_ns_ioctl (ns, cmd, argp); -nvme_put_ns_from_disk (head, srcu_idx); -return ret; +return nvme_ctrl_ioctl (ns->ctrl, cmd, argp); +return nvme_ns_ioctl (ns, cmd, argp); }static int nvme_open (struct block_device *bdev,fmode_t mode)
@@ -2363,12 +2336,50 @@ static void nvme_ns_head_release(struct gendisk *disk, fmode_t mode)nvme_put_ns_head (disk->private_data); } +static int nvme_ns_head_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); + ret =nvme_ctrl_ioctl (ns->ctrl, cmd, argp); +nvme_put_ctrl (ctrl); +return ret; +} + +static int nvme_ns_head_ioctl (struct block_device *bdev,fmode_t mode, +unsigned int cmd,unsigned long arg) +{ +struct nvme_ns_head *head =NULL ; +void __user *argp = (void __user *)arg; +struct nvme_ns *ns; +int srcu_idx, ret; + + ns =nvme_get_ns_from_disk (bdev->bd_disk, &head, &srcu_idx); +if (unlikely (!ns)) +return -EWOULDBLOCK ; + +/* +* Handle ioctls that apply to the controller instead of the namespace +* seperately and drop the ns SRCU reference early. This avoids a +* deadlock when deleting namespaces using the passthrough interface. +*/ +if (is_ctrl_ioctl (cmd)) +return nvme_ns_head_ctrl_ioctl (ns, cmd, argp, head, srcu_idx); + + ret =nvme_ns_ioctl (ns, cmd, argp); +nvme_put_ns_from_disk (head, srcu_idx); +return ret; +} +const struct block_device_operations nvme_ns_head_ops = { .owner =THIS_MODULE , .submit_bio = nvme_ns_head_submit_bio, .open = nvme_ns_head_open, .release = nvme_ns_head_release, - .ioctl = nvme_ioctl, + .ioctl = nvme_ns_head_ioctl, .getgeo = nvme_getgeo, .report_zones = nvme_report_zones, .pr_ops = &nvme_pr_ops,
Signature · 7 lines
2.30.1 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerPATCH 7/13 nvme: don't bother to look up a namespace for controller ioctls
In reply to Christoph HellwigDon't bother to look up a namespace just to drop if after retreiving the controller for the multipath case. Just look up a live controller for the subsystem directly.
--- drivers/nvme/host/core.c | 66 +++++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 24 deletions(-)
drivers/nvme/host/core.c +42 -24
@@ -2336,42 +2336,60 @@ static void nvme_ns_head_release(struct gendisk *disk, fmode_t mode)nvme_put_ns_head (disk->private_data); } -static int nvme_ns_head_ctrl_ioctl (struct nvme_ns *ns,unsigned int cmd, -void __user *argp,struct nvme_ns_head *head,int srcu_idx) +static struct nvme_ctrl *nvme_find_get_live_ctrl (struct nvme_subsystem *subsys) { -struct nvme_ctrl *ctrl = ns->ctrl; +struct nvme_ctrl *ctrl;int ret; -nvme_get_ctrl (ns->ctrl); -nvme_put_ns_from_disk (head, srcu_idx); - ret =nvme_ctrl_ioctl (ns->ctrl, cmd, argp); + ret =mutex_lock_killable (&nvme_subsystems_lock); +if (ret) +return ERR_PTR (ret); +list_for_each_entry (ctrl, &subsys->ctrls, subsys_entry) { +if (ctrl->state ==NVME_CTRL_LIVE ) + goto found; + } +mutex_unlock (&nvme_subsystems_lock); +return ERR_PTR (-EWOULDBLOCK ); +found: +nvme_get_ctrl (ctrl); +mutex_unlock (&nvme_subsystems_lock); +return ctrl; +} + +static int nvme_ns_head_ctrl_ioctl (struct nvme_ns_head *head, +unsigned int cmd,void __user *argp) +{ +struct nvme_ctrl *ctrl =nvme_find_get_live_ctrl (head->subsys); +int ret; + +if (IS_ERR (ctrl)) +return PTR_ERR (ctrl); + ret =nvme_ctrl_ioctl (ctrl, cmd, argp);nvme_put_ctrl (ctrl);return ret; } +static int nvme_ns_head_ns_ioctl (struct nvme_ns_head *head, +unsigned int cmd,void __user *argp) +{ +int srcu_idx =srcu_read_lock (&head->srcu); +struct nvme_ns *ns =nvme_find_path (head); +int ret = -EWOULDBLOCK ; + +if (ns) + ret =nvme_ns_ioctl (ns, cmd, argp); +srcu_read_unlock (&head->srcu, srcu_idx); +return ret; +} +static int nvme_ns_head_ioctl (struct block_device *bdev,fmode_t mode,unsigned int cmd,unsigned long arg) { -struct nvme_ns_head *head =NULL ; -void __user *argp = (void __user *)arg; -struct nvme_ns *ns; -int srcu_idx, ret; - - ns =nvme_get_ns_from_disk (bdev->bd_disk, &head, &srcu_idx); -if (unlikely (!ns)) -return -EWOULDBLOCK ; +struct nvme_ns_head *head = bdev->bd_disk->private_data; -/* -* Handle ioctls that apply to the controller instead of the namespace -* seperately and drop the ns SRCU reference early. This avoids a -* deadlock when deleting namespaces using the passthrough interface. -*/ if (is_ctrl_ioctl (cmd)) -return nvme_ns_head_ctrl_ioctl (ns, cmd, argp, head, srcu_idx); - - ret =nvme_ns_ioctl (ns, cmd, argp); -nvme_put_ns_from_disk (head, srcu_idx); -return ret; +return nvme_ns_head_ctrl_ioctl (head, cmd, (void __user *)arg); +return nvme_ns_head_ns_ioctl (head, cmd, (void __user *)arg); }const struct block_device_operations nvme_ns_head_ops = {
Signature · 7 lines
2.30.1 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerPATCH 8/13 nvme: move the ioctl code to a separate file
In reply to Christoph HellwigSplit out the ioctl code from core.c into a new file. Also update copyrights while we're at it.
--- drivers/nvme/host/Makefile | 2 +- drivers/nvme/host/core.c | 450 +----------------------------------- drivers/nvme/host/ioctl.c | 455 +++++++++++++++++++++++++++++++++++++ drivers/nvme/host/nvme.h | 10 +- 4 files changed, 468 insertions(+), 449 deletions(-) create mode 100644 drivers/nvme/host/ioctl.c
drivers/nvme/host/Makefile +1 -1
@@ -9,7 +9,7 @@ obj-$(CONFIG_NVME_RDMA) += nvme-rdma.o obj-$(CONFIG_NVME_FC) += nvme-fc.o obj-$(CONFIG_NVME_TCP) += nvme-tcp.o -nvme-core-y := core.o +nvme-core-y := core.o ioctl.o nvme-core-$(CONFIG_TRACING) += trace.o nvme-core-$(CONFIG_NVME_MULTIPATH) += multipath.o nvme-core-$(CONFIG_NVM) += lightnvm.o
drivers/nvme/host/core.c +3 -447
504 lines not on this page · raw message
drivers/nvme/host/ioctl.c new file +455 -0
455 lines not on this page · raw message
drivers/nvme/host/nvme.h +9 -1
@@ -647,14 +647,22 @@ int nvme_get_features(struct nvme_ctrl *dev, unsigned int fid,int nvme_set_queue_count (struct nvme_ctrl *ctrl,int *count);void nvme_stop_keep_alive (struct nvme_ctrl *ctrl);int nvme_reset_ctrl (struct nvme_ctrl *ctrl); +int nvme_reset_ctrl_sync (struct nvme_ctrl *ctrl);int nvme_try_sched_reset (struct nvme_ctrl *ctrl);int nvme_delete_ctrl (struct nvme_ctrl *ctrl); - +void nvme_queue_scan (struct nvme_ctrl *ctrl);int nvme_get_log (struct nvme_ctrl *ctrl,u32 nsid,u8 log_page,u8 lsp,u8 csi,void *log,size_t size,u64 offset);struct nvme_ns *nvme_get_ns_from_disk (struct gendisk *disk,struct nvme_ns_head **head,int *srcu_idx);void nvme_put_ns_from_disk (struct nvme_ns_head *head,int idx); +struct nvme_ctrl *nvme_find_get_live_ctrl (struct nvme_subsystem *subsys); +int nvme_ioctl (struct block_device *bdev,fmode_t mode, +unsigned int cmd,unsigned long arg); +int nvme_ns_head_ioctl (struct block_device *bdev,fmode_t mode, +unsigned int cmd,unsigned long arg); +long nvme_dev_ioctl (struct file *file,unsigned int cmd, +unsigned long arg);extern const struct attribute_group *nvme_ns_id_attr_groups[];extern const struct block_device_operations nvme_ns_head_ops;
Signature · 7 lines
2.30.1 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Re: [PATCH 08/13] nvme: move the ioctl code to a separate file
Quoted 5 lines · Christoph Hellwig
Split out the ioctl code from
core.cinto a new file. Also update copyrights while we're at it.Signed-off-by Christoph Hellwig <[email protected]>---
Looks good.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerPATCH 9/13 nvme: factor out a nvme_tryget_ns_head helper
In reply to Christoph HellwigAdd a helper to avoid opencoding ns_head->ref manipulations.
--- drivers/nvme/host/core.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/nvme/host/core.c +6 -3
@@ -549,6 +549,11 @@ static void nvme_free_ns_head(struct kref *ref)kfree (head); } +static bool nvme_tryget_ns_head (struct nvme_ns_head *head) +{ +return kref_get_unless_zero (&head->ref); +} +static void nvme_put_ns_head (struct nvme_ns_head *head) {kref_put (&head->ref, nvme_free_ns_head);
@@ -1975,9 +1980,7 @@ static const struct block_device_operations nvme_bdev_ops = {#ifdef CONFIG_NVME_MULTIPATH static int nvme_ns_head_open (struct block_device *bdev,fmode_t mode) { -struct nvme_ns_head *head = bdev->bd_disk->private_data; - -if (!kref_get_unless_zero (&head->ref)) +if (!nvme_tryget_ns_head (bdev->bd_disk->private_data))return -ENXIO ;return 0 ; }
Signature · 7 lines
2.30.1 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Re: [PATCH 09/13] nvme: factor out a nvme_tryget_ns_head helper
Quoted 3 lines · Christoph Hellwig
Add a helper to avoid opencoding
ns_head->refmanipulations.Signed-off-by Christoph Hellwig <[email protected]>
Should we wait to have a second user for this ? unless it is there in next patches in this series.
In any case, looks good.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerRe: [PATCH 09/13] nvme: factor out a nvme_tryget_ns_head helper
Quoted 7 lines · Chaitanya Kulkarni
Quoted 3 lines · Christoph Hellwig
Add a helper to avoid opencoding
ns_head->refmanipulations.Signed-off-by Christoph Hellwig <[email protected]>Should we wait to have a second user for this ? unless it is there in next patches in this series.
It is really to be symmetric to the put case.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Re: [PATCH 09/13] nvme: factor out a nvme_tryget_ns_head helper
Quoted 4 lines · Christoph Hellwig
Quoted 2 lines
Should we wait to have a second user for this ? unless it is there in next patches in this series.
It is really to be symmetric to the put case.
Okay.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Re: [PATCH 09/13] nvme: factor out a nvme_tryget_ns_head helper
In reply to Christoph HellwigQuoted 25 lines · Christoph Hellwig
Add a helper to avoid opencoding
ns_head->refmanipulations.Signed-off-by Christoph Hellwig <[email protected]>--- drivers/nvme/host/core.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)drivers/nvme/host/core.c +5
-0@@ -549,6 +549,11 @@ static void nvme_free_ns_head(struct kref *ref)kfree (head); } +static bool nvme_tryget_ns_head (struct nvme_ns_head *head) +{ +return kref_get_unless_zero (&head->ref); +} +static void nvme_put_ns_head (struct nvme_ns_head *head) {kref_put (&head->ref, nvme_free_ns_head);
drivers/nvme/host/core.c static const struct block_device_operations nvme_bdev_ops = { · line 1986
Quoted 10 lines
drivers/nvme/host/core.c +1
-3@@ -1975,9 +1980,7 @@ static const struct block_device_operations nvme_bdev_ops = {#ifdef CONFIG_NVME_MULTIPATH static int nvme_ns_head_open (struct block_device *bdev,fmode_t mode) { -struct nvme_ns_head *head = bdev->bd_disk->private_data; - -if (!kref_get_unless_zero (&head->ref)) +if (!nvme_tryget_ns_head (bdev->bd_disk->private_data))return -ENXIO ;return 0 ; }
This new helper needs to be added inside nvme_find_ns_head() as well?
Signature · 6 lines
Kanchan _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerRe: [PATCH 09/13] nvme: factor out a nvme_tryget_ns_head helper
Quoted 1 line · Kanchan Joshi
This new helper needs to be added inside
nvme_find_ns_head()as well?
Yes, good idea.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerPATCH 10/13 nvme: move nvme_ns_head_ops to multipath.c
In reply to Christoph HellwigMove the multipath block_device_operations to multipath.c, where they belong.
--- drivers/nvme/host/core.c | 31 ++++--------------------------- drivers/nvme/host/multipath.c | 25 ++++++++++++++++++++++++- drivers/nvme/host/nvme.h | 5 ++++- 3 files changed, 32 insertions(+), 29 deletions(-)
drivers/nvme/host/core.c +4 -27
@@ -549,12 +549,12 @@ static void nvme_free_ns_head(struct kref *ref)kfree (head); } -static bool nvme_tryget_ns_head (struct nvme_ns_head *head) +bool nvme_tryget_ns_head (struct nvme_ns_head *head) {return kref_get_unless_zero (&head->ref); } -static void nvme_put_ns_head (struct nvme_ns_head *head) +void nvme_put_ns_head (struct nvme_ns_head *head) {kref_put (&head->ref, nvme_free_ns_head); }
@@ -1511,7 +1511,7 @@ static void nvme_release(struct gendisk *disk, fmode_t mode)nvme_put_ns (ns); } -static int nvme_getgeo (struct block_device *bdev,struct hd_geometry *geo) +int nvme_getgeo (struct block_device *bdev,struct hd_geometry *geo) {/* some standard values */ geo->heads =1 <<6 ;
@@ -1937,7 +1937,7 @@ static int nvme_pr_release(struct block_device *bdev, u64 key, enum pr_type typereturn nvme_pr_command (bdev, cdw10, key,0 , nvme_cmd_resv_release); } -static const struct pr_ops nvme_pr_ops = { +const struct pr_ops nvme_pr_ops = { .pr_register = nvme_pr_register, .pr_reserve = nvme_pr_reserve, .pr_release = nvme_pr_release,
@@ -1978,18 +1978,6 @@ static const struct block_device_operations nvme_bdev_ops = { };#ifdef CONFIG_NVME_MULTIPATH -static int nvme_ns_head_open (struct block_device *bdev,fmode_t mode) -{ -if (!nvme_tryget_ns_head (bdev->bd_disk->private_data)) -return -ENXIO ; -return 0 ; -} - -static void nvme_ns_head_release (struct gendisk *disk,fmode_t mode) -{ -nvme_put_ns_head (disk->private_data); -} -struct nvme_ctrl *nvme_find_get_live_ctrl (struct nvme_subsystem *subsys) {struct nvme_ctrl *ctrl;
@@ -2009,17 +1997,6 @@ struct nvme_ctrl *nvme_find_get_live_ctrl(struct nvme_subsystem *subsys)mutex_unlock (&nvme_subsystems_lock); return ctrl; } - -const struct block_device_operations nvme_ns_head_ops = { - .owner =THIS_MODULE , - .submit_bio = nvme_ns_head_submit_bio, - .open = nvme_ns_head_open, - .release = nvme_ns_head_release, - .ioctl = nvme_ns_head_ioctl, - .getgeo = nvme_getgeo, - .report_zones = nvme_report_zones, - .pr_ops = &nvme_pr_ops, -};#endif /* CONFIG_NVME_MULTIPATH */ static int nvme_wait_ready (struct nvme_ctrl *ctrl,u64 cap,bool enabled)
drivers/nvme/host/multipath.c +24 -1
@@ -294,7 +294,7 @@ static bool nvme_available_path(struct nvme_ns_head *head)return false; } -blk_qc_t nvme_ns_head_submit_bio (struct bio *bio) +static blk_qc_t nvme_ns_head_submit_bio (struct bio *bio) {struct nvme_ns_head *head = bio->bi_bdev->bd_disk->private_data;struct device *dev =disk_to_dev (head->disk);
@@ -334,6 +334,29 @@ blk_qc_t nvme_ns_head_submit_bio(struct bio *bio)return ret; } +static int nvme_ns_head_open (struct block_device *bdev,fmode_t mode) +{ +if (!nvme_tryget_ns_head (bdev->bd_disk->private_data)) +return -ENXIO ; +return 0 ; +} + +static void nvme_ns_head_release (struct gendisk *disk,fmode_t mode) +{ +nvme_put_ns_head (disk->private_data); +} + +const struct block_device_operations nvme_ns_head_ops = { + .owner =THIS_MODULE , + .submit_bio = nvme_ns_head_submit_bio, + .open = nvme_ns_head_open, + .release = nvme_ns_head_release, + .ioctl = nvme_ns_head_ioctl, + .getgeo = nvme_getgeo, + .report_zones = nvme_report_zones, + .pr_ops = &nvme_pr_ops, +}; +static void nvme_requeue_work (struct work_struct *work) { struct nvme_ns_head *head =
drivers/nvme/host/nvme.h +4 -1
@@ -656,6 +656,8 @@ int nvme_get_log(struct nvme_ctrl *ctrl, u32 nsid, u8 log_page, u8 lsp, u8 csi,struct nvme_ns *nvme_get_ns_from_disk (struct gendisk *disk,struct nvme_ns_head **head,int *srcu_idx);void nvme_put_ns_from_disk (struct nvme_ns_head *head,int idx); +bool nvme_tryget_ns_head (struct nvme_ns_head *head); +void nvme_put_ns_head (struct nvme_ns_head *head);struct nvme_ctrl *nvme_find_get_live_ctrl (struct nvme_subsystem *subsys);int nvme_ioctl (struct block_device *bdev,fmode_t mode,unsigned int cmd,unsigned long arg);
@@ -663,8 +665,10 @@ int nvme_ns_head_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg);long nvme_dev_ioctl (struct file *file,unsigned int cmd,unsigned long arg); +int nvme_getgeo (struct block_device *bdev,struct hd_geometry *geo);extern const struct attribute_group *nvme_ns_id_attr_groups[]; +extern const struct pr_ops nvme_pr_ops;extern const struct block_device_operations nvme_ns_head_ops;#ifdef CONFIG_NVME_MULTIPATH
@@ -688,7 +692,6 @@ void nvme_mpath_stop(struct nvme_ctrl *ctrl);bool nvme_mpath_clear_current_path (struct nvme_ns *ns);void nvme_mpath_clear_ctrl_paths (struct nvme_ctrl *ctrl);struct nvme_ns *nvme_find_path (struct nvme_ns_head *head); -blk_qc_t nvme_ns_head_submit_bio (struct bio *bio);static inline void nvme_mpath_check_last_path (struct nvme_ns *ns) {
Signature · 7 lines
2.30.1 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Re: [PATCH 10/13] nvme: move nvme_ns_head_ops to multipath.c
Quoted 4 lines · Christoph Hellwig
Move the multipath
block_device_operationstomultipath.c, where they belong.Signed-off-by Christoph Hellwig <[email protected]>
Looks good.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerPATCH 11/13 nvme: factor out nvme_ns_open and nvme_ns_release helpers
In reply to Christoph HellwigThese will be reused for the per-namespace character devices.
--- drivers/nvme/host/core.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/nvme/host/core.c +12 -4
@@ -1483,9 +1483,8 @@ void nvme_put_ns_from_disk(struct nvme_ns_head *head, int idx)srcu_read_unlock (&head->srcu, idx); } -static int nvme_open (struct block_device *bdev,fmode_t mode) +static int nvme_ns_open (struct nvme_ns *ns) { -struct nvme_ns *ns = bdev->bd_disk->private_data;/* should never be called due to GENHD_FL_HIDDEN */ if (WARN_ON_ONCE (nvme_ns_head_multipath (ns->head)))
@@ -1503,14 +1502,23 @@ static int nvme_open(struct block_device *bdev, fmode_t mode)return -ENXIO ; } -static void nvme_release (struct gendisk *disk,fmode_t mode) +static void nvme_ns_release (struct nvme_ns *ns) { -struct nvme_ns *ns = disk->private_data;module_put (ns->ctrl->ops->module);nvme_put_ns (ns); } +static int nvme_open (struct block_device *bdev,fmode_t mode) +{ +return nvme_ns_open (bdev->bd_disk->private_data); +} + +static void nvme_release (struct gendisk *disk,fmode_t mode) +{ +nvme_ns_release (disk->private_data); +} +int nvme_getgeo (struct block_device *bdev,struct hd_geometry *geo) {/* some standard values */
Signature · 7 lines
2.30.1 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Re: [PATCH 11/13] nvme: factor out nvme_ns_open and nvme_ns_release helpers
Quoted 3 lines · Christoph Hellwig
These will be reused for the per-namespace character devices.
Signed-off-by Christoph Hellwig <[email protected]>
Looks good.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerPATCH 12/13 nvme: let namespace probing continue for unsupported features
In reply to Christoph HellwigInstead of failing to scan the namespace entirely when unsupported features are detected, just mark the gendisk hidden but allow other access like the upcoming per-namespace character device.
--- drivers/nvme/host/core.c | 11 ++++++++++- drivers/nvme/host/zns.c | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-)
drivers/nvme/host/core.c +10 -1
@@ -1832,7 +1832,7 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id)if (blk_queue_is_zoned (ns->queue)) { ret =nvme_revalidate_zones (ns);if (ret && !nvme_first_scan (ns->disk)) -return ret; + goto out; }if (nvme_ns_head_multipath (ns->head)) {
@@ -1847,6 +1847,15 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id) out_unfreeze:blk_mq_unfreeze_queue (ns->disk->queue); +out: +/* +* If probing fails due an unsupported feature, hide the block device, +* but still allow other access. +*/ +if (ret == -ENODEV ) { + ns->disk->flags |=GENHD_FL_HIDDEN ; + ret =0 ; + }return ret; }
drivers/nvme/host/zns.c +2 -2
@@ -96,7 +96,7 @@ int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf)dev_warn (ns->ctrl->device,"zone operations:%x not supported for namespace:%u\n" ,le16_to_cpu (id->zoc), ns->head->ns_id); - status = -EINVAL ; + status = -ENODEV ; goto free_data; }
@@ -105,7 +105,7 @@ int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf)dev_warn (ns->ctrl->device,"invalid zone size:%llu for namespace:%u\n" , ns->zsze, ns->head->ns_id); - status = -EINVAL ; + status = -ENODEV ; goto free_data; }
Signature · 7 lines
2.30.1 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Keith Busch
maintainerRe: [PATCH 12/13] nvme: let namespace probing continue for unsupported features
Quoted 3 lines · Christoph Hellwig
Instead of failing to scan the namespace entirely when unsupported features are detected, just mark the gendisk hidden but allow other access like the upcoming per-namespace character device.
This part looks fine for what it is, but I thought we were going even further by allocating a namespace for the generic char device even if its Command Set Indicator was unsupported by the kernel.
Quoted 50 lines
Signed-off-by Christoph Hellwig <[email protected]>--- drivers/nvme/host/core.c | 11 ++++++++++- drivers/nvme/host/zns.c | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-)drivers/nvme/host/core.c +10
-1@@ -1832,7 +1832,7 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id)if (blk_queue_is_zoned (ns->queue)) { ret =nvme_revalidate_zones (ns);if (ret && !nvme_first_scan (ns->disk)) -return ret; + goto out; }if (nvme_ns_head_multipath (ns->head)) {@@ -1847,6 +1847,15 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id) out_unfreeze:blk_mq_unfreeze_queue (ns->disk->queue); +out: +/* +* If probing fails due an unsupported feature, hide the block device, +* but still allow other access. +*/ +if (ret == -ENODEV ) { + ns->disk->flags |=GENHD_FL_HIDDEN ; + ret =0 ; + }return ret; }drivers/nvme/host/zns.c +1
-1@@ -96,7 +96,7 @@ int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf)dev_warn (ns->ctrl->device,"zone operations:%x not supported for namespace:%u\n" ,le16_to_cpu (id->zoc), ns->head->ns_id); - status = -EINVAL ; + status = -ENODEV ; goto free_data; }
drivers/nvme/host/zns.c int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf) · line 111
Quoted 8 lines
drivers/nvme/host/zns.c +1
-1@@ -105,7 +105,7 @@ int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf)dev_warn (ns->ctrl->device,"invalid zone size:%llu for namespace:%u\n" , ns->zsze, ns->head->ns_id); - status = -EINVAL ; + status = -ENODEV ; goto free_data; }
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerRe: [PATCH 12/13] nvme: let namespace probing continue for unsupported features
Quoted 8 lines · Keith Busch
Quoted 3 lines · Christoph Hellwig
Instead of failing to scan the namespace entirely when unsupported features are detected, just mark the gendisk hidden but allow other access like the upcoming per-namespace character device.
This part looks fine for what it is, but I thought we were going even further by allocating a namespace for the generic char device even if its Command Set Indicator was unsupported by the kernel.
We need a currently unpublished TP (don't remember the number offhand) that adds another new Identify page for that. So it is on the TODO list but can't be done yet.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Keith Busch
maintainerRe: [PATCH 12/13] nvme: let namespace probing continue for unsupported features
Quoted 6 lines · Christoph Hellwig
Quoted 5 lines · Keith Busch
Quoted 3 lines · Christoph Hellwig
Instead of failing to scan the namespace entirely when unsupported features are detected, just mark the gendisk hidden but allow other access like the upcoming per-namespace character device.
Quoted 7 lines
Quoted 3 lines
This part looks fine for what it is, but I thought we were going even further by allocating a namespace for the generic char device even if its Command Set Indicator was unsupported by the kernel.
We need a currently unpublished TP (don't remember the number offhand) that adds another new Identify page for that. So it is on the TODO list but can't be done yet.
Oh, I was thinking if the kernel doesn't have CONFIG_BLK_DEV_ZONED. That's not necessary for the ng device.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerRe: [PATCH 12/13] nvme: let namespace probing continue for unsupported features
Quoted 6 lines · Keith Busch
Quoted 3 lines
We need a currently unpublished TP (don't remember the number offhand) that adds another new Identify page for that. So it is on the TODO list but can't be done yet.
Oh, I was thinking if the kernel doesn't have
CONFIG_BLK_DEV_ZONED. That's not necessary for the ng device.
Hmm. That means we need another special just for ZNS that does not use the command set independent identify. Not sure that is really worth it. I'd rather wait for the new TP and have one generic path.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerPATCH 13/13 nvme: introduce generic per-namespace chardev
In reply to Christoph HellwigFrom: Minwoo Im <[email protected]>
Userspace has not been allowed to I/O to device that's failed to be initialized. This patch introduces generic per-namespace character device to allow userspace to I/O regardless the block device is there or not.
The chardev naming convention will similar to the existing blkdev naming, using a ng prefix instead of nvme, i.e.
- /dev/ngXnY
It also supports multipath which means it will not expose chardev for the hidden namespace blkdevs (e.g., nvmeXcYnZ). If /dev/ngXnY is created for a ns_head, then I/O request will be routed to a specific controller selected by the iopolicy of the subsystem.
[hch: rebased on top of the ioctl cleanups, split the ns_head and ns
implementations]
--- drivers/nvme/host/core.c | 81 +++++++++++++++++++++++++++++++++++ drivers/nvme/host/ioctl.c | 17 ++++++++ drivers/nvme/host/multipath.c | 51 ++++++++++++++++++++-- drivers/nvme/host/nvme.h | 12 ++++++ 4 files changed, 158 insertions(+), 3 deletions(-)
drivers/nvme/host/core.c +81 -0
@@ -89,6 +89,10 @@ static dev_t nvme_ctrl_base_chr_devt;static struct class *nvme_class;static struct class *nvme_subsys_class; +static DEFINE_IDA (nvme_ns_chr_minor_ida); +static dev_t nvme_ns_chr_devt; +static struct class *nvme_ns_chr_class; +static void nvme_put_subsystem (struct nvme_subsystem *subsys);static void nvme_remove_invalid_namespaces (struct nvme_ctrl *ctrl,unsigned nsid);
@@ -3424,6 +3428,60 @@ static int __nvme_check_ids(struct nvme_subsystem *subsys,return 0 ; } +int nvme_cdev_add (struct cdev *cdev,struct device *cdev_device, +const struct file_operations *fops,struct module *owner) +{ +int minor, ret; + + minor =ida_simple_get (&nvme_ns_chr_minor_ida,0 ,0 ,GFP_KERNEL ); +if (minor <0 ) +return minor; + cdev_device->devt =MKDEV (MAJOR (nvme_ns_chr_devt), minor); + cdev_device->class = nvme_ns_chr_class; +device_initialize (cdev_device); +cdev_init (cdev, fops); + cdev->owner = owner; + ret =cdev_device_add (cdev, cdev_device); +if (ret) +ida_simple_remove (&nvme_ns_chr_minor_ida, minor); +return ret; +} + +static int nvme_ns_chr_open (struct inode *inode,struct file *file) +{ + return nvme_ns_open(container_of(inode->i_cdev, struct nvme_ns, cdev)); +} + +static int nvme_ns_chr_release (struct inode *inode,struct file *file) +{ + nvme_ns_release(container_of(inode->i_cdev, struct nvme_ns, cdev)); +return 0 ; +} + +static const struct file_operations nvme_ns_chr_fops = { + .owner =THIS_MODULE , + .open = nvme_ns_chr_open, + .release = nvme_ns_chr_release, + .unlocked_ioctl = nvme_ns_chr_ioctl, + .compat_ioctl = compat_ptr_ioctl, +}; + +static int nvme_add_ns_cdev (struct nvme_ns *ns) +{ +int ret; + + ns->cdev_device.parent = ns->ctrl->device; + ret =dev_set_name (&ns->cdev_device,"ng%dn%d" , + ns->ctrl->instance, ns->head->instance); +if (ret) +return ret; + ret =nvme_cdev_add (&ns->cdev, &ns->cdev_device, &nvme_ns_chr_fops, + ns->ctrl->ops->module); +if (ret) +kfree_const (ns->cdev_device.kobj.name); +return ret; +} +static struct nvme_ns_head *nvme_alloc_ns_head (struct nvme_ctrl *ctrl,unsigned nsid,struct nvme_ns_ids *ids) {
@@ -3625,6 +3683,8 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid,nvme_get_ctrl (ctrl);device_add_disk (ctrl->device, ns->disk, nvme_ns_id_attr_groups); +if (!nvme_ns_head_multipath (ns->head)) +nvme_add_ns_cdev (ns);nvme_mpath_add_disk (ns, id);nvme_fault_inject_init (&ns->fault_inject, ns->disk->disk_name);
@@ -3669,6 +3729,8 @@ static void nvme_ns_remove(struct nvme_ns *ns)synchronize_srcu (&ns->head->srcu);/* wait for concurrent submissions */ if (ns->disk->flags &GENHD_FL_UP ) { +if (!nvme_ns_head_multipath (ns->head)) +cdev_device_del (&ns->cdev, &ns->cdev_device);del_gendisk (ns->disk);blk_cleanup_queue (ns->queue);if (blk_get_integrity (ns->disk))
@@ -4459,8 +4521,24 @@ static int __init nvme_core_init(void) result =PTR_ERR (nvme_subsys_class); goto destroy_class; } + + result =alloc_chrdev_region (&nvme_ns_chr_devt,0 ,NVME_MINORS , +"nvme-generic" ); +if (result <0 ) + goto destroy_subsys_class; + + nvme_ns_chr_class =class_create (THIS_MODULE ,"nvme-generic" ); +if (IS_ERR (nvme_ns_chr_class)) { + result =PTR_ERR (nvme_ns_chr_class); + goto unregister_generic_ns; + } +return 0 ; +unregister_generic_ns: +unregister_chrdev_region (nvme_ns_chr_devt,NVME_MINORS ); +destroy_subsys_class: +class_destroy (nvme_subsys_class); destroy_class:class_destroy (nvme_class); unregister_chrdev:
@@ -4477,12 +4555,15 @@ static int __init nvme_core_init(void) static void __exit nvme_core_exit(void) { +class_destroy (nvme_ns_chr_class);class_destroy (nvme_subsys_class);class_destroy (nvme_class); +unregister_chrdev_region (nvme_ns_chr_devt,NVME_MINORS );unregister_chrdev_region (nvme_ctrl_base_chr_devt,NVME_MINORS );destroy_workqueue (nvme_delete_wq);destroy_workqueue (nvme_reset_wq);destroy_workqueue (nvme_wq); +ida_destroy (&nvme_ns_chr_minor_ida);ida_destroy (&nvme_instance_ida); }
drivers/nvme/host/ioctl.c +17 -0
@@ -357,6 +357,14 @@ int nvme_ioctl(struct block_device *bdev, fmode_t mode,return nvme_ns_ioctl (ns, cmd, argp); } +long nvme_ns_chr_ioctl (struct file *file,unsigned int cmd,unsigned long arg) +{ +struct nvme_ns *ns = + container_of(file_inode(file)->i_cdev, struct nvme_ns, cdev); + +return nvme_ns_ioctl (ns, cmd, (void __user *)arg); +} +#ifdef CONFIG_NVME_MULTIPATH static int nvme_ns_head_ctrl_ioctl (struct nvme_ns_head *head,unsigned int cmd,void __user *argp)
@@ -393,6 +401,15 @@ int nvme_ns_head_ioctl(struct block_device *bdev, fmode_t mode,return nvme_ns_head_ctrl_ioctl (head, cmd, (void __user *)arg);return nvme_ns_head_ns_ioctl (head, cmd, (void __user *)arg); } + +long nvme_ns_head_chr_ioctl (struct file *file,unsigned int cmd, +unsigned long arg) +{ +struct cdev *cdev =file_inode (file)->i_cdev; + struct nvme_ns_head *head = container_of(cdev, struct nvme_ns_head, cdev); + +return nvme_ns_head_ns_ioctl (head, cmd, (void __user *)arg); +}#endif /* CONFIG_NVME_MULTIPATH */ static int nvme_dev_user_cmd (struct nvme_ctrl *ctrl,void __user *argp)
drivers/nvme/host/multipath.c +48 -3
75 lines not on this page · raw message
drivers/nvme/host/nvme.h +12 -0
@@ -413,6 +413,10 @@ struct nvme_ns_head {bool shared;int instance;struct nvme_effects_log *effects; + +struct cdev cdev; +struct device cdev_device; +struct gendisk *disk;#ifdef CONFIG_NVME_MULTIPATH struct bio_list requeue_list;
@@ -465,6 +469,9 @@ struct nvme_ns {#define NVME_NS_ANA_PENDING 2#define NVME_NS_FORCE_RO 3 +struct cdev cdev; +struct device cdev_device; +struct nvme_fault_inject fault_inject; };
@@ -659,10 +666,15 @@ void nvme_put_ns_from_disk(struct nvme_ns_head *head, int idx);bool nvme_tryget_ns_head (struct nvme_ns_head *head);void nvme_put_ns_head (struct nvme_ns_head *head);struct nvme_ctrl *nvme_find_get_live_ctrl (struct nvme_subsystem *subsys); +int nvme_cdev_add (struct cdev *cdev,struct device *cdev_device, +const struct file_operations *fops,struct module *owner);int nvme_ioctl (struct block_device *bdev,fmode_t mode,unsigned int cmd,unsigned long arg); +long nvme_ns_chr_ioctl (struct file *file,unsigned int cmd,unsigned long arg);int nvme_ns_head_ioctl (struct block_device *bdev,fmode_t mode,unsigned int cmd,unsigned long arg); +long nvme_ns_head_chr_ioctl (struct file *file,unsigned int cmd, +unsigned long arg);long nvme_dev_ioctl (struct file *file,unsigned int cmd,unsigned long arg);int nvme_getgeo (struct block_device *bdev,struct hd_geometry *geo);
Signature · 7 lines
2.30.1 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Keith Busch
maintainerRe: [PATCH 13/13] nvme: introduce generic per-namespace chardev
drivers/nvme/host/core.c static int __nvme_check_ids(struct nvme_subsystem *subsys, · line 3436
Quoted 6 lines · Christoph Hellwig
drivers/nvme/host/core.c +6
-0+int nvme_cdev_add (struct cdev *cdev,struct device *cdev_device, +const struct file_operations *fops,struct module *owner) +{ +int minor, ret; + + minor =ida_simple_get (&nvme_ns_chr_minor_ida,0 ,0 ,GFP_KERNEL );
Do we really need to allocate a minor specific for this char dev? It looks like the ns->head->instance can provide the unique value.
drivers/nvme/host/core.c static int __nvme_check_ids(struct nvme_subsystem *subsys, · line 3439
Quoted 3 lines
drivers/nvme/host/core.c +3
-0+if (minor <0 ) +return minor; + cdev_device->devt =MKDEV (MAJOR (nvme_ns_chr_devt), minor);
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerRe: [PATCH 13/13] nvme: introduce generic per-namespace chardev
Quoted 10 lines · Keith Busch
drivers/nvme/host/core.c static int __nvme_check_ids(struct nvme_subsystem *subsys, · line 3436
Quoted 6 lines · Christoph Hellwig
drivers/nvme/host/core.c +6
-0+int nvme_cdev_add (struct cdev *cdev,struct device *cdev_device, +const struct file_operations *fops,struct module *owner) +{ +int minor, ret; + + minor =ida_simple_get (&nvme_ns_chr_minor_ida,0 ,0 ,GFP_KERNEL );Do we really need to allocate a minor specific for this char dev? It looks like the
ns->head->instancecan provide the unique value.
Indeed. I think we can just kill off this IDA, let me give that a spin.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerRe: [PATCH 13/13] nvme: introduce generic per-namespace chardev
In reply to Keith BuschQuoted 10 lines · Keith Busch
drivers/nvme/host/core.c static int __nvme_check_ids(struct nvme_subsystem *subsys, · line 3436
Quoted 6 lines · Christoph Hellwig
drivers/nvme/host/core.c +6
-0+int nvme_cdev_add (struct cdev *cdev,struct device *cdev_device, +const struct file_operations *fops,struct module *owner) +{ +int minor, ret; + + minor =ida_simple_get (&nvme_ns_chr_minor_ida,0 ,0 ,GFP_KERNEL );Do we really need to allocate a minor specific for this char dev? It looks like the
ns->head->instancecan provide the unique value.
Looking at this: no, head->instance doesn't help as it is an instance relative to subsystem, but doesn't help with a global allocation over all subsystems.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Keith Busch
maintainerRe: [PATCH 13/13] nvme: introduce generic per-namespace chardev
Quoted 12 lines · Christoph Hellwig
Quoted 10 lines · Keith Busch
drivers/nvme/host/core.c static int __nvme_check_ids(struct nvme_subsystem *subsys, · line 3436
Quoted 6 lines · Christoph Hellwig
drivers/nvme/host/core.c +6
-0+int nvme_cdev_add (struct cdev *cdev,struct device *cdev_device, +const struct file_operations *fops,struct module *owner) +{ +int minor, ret; + + minor =ida_simple_get (&nvme_ns_chr_minor_ida,0 ,0 ,GFP_KERNEL );Do we really need to allocate a minor specific for this char dev? It looks like the
ns->head->instancecan provide the unique value.
Quoted 3 lines
Looking at this: no,
head->instancedoesn't help as it is an instance relative to subsystem, but doesn't help with a global allocation over all subsystems.
Right, my mistake.
In that case, there needs to be a ida_simple_remove() after the cdev_device_del() so we don't leak the ida.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerRe: [PATCH 13/13] nvme: introduce generic per-namespace chardev
Quoted 4 lines · Keith Busch
Right, my mistake.
In that case, there needs to be a
ida_simple_remove()after thecdev_device_del()so we don't leak the ida.
Yes, I actually noticed that while I looked into your idea. As of this morning my local tree has a helper that does the cdev_device_del and the ida_simple_remove in one go.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Re: [PATCH 13/13] nvme: introduce generic per-namespace chardev
In reply to Christoph HellwigQuoted 23 lines · Christoph Hellwig
drivers/nvme/host/ioctl.c +8
-0@@ -357,6 +357,14 @@ int nvme_ioctl(struct block_device *bdev, fmode_t mode,return nvme_ns_ioctl (ns, cmd, argp); } +long nvme_ns_chr_ioctl (struct file *file,unsigned int cmd,unsigned long arg) +{ +struct nvme_ns *ns = + container_of(file_inode(file)->i_cdev, struct nvme_ns, cdev); + +return nvme_ns_ioctl (ns, cmd, (void __user *)arg); +} +#ifdef CONFIG_NVME_MULTIPATH static int nvme_ns_head_ctrl_ioctl (struct nvme_ns_head *head,unsigned int cmd,void __user *argp)@@ -393,6 +401,15 @@ int nvme_ns_head_ioctl(struct block_device *bdev, fmode_t mode,return nvme_ns_head_ctrl_ioctl (head, cmd, (void __user *)arg);return nvme_ns_head_ns_ioctl (head, cmd, (void __user *)arg); }
drivers/nvme/host/ioctl.c int nvme_ns_head_ioctl(struct block_device *bdev, fmode_t mode, · line 413
Quoted 10 lines
drivers/nvme/host/ioctl.c +9
-0+ +long nvme_ns_head_chr_ioctl (struct file *file,unsigned int cmd, +unsigned long arg) +{ +struct cdev *cdev =file_inode (file)->i_cdev; + struct nvme_ns_head *head = container_of(cdev, struct nvme_ns_head, cdev); + +return nvme_ns_head_ns_ioctl (head, cmd, (void __user *)arg); +}#endif /* CONFIG_NVME_MULTIPATH */
Tested with namespace-specific admin commmand (Identify Namespace). And it fails with invalid IOCTl because we don't have a route to the controller IOCTL for the generic chrdev.
Maybe we can have the following patch with simplifying the little bit duplicated codes and make blkdev and generic device consistent which will make user-space application happy?
drivers/nvme/host/ioctl.c +19 -9
@@ -346,15 +346,19 @@ static int nvme_ns_ioctl(struct nvme_ns *ns, unsigned int cmd, } } +static int __nvme_ioctl (struct nvme_ns *ns,unsigned int cmd,void __user *arg) +{ +if (is_ctrl_ioctl (cmd)) +return nvme_ctrl_ioctl (ns->ctrl, cmd, arg); +return nvme_ns_ioctl (ns, cmd, arg); +} +int nvme_ioctl (struct block_device *bdev,fmode_t mode,unsigned int cmd,unsigned long arg) {struct nvme_ns *ns = bdev->bd_disk->private_data; -void __user *argp = (void __user *)arg; -if (is_ctrl_ioctl (cmd)) -return nvme_ctrl_ioctl (ns->ctrl, cmd, argp); -return nvme_ns_ioctl (ns, cmd, argp); +return __nvme_ioctl (ns, cmd, (void __user *)arg); }long nvme_ns_chr_ioctl (struct file *file,unsigned int cmd,unsigned long arg)
@@ -362,7 +366,7 @@ long nvme_ns_chr_ioctl(struct file *file, unsigned int cmd, unsigned long arg)struct nvme_ns *ns = container_of(file_inode(file)->i_cdev, struct nvme_ns, cdev); -return nvme_ns_ioctl (ns, cmd, (void __user *)arg); +return __nvme_ioctl (ns, cmd, (void __user *)arg); }#ifdef CONFIG_NVME_MULTIPATH
@@ -392,14 +396,20 @@ static int nvme_ns_head_ns_ioctl(struct nvme_ns_head *head,return ret; } +static int __nvme_ns_head_ioctl (struct nvme_ns_head *head,unsigned int cmd, +void __user *arg) +{ +if (is_ctrl_ioctl (cmd)) +return nvme_ns_head_ctrl_ioctl (head, cmd, arg); +return nvme_ns_head_ns_ioctl (head, cmd, arg); +} +int nvme_ns_head_ioctl (struct block_device *bdev,fmode_t mode,unsigned int cmd,unsigned long arg) {struct nvme_ns_head *head = bdev->bd_disk->private_data; -if (is_ctrl_ioctl (cmd)) -return nvme_ns_head_ctrl_ioctl (head, cmd, (void __user *)arg); -return nvme_ns_head_ns_ioctl (head, cmd, (void __user *)arg); +return __nvme_ns_head_ioctl (head, cmd, (void __user *)arg); } long nvme_ns_head_chr_ioctl(struct file *file, unsigned int cmd,
@@ -408,7 +418,7 @@ long nvme_ns_head_chr_ioctl(struct file *file, unsigned int cmd,struct cdev *cdev =file_inode (file)->i_cdev; struct nvme_ns_head *head = container_of(cdev, struct nvme_ns_head, cdev); - return nvme_ns_head_ns_ioctl(head, cmd, (void __user *)arg); + return __nvme_ns_head_ioctl(head, cmd, (void __user *)arg); }#endif /* CONFIG_NVME_MULTIPATH */
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerRe: [PATCH 13/13] nvme: introduce generic per-namespace chardev
Quoted 3 lines · Minwoo Im
Tested with namespace-specific admin commmand (Identify Namespace). And it fails with invalid IOCTl because we don't have a route to the controller IOCTL for the generic chrdev.
Yes, that is intentional, as supporting the per-controller ioctls on the per-namespace devices is a mess.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Re: [PATCH 13/13] nvme: introduce generic per-namespace chardev
Quoted 7 lines · Christoph Hellwig
Quoted 3 lines · Minwoo Im
Tested with namespace-specific admin commmand (Identify Namespace). And it fails with invalid IOCTl because we don't have a route to the controller IOCTL for the generic chrdev.
Yes, that is intentional, as supporting the per-controller ioctls on the per-namespace devices is a mess.
In multipath case, head blkdev is also per-namespace node which is now supporting the controller ioctl by nvme_find_get_live_ctrl(). Is there any different policy between the existing blkdev and generic device in the current series ? Or should be just deprecate the controller ioctl from the head blkdev ioctl in multipath case ?
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerRe: [PATCH 13/13] nvme: introduce generic per-namespace chardev
Quoted 6 lines · Minwoo Im
Quoted 5 lines · Christoph Hellwig
Quoted 3 lines · Minwoo Im
Tested with namespace-specific admin commmand (Identify Namespace). And it fails with invalid IOCTl because we don't have a route to the controller IOCTL for the generic chrdev.
Quoted 8 lines
Quoted 2 lines
Yes, that is intentional, as supporting the per-controller ioctls on the per-namespace devices is a mess.
In multipath case, head blkdev is also per-namespace node which is now supporting the controller ioctl by
nvme_find_get_live_ctrl(). Is there any different policy between the existing blkdev and generic device in the current series ? Or should be just deprecate the controller ioctl from the head blkdev ioctl in multipath case ?
Well, the multipath block device is supposed to be a full drop in for the block device, including having the same name. So I don't think we can just deprecate it, even if that would really improve things.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Re: [PATCH 13/13] nvme: introduce generic per-namespace chardev
Quoted 16 lines · Christoph Hellwig
Quoted 6 lines · Minwoo Im
Quoted 5 lines · Christoph Hellwig
Quoted 3 lines · Minwoo Im
Tested with namespace-specific admin commmand (Identify Namespace). And it fails with invalid IOCTl because we don't have a route to the controller IOCTL for the generic chrdev.
Quoted 8 lines
Quoted 2 lines
Yes, that is intentional, as supporting the per-controller ioctls on the per-namespace devices is a mess.
In multipath case, head blkdev is also per-namespace node which is now supporting the controller ioctl by
nvme_find_get_live_ctrl(). Is there any different policy between the existing blkdev and generic device in the current series ? Or should be just deprecate the controller ioctl from the head blkdev ioctl in multipath case ?
Quoted 3 lines
Well, the multipath block device is supposed to be a full drop in for the block device, including having the same name. So I don't think we can just deprecate it, even if that would really improve things.
I think if we don't have a route to the live controller from the multipath node /dev/ng0n1, how does application figure out controller node to request admin commands like Identify Namespace before their own I/O ?
We have sysfs, but it does not provide every information about the namespace. Or is there any charming way to find out the live controller from a head node through sysfs or something that I missed here ? :)
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerRe: [PATCH 13/13] nvme: introduce generic per-namespace chardev
Quoted 9 lines · Minwoo Im
I think if we don't have a route to the live controller from the multipath node
/dev/ng0n1, how does application figure out controller node to request admin commands like Identify Namespace before their own I/O ?We have sysfs, but it does not provide every information about the namespace. Or is there any charming way to find out the live controller from a head node through sysfs or something that I missed here ? :)
The devie links points to the subsystem, which then points to the controllers:
root@testvm:/sys/class/nvme-generic/ng0n1# ls -l device/ total 0 -r--r--r-- 1 root root 4096 Apr 12 07:43 firmware_rev -rw-r--r-- 1 root root 4096 Apr 12 07:44 iopolicy -r--r--r-- 1 root root 4096 Apr 12 07:43 model drwxr-xr-x 3 root root 0 Apr 12 07:43 ng0n1 drwxr-xr-x 3 root root 0 Apr 12 07:43 ng0n2 lrwxrwxrwx 1 root root 0 Apr 12 07:44 nvme0 -> ../../nvme-fabrics/ctl/nvme0 drwxr-xr-x 9 root root 0 Apr 12 07:43 nvme0n1 drwxr-xr-x 9 root root 0 Apr 12 07:43 nvme0n2 lrwxrwxrwx 1 root root 0 Apr 12 07:44 nvme1 -> ../../nvme-fabrics/ctl/nvme1 drwxr-xr-x 2 root root 0 Apr 12 07:44 power -r--r--r-- 1 root root 4096 Apr 12 07:43 serial -r--r--r-- 1 root root 4096 Apr 12 07:44 subsysnqn lrwxrwxrwx 1 root root 0 Apr 12 07:43 subsystem -> ../../../../class/nvme-subsystem -rw-r--r-- 1 root root 4096 Apr 12 07:43 uevent
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Re: [PATCH 13/13] nvme: introduce generic per-namespace chardev
Quoted 28 lines · Christoph Hellwig
Quoted 9 lines · Minwoo Im
I think if we don't have a route to the live controller from the multipath node
/dev/ng0n1, how does application figure out controller node to request admin commands like Identify Namespace before their own I/O ?We have sysfs, but it does not provide every information about the namespace. Or is there any charming way to find out the live controller from a head node through sysfs or something that I missed here ? :)
The devie links points to the subsystem, which then points to the controllers:
root@testvm:/sys/class/nvme-generic/ng0n1# ls -l device/ total 0(quoted diff) +0
-3-r--r--r-- 1 root root 4096 Apr 12 07:43 firmware_rev -rw-r--r-- 1 root root 4096 Apr 12 07:44 iopolicy -r--r--r-- 1 root root 4096 Apr 12 07:43 modeldrwxr-xr-x 3 root root 0 Apr 12 07:43 ng0n1 drwxr-xr-x 3 root root 0 Apr 12 07:43 ng0n2 lrwxrwxrwx 1 root root 0 Apr 12 07:44 nvme0 -> ../../nvme-fabrics/ctl/nvme0 drwxr-xr-x 9 root root 0 Apr 12 07:43 nvme0n1 drwxr-xr-x 9 root root 0 Apr 12 07:43 nvme0n2 lrwxrwxrwx 1 root root 0 Apr 12 07:44 nvme1 -> ../../nvme-fabrics/ctl/nvme1 drwxr-xr-x 2 root root 0 Apr 12 07:44 power(quoted diff) +0
-2-r--r--r-- 1 root root 4096 Apr 12 07:43 serial -r--r--r-- 1 root root 4096 Apr 12 07:44 subsysnqn
Quoted 3 lines
lrwxrwxrwx 1 root root 0 Apr 12 07:43 subsystem -> ../../../../class/nvme-subsystem
-rw-r--r-- 1 root root 4096 Apr 12 07:43 uevent
It seems like a limitation that we have to transverse sysfs to make an in-application enumeration to submit namespace-specific admin commands.
Ideally, applications that are already using IOCTLs should be able to directly work with the char device. If this is not the case, I am afraid that the applicability will be limited.
I understand that identifying the live controller in multipath is something that we need to improve. The question is that if this is a reasonable thing for you. If there is no fundamental limitation here, I think we can work the details of enabling namespace admin commands through and merge the same support for the block device and the char device.
What do you think?
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Quoted 6 lines · Christoph Hellwig
Hi all,
this series picks up the generic per-namespace character device from Minwoo and Javier with a few small fixed, but rebases them on an ioctl refactoring I had pending, which cleans up a lot of the lower level code.
Patches 1-12 look good.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Javier Gonz??lez
Reviewed-byQuoted 6 lines · Christoph Hellwig
Hi all,
this series picks up the generic per-namespace character device from Minwoo and Javier with a few small fixed, but rebases them on an ioctl refactoring I had pending, which cleans up a lot of the lower level code.
You can also add my review tag for 1-12.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerQuoted 6 lines · Christoph Hellwig
Hi all,
this series picks up the generic per-namespace character device from Minwoo and Javier with a few small fixed, but rebases them on an ioctl refactoring I had pending, which cleans up a lot of the lower level code.
I've pulled patches into nvme-5.13, and I'll resend patch 13.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme