Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1592243pxb; Thu, 28 Jan 2021 23:09:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJxDFE91/08ICW6ZE0dYJtp5ThF7gL3Iv7nmzD2vJvk6jkNqnV21Hd5y1HwLftzCQ+zLjv1C X-Received: by 2002:a05:6402:3589:: with SMTP id y9mr3657739edc.344.1611904155253; Thu, 28 Jan 2021 23:09:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611904155; cv=none; d=google.com; s=arc-20160816; b=NU1Nipk/B+IW3AOUB7WytRNcAd6SJp6PeGqw8Cgysn9AXss3Uc2J13cw7ttbCBT223 TCYtpsyAKl/RlTInbes7VToKRkLAv3TvLbUr4kntv6W4nlvPR2qIoVlOvY/eHRz7sM85 Uh12HxXVl2uA6/+r+RnY6Z01Pk09LvD7WycqfsvaZMkElhN028cUyIsFx5/XGaYqHGDM AJvwbVD/s4l4hBn/cy1rsZvawk0B7g7cI0S4C/P6xb/TDIlgHvJf8sLdX9QRORKc9WX9 LtSV8z62HaMoVvNJVhzLs/Uh8XS1Rhxf1UIjBLcwTpgu6hatMigNImQx0UtRTANZ2r5N DzTw== 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=dFwMWvFD6uK1GLP+ZVOLsuV7XpjMFJMsv0bgElMwi/c=; b=SkGmimlKc6LyQAcuVTCzbsvvhya7f0+Ru8VsdMR+G7fAhulBfPRb02i4W3GSPp7Feg ytY9Cnw2LPtplWVYYc++h3D+NXshcz2ecQZxPIvF3U/OmCy1FDpQYYhmljaNL0HkOnA2 EF6SCSdKHO2XudSMYpxRBv0Bbde/KBjoU4aSA/p/5JG1uFztinB4OnhaD8MsJtyxAhbH hCtAj7bcOKTR24+S+y8N+pXZBgKfiO7OKV8lG8TBSavBuCbjIKgbbMnUtRnyc0walkIb 5ezKjTMoFnruFEuXFp1P7jGuGiWj9YpHYlJFf6WoWCeVqr1hkA96iyKy/5eELg2OxVD5 hGLA== 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 b6si5238321edu.567.2021.01.28.23.08.47; Thu, 28 Jan 2021 23:09:15 -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 S232040AbhA2HHq (ORCPT + 99 others); Fri, 29 Jan 2021 02:07:46 -0500 Received: from mx2.suse.de ([195.135.220.15]:35406 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231977AbhA2HHl (ORCPT ); Fri, 29 Jan 2021 02:07:41 -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 25AADAD3E; Fri, 29 Jan 2021 07:06:59 +0000 (UTC) Subject: Re: [PATCH v2] nvme-multipath: Early exit if no path is available To: Chao Leng , Sagi Grimberg , Daniel Wagner Cc: linux-nvme@lists.infradead.org, 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> <20210128094004.erwnszjqcxlsi2kd@beryllium.lan> <675d3cf7-1ae8-adc5-b6d0-359fe10f6b23@grimberg.me> <59cd053e-46cb-0235-141f-4ce919c93f48@huawei.com> From: Hannes Reinecke Message-ID: <65392653-6b03-9195-f686-5fe4b3290bd2@suse.de> Date: Fri, 29 Jan 2021 08:06:57 +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: <59cd053e-46cb-0235-141f-4ce919c93f48@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/29/21 4:07 AM, Chao Leng wrote: > > > On 2021/1/29 9:42, Sagi Grimberg wrote: >> >>>> You can't see exactly where it dies but I followed the assembly to >>>> nvme_round_robin_path(). Maybe it's not the initial nvme_next_ns(head, >>>> old) which returns NULL but nvme_next_ns() is returning NULL eventually >>>> (list_next_or_null_rcu()). >>> So there is other bug cause nvme_next_ns abormal. >>> I review the code about head->list and head->current_path, I find 2 bugs >>> may cause the bug: >>> First, I already send the patch. see: >>> https://lore.kernel.org/linux-nvme/20210128033351.22116-1-lengchao@huawei.com/ >>> >>> Second, in nvme_ns_remove, list_del_rcu is before >>> nvme_mpath_clear_current_path. This may cause "old" is deleted from the >>> "head", but still use "old". I'm not sure there's any other >>> consideration here, I will check it and try to fix it. >> >> The reason why we first remove from head->list and only then clear >> current_path is because the other way around there is no way >> to guarantee that that the ns won't be assigned as current_path >> again (because it is in head->list). > ok, I see. >> >> nvme_ns_remove fences continue of deletion of the ns by synchronizing >> the srcu such that for sure the current_path clearance is visible. > The list will be like this: > head->next = ns1; > ns1->next = head; > old->next = ns1; Where does 'old' pointing to? > This may cause infinite loop in nvme_round_robin_path. > for (ns = nvme_next_ns(head, old); >     ns != old; >     ns = nvme_next_ns(head, ns)) > The ns will always be ns1, and then infinite loop. No. nvme_next_ns() will return NULL. 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