Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nvme-multipath: Add visibility for queue-depth io-policy

This patch helps add nvme native multipath visibility for queue-depth
io-policy. It adds a new attribute file named "queue_depth" under
namespace device path node which would print the number of active/
in-flight I/O requests currently queued for the given path.

For instance, if we have a shared namespace accessible from two different
controllers/paths then accessing head block node of the shared namespace
would show the following output:

$ ls -l /sys/block/nvme1n1/multipath/
nvme1c1n1 -> ../../../../../pci052e:78/052e:78:00.0/nvme/nvme1/nvme1c1n1
nvme1c3n1 -> ../../../../../pci058e:78/058e:78:00.0/nvme/nvme3/nvme1c3n1

In the above example, nvme1n1 is head gendisk node created for a shared
namespace and the namespace is accessible from nvme1c1n1 and nvme1c3n1
paths. For queue-depth io-policy we can then refer the "queue_depth"
attribute file created under each namespace path:

$ cat /sys/block/nvme1n1/multipath/nvme1c1n1/queue_depth
518

$cat /sys/block/nvme1n1/multipath/nvme1c3n1/queue_depth
504

>From the above output, we can infer that I/O workload targeted at nvme1n1
uses two paths nvme1c1n1 and nvme1c3n1 and the current queue depth of each
path is 518 and 504 respectively. Reading "queue_depth" file when
configured io-policy is anything but queue-depth would show no output.

Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Nilay Shroff <nilay@linux.ibm.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>

authored by

Nilay Shroff and committed by
Keith Busch
7cbafa3f 6546cc4a

+15 -1
+12
drivers/nvme/host/multipath.c
··· 976 976 } 977 977 DEVICE_ATTR_RO(ana_state); 978 978 979 + static ssize_t queue_depth_show(struct device *dev, 980 + struct device_attribute *attr, char *buf) 981 + { 982 + struct nvme_ns *ns = nvme_get_ns_from_dev(dev); 983 + 984 + if (ns->head->subsys->iopolicy != NVME_IOPOLICY_QD) 985 + return 0; 986 + 987 + return sysfs_emit(buf, "%d\n", atomic_read(&ns->ctrl->nr_active)); 988 + } 989 + DEVICE_ATTR_RO(queue_depth); 990 + 979 991 static ssize_t numa_nodes_show(struct device *dev, struct device_attribute *attr, 980 992 char *buf) 981 993 {
+1
drivers/nvme/host/nvme.h
··· 984 984 extern bool multipath; 985 985 extern struct device_attribute dev_attr_ana_grpid; 986 986 extern struct device_attribute dev_attr_ana_state; 987 + extern struct device_attribute dev_attr_queue_depth; 987 988 extern struct device_attribute dev_attr_numa_nodes; 988 989 extern struct device_attribute subsys_attr_iopolicy; 989 990
+2 -1
drivers/nvme/host/sysfs.c
··· 258 258 #ifdef CONFIG_NVME_MULTIPATH 259 259 &dev_attr_ana_grpid.attr, 260 260 &dev_attr_ana_state.attr, 261 + &dev_attr_queue_depth.attr, 261 262 &dev_attr_numa_nodes.attr, 262 263 #endif 263 264 &dev_attr_io_passthru_err_log_enabled.attr, ··· 292 291 if (!nvme_ctrl_use_ana(nvme_get_ns_from_dev(dev)->ctrl)) 293 292 return 0; 294 293 } 295 - if (a == &dev_attr_numa_nodes.attr) { 294 + if (a == &dev_attr_queue_depth.attr || a == &dev_attr_numa_nodes.attr) { 296 295 if (nvme_disk_is_ns_head(dev_to_disk(dev))) 297 296 return 0; 298 297 }