[PATCH 2/2] nvme-multipath: do not fall back to __nvme_find_path() for non-optimized paths

Hannes Reinecke hare at suse.de
Tue Jul 28 04:14:14 EDT 2020


On 7/28/20 10:02 AM, Christoph Hellwig wrote:
> On Tue, Jul 28, 2020 at 08:25:18AM +0200, Hannes Reinecke wrote:
>>> Maybe instead of the early return put the following condition on else?
>>
>> That depends on whether we want to have a fallback to __nvme_find_path() or 
>> not. With your suggestion we would lose that; I'd rather keep it.
> 
> Why would we want to fall back?  nvme_round_robin_path only
> returns NULL in case there is a single disabled path, in which
> case __nvme_find_path won't find anything either.  I'd go for something
> like this:
> 
> ---
> From 4f578364a3d15898c7d715315a3371b2f71db416 Mon Sep 17 00:00:00 2001
> From: Hannes Reinecke <hare at suse.de>
> Date: Mon, 27 Jul 2020 18:08:03 +0200
> Subject: nvme-multipath: do not fall back to __nvme_find_path() for
>  non-optimized paths
> 
> When nvme_round_robin_path() finds a valid namespace we should be using it;
> falling back to __nvme_find_path() for non-optimized paths will cause the
> result from nvme_round_robin_path() to be ignored for non-optimized paths.
> 
> Signed-off-by: Martin Wilck <mwilck at suse.com>
> Signed-off-by: Hannes Reinecke <hare at suse.de>
> Reviewed-by: Sagi Grimberg <sagi at grimberg.me>
> Signed-off-by: Christoph Hellwig <hch at lst.de>
> ---
>  drivers/nvme/host/multipath.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
> index 93c70e1591de8f..3ded54d2c9c6ad 100644
> --- a/drivers/nvme/host/multipath.c
> +++ b/drivers/nvme/host/multipath.c
> @@ -281,10 +281,13 @@ inline struct nvme_ns *nvme_find_path(struct nvme_ns_head *head)
>  	struct nvme_ns *ns;
>  
>  	ns = srcu_dereference(head->current_path[node], &head->srcu);
> -	if (READ_ONCE(head->subsys->iopolicy) == NVME_IOPOLICY_RR && ns)
> -		ns = nvme_round_robin_path(head, node, ns);
> -	if (unlikely(!ns || !nvme_path_is_optimized(ns)))
> -		ns = __nvme_find_path(head, node);
> +	if (unlikely(!ns))
> +		return __nvme_find_path(head, node);
> +
> +	if (READ_ONCE(head->subsys->iopolicy) == NVME_IOPOLICY_RR)
> +		return nvme_round_robin_path(head, node, ns);
> +	if (unlikely(!nvme_path_is_optimized(ns)))
> +		return __nvme_find_path(head, node);
>  	return ns;
>  }
>  
> 

Yes, that would work, too.

Should I resend?

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		           Kernel Storage Architect
hare at suse.de			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer



More information about the Linux-nvme mailing list