Re: [PATCH v2] nvme-multipath: Early exit if no path is available

From: Hannes Reinecke
Date: Thu Jan 28 2021 - 04:31:42 EST


On 1/28/21 10:18 AM, Chao Leng wrote:


On 2021/1/28 15:58, Daniel Wagner wrote:
On Thu, Jan 28, 2021 at 09:31:30AM +0800, Chao Leng wrote:
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -221,7 +221,7 @@ static struct nvme_ns *nvme_round_robin_path(struct nvme_ns_head *head,
       }
       for (ns = nvme_next_ns(head, old);
-         ns != old;
+         ns && ns != old;
nvme_round_robin_path just be called when !"old".
nvme_next_ns should not return NULL when !"old".
It seems unnecessary to add checking "ns".

The problem is when we enter nvme_round_robin_path() and there is no
path available. In this case the initialization ns = nvme_next_ns(head,
old) could return a NULL pointer."old" should not be NULL, so there is at least one path that is "old".
It is impossible to return NULL for nvme_next_ns(head, old).

No. list_next_or_null_rcu()/list_first_or_null_rcu() will return NULL when then end of the list is reached.

Cheers,

Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@xxxxxxx +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer