Add an attribute to show multipath NUMA node per-path (scsi_disk). The following is an example of reading the file:
$ cat /sys/devices/platform/host8/session1/target8:0:0/8:0:0:0/block/sdc:0/numa_ mpath_numa_nodes 0-3 $ cat /sys/devices/platform/host9/session2/target9:0:0/9:0:0:0/block/sdc:1/numa_ mpath_numa_nodes $ Signed-off-by: John Garry <[email protected]> --- drivers/scsi/sd.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index f5922a9fe6c1b..52d9bc34bd666 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -4213,8 +4213,28 @@ static ssize_t sd_mpath_dev_show(struct device *dev, } static DEVICE_ATTR(mpath_dev, 0444, sd_mpath_dev_show, NULL); +static ssize_t sd_mpath_numa_nodes_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct gendisk *gd = dev_to_disk(dev); + struct scsi_disk *sdkp = gd->private_data; + struct scsi_device *sdev = sdkp->device; + struct scsi_mpath_device *scsi_mpath_dev = sdev->scsi_mpath_dev; + struct mpath_device *mpath_device = &scsi_mpath_dev->mpath_device; + struct sd_mpath_disk *sd_mpath_disk = sdkp->sd_mpath_disk; + struct mpath_disk *mpath_disk = sd_mpath_disk->mpath_disk; + struct mpath_head *mpath_head = mpath_disk->mpath_head; + struct scsi_mpath_head *scsi_mpath_head = mpath_head->drvdata; + struct mpath_iopolicy *mpath_iopolicy = &scsi_mpath_head->iopolicy; + + return mpath_numa_nodes_show(mpath_head, mpath_device, + mpath_iopolicy, buf); +} +static DEVICE_ATTR(mpath_numa_nodes, 0444, sd_mpath_numa_nodes_show, NULL); + static struct attribute *sd_mpath_dev_attrs[] = { &dev_attr_mpath_dev.attr, + &dev_attr_mpath_numa_nodes.attr, NULL }; -- 2.43.5

