nvmet: debugfs support
Subsystems (5)
v3 cover nvmet: debugfs support
Hi all,
taking up the original patchset for nvmet debugfs I've improved upon that submission by modifying the layout:
/dev/kernel/debug/nvmet
<subsysnqn>
ctrl<cntlid>
port
state
hostnqn
kato
host_traddr
queue<qnum>
sqsize
sqhead
The 'state' attribute is the value of the CSTS register; one can trigger a controller reset by writing 'fatal' into it (to set CSTS.CFS).
As usual, comments and reviews are welcome.
Changes to v2:
- Move the 'host_traddr' attribute to the controller directory
- Rename callback to 'host_traddr'
Hannes Reinecke (8):
nvmet: add debugfs support
nvmet: add 'host_traddr' callback for debugfs
nvmet-tcp: implement host_traddr()
nvmet-rdma: implement host_traddr()
nvmet-fc: implement host_traddr()
nvme-fcloop: implement 'host_traddr'
lpfc_nvmet: implement 'host_traddr'
nvmet: add debugfs support for queues
drivers/nvme/target/Kconfig | 9 ++ drivers/nvme/target/Makefile | 1 + drivers/nvme/target/core.c | 32 ++++- drivers/nvme/target/debugfs.c | 250 +++++++++++++++++++++++++++++++++ drivers/nvme/target/debugfs.h | 50 +++++++ drivers/nvme/target/fc.c | 33 +++++ drivers/nvme/target/fcloop.c | 11 ++ drivers/nvme/target/nvmet.h | 15 +- drivers/nvme/target/rdma.c | 12 ++ drivers/nvme/target/tcp.c | 14 ++ drivers/scsi/lpfc/lpfc_nvmet.c | 11 ++ include/linux/nvme-fc-driver.h | 4 + 12 files changed, 439 insertions(+), 3 deletions(-) create mode 100644 drivers/nvme/target/debugfs.c create mode 100644 drivers/nvme/target/debugfs.h
Signature · 1 line
2.35.3
PATCH v3 2/8 nvmet: add 'host_traddr' callback for debugfs
We want to display the transport address of the connected host in debugfs, but this is a property of the transport. So add a callback 'host_traddr' to allow the transport drivers to fill in the data.
--- drivers/nvme/target/core.c | 8 ++++++++ drivers/nvme/target/debugfs.c | 19 +++++++++++++++++++ drivers/nvme/target/nvmet.h | 4 ++++ 3 files changed, 31 insertions(+)
drivers/nvme/target/core.c +8 -0
@@ -1527,6 +1527,14 @@ void nvmet_ctrl_fatal_error(struct nvmet_ctrl *ctrl) }EXPORT_SYMBOL_GPL (nvmet_ctrl_fatal_error); +ssize_t nvmet_ctrl_host_traddr (struct nvmet_ctrl *ctrl, +char *traddr,size_t traddr_len) +{ +if (!ctrl->ops->host_traddr) +return -EOPNOTSUPP ; +return ctrl->ops->host_traddr (ctrl, traddr, traddr_len); +} +static struct nvmet_subsys *nvmet_find_get_subsys (struct nvmet_port *port,const char *subsysnqn) {
drivers/nvme/target/debugfs.c +19 -0
@@ -114,6 +114,23 @@ static ssize_t nvmet_ctrl_state_write(struct file *file, const char __user *buf, }NVMET_DEBUGFS_RW_ATTR (nvmet_ctrl_state); +static int nvmet_ctrl_host_traddr_show (struct seq_file *m,void *p) +{ +struct nvmet_ctrl *ctrl = (struct nvmet_ctrl *)m->private; +ssize_t size; +char buf[NVMF_TRADDR_SIZE +1 ]; + + size =nvmet_ctrl_host_traddr (ctrl, buf,NVMF_TRADDR_SIZE ); +if (size <0 ) { + buf[0 ] ='\0' ; + size =0 ; + } + buf[size] ='\0' ; +seq_printf (m,"%s\n" , buf); +return 0 ; +} +NVMET_DEBUGFS_ATTR (nvmet_ctrl_host_traddr); +int nvmet_debugfs_ctrl_setup (struct nvmet_ctrl *ctrl) {char name[32 ];
@@ -137,6 +154,8 @@ int nvmet_debugfs_ctrl_setup(struct nvmet_ctrl *ctrl) &nvmet_ctrl_kato_fops);debugfs_create_file ("state" ,S_IRUSR |S_IWUSR , ctrl->debugfs_dir, ctrl, &nvmet_ctrl_state_fops); +debugfs_create_file ("host_traddr" ,S_IRUSR , ctrl->debugfs_dir, ctrl, + &nvmet_ctrl_host_traddr_fops);return 0 ; }
drivers/nvme/target/nvmet.h +4 -0
@@ -361,6 +361,8 @@ struct nvmet_fabrics_ops {void (*delete_ctrl)(struct nvmet_ctrl *ctrl);void (*disc_traddr)(struct nvmet_req *req,struct nvmet_port *port,char *traddr); +ssize_t (*host_traddr)(struct nvmet_ctrl *ctrl, +char *traddr,size_t traddr_len);u16 (*install_queue)(struct nvmet_sq *nvme_sq);void (*discovery_chg)(struct nvmet_port *port);u8 (*get_mdts)(const struct nvmet_ctrl *ctrl);
@@ -509,6 +511,8 @@ struct nvmet_ctrl *nvmet_ctrl_find_get(const char *subsysnqn, struct nvmet_req *req);void nvmet_ctrl_put (struct nvmet_ctrl *ctrl);u16 nvmet_check_ctrl_status (struct nvmet_req *req); +ssize_t nvmet_ctrl_host_traddr (struct nvmet_ctrl *ctrl, +char *traddr,size_t traddr_len);struct nvmet_subsys *nvmet_subsys_alloc (const char *subsysnqn,enum nvme_subsys_type type);
Signature · 1 line
2.35.3
PATCH v3 1/8 nvmet: add debugfs support
In reply to Hannes ReineckeAdd a debugfs hierarchy to display the configured subsystems and the controllers attached to the subsystems.
--- drivers/nvme/target/Kconfig | 9 ++ drivers/nvme/target/Makefile | 1 + drivers/nvme/target/core.c | 22 +++- drivers/nvme/target/debugfs.c | 182 ++++++++++++++++++++++++++++++++++ drivers/nvme/target/debugfs.h | 42 ++++++++ drivers/nvme/target/nvmet.h | 8 +- 6 files changed, 261 insertions(+), 3 deletions(-) create mode 100644 drivers/nvme/target/debugfs.c create mode 100644 drivers/nvme/target/debugfs.h
drivers/nvme/target/Kconfig +9 -0
@@ -18,6 +18,15 @@ config NVME_TARGET To configure the NVMe target you probably want to use the nvmetcli tool from http://git.infradead.org/users/hch/nvmetcli.git. +config NVME_TARGET_DEBUGFS + bool "NVMe Target debugfs support" + depends on NVME_TARGET + help + This enables debugfs support to display the connected controllers + to each subsystem + + If unsure, say N. + config NVME_TARGET_PASSTHRU bool "NVMe Target Passthrough support" depends on NVME_TARGET
drivers/nvme/target/Makefile +1 -0
@@ -11,6 +11,7 @@ obj-$(CONFIG_NVME_TARGET_TCP) += nvmet-tcp.o nvmet-y += core.o configfs.o admin-cmd.o fabrics-cmd.o \ discovery.o io-cmd-file.o io-cmd-bdev.o +nvmet-$(CONFIG_NVME_TARGET_DEBUGFS) += debugfs.o nvmet-$(CONFIG_NVME_TARGET_PASSTHRU) += passthru.o nvmet-$(CONFIG_BLK_DEV_ZONED) += zns.o nvmet-$(CONFIG_NVME_TARGET_AUTH) += fabrics-cmd-auth.o auth.o
drivers/nvme/target/core.c +21 -1
@@ -16,6 +16,7 @@#include "trace.h" #include "nvmet.h" +#include "debugfs.h" struct kmem_cache *nvmet_bvec_cache;struct workqueue_struct *buffered_io_wq;
@@ -1463,6 +1464,7 @@ u16 nvmet_alloc_ctrl(const char *subsysnqn, const char *hostnqn,mutex_lock (&subsys->lock);list_add_tail (&ctrl->subsys_entry, &subsys->ctrls);nvmet_setup_p2p_ns_map (ctrl, req); +nvmet_debugfs_ctrl_setup (ctrl);mutex_unlock (&subsys->lock); *ctrlp = ctrl;
@@ -1497,6 +1499,8 @@ static void nvmet_ctrl_free(struct kref *ref)nvmet_destroy_auth (ctrl); +nvmet_debugfs_ctrl_free (ctrl); +ida_free (&cntlid_ida, ctrl->cntlid);nvmet_async_events_free (ctrl);
@@ -1610,8 +1614,14 @@ struct nvmet_subsys *nvmet_subsys_alloc(const char *subsysnqn,INIT_LIST_HEAD (&subsys->ctrls);INIT_LIST_HEAD (&subsys->hosts); + ret =nvmet_debugfs_subsys_setup (subsys); +if (ret) + goto free_subsysnqn; +return subsys; +free_subsysnqn: +kfree (subsys->subsysnqn); free_fr:kfree (subsys->firmware_rev); free_mn:
@@ -1628,6 +1638,8 @@ static void nvmet_subsys_free(struct kref *ref)WARN_ON_ONCE (!xa_empty (&subsys->namespaces)); +nvmet_debugfs_subsys_free (subsys); +xa_destroy (&subsys->namespaces);nvmet_passthru_subsys_free (subsys);
@@ -1681,11 +1693,18 @@ static int __init nvmet_init(void)if (error) goto out_free_nvmet_work_queue; - error =nvmet_init_configfs (); + error =nvmet_init_debugfs ();if (error) goto out_exit_discovery; + + error =nvmet_init_configfs (); +if (error) + goto out_exit_debugfs; +return 0 ; +out_exit_debugfs: +nvmet_exit_debugfs (); out_exit_discovery:nvmet_exit_discovery (); out_free_nvmet_work_queue:
@@ -1702,6 +1721,7 @@ static int __init nvmet_init(void) static void __exit nvmet_exit(void) {nvmet_exit_configfs (); +nvmet_exit_debugfs ();nvmet_exit_discovery ();ida_destroy (&cntlid_ida);destroy_workqueue (nvmet_wq);
drivers/nvme/target/debugfs.c new file +182 -0
182 lines not on this page · raw message
drivers/nvme/target/debugfs.h new file +42 -0
42 lines not on this page · raw message
drivers/nvme/target/nvmet.h +6 -2
@@ -233,7 +233,9 @@ struct nvmet_ctrl {struct device *p2p_client;struct radix_tree_root p2p_ns_map; - +#ifdef CONFIG_NVME_TARGET_DEBUGFS +struct dentry *debugfs_dir; +#endif spinlock_t error_lock;u64 err_counter;struct nvme_error_slot slots[NVMET_ERROR_LOG_SLOTS ];
@@ -269,7 +271,9 @@ struct nvmet_subsys {struct list_head hosts;bool allow_any_host; - +#ifdef CONFIG_NVME_TARGET_DEBUGFS +struct dentry *debugfs_dir; +#endif u16 max_qid;u64 ver;
Signature · 1 line
2.35.3
PATCH v3 3/8 nvmet-tcp: implement host_traddr()
In reply to Hannes ReineckeImplement callback to display the host transport address.
--- drivers/nvme/target/tcp.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/nvme/target/tcp.c +14 -0
@@ -2201,6 +2201,19 @@ static void nvmet_tcp_disc_port_addr(struct nvmet_req *req, } } +static ssize_t nvmet_tcp_host_port_addr (struct nvmet_ctrl *ctrl, +char *traddr,size_t traddr_len) +{ +struct nvmet_sq *sq = ctrl->sqs[0 ]; +struct nvmet_tcp_queue *queue = + container_of(sq, struct nvmet_tcp_queue, nvme_sq); + +if (queue->sockaddr_peer.ss_family ==AF_UNSPEC ) +return -EINVAL ; +return snprintf (traddr, traddr_len,"%pISc" , + (struct sockaddr *)&queue->sockaddr_peer); +} +static const struct nvmet_fabrics_ops nvmet_tcp_ops = { .owner =THIS_MODULE , .type =NVMF_TRTYPE_TCP ,
@@ -2211,6 +2224,7 @@ static const struct nvmet_fabrics_ops nvmet_tcp_ops = { .delete_ctrl = nvmet_tcp_delete_ctrl, .install_queue = nvmet_tcp_install_queue, .disc_traddr = nvmet_tcp_disc_port_addr, + .host_traddr = nvmet_tcp_host_port_addr, };static int __init nvmet_tcp_init (void )
Signature · 1 line
2.35.3
PATCH v3 4/8 nvmet-rdma: implement host_traddr()
In reply to Hannes ReineckeImplement callback to display the host transport address.
--- drivers/nvme/target/rdma.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/nvme/target/rdma.c +12 -0
@@ -2014,6 +2014,17 @@ static void nvmet_rdma_disc_port_addr(struct nvmet_req *req, } } +static ssize_t nvmet_rdma_host_port_addr (struct nvmet_ctrl *ctrl, +char *traddr,size_t traddr_len) +{ +struct nvmet_sq *nvme_sq = ctrl->sqs[0 ]; +struct nvmet_rdma_queue *queue = + container_of(nvme_sq, struct nvmet_rdma_queue, nvme_sq); + +return snprintf (traddr, traddr_len,"%pISc" , + (struct sockaddr *)&queue->cm_id->route.addr.dst_addr); +} +static u8 nvmet_rdma_get_mdts (const struct nvmet_ctrl *ctrl) {if (ctrl->pi_support)
@@ -2038,6 +2049,7 @@ static const struct nvmet_fabrics_ops nvmet_rdma_ops = { .queue_response = nvmet_rdma_queue_response, .delete_ctrl = nvmet_rdma_delete_ctrl, .disc_traddr = nvmet_rdma_disc_port_addr, + .host_traddr = nvmet_rdma_host_port_addr, .get_mdts = nvmet_rdma_get_mdts, .get_max_queue_size = nvmet_rdma_get_max_queue_size, };
Signature · 1 line
2.35.3
PATCH v3 6/8 nvme-fcloop: implement 'host_traddr'
In reply to Hannes ReineckeImplement the 'host_traddr' callback to display the host transport address for nvmet debugfs.
--- drivers/nvme/target/fcloop.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/nvme/target/fcloop.c +11 -0
@@ -492,6 +492,16 @@ fcloop_t2h_host_release(void *hosthandle)/* host handle ignored for now */ } +static int +fcloop_t2h_host_traddr (void *hosthandle,u64 *wwnn,u64 *wwpn) +{ +struct fcloop_rport *rport = hosthandle; + + *wwnn = rport->lport->localport->node_name; + *wwpn = rport->lport->localport->port_name; +return 0 ; +} +/* * Simulate reception of RSCN and converting it to a initiator transport * call to rescan a remote port.
@@ -1074,6 +1084,7 @@ static struct nvmet_fc_target_template tgttemplate = { .ls_req = fcloop_t2h_ls_req, .ls_abort = fcloop_t2h_ls_abort, .host_release = fcloop_t2h_host_release, + .host_traddr = fcloop_t2h_host_traddr, .max_hw_queues = FCLOOP_HW_QUEUES, .max_sgl_segments = FCLOOP_SGL_SEGS, .max_dif_sgl_segments = FCLOOP_SGL_SEGS,
Signature · 1 line
2.35.3
PATCH v3 5/8 nvmet-fc: implement host_traddr()
In reply to Hannes ReineckeImplement callback to display the host transport address by adding a callback 'host_traddr' for nvmet_fc_target_template.
--- drivers/nvme/target/fc.c | 33 +++++++++++++++++++++++++++++++++ include/linux/nvme-fc-driver.h | 4 ++++ 2 files changed, 37 insertions(+)
drivers/nvme/target/fc.c +33 -0
@@ -2931,6 +2931,38 @@ nvmet_fc_discovery_chg(struct nvmet_port *port) tgtport->ops->discovery_event (&tgtport->fc_target_port); } +static ssize_t +nvmet_fc_host_traddr (struct nvmet_ctrl *ctrl, +char *traddr,size_t traddr_size) +{ +struct nvmet_sq *sq = ctrl->sqs[0 ]; +struct nvmet_fc_tgt_queue *queue = + container_of(sq, struct nvmet_fc_tgt_queue, nvme_sq); +struct nvmet_fc_tgtport *tgtport = queue->assoc ? queue->assoc->tgtport :NULL ; +struct nvmet_fc_hostport *hostport = queue->assoc ? queue->assoc->hostport :NULL ; +u64 wwnn, wwpn; +ssize_t ret =0 ; + +if (!tgtport || !nvmet_fc_tgtport_get (tgtport)) +return -ENODEV ; +if (!hostport || !nvmet_fc_hostport_get (hostport)) { + ret = -ENODEV ; + goto out_put; + } + +if (tgtport->ops->host_traddr) { + ret = tgtport->ops->host_traddr (hostport->hosthandle, &wwnn, &wwpn); +if (ret) + goto out_put_host; + ret =snprintf (traddr, traddr_size,"nn-0x%llx:pn-0x%llx" , wwnn, wwpn); + } +out_put_host: +nvmet_fc_hostport_put (hostport); +out_put: +nvmet_fc_tgtport_put (tgtport); +return ret; +} +static const struct nvmet_fabrics_ops nvmet_fc_tgt_fcp_ops = { .owner =THIS_MODULE , .type =NVMF_TRTYPE_FC ,
@@ -2940,6 +2972,7 @@ static const struct nvmet_fabrics_ops nvmet_fc_tgt_fcp_ops = { .queue_response = nvmet_fc_fcp_nvme_cmd_done, .delete_ctrl = nvmet_fc_delete_ctrl, .discovery_chg = nvmet_fc_discovery_chg, + .host_traddr = nvmet_fc_host_traddr, };static int __init nvmet_fc_init_module (void )
include/linux/nvme-fc-driver.h +4 -0
@@ -920,6 +920,9 @@ struct nvmet_fc_target_port {* further references to hosthandle. * Entrypoint is Mandatory if the lldd calls nvmet_fc_invalidate_host(). * +* @host_traddr: called by the transport to retrieve the node name and +* port name of the host port address. +* * @max_hw_queues: indicates the maximum number of hw queues the LLDD * supports for cpu affinitization. * Value is Mandatory. Must be at least 1.
@@ -975,6 +978,7 @@ struct nvmet_fc_target_template {void (*ls_abort)(struct nvmet_fc_target_port *targetport,void *hosthandle,struct nvmefc_ls_req *lsreq);void (*host_release)(void *hosthandle); +int (*host_traddr)(void *hosthandle,u64 *wwnn,u64 *wwpn);u32 max_hw_queues;u16 max_sgl_segments;
Signature · 1 line
2.35.3
PATCH v3 7/8 lpfc_nvmet: implement 'host_traddr'
In reply to Hannes ReineckeImplement the 'host_traddr' callback to display the host transport address for nvmet debugfs.
--- drivers/scsi/lpfc/lpfc_nvmet.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/scsi/lpfc/lpfc_nvmet.c +11 -0
@@ -1363,6 +1363,16 @@ lpfc_nvmet_ls_abort(struct nvmet_fc_target_port *targetport,atomic_inc (&lpfc_nvmet->xmt_ls_abort); } +static int +lpfc_nvmet_host_traddr (void *hosthandle,u64 *wwnn,u64 *wwpn) +{ +struct lpfc_nodelist *ndlp = hosthandle; + + *wwnn =wwn_to_u64 (ndlp->nlp_nodename.u.wwn); + *wwpn =wwn_to_u64 (ndlp->nlp_portname.u.wwn); +return 0 ; +} +static void lpfc_nvmet_host_release (void *hosthandle) {
@@ -1413,6 +1423,7 @@ static struct nvmet_fc_target_template lpfc_tgttemplate = { .ls_req = lpfc_nvmet_ls_req, .ls_abort = lpfc_nvmet_ls_abort, .host_release = lpfc_nvmet_host_release, + .host_traddr = lpfc_nvmet_host_traddr, .max_hw_queues = 1, .max_sgl_segments = LPFC_NVMET_DEFAULT_SEGS,
Signature · 1 line
2.35.3
PATCH v3 8/8 nvmet: add debugfs support for queues
In reply to Hannes ReineckeAdd debugfs entries to display the status of the controller queues.
--- drivers/nvme/target/core.c | 2 ++ drivers/nvme/target/debugfs.c | 49 +++++++++++++++++++++++++++++++++++ drivers/nvme/target/debugfs.h | 8 ++++++ drivers/nvme/target/nvmet.h | 3 +++ 4 files changed, 62 insertions(+)
drivers/nvme/target/core.c +2 -0
@@ -791,6 +791,7 @@ void nvmet_sq_setup(struct nvmet_ctrl *ctrl, struct nvmet_sq *sq, sq->size = size; ctrl->sqs[qid] = sq; +nvmet_debugfs_queue_setup (ctrl, sq); }static void nvmet_confirm_sq (struct percpu_ref *ref)
@@ -815,6 +816,7 @@ void nvmet_sq_destroy(struct nvmet_sq *sq)wait_for_completion (&sq->free_done);percpu_ref_exit (&sq->ref);nvmet_auth_sq_free (sq); +nvmet_debugfs_queue_free (sq);if (ctrl) {/*
drivers/nvme/target/debugfs.c +49 -0
55 lines not on this page · raw message
drivers/nvme/target/debugfs.h +8 -0
@@ -14,6 +14,8 @@ int nvmet_debugfs_subsys_setup(struct nvmet_subsys *subsys);void nvmet_debugfs_subsys_free (struct nvmet_subsys *subsys);int nvmet_debugfs_ctrl_setup (struct nvmet_ctrl *ctrl);void nvmet_debugfs_ctrl_free (struct nvmet_ctrl *ctrl); +int nvmet_debugfs_queue_setup (struct nvmet_ctrl *ctrl,struct nvmet_sq *sq); +void nvmet_debugfs_queue_free (struct nvmet_sq *sq);int __init nvmet_init_debugfs (void );void nvmet_exit_debugfs (void );
@@ -30,6 +32,12 @@ static inline int nvmet_debugfs_ctrl_setup(struct nvmet_ctrl *ctrl) }static inline void nvmet_debugfs_ctrl_free (struct nvmet_ctrl *ctrl) {} +static inline int nvmet_debugfs_sq_setup (struct nvmet_ctrl *ctrl,struct nvmet_sq *sq) +{ +return 0 ; +} +static inline void nvmet_debugfs_sq_free (struct nvmet_sq *sq) {} +static inline int __init nvmet_init_debugfs (void ) {return 0 ;
drivers/nvme/target/nvmet.h +3 -0
@@ -109,6 +109,9 @@ struct nvmet_sq {u16 size;u32 sqhd;bool sqhd_disabled; +#ifdef CONFIG_NVME_TARGET_DEBUGFS +struct dentry *debugfs_dir; +#endif #ifdef CONFIG_NVME_TARGET_AUTH bool authenticated;struct delayed_work auth_expired_work;
Signature · 1 line
2.35.3
Sagi Grimberg
maintainerRe: [PATCH 1/8] nvmet: add debugfs support
In reply to Hannes ReineckeQuoted 7 lines
drivers/nvme/target/debugfs.c new file +7
-0+int nvmet_debugfs_subsys_setup (struct nvmet_subsys *subsys) +{ +int ret =0 ; + + subsys->debugfs_dir =debugfs_create_dir (subsys->subsysnqn, + nvmet_debugfs); +if (IS_ERR (subsys->debugfs_dir)) {
drivers/nvme/target/debugfs.c line 164
Quoted 10 lines
drivers/nvme/target/debugfs.c new file +10
-0+ ret =PTR_ERR (subsys->debugfs_dir); + subsys->debugfs_dir =NULL ; + } +return ret; +} + +void nvmet_debugfs_subsys_free (struct nvmet_subsys *subsys) +{ +debugfs_remove_recursive (subsys->debugfs_dir); +}
The subsys setup/free look trivial enough to just open-code in the call-sites.
The rest looks fine to me.
Re: [PATCH 2/8] nvmet: add 'host_traddr' callback for debugfs
In reply to Hannes ReineckeRe: [PATCH 3/8] nvmet-tcp: implement host_traddr()
In reply to Hannes ReineckeRe: [PATCH 4/8] nvmet-rdma: implement host_traddr()
In reply to Hannes ReineckeSagi Grimberg
maintainerRe: [PATCH 8/8] nvmet: add debugfs support for queues
In reply to Hannes ReineckeQuoted 2 lines · Hannes Reinecke
Add debugfs entries to display the status of the controller queues.
I'm questioning the value of this. We can possibly see lots and lots of queues and I wonder how a queue entry will this actually help.
Re: [PATCH 8/8] nvmet: add debugfs support for queues
Quoted 8 lines · Sagi Grimberg
Quoted 2 lines · Hannes Reinecke
Add debugfs entries to display the status of the controller queues.
I'm questioning the value of this. We can possibly see lots and lots of queues and I wonder how a queue entry will this actually help.
One can inspect I/O progress via the sqhead attribute; also one would
want to know the number of queues created.
But we can leave it for now; main part of this patchset is the controller entries and the possibility to trigger a controller reset.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Sagi Grimberg
maintainerRe: [PATCH 8/8] nvmet: add debugfs support for queues
Quoted 7 lines · Hannes Reinecke
Quoted 6 lines · Sagi Grimberg
Quoted 2 lines · Hannes Reinecke
Add debugfs entries to display the status of the controller queues.
Quoted 6 lines
Quoted 2 lines
I'm questioning the value of this. We can possibly see lots and lots of queues and I wonder how a queue entry will this actually help.
One can inspect I/O progress via the sqhead attribute; also one would
want to know the number of queues created.
But we can leave it for now; main part of this patchset is the controller entries and the possibility to trigger a controller reset.
Lets drop the queue debug stats for now
Re: [PATCH 1/8] nvmet: add debugfs support
In reply to Hannes ReineckeReview
Quoted 13 lines · Hannes Reinecke
(quoted diff) +13
-0+static ssize_t nvmet_ctrl_state_write(struct file *file, const char __user *buf, + size_t count, loff_t *ppos) +{ + struct seq_file *m = file->private_data; + struct nvmet_ctrl *ctrl = m->private; + char reset[16]; + + if (count >= sizeof(reset)) + return -EINVAL; + if (copy_from_user(reset, buf, count)) + return -EFAULT; + if (!memcmp(reset, "fatal", 5)) + nvmet_ctrl_fatal_error(ctrl);
I'd like to use this also to trigger a reset. This allows to test the auth code a bit better, e.g. after changing the ctrl key on the target nothing will happen until a reconnect happens. Currently, I have to set the max queue count which triggers a reset. Also it would make the 'support real hardware' series for blktests why more generic.
This here should does the trick in my local testing:
drivers/nvme/target/debugfs.c +2 -0
@@ -157,6 +157,8 @@ static ssize_t nvmet_ctrl_state_write(struct file *file, const char __user *buf,return -EFAULT ;if (!memcmp (reset,"fatal" ,5 ))nvmet_ctrl_fatal_error (ctrl); +else if (!memcmp (reset,"reset" ,5 )) + ctrl->ops->delete_ctrl (ctrl);else return -EINVAL ;return count;
Re: [PATCH 1/8] nvmet: add debugfs support
Quoted 27 lines · Daniel Wagner
Review
Quoted 13 lines · Hannes Reinecke
(quoted diff) +13
-0+static ssize_t nvmet_ctrl_state_write(struct file *file, const char __user *buf, + size_t count, loff_t *ppos) +{ + struct seq_file *m = file->private_data; + struct nvmet_ctrl *ctrl = m->private; + char reset[16]; + + if (count >= sizeof(reset)) + return -EINVAL; + if (copy_from_user(reset, buf, count)) + return -EFAULT; + if (!memcmp(reset, "fatal", 5)) + nvmet_ctrl_fatal_error(ctrl);I'd like to use this also to trigger a reset. This allows to test the auth code a bit better, e.g. after changing the ctrl key on the target nothing will happen until a reconnect happens. Currently, I have to set the max queue count which triggers a reset. Also it would make the 'support real hardware' series for blktests why more generic.
This here should does the trick in my local testing:
drivers/nvme/target/debugfs.c static ssize_t nvmet_ctrl_state_write(struct file *file, const char __user *buf, · line 164
Quoted 8 lines
drivers/nvme/target/debugfs.c +2
-0@@ -157,6 +157,8 @@ static ssize_t nvmet_ctrl_state_write(struct file *file, const char __user *buf,return -EFAULT ;if (!memcmp (reset,"fatal" ,5 ))nvmet_ctrl_fatal_error (ctrl); +else if (!memcmp (reset,"reset" ,5 )) + ctrl->ops->delete_ctrl (ctrl);else return -EINVAL ;return count;
and here the corresponding test extension (nvme/045)
echo "Renew host key on the controller and force reconnect"
new_hostkey="$(nvme gen-dhchap-key -n ${def_subsysnqn} 2> /dev/null)"
_set_nvmet_hostkey "${def_hostnqn}" "${new_hostkey}"
# Force a reconnect
nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
cntlid="$(nvme id-ctrl -o json "/dev/${nvmedev}" | jq .cntlid)"
echo "reset" > /sys/kernel/debug/nvmet/"${def_subsysnqn}/ctrl${cntlid}"/state
nvmf_wait_for_ctrl_delete "${nvmedev}"Sagi Grimberg
maintainerRe: [PATCH 1/8] nvmet: add debugfs support
In reply to Daniel WagnerQuoted 25 lines · Daniel Wagner
Review
Quoted 13 lines · Hannes Reinecke
(quoted diff) +13
-0+static ssize_t nvmet_ctrl_state_write(struct file *file, const char __user *buf, + size_t count, loff_t *ppos) +{ + struct seq_file *m = file->private_data; + struct nvmet_ctrl *ctrl = m->private; + char reset[16]; + + if (count >= sizeof(reset)) + return -EINVAL; + if (copy_from_user(reset, buf, count)) + return -EFAULT; + if (!memcmp(reset, "fatal", 5)) + nvmet_ctrl_fatal_error(ctrl);I'd like to use this also to trigger a reset. This allows to test the auth code a bit better, e.g. after changing the ctrl key on the target nothing will happen until a reconnect happens. Currently, I have to set the max queue count which triggers a reset. Also it would make the 'support real hardware' series for blktests why more generic.
This here should does the trick in my local testing:
drivers/nvme/target/debugfs.c static ssize_t nvmet_ctrl_state_write(struct file *file, const char __user *buf, · line 164
Quoted 8 lines
drivers/nvme/target/debugfs.c +2
-0@@ -157,6 +157,8 @@ static ssize_t nvmet_ctrl_state_write(struct file *file, const char __user *buf,return -EFAULT ;if (!memcmp (reset,"fatal" ,5 ))nvmet_ctrl_fatal_error (ctrl); +else if (!memcmp (reset,"reset" ,5 )) + ctrl->ops->delete_ctrl (ctrl);else return -EINVAL ;return count;
What is the difference between fatal and reset?
Re: [PATCH 1/8] nvmet: add debugfs support
In reply to Daniel WagnerQuoted 27 lines · Daniel Wagner
Review
Quoted 13 lines · Hannes Reinecke
(quoted diff) +13
-0+static ssize_t nvmet_ctrl_state_write(struct file *file, const char __user *buf, + size_t count, loff_t *ppos) +{ + struct seq_file *m = file->private_data; + struct nvmet_ctrl *ctrl = m->private; + char reset[16]; + + if (count >= sizeof(reset)) + return -EINVAL; + if (copy_from_user(reset, buf, count)) + return -EFAULT; + if (!memcmp(reset, "fatal", 5)) + nvmet_ctrl_fatal_error(ctrl);I'd like to use this also to trigger a reset. This allows to test the auth code a bit better, e.g. after changing the ctrl key on the target nothing will happen until a reconnect happens. Currently, I have to set the max queue count which triggers a reset. Also it would make the 'support real hardware' series for blktests why more generic.
This here should does the trick in my local testing:
drivers/nvme/target/debugfs.c static ssize_t nvmet_ctrl_state_write(struct file *file, const char __user *buf, · line 164
Quoted 8 lines
drivers/nvme/target/debugfs.c +2
-0@@ -157,6 +157,8 @@ static ssize_t nvmet_ctrl_state_write(struct file *file, const char __user *buf,return -EFAULT ;if (!memcmp (reset,"fatal" ,5 ))nvmet_ctrl_fatal_error (ctrl); +else if (!memcmp (reset,"reset" ,5 )) + ctrl->ops->delete_ctrl (ctrl);else return -EINVAL ;return count;
Weelll ... guess what the 'fatal' status does ...
I can rename it to 'reset' if you'd like, but 'fatal' corresponds to one of the controller states, whereas 'reset' doesn't. But I can make it an alias if you really want to write 'reset' :-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Re: [PATCH 1/8] nvmet: add debugfs support
In reply to Sagi GrimbergQuoted 25 lines · Sagi Grimberg
Quoted 22 lines · Daniel Wagner
Review
Quoted 13 lines · Hannes Reinecke
(quoted diff) +13
-0+static ssize_t nvmet_ctrl_state_write(struct file *file, const char __user *buf, + size_t count, loff_t *ppos) +{ + struct seq_file *m = file->private_data; + struct nvmet_ctrl *ctrl = m->private; + char reset[16]; + + if (count >= sizeof(reset)) + return -EINVAL; + if (copy_from_user(reset, buf, count)) + return -EFAULT; + if (!memcmp(reset, "fatal", 5)) + nvmet_ctrl_fatal_error(ctrl);I'd like to use this also to trigger a reset. This allows to test the auth code a bit better, e.g. after changing the ctrl key on the target nothing will happen until a reconnect happens. Currently, I have to set the max queue count which triggers a reset. Also it would make the 'support real hardware' series for blktests why more generic.
This here should does the trick in my local testing:
Quoted 13 lines
drivers/nvme/target/debugfs.c static ssize_t nvmet_ctrl_state_write(struct file *file, const char __user *buf, · line 164
Quoted 11 lines
drivers/nvme/target/debugfs.c +2
-0@@ -157,6 +157,8 @@ static ssize_t nvmet_ctrl_state_write(struct file *file, const char __user *buf,return -EFAULT ;if (!memcmp (reset,"fatal" ,5 ))nvmet_ctrl_fatal_error (ctrl); +else if (!memcmp (reset,"reset" ,5 )) + ctrl->ops->delete_ctrl (ctrl);else return -EINVAL ;return count;What is the difference between fatal and reset?
nvmet_ctrl_fatal_error() also calls ctrl->ops->delete_ctrl() eventually but also logs 'fatal error occurred'. This works also just fine for what I had in mind.
Re: [PATCH 1/8] nvmet: add debugfs support
In reply to Hannes ReineckeQuoted 4 lines · Hannes Reinecke
Weelll ... guess what the 'fatal' status does ...
I can rename it to 'reset' if you'd like, but 'fatal' corresponds to one of the controller states, whereas 'reset' doesn't.
But I can make it an alias if you really want to write 'reset' :-)
I am fine with 'fatal'.
Re: [PATCH 1/8] nvmet: add debugfs support
In reply to Sagi GrimbergQuoted 21 lines · Sagi Grimberg
Quoted 7 lines
drivers/nvme/target/debugfs.c new file +7
-0+int nvmet_debugfs_subsys_setup (struct nvmet_subsys *subsys) +{ + int ret = 0; + + subsys->debugfs_dir = debugfs_create_dir(subsys->subsysnqn, + nvmet_debugfs); + if (IS_ERR(subsys->debugfs_dir)) {drivers/nvme/target/debugfs.c line 164
Quoted 10 lines
drivers/nvme/target/debugfs.c new file +10
-0+ ret = PTR_ERR(subsys->debugfs_dir); + subsys->debugfs_dir = NULL; + } + return ret; +} + +void nvmet_debugfs_subsys_free (struct nvmet_subsys *subsys) +{ + debugfs_remove_recursive(subsys->debugfs_dir); +}The subsys setup/free look trivial enough to just open-code in the call-sites.
Quoted 1 line
The rest looks fine to me.
Agreed for the 'free' call, the setup call has to stay as it's referring to the static dentry 'nvmet_debugfs', which I'd like to keep private to 'debugfs.c'.
Cheers,
Hannes