Skip to content

Commit 863fe60

Browse files
shroffnikeithbusch
authored andcommitted
nvme: find numa distance only if controller has valid numa id
On system where native nvme multipath is configured and iopolicy is set to numa but the nvme controller numa node id is undefined or -1 (NUMA_NO_NODE) then avoid calculating node distance for finding optimal io path. In such case we may access numa distance table with invalid index and that may potentially refer to incorrect memory. So this patch ensures that if the nvme controller numa node id is -1 then instead of calculating node distance for finding optimal io path, we set the numa node distance of such controller to default 10 (LOCAL_DISTANCE). Link: https://lore.kernel.org/all/20240413090614.678353-1-nilay@linux.ibm.com/ Signed-off-by: Nilay Shroff <nilay@linux.ibm.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> Signed-off-by: Keith Busch <kbusch@kernel.org>
1 parent 0bc2e80 commit 863fe60

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

drivers/nvme/host/multipath.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,8 @@ static struct nvme_ns *__nvme_find_path(struct nvme_ns_head *head, int node)
247247
if (nvme_path_is_disabled(ns))
248248
continue;
249249

250-
if (READ_ONCE(head->subsys->iopolicy) == NVME_IOPOLICY_NUMA)
250+
if (ns->ctrl->numa_node != NUMA_NO_NODE &&
251+
READ_ONCE(head->subsys->iopolicy) == NVME_IOPOLICY_NUMA)
251252
distance = node_distance(node, ns->ctrl->numa_node);
252253
else
253254
distance = LOCAL_DISTANCE;

0 commit comments

Comments
 (0)