Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp848839pxb; Thu, 28 Jan 2021 01:32:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJx6r/Pfv9ZX3mXrTLOfyNGNAjlXz0MvvyB6HMm9Poc0Tr7WktqwZieEXQPwMGYOGAbktOpk X-Received: by 2002:a17:906:eb1b:: with SMTP id mb27mr10602058ejb.332.1611826336095; Thu, 28 Jan 2021 01:32:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611826336; cv=none; d=google.com; s=arc-20160816; b=SLtz2Sl4nR56TYpVKLg9uYmE9rX8wZqC8JOUeLn4g+B2MR5yPSYyGcbHpVT+OJlRDD mbP9ma2ge3BEM9S5aat9v2Hy8oisB2Pi7DMIptWwNZaIv8IBfAbYnnNJfDcAcTm1zqMg QMnmSnfl1g/UG17Ohc2r0BHWyMTWomGhFr6nJsTUt5aizAZDlxXTdpgbIPJeeawKuJh4 kjbR0Y6TWtgnE0JpQJGYR4zsN+hkJrJdsi18LpmEUF8NM2CkL8iepPCo1fMfZWuC46Lx Zxt5lsIh8wbREApbhMF210CzMQMwG+bnkXerctPoVaEGu3Tq0GiEAqA+FttRzc3btN3Z LNJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=zzbkie8qJiVNT//Qw/k7OznKdtjrf6EJvlzFxMeW2DI=; b=BQr1xaW1iM7IIKzLFdgGaSyJHiRmJ4tFbljp5WEvEe3gmv4HkAll6IEJ0gL80SFZ6p P48J/6HuVauvcn0CEQEBxCo5S+lvrCDnUtpM+sxmPw8JLNmvEB8hKcUhbNAns9bFgr14 /wewVwNgNxgey9rs/3f6g7Pvn+/WXUqel/RcZxCtXpSB07l17NqoE2rvKDMtv1djDAa/ 3zmSwLLu2yH1l2UkNqfVKb9jjATXAOa+siIgCvujQUkmQq/RAfdwazY6juPxwx0EypE+ EVTGK1mTluEdazSpq5vtsElmC3J0MiRf4qV3mvf5mj9VXo6fHh9+N0eeAQIo/0FkWual bGLw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lo3si2161458ejb.686.2021.01.28.01.31.51; Thu, 28 Jan 2021 01:32:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232418AbhA1Ja7 (ORCPT + 99 others); Thu, 28 Jan 2021 04:30:59 -0500 Received: from mx2.suse.de ([195.135.220.15]:53970 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232395AbhA1JY2 (ORCPT ); Thu, 28 Jan 2021 04:24:28 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 6CE71AE12; Thu, 28 Jan 2021 09:23:43 +0000 (UTC) Subject: Re: [PATCH v2] nvme-multipath: Early exit if no path is available To: Chao Leng , Daniel Wagner Cc: linux-nvme@lists.infradead.org, Sagi Grimberg , linux-kernel@vger.kernel.org, Jens Axboe , Keith Busch , Christoph Hellwig References: <20210127103033.15318-1-dwagner@suse.de> <20210128075837.u5u56t23fq5gu6ou@beryllium.lan> <69575290-200e-b4a1-4269-c71e4c2cc37b@huawei.com> From: Hannes Reinecke Message-ID: <8704038d-0b71-5c9c-2d2b-a9ff2166dbe4@suse.de> Date: Thu, 28 Jan 2021 10:23:42 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <69575290-200e-b4a1-4269-c71e4c2cc37b@huawei.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer