Skip to contentSkip to conversation

nvme: fix build error: nvme_mpath_update stub without static

PATCH Superseded Anton Eidelman 2 participants 9 messages Mar 23, 2022 – Mar 24, 2022 NVMe

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme: fix build error: nvme_mpath_update stub without static

Fix multiple definition of nvme_mpath_update() on
builds with CONFIG_NVME_MULTIPATH disabled:
the stub function is missing "static inline".

Fixes d50c992edf10 ("nvme-multipath: fix hang when disk goes live over reconnect")
---
 drivers/nvme/host/nvme.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/nvme.h +1 -1
index 76f7a5f37379..8cf90c9ed667 100644
@@ -853,7 +853,7 @@ static inline int nvme_mpath_init_identify(struct nvme_ctrl *ctrl,
 "Please enable CONFIG_NVME_MULTIPATH for full support of multi-port devices.\n");
 	return 0;
 }
-void nvme_mpath_update(struct nvme_ctrl *ctrl)
+static inline void nvme_mpath_update(struct nvme_ctrl *ctrl)
 {
 }
 static inline void nvme_mpath_uninit(struct nvme_ctrl *ctrl)
Signature · 1 line
2.25.1
#1 lore raw

v2 cover Fix issues with nvme_mpath_update

My recent commit d50c992edf10
("nvme-multipath: fix hang when disk goes live over reconnect") introduced two issues:
1) Build error with CONFIG_NVME_MULTIPATH=n
- missing "static inline" for the nvme_mpath_update() stub.
2) Crash when CONFIG_NVME_MULTIPATH=y but
either multipath is off or the ctrl is not ANA-enabled.

Fixing both - sorry for inconvenience.

Anton Eidelman (2):
nvme: fix build error: nvme_mpath_update stub without static nvme/mpath: fix crash in nvme_mpath_update for non-ana ctrl

 drivers/nvme/host/multipath.c | 10 ++++++----
 drivers/nvme/host/nvme.h      |  2 +-
 2 files changed, 7 insertions(+), 5 deletions(-)
Signature · 1 line
2.25.1
#2 lore raw

PATCH v2 1/2 nvme: fix build error: nvme_mpath_update stub without static

Fix multiple definition of nvme_mpath_update() on
builds with CONFIG_NVME_MULTIPATH disabled:
the stub function is missing "static inline".

Fixes d50c992edf10 ("nvme-multipath: fix hang when disk goes live over reconnect")
---
 drivers/nvme/host/nvme.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/nvme.h +1 -1
index 76f7a5f37379..8cf90c9ed667 100644
@@ -853,7 +853,7 @@ static inline int nvme_mpath_init_identify(struct nvme_ctrl *ctrl,
 "Please enable CONFIG_NVME_MULTIPATH for full support of multi-port devices.\n");
 	return 0;
 }
-void nvme_mpath_update(struct nvme_ctrl *ctrl)
+static inline void nvme_mpath_update(struct nvme_ctrl *ctrl)
 {
 }
 static inline void nvme_mpath_uninit(struct nvme_ctrl *ctrl)
Signature · 1 line
2.25.1
#3 lore raw

PATCH v2 2/2 nvme/mpath: fix crash in nvme_mpath_update for non-ana ctrl

In reply to Anton Eidelman

When CONFIG_NVME_MULTIPATH is enabled, the nvme_mpath_update() is called from nvme_start_ctrl()
for both ANA and non-ANA ctrls and regardless of multipath on/off.

Unless multipath is on and the ctrl is ANA-enabled the function will crash as the initializations
for ANA specific parts of the ctrl are skipped in such cases in nvme_mpath_init_identify().

Fix: check as done in nvme_handle_aen_notice() for ana_work:
a NULL ctrl->ana_log_buf indicates ctrl does not have ANA.

Fixes d50c992edf10 ("nvme-multipath: fix hang when disk goes live over reconnect")
---
 drivers/nvme/host/multipath.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/nvme/host/multipath.c +6 -4
index 12d4afde3662..f15badc0410a 100644
@@ -712,11 +712,13 @@ static void nvme_ana_work(struct work_struct *work)
 
 void nvme_mpath_update(struct nvme_ctrl *ctrl)
 {
-	u32 nr_change_groups = 0;
+	if (!ctrl->ana_log_buf) {
+		u32 nr_change_groups = 0;
 
-	mutex_lock(&ctrl->ana_lock);
-	nvme_parse_ana_log(ctrl, &nr_change_groups, nvme_update_ana_state);
-	mutex_unlock(&ctrl->ana_lock);
+		mutex_lock(&ctrl->ana_lock);
+		nvme_parse_ana_log(ctrl, &nr_change_groups, nvme_update_ana_state);
+		mutex_unlock(&ctrl->ana_lock);
+	}
 }
 
 static void nvme_anatt_timeout(struct timer_list *t)
Signature · 1 line
2.25.1
#4 lore raw

v3 cover Fix issues with nvme_mpath_update

