nvme: improve logging
cover nvme: improve logging
These code changes are originally posted by
Hannes Reinecke <hare at suse.com> :-
http://lists.infradead.org/pipermail/linux-nvme/2019-April/023336.html
I've added all the comments posted on this patch-series along with my signoff to the patches. Please keep my sign off if Hannes is okay with it.
Regards,
-Chaitanya
Changes from V1:
1. Move the NVMe ctrl state array of string to the header file whee all controller states are defined.
2. Remvoe extra state_name variable and use the nvme_get_ctrl_state_name() when reporting the ctrl state.
3. Add "nvme-mp" prefix to the debug message for multipating code. Chaitanya Kulkarni (3):
nvme: introduce nvme-ctrl state name string array
nvme: improve logging
nvme-multipath: improve logging
drivers/nvme/host/core.c | 41 ++++++++++++++++++++--------------- drivers/nvme/host/multipath.c | 5 ++++- drivers/nvme/host/nvme.h | 10 +++++++++ 3 files changed, 37 insertions(+), 19 deletions(-)
Signature · 1 line
2.17.0
PATCH v2 1/3 nvme: introduce nvme-ctrl state name string array
From: Hannes Reinecke <[email protected]>
This patch intoduces nvme-ctrl state name array which is used inthe the later patch to improve the logging of the ctrl state.
--- drivers/nvme/host/nvme.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/nvme/host/nvme.h +10 -0
@@ -146,6 +146,16 @@ enum nvme_ctrl_state { NVME_CTRL_DEAD, }; +static const char *const nvme_ctrl_state_name[] = { + [NVME_CTRL_NEW ] ="new" , + [NVME_CTRL_LIVE ] ="live" , + [NVME_CTRL_ADMIN_ONLY ] ="only-admin" , + [NVME_CTRL_RESETTING ] ="resetting" , + [NVME_CTRL_CONNECTING ] ="connecting" , + [NVME_CTRL_DELETING ] ="deleting" , + [NVME_CTRL_DEAD ] ="dead" , +}; +struct nvme_ctrl {bool comp_seen;enum nvme_ctrl_state state;
Signature · 1 line
2.17.0
PATCH v2 1/3 nvme: introduce nvme-ctrl state name string array
Quoted 3 lines · Chaitanya Kulkarni
From: Hannes Reinecke <hare at suse.com>
This patch intoduces nvme-ctrl state name array which is used inthe the
s/intoduces /introduces/
s/inthe/in the/
Quoted 15 lines
later patch to improve the logging of the ctrl state.
Signed-off-by Hannes Reinecke <hare at suse.com>Signed-off-by Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>--- drivers/nvme/host/nvme.h | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/nvme/host/nvme.h +0
-0@@ -146,6 +146,16 @@ enum nvme_ctrl_state { NVME_CTRL_DEAD, };
drivers/nvme/host/nvme.h enum nvme_ctrl_state { · line 157
Quoted 10 lines
drivers/nvme/host/nvme.h +9
-0+static const char *const nvme_ctrl_state_name[] = { + [NVME_CTRL_NEW ] ="new" , + [NVME_CTRL_LIVE ] ="live" , + [NVME_CTRL_ADMIN_ONLY ] ="only-admin" , + [NVME_CTRL_RESETTING ] ="resetting" , + [NVME_CTRL_CONNECTING ] ="connecting" , + [NVME_CTRL_DELETING ] ="deleting" , + [NVME_CTRL_DEAD ] ="dead" , +};
I haven't been paying attention if this was bought up before but won't this create multiple copies of this data for every source file the includes the header file?
Quoted 5 lines
drivers/nvme/host/nvme.h +1
-0+struct nvme_ctrl {bool comp_seen;enum nvme_ctrl_state state;
PATCH v2 1/3 nvme: introduce nvme-ctrl state name string array
Quoted 25 lines · Kenneth
Quoted 3 lines · Chaitanya Kulkarni
From: Hannes Reinecke <hare at suse.com>
This patch intoduces nvme-ctrl state name array which is used inthe the
s/intoduces /introduces/
s/inthe/in the/Quoted 16 lines
later patch to improve the logging of the ctrl state.
Signed-off-by Hannes Reinecke <hare at suse.com>Signed-off-by Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>--- drivers/nvme/host/nvme.h | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/nvme/host/nvme.h +0
-0@@ -146,6 +146,16 @@ enum nvme_ctrl_state { NVME_CTRL_DEAD, };
Quoted 13 lines
drivers/nvme/host/nvme.h enum nvme_ctrl_state { · line 157
Quoted 9 lines
drivers/nvme/host/nvme.h +9
-0+static const char *const nvme_ctrl_state_name[] = { + [NVME_CTRL_NEW ] ="new" , + [NVME_CTRL_LIVE ] ="live" , + [NVME_CTRL_ADMIN_ONLY ] ="only-admin" , + [NVME_CTRL_RESETTING ] ="resetting" , + [NVME_CTRL_CONNECTING ] ="connecting" , + [NVME_CTRL_DELETING ] ="deleting" , + [NVME_CTRL_DEAD ] ="dead" , +};I haven't been paying attention if this was bought up before but won't this create multiple copies of this data for every source file the includes the header file?
Yes, we did discuss this.
Quoted 12 lines
drivers/nvme/host/nvme.h enum nvme_ctrl_state { · line 161
Quoted 6 lines
drivers/nvme/host/nvme.h +1
-0+struct nvme_ctrl {bool comp_seen;enum nvme_ctrl_state state;_______________________________________________
Linux-nvme mailing list
Linux-nvme at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
PATCH v2 1/3 nvme: introduce nvme-ctrl state name string array
Quoted 41 lines · Chaitanya Kulkarni
Quoted 26 lines · Kenneth
Quoted 3 lines · Chaitanya Kulkarni
From: Hannes Reinecke <hare at suse.com>
This patch intoduces nvme-ctrl state name array which is used inthe the
s/intoduces /introduces/
s/inthe/in the/Quoted 16 lines
later patch to improve the logging of the ctrl state.
Signed-off-by Hannes Reinecke <hare at suse.com>Signed-off-by Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>--- drivers/nvme/host/nvme.h | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/nvme/host/nvme.h +0
-0@@ -146,6 +146,16 @@ enum nvme_ctrl_state { NVME_CTRL_DEAD, };Quoted 13 lines
drivers/nvme/host/nvme.h enum nvme_ctrl_state { · line 157
Quoted 9 lines
drivers/nvme/host/nvme.h +9
-0+static const char *const nvme_ctrl_state_name[] = { + [NVME_CTRL_NEW ] ="new" , + [NVME_CTRL_LIVE ] ="live" , + [NVME_CTRL_ADMIN_ONLY ] ="only-admin" , + [NVME_CTRL_RESETTING ] ="resetting" , + [NVME_CTRL_CONNECTING ] ="connecting" , + [NVME_CTRL_DELETING ] ="deleting" , + [NVME_CTRL_DEAD ] ="dead" , +};I haven't been paying attention if this was bought up before but won't this create multiple copies of this data for every source file the includes the header file?
Quoted 1 line
Yes, we did discuss this.
Hi Chaitanya,
In an e-mail from Christoph I found the following recommendation with regard to the nvme_ctrl_state_name[] array: "Just keep it near the top of multipath.c." and you replied "Okay, that works too."
Did I perhaps miss something?
Thanks,
Bart.
Sagi Grimberg
maintainerPATCH v2 1/3 nvme: introduce nvme-ctrl state name string array
Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
I haven't been paying attention if this was bought up before but won't this create multiple copies of this data for every source file the includes the header file?
Yes, we did discuss this.
Quoted 7 lines
Hi Chaitanya,
In an e-mail from Christoph I found the following recommendation with regard to the nvme_ctrl_state_name[] array: "Just keep it near the top of
multipath.c." and you replied "Okay, that works too."Did I perhaps miss something?
That was my recollection too...
PATCH v2 1/3 nvme: introduce nvme-ctrl state name string array
Seems like I missed it. Let me send the V3 along with other comments from Sagi.
Quoted 6 lines · Linux-nvme on behalf of Sagi Grimberg
Quoted 5 lines
Quoted 3 lines
I haven't been paying attention if this was bought up before but won't this create multiple copies of this data for every source file the includes the header file?
Yes, we did discuss this.
Quoted 7 lines
Hi Chaitanya,
In an e-mail from Christoph I found the following recommendation with regard to the nvme_ctrl_state_name[] array: "Just keep it near the top of
multipath.c." and you replied "Okay, that works too."Did I perhaps miss something?
That was my recollection too...
_______________________________________________
Linux-nvme mailing list
Linux-nvme at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
PATCH v2 2/3 nvme: improve logging
In reply to Chaitanya KulkarniFrom: Hannes Reinecke <[email protected]>
Currently nvme is very reluctant if it comes to logging anything, _unless_ it's an ANA AEN. So this patch tries to remedy this by decreasing the priority for the ANA AEN logging message, and improve the logging when calling nvme_reset_ctrl().
Also, print ctrl state transition info.
--- drivers/nvme/host/core.c | 41 ++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-)
drivers/nvme/host/core.c +23 -18
@@ -94,6 +94,13 @@ static void nvme_put_subsystem(struct nvme_subsystem *subsys);static void nvme_remove_invalid_namespaces (struct nvme_ctrl *ctrl,unsigned nsid); +static const char *nvme_get_ctrl_state_name (unsigned int state) +{ +if ((unsigned int ) state <ARRAY_SIZE (nvme_ctrl_state_name)) +return nvme_ctrl_state_name[state]; +return "unknown" ; +} +static void nvme_set_queue_dying (struct nvme_ns *ns) {/*
@@ -119,10 +126,16 @@ static void nvme_queue_scan(struct nvme_ctrl *ctrl)int nvme_reset_ctrl (struct nvme_ctrl *ctrl) { -if (!nvme_change_ctrl_state (ctrl,NVME_CTRL_RESETTING )) +if (!nvme_change_ctrl_state (ctrl,NVME_CTRL_RESETTING )) { +dev_warn (ctrl->device,"cannot reset ctrl in state %s\n" , +nvme_get_ctrl_state_name (ctrl->state));return -EBUSY ; -if (!queue_work (nvme_reset_wq, &ctrl->reset_work)) + } +if (!queue_work (nvme_reset_wq, &ctrl->reset_work)) { +dev_dbg (ctrl->device,"ctrl reset already queued\n" );return -EBUSY ; + } +return 0 ; }EXPORT_SYMBOL_GPL (nvme_reset_ctrl);
@@ -370,8 +383,13 @@ bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl,break ; } -if (changed) +if (changed) { ctrl->state = new_state; +dev_info (ctrl->device,"state change from (%s -> %s)\n" , +nvme_get_ctrl_state_name (new_state), +nvme_get_ctrl_state_name (ctrl->state)); + + }spin_unlock_irqrestore (&ctrl->lock, flags);if (changed && ctrl->state ==NVME_CTRL_LIVE )
@@ -2960,21 +2978,8 @@ static ssize_t nvme_sysfs_show_state(struct device *dev, char *buf) {struct nvme_ctrl *ctrl =dev_get_drvdata (dev); -static const char *const state_name[] = { - [NVME_CTRL_NEW ] ="new" , - [NVME_CTRL_LIVE ] ="live" , - [NVME_CTRL_ADMIN_ONLY ] ="only-admin" , - [NVME_CTRL_RESETTING ] ="resetting" , - [NVME_CTRL_CONNECTING ] ="connecting" , - [NVME_CTRL_DELETING ] ="deleting" , - [NVME_CTRL_DEAD ] ="dead" , - }; - -if ((unsigned )ctrl->state <ARRAY_SIZE (state_name) && - state_name[ctrl->state]) -return sprintf (buf,"%s\n" , state_name[ctrl->state]); - -return sprintf (buf,"unknown state\n" ); + +return sprintf (buf,"%s\n" ,nvme_get_ctrl_state_name (ctrl->state)); } static DEVICE_ATTR(state, S_IRUGO, nvme_sysfs_show_state, NULL);
Signature · 1 line
2.17.0
Sagi Grimberg
maintainerPATCH v2 2/3 nvme: improve logging
drivers/nvme/host/core.c bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl, · line 390
Quoted 7 lines
drivers/nvme/host/core.c +4
-1-if (changed) +if (changed) { ctrl->state = new_state; +dev_info (ctrl->device,"state change from (%s -> %s)\n" , +nvme_get_ctrl_state_name (new_state), +nvme_get_ctrl_state_name (ctrl->state));
dev_info is too chatty... dev_dbg please...
drivers/nvme/host/core.c static ssize_t nvme_sysfs_show_state(struct device *dev, · line 2971
Quoted 13 lines
drivers/nvme/host/core.c +0
-9@@ -2960,21 +2978,8 @@ static ssize_t nvme_sysfs_show_state(struct device *dev, char *buf) {struct nvme_ctrl *ctrl =dev_get_drvdata (dev); -static const char *const state_name[] = { - [NVME_CTRL_NEW ] ="new" , - [NVME_CTRL_LIVE ] ="live" , - [NVME_CTRL_ADMIN_ONLY ] ="only-admin" , - [NVME_CTRL_RESETTING ] ="resetting" , - [NVME_CTRL_CONNECTING ] ="connecting" , - [NVME_CTRL_DELETING ] ="deleting" , - [NVME_CTRL_DEAD ] ="dead" , - };
Patch #1 should erase this table here.
Quoted 12 lines
drivers/nvme/host/core.c +2
-6- -if ((unsigned )ctrl->state <ARRAY_SIZE (state_name) && - state_name[ctrl->state]) -return sprintf (buf,"%s\n" , state_name[ctrl->state]); - -return sprintf (buf,"unknown state\n" ); + +return sprintf (buf,"%s\n" ,nvme_get_ctrl_state_name (ctrl->state)); } static DEVICE_ATTR(state, S_IRUGO, nvme_sysfs_show_state, NULL);
PATCH v2 3/3 nvme-multipath: improve logging
In reply to Chaitanya KulkarniFrom: Hannes Reinecke <[email protected]>
This patch improves the logging for nvme-multipath code.
--- drivers/nvme/host/multipath.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/nvme/host/multipath.c +4 -1
@@ -81,6 +81,9 @@ void nvme_failover_req(struct request *req)* Reset the controller for any non-ANA error as we don't know * what caused the error. */ +dev_info (ns->ctrl->device, +"nvme-mp: status 0x%04x, resetting controller\n" , + status);nvme_reset_ctrl (ns->ctrl);break ; }
@@ -421,7 +424,7 @@ static int nvme_update_ana_state(struct nvme_ctrl *ctrl,unsigned *nr_change_groups = data;struct nvme_ns *ns; -dev_info (ctrl->device,"ANA group %d: %s.\n" , +dev_dbg (ctrl->device,"ANA group %d: %s.\n" ,le32_to_cpu (desc->grpid), nvme_ana_state_names[desc->state]);
Signature · 1 line
2.17.0
Sagi Grimberg
maintainerPATCH v2 3/3 nvme-multipath: improve logging
Looks fine,
Christoph Hellwig
AppliedPATCH v2 3/3 nvme-multipath: improve logging
In reply to Chaitanya Kulkarnidrivers/nvme/host/multipath.c void nvme_failover_req(struct request *req) · line 86
Quoted 3 lines
drivers/nvme/host/multipath.c +3
-0+dev_info (ns->ctrl->device, +"nvme-mp: status 0x%04x, resetting controller\n" , + status);
This message still looks a little gibberish to me.
Why not:
"resetting path due to unhandled error (0x%04x")"
drivers/nvme/host/multipath.c static int nvme_update_ana_state(struct nvme_ctrl *ctrl, · line 429
Quoted 4 lines
drivers/nvme/host/multipath.c +1
-1-dev_info (ctrl->device,"ANA group %d: %s.\n" , +dev_dbg (ctrl->device,"ANA group %d: %s.\n" ,le32_to_cpu (desc->grpid), nvme_ana_state_names[desc->state]);
I've applied this hunk to nvme-5.2, thanks.