Skip to contentSkip to conversation

nvme: use nvme_disk_is_ns_head helper

PATCH Superseded Guixin Liu 2 participants 3 messages Mar 12, 2024 NVMe

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Guixin Liu

author
#0 lore raw

PATCH 1/1 nvme: use nvme_disk_is_ns_head helper

Use nvme_disk_is_ns_head helper instead of check
fops directly.

---
 drivers/nvme/host/sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/sysfs.c +1 -1
index f2832f70e7e0..ac8d622b5fc0 100644
@@ -240,7 +240,7 @@ static ssize_t nuse_show(struct device *dev, struct device_attribute *attr,
 	int ret;
 
 	if (IS_ENABLED(CONFIG_NVME_MULTIPATH) &&
-	    bdev->bd_disk->fops == &nvme_ns_head_ops)
+	    nvme_disk_is_ns_head(bdev->bd_disk))
 		ret = ns_head_update_nuse(head);
 	else
 		ret = ns_update_nuse(bdev->bd_disk->private_data);
Signature · 1 line
2.43.0
#1 lore raw
Quoted 13 lines · Guixin Liu

Use nvme_disk_is_ns_head helper instead of check
fops directly.

---
 drivers/nvme/host/sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/sysfs.c +0 -0
index f2832f70e7e0..ac8d622b5fc0 100644

drivers/nvme/host/sysfs.c static ssize_t nuse_show(struct device *dev, struct device_attribute *attr, · line 243

Quoted 5 lines
drivers/nvme/host/sysfs.c +1 -1
@@ -240,7 +240,7 @@ static ssize_t nuse_show(struct device *dev, struct device_attribute *attr,
 	int ret;
 
 	if (IS_ENABLED(CONFIG_NVME_MULTIPATH) &&
-	    bdev->bd_disk->fops == &nvme_ns_head_ops)
+	    nvme_disk_is_ns_head(bdev->bd_disk))

When using nvme_disk_is_ns_head we should also be able to drop the IS_ENABLED(CONFIG_NVME_MULTIPATH) check.

author
#2 lore raw
Quoted 16 lines · Christoph Hellwig
Quoted 15 lines · Guixin Liu

Use nvme_disk_is_ns_head helper instead of check
fops directly.

---
  drivers/nvme/host/sysfs.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/sysfs.c +0 -0
index f2832f70e7e0..ac8d622b5fc0 100644
@@ -240,7 +240,7 @@ static ssize_t nuse_show(struct device *dev, struct device_attribute *attr,
  	int ret;
 
Quoted 5 lines

drivers/nvme/host/sysfs.c static ssize_t nuse_show(struct device *dev, struct device_attribute *attr, · line 243

Quoted 3 lines
drivers/nvme/host/sysfs.c +1 -1
  	if (IS_ENABLED(CONFIG_NVME_MULTIPATH) &&
-	    bdev->bd_disk->fops == &nvme_ns_head_ops)
+	    nvme_disk_is_ns_head(bdev->bd_disk))

When using nvme_disk_is_ns_head we should also be able to drop the IS_ENABLED(CONFIG_NVME_MULTIPATH) check.

It will be changed in v2, and I will also remove

IS_ENABLED(CONFIG_NVME_MULTIPATH) check in nvme_send_pr_command().

Best regards,
Guixin Liu