Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2029648pxb; Mon, 23 Aug 2021 10:18:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxecBr2kOdbphCPcKqJwJznfhR39GfWHBcseXBM0FJVteVBTXFktlX2/OGgsIfzbc/hqofq X-Received: by 2002:aa7:d5c8:: with SMTP id d8mr38644347eds.110.1629739102781; Mon, 23 Aug 2021 10:18:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629739102; cv=none; d=google.com; s=arc-20160816; b=U1yPvLONnMueZjlxtbnSYnYN/gEkt3WjCXKsOTr5bdWBQ2rKQVEIZkRNUYXbBHdWSP 2KysFZEN3Vfq+WuDO0d5yVsiUoNAwBYnf9/YqoiGebg0xkon9b/eCvlbD5goVTnDE88W j0oYd9CBoMxW8gckEp+LUJYEb0YQ9Y9KnMs30pY6FzK9jLmjfKSX2KqtK4q10FwSXorz ZV8zfN/jB7dwJZPK2wYo1u4VOtVq+i3HoBc3BwwMEpnOa3IRffdbQeF/8+e9hc032G0P A1OmZhhro87hBQwvGqOe0ZqsjCgGNVgqxyfwrhaE72QJwBYCl3AL6k2dQugpETWiIw1k czjQ== 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=qUCyu2M+XnnIg56S9qGvy39oPESzj10FdrNHnuAxzuc=; b=ox9M83/Nwi+BMYESmGddyLoAGchbehvrGtPTL9fEN1w4bpANhf317prqOaD1AVek0L rvZGmxRdhyNcXx4c0u+IJN1GFRR83BBikYlgpbrU41oXkahV3TI5UBufnnn8g7Ve89T8 J6gTEgYazN75gCLZyl1AJ68D54qGlvIFyMBGv6xpTrEFxmBHcNi06nihe3JBmR0uddtO zBDqFLzm8oid3VEgZshQ+yI7NftADeRjbmIgikeJs9gSoJdW6QRGF31Mw+CmEfKtXBdu DwM22XC3WQ6H0ySRwWRm8G9niR4towcLefIki1bVrbjpg3Kopoj8Bt2+WiPlDrFZHrkC r5mQ== 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 ho41si2043513ejc.277.2021.08.23.10.17.58; Mon, 23 Aug 2021 10:18:22 -0700 (PDT) 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 S232193AbhHWRRP (ORCPT + 99 others); Mon, 23 Aug 2021 13:17:15 -0400 Received: from mail-ed1-f52.google.com ([209.85.208.52]:42760 "EHLO mail-ed1-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231789AbhHWRRH (ORCPT ); Mon, 23 Aug 2021 13:17:07 -0400 Received: by mail-ed1-f52.google.com with SMTP id z19so2766556edi.9 for ; Mon, 23 Aug 2021 10:16:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=qUCyu2M+XnnIg56S9qGvy39oPESzj10FdrNHnuAxzuc=; b=ICkv1qwXWCE/+QK5J79Odhh1gaDlTsDLwLwwx+3ZPuNnYgI5bfKrC6QkabPzNPco1a oL9RfhRa2lfmHgMlIZE8jAm2RKXbu0R+SQAqjS1O/CyQSZaEdPNvvxWCFS4VLESEJ02B Mtx7CBM4n4Bx9iruKoose1oCZEHwXEaW2DuPYCPn+pMVVDnMdyWO0OAeZfMuHXO3kYsn bovtpJjgYHaGFAQrYDSFr/vRXSo7aKdyBpK0K6k8DsCAGfOIlkT1bJbTN3vFMBAInN5O VU1edZar4cQFQ/sf2KM8aCd76Y6GXr4T1HBO2ygOKyKzt5B+iDJjEw7myTVILC4NXPCr flpg== X-Gm-Message-State: AOAM5307eTgMFPdBzjq46Yy65MrLCuIpcsrkvtXtWO3fnfsCPJGzevcA uOyQyqs3N5SVMOnzyL6auqk= X-Received: by 2002:a05:6402:1c03:: with SMTP id ck3mr38504746edb.312.1629738983576; Mon, 23 Aug 2021 10:16:23 -0700 (PDT) Received: from [10.100.102.14] (109-186-228-184.bb.netvision.net.il. [109.186.228.184]) by smtp.gmail.com with ESMTPSA id v12sm9885549ede.16.2021.08.23.10.16.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 23 Aug 2021 10:16:23 -0700 (PDT) Subject: Re: [PATCH v3] nvme: revalidate paths during rescan To: Daniel Wagner , linux-nvme@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Hannes Reinecke References: <20210811152803.30017-1-dwagner@suse.de> From: Sagi Grimberg Message-ID: <93e8d113-55bb-e859-bf3d-54433dd23683@grimberg.me> Date: Mon, 23 Aug 2021 10:16:23 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210811152803.30017-1-dwagner@suse.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/11/21 8:28 AM, Daniel Wagner wrote: > From: Hannes Reinecke > > When triggering a rescan due to a namespace resize we will be > receiving AENs on every controller, triggering a rescan of all > attached namespaces. If multipath is active only the current path and > the ns_head disk will be updated, the other paths will still refer to > the old size until AENs for the remaining controllers are received. > > If I/O comes in before that it might be routed to one of the old > paths, triggering an I/O failure with 'access beyond end of device'. > With this patch the old paths are skipped from multipath path > selection until the controller serving these paths has been rescanned. > > Signed-off-by: Hannes Reinecke > [dwagner: - introduce NVME_NS_READY flag instead of NVME_NS_INVALIDATE > - use 'revalidate' instead of 'invalidate' which > follows the zoned device code path.] > Tested-by: Daniel Wagner > Signed-off-by: Daniel Wagner > --- > v3: > - Renamed nvme_mpath_invalidated_paths to nvme_mpath_revalidate_paths() > - Replaced NVME_NS_INVALIDATE with NVME_NS_READY > v2: > - https://lore.kernel.org/linux-nvme/20210730071059.124347-1-dwagner@suse.de/ > - removed churn from failed rebase. > v1: > - https://lore.kernel.org/linux-nvme/20210729194630.i5mhvvgb73duojqq@beryllium.lan/ > > drivers/nvme/host/core.c | 3 +++ > drivers/nvme/host/multipath.c | 17 ++++++++++++++++- > drivers/nvme/host/nvme.h | 5 +++++ > 3 files changed, 24 insertions(+), 1 deletion(-) > > diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c > index 2f0cbaba12ac..54aafde4f556 100644 > --- a/drivers/nvme/host/core.c > +++ b/drivers/nvme/host/core.c > @@ -1878,6 +1878,7 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id) > goto out_unfreeze; > } > > + set_bit(NVME_NS_READY, &ns->flags); > blk_mq_unfreeze_queue(ns->disk->queue); > > if (blk_queue_is_zoned(ns->queue)) { > @@ -1889,6 +1890,7 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id) > if (nvme_ns_head_multipath(ns->head)) { > blk_mq_freeze_queue(ns->head->disk->queue); > nvme_update_disk_info(ns->head->disk, ns, id); > + nvme_mpath_revalidate_paths(ns); > blk_stack_limits(&ns->head->disk->queue->limits, > &ns->queue->limits, 0); > blk_queue_update_readahead(ns->head->disk->queue); > @@ -3816,6 +3818,7 @@ static void nvme_ns_remove(struct nvme_ns *ns) > if (test_and_set_bit(NVME_NS_REMOVING, &ns->flags)) > return; > > + clear_bit(NVME_NS_READY, &ns->flags); > set_capacity(ns->disk, 0); > nvme_fault_inject_fini(&ns->fault_inject); > > diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c > index 3f32c5e86bfc..d390f14b8bb6 100644 > --- a/drivers/nvme/host/multipath.c > +++ b/drivers/nvme/host/multipath.c > @@ -147,6 +147,21 @@ void nvme_mpath_clear_ctrl_paths(struct nvme_ctrl *ctrl) > mutex_unlock(&ctrl->scan_lock); > } > > +void nvme_mpath_revalidate_paths(struct nvme_ns *ns) > +{ > + struct nvme_ns_head *head = ns->head; > + sector_t capacity = get_capacity(head->disk); > + int node; > + > + for_each_node(node) > + rcu_assign_pointer(head->current_path[node], NULL); > + > + list_for_each_entry_rcu(ns, &head->list, siblings) { > + if (capacity != get_capacity(ns->disk)) > + clear_bit(NVME_NS_READY, &ns->flags); > + } Shouldn't the null setting to current_path come after we clear NVME_NS_READY on the ns? Otherwise we may still submit and current_path will be populated with the ns again...