My recent commit d50c992edf10
("nvme-multipath: fix hang when disk goes live over reconnect") introduced two issues:
1) Build error with CONFIG_NVME_MULTIPATH=n
- missing "static inline" for the nvme_mpath_update() stub.
2) Crash when CONFIG_NVME_MULTIPATH=y but
either multipath is off or the ctrl is not ANA-enabled.

Fixing both - sorry for inconvenience.

Anton Eidelman (2):
nvme: fix build error: nvme_mpath_update stub without static nvme/mpath: fix crash in nvme_mpath_update for non-ana ctrl

 drivers/nvme/host/multipath.c | 10 ++++++----
 drivers/nvme/host/nvme.h      |  2 +-
 2 files changed, 7 insertions(+), 5 deletions(-)
Signature · 1 line
2.25.1
#5 lore raw

PATCH v3 1/2 nvme: fix build error: nvme_mpath_update stub without static

Fix multiple definition of nvme_mpath_update() on
builds with CONFIG_NVME_MULTIPATH disabled:
the stub function is missing "static inline".

Fixes d50c992edf10 ("nvme-multipath: fix hang when disk goes live over reconnect")
---
 drivers/nvme/host/nvme.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/nvme.h +1 -1
index 76f7a5f37379..8cf90c9ed667 100644
@@ -853,7 +853,7 @@ static inline int nvme_mpath_init_identify(struct nvme_ctrl *ctrl,
 "Please enable CONFIG_NVME_MULTIPATH for full support of multi-port devices.\n");
 	return 0;
 }
-void nvme_mpath_update(struct nvme_ctrl *ctrl)
+static inline void nvme_mpath_update(struct nvme_ctrl *ctrl)
 {
 }
 static inline void nvme_mpath_uninit(struct nvme_ctrl *ctrl)
Signature · 1 line
2.25.1
#6 lore raw
Quoted 3 lines · Anton Eidelman

Fix multiple definition of nvme_mpath_update() on
builds with CONFIG_NVME_MULTIPATH disabled:
the stub function is missing "static inline".

Please just resend a new patch. I've dropped the old one from the nvme-5.18 branch for now.

#7 lore raw

PATCH v3 2/2 nvme/mpath: fix crash in nvme_mpath_update for non-ana ctrl

In reply to Anton Eidelman

When CONFIG_NVME_MULTIPATH is enabled, the nvme_mpath_update() is called from nvme_start_ctrl()
for both ANA and non-ANA ctrls and regardless of multipath on/off.

Unless multipath is on and the ctrl is ANA-enabled the function will crash as the initializations
for ANA specific parts of the ctrl are skipped in such cases in nvme_mpath_init_identify().

Fix: check as done in nvme_handle_aen_notice() for ana_work:
a NULL ctrl->ana_log_buf indicates ctrl does not have ANA.

Fixes d50c992edf10 ("nvme-multipath: fix hang when disk goes live over reconnect")
---
 drivers/nvme/host/multipath.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/nvme/host/multipath.c +6 -4
index 12d4afde3662..d36f2543ebe1 100644
@@ -712,11 +712,13 @@ static void nvme_ana_work(struct work_struct *work)
 
 void nvme_mpath_update(struct nvme_ctrl *ctrl)
 {
-	u32 nr_change_groups = 0;
+	if (ctrl->ana_log_buf) {
+		u32 nr_change_groups = 0;
 
-	mutex_lock(&ctrl->ana_lock);
-	nvme_parse_ana_log(ctrl, &nr_change_groups, nvme_update_ana_state);
-	mutex_unlock(&ctrl->ana_lock);
+		mutex_lock(&ctrl->ana_lock);
+		nvme_parse_ana_log(ctrl, &nr_change_groups, nvme_update_ana_state);
+		mutex_unlock(&ctrl->ana_lock);
+	}
 }
 
 static void nvme_anatt_timeout(struct timer_list *t)
Signature · 1 line
2.25.1
#8 lore raw

Re: [PATCH v3 2/2] nvme/mpath: fix crash in nvme_mpath_update for non-ana ctrl

Quoted 7 lines
drivers/nvme/host/multipath.c +0 -0
index 12d4afde3662..d36f2543ebe1 100644
@@ -712,11 +712,13 @@ static void nvme_ana_work(struct work_struct *work)
 
 void nvme_mpath_update(struct nvme_ctrl *ctrl)

drivers/nvme/host/multipath.c static void nvme_ana_work(struct work_struct *work) · line 719

Quoted 10 lines
drivers/nvme/host/multipath.c +4 -4
 {
-	u32 nr_change_groups = 0;
+	if (ctrl->ana_log_buf) {
+		u32 nr_change_groups = 0;
 
-	mutex_lock(&ctrl->ana_lock);
-	nvme_parse_ana_log(ctrl, &nr_change_groups, nvme_update_ana_state);
-	mutex_unlock(&ctrl->ana_lock);
+		mutex_lock(&ctrl->ana_lock);
+		nvme_parse_ana_log(ctrl, &nr_change_groups, nvme_update_ana_state);

Overly long line. Kust retun early for the !ana_log_buf case to sort this out trivially.