All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvme-multipath: handle ANA log parse failures gracefully
@ 2019-05-17 11:29 Hannes Reinecke
  2019-05-21  6:52 ` Christoph Hellwig
  0 siblings, 1 reply; 2+ messages in thread
From: Hannes Reinecke @ 2019-05-17 11:29 UTC (permalink / raw)


When we're failing to parse the ANA log the ana log buffer will
not be allocated, causing a crash in nvme_mpath_add_disk().
This makes debugging impossible as no connection will be established,
and one cannot check why parsing failed.
So this patch will be emitting a warning for this situation, and
set the path to OPTIMIZED.

Signed-off-by: Hannes Reinecke <hare at suse.com>
---
 drivers/nvme/host/multipath.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index 499acf07d61a..9e67462541f1 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -373,6 +373,8 @@ static int nvme_parse_ana_log(struct nvme_ctrl *ctrl, void *data,
 	int error, i;
 
 	lockdep_assert_held(&ctrl->ana_lock);
+	if (!ctrl->ana_log_buf)
+		return -EINVAL;
 
 	for (i = 0; i < le16_to_cpu(ctrl->ana_log_buf->ngrps); i++) {
 		struct nvme_ana_group_desc *desc = base + offset;
@@ -583,17 +585,19 @@ static int nvme_set_ns_ana_state(struct nvme_ctrl *ctrl,
 
 void nvme_mpath_add_disk(struct nvme_ns *ns, struct nvme_id_ns *id)
 {
+	mutex_lock(&ns->ctrl->ana_lock);
 	if (nvme_ctrl_use_ana(ns->ctrl)) {
-		mutex_lock(&ns->ctrl->ana_lock);
 		ns->ana_grpid = le32_to_cpu(id->anagrpid);
-		nvme_parse_ana_log(ns->ctrl, ns, nvme_set_ns_ana_state);
-		mutex_unlock(&ns->ctrl->ana_lock);
-	} else {
-		mutex_lock(&ns->head->lock);
-		ns->ana_state = NVME_ANA_OPTIMIZED; 
-		nvme_mpath_set_live(ns);
-		mutex_unlock(&ns->head->lock);
+		if (!nvme_parse_ana_log(ns->ctrl, ns, nvme_set_ns_ana_state))
+			goto out_unlock;
+		dev_warn(ns->ctrl->device,
+			 "Failed to parse ANA log, set to OPTIMIZED\n");
 	}
+	ns->ana_state = NVME_ANA_OPTIMIZED;
+	nvme_mpath_set_live(ns);
+
+out_unlock:
+	mutex_unlock(&ns->ctrl->ana_lock);
 }
 
 void nvme_mpath_remove_disk(struct nvme_ns_head *head)
-- 
2.16.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] nvme-multipath: handle ANA log parse failures gracefully
  2019-05-17 11:29 [PATCH] nvme-multipath: handle ANA log parse failures gracefully Hannes Reinecke
@ 2019-05-21  6:52 ` Christoph Hellwig
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2019-05-21  6:52 UTC (permalink / raw)


On Fri, May 17, 2019@01:29:12PM +0200, Hannes Reinecke wrote:
> When we're failing to parse the ANA log the ana log buffer will
> not be allocated, causing a crash in nvme_mpath_add_disk().

How can we even reach nvme_mpath_add_disk?  If we fail to allocate the
buffer we error out in nvme_mpath_init, which leads to an error return
from nvme_init_identify, which should eventually lead to a probe
failure.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-05-21  6:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-17 11:29 [PATCH] nvme-multipath: handle ANA log parse failures gracefully Hannes Reinecke
2019-05-21  6:52 ` Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.