Skip to contentSkip to conversation

minor changes regarding multipath-head assertion

PATCH Applied Irvin Cote 4 participants 7 messages May 18, 2023 – Jun 12, 2023 NVMe

lore
Share & tools
lore

Irvin Cote

author
#0 lore raw

cover minor changes regarding multipath-head assertion

Irvin Cote (2):
nvme-core: remove redundant condition in nvme_ns_head_multipath
nvme-core: use nvme_ns_head_multipath instead of ns->head->disk

 drivers/nvme/host/core.c | 2 +-
 drivers/nvme/host/nvme.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.39.2
author
#1 lore raw

PATCH 1/2 nvme-core: remove redundant condition in nvme_ns_head_multipath

head->disk implies IS_ENABLED(CONFIG_NVME_MULTIPATH) (c.f nvme_mpath_alloc_disk) hence the condition is redundant.

---
 drivers/nvme/host/nvme.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/nvme.h +1 -1
index bf46f122e9e1..7820e40cdce4 100644
@@ -453,7 +453,7 @@ struct nvme_ns_head {
 
 static inline bool nvme_ns_head_multipath(struct nvme_ns_head *head)
 {
-	return IS_ENABLED(CONFIG_NVME_MULTIPATH) && head->disk;
+	return head->disk;
 }
 
 enum nvme_ns_features {
Signature · 1 line
2.39.2
maintainer
#2 lore raw

Re: [PATCH 1/2] nvme-core: remove redundant condition in nvme_ns_head_multipath

Quoted 13 lines · Irvin Cote

head->disk implies IS_ENABLED(CONFIG_NVME_MULTIPATH) (c.f nvme_mpath_alloc_disk) hence the condition is redundant.

---
 drivers/nvme/host/nvme.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/nvme.h +0 -0
index bf46f122e9e1..7820e40cdce4 100644

drivers/nvme/host/nvme.h struct nvme_ns_head { · line 457

Quoted 6 lines
drivers/nvme/host/nvme.h +1 -1
@@ -453,7 +453,7 @@ struct nvme_ns_head {
 
 static inline bool nvme_ns_head_multipath(struct nvme_ns_head *head)
 {
-	return IS_ENABLED(CONFIG_NVME_MULTIPATH) && head->disk;
+	return head->disk;
 }

Might not matter for this case, but this changes something that'd compile away for !CONFIG_NVME_MULTIPATH to now needing to read disk->head instead. That doesn't seem like a good change.

Signature · 1 line
Jens Axboe
#3 lore raw

Re: [PATCH 1/2] nvme-core: remove redundant condition in nvme_ns_head_multipath

Quoted 9 lines · Jens Axboe

drivers/nvme/host/nvme.h struct nvme_ns_head { · line 457

Quoted 5 lines

static inline bool nvme_ns_head_multipath(struct nvme_ns_head *head) {

drivers/nvme/host/nvme.h +1 -1
-	return IS_ENABLED(CONFIG_NVME_MULTIPATH) && head->disk;
+	return head->disk;
 }

Might not matter for this case, but this changes something that'd compile away for !CONFIG_NVME_MULTIPATH to now needing to read disk->head instead. That doesn't seem like a good change.

Exactly. That's the reason why this helper and check exist.

author
#4 lore raw

PATCH 2/2 nvme-core: use nvme_ns_head_multipath instead of ns->head->disk

In reply to Irvin Cote

Change the way we check for a multipath nshead so as to consistently use the same check to assert the same condition.

---
 drivers/nvme/host/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/core.c +1 -1
index ccb6eb1282f8..c6889cf4439d 100644
@@ -4310,7 +4310,7 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, struct nvme_ns_info *info)
 	 * instance as shared namespaces will show up as multiple block
 	 * devices.
 	 */
-	if (ns->head->disk) {
+	if (nvme_ns_head_multipath(ns->head)) {
 		sprintf(disk->disk_name, "nvme%dc%dn%d", ctrl->subsys->instance,
 			ctrl->instance, ns->head->instance);
 		disk->flags |= GENHD_FL_HIDDEN;
Signature · 1 line
2.39.2
maintainer Applied
#6 lore raw

Re: [PATCH 2/2] nvme-core: use nvme_ns_head_multipath instead of ns->head->disk

In reply to Irvin Cote

Thanks, applied to nvme-6.5, skipping patch 1/2.