From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7ADE3CE7AE3 for ; Fri, 6 Sep 2024 07:29:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=TEOehQ8I952EmnNS9lh239LnfPaU6hblXFIm+mJTCu8=; b=akJcNJCeAlxd7mmvSAtvehSNPA RDtUFdKIMtoNPbk1B4PawVLUHOJbo6/ikwtBciKKtKtUxgqO/2l00aY28keboAIU7Y4wO626jDSsC qRvu9GzjyzAG/0aRFySnVnGlpi+KPBWuL6I6hBkiCTT6orDKNBIYWuhHWIz6d+07Snwn+GFqObldQ 5I7zJr32RlQbLg+xb0m5UGu5vGCsErSABvPLGamx67jq2PwBPT8iEgpcvj7GJcgioVSzKNenSIp4i iIVsABEiPoGq31q/r1Zi280ICsT3hxdTFmStRFWVs75ZkeFeB4NLXYKf0ZK4EEPBfWA4wqmw0cXVA ihEz278w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smTPD-0000000B5E9-0ZzU; Fri, 06 Sep 2024 07:29:19 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smTEx-0000000B3U3-1EAd for linux-nvme@lists.infradead.org; Fri, 06 Sep 2024 07:18:44 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 28D6F5C570D; Fri, 6 Sep 2024 07:18:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1DCD4C4CEC6; Fri, 6 Sep 2024 07:18:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725607122; bh=qMAM6psHMlFzG06NjzzBNd1UOdmvok/hR0I+k9Ypiu8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JFZXha0aPBqnLyIVGqNX5wi/JGyjYnYGmxkNdq9YSykLbMayZaKL6ql0ty87rSPjq j5PVLCiepXYMqsR5f71VJ/Jw81icsRV5rbJe72hTgxZiK/Loq5kN3jfKoJjfY0igAn dbZQyoBpYjIQBsQWrKhvbqTPkVyCXm07vSEW7p11+lzNEwppJGjXnhJyiXf9UiRVza Cm5RgpFqTiIjfMK3Rs4+GVWCtDVbpnBP8ULiuql2+6aDhGQWtjM6nLLpc++0AC97DQ fmaumZK9V2O0Or+Lc1hcHjgBmzeHoDfCYhmnk8zBXHhFUCRAtYwi4qr5yoEWDYZiss OFbviSdvGdhMg== From: Hannes Reinecke To: Christoph Hellwig Cc: Sagi Grimberg , Keith Busch , linux-nvme@lists.infradead.org, Hannes Reinecke Subject: [PATCH 2/4] nvme-multipath: check for NVME_NSHEAD_DISK_LIVE when selecting paths Date: Fri, 6 Sep 2024 09:18:26 +0200 Message-Id: <20240906071828.125614-3-hare@kernel.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240906071828.125614-1-hare@kernel.org> References: <20240906071828.125614-1-hare@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240906_001843_485104_A0077581 X-CRM114-Status: GOOD ( 15.67 ) X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-nvme" Errors-To: linux-nvme-bounces+linux-nvme=archiver.kernel.org@lists.infradead.org During repetitive namespace remapping operations on the target the namespace might have changed between the time the initial scan was performed, and partition scan was invoked by device_add_disk() in nvme_mpath_set_live(). We then end up with a stuck scanning process: [<0>] folio_wait_bit_common+0x12a/0x310 [<0>] filemap_read_folio+0x97/0xd0 [<0>] do_read_cache_folio+0x108/0x390 [<0>] read_part_sector+0x31/0xa0 [<0>] read_lba+0xc5/0x160 [<0>] efi_partition+0xd9/0x8f0 [<0>] bdev_disk_changed+0x23d/0x6d0 [<0>] blkdev_get_whole+0x78/0xc0 [<0>] bdev_open+0x2c6/0x3b0 [<0>] bdev_file_open_by_dev+0xcb/0x120 [<0>] disk_scan_partitions+0x5d/0x100 [<0>] device_add_disk+0x402/0x420 [<0>] nvme_mpath_set_live+0x4f/0x1f0 [nvme_core] [<0>] nvme_mpath_add_disk+0x107/0x120 [nvme_core] [<0>] nvme_alloc_ns+0xac6/0xe60 [nvme_core] [<0>] nvme_scan_ns+0x2dd/0x3e0 [nvme_core] [<0>] nvme_scan_work+0x1a3/0x490 [nvme_core] This happens when we have several paths, some of which are inaccessible, and the active paths are removed first. Then nvme_find_path() will requeue I/O in the ns_head (as paths are present), but the requeue list is never triggered as all remaining paths are inactive. This patch checks for NVME_NSHEAD_DISK_LIVE in nvme_available_path(), and requeue I/O after NVME_NSHEAD_DISK_LIVE has been cleared once the last path has been removed to properly terminate pending I/O. Signed-off-by: Hannes Reinecke --- drivers/nvme/host/multipath.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c index c9d23b1b8efc..f72c5a6a2d8e 100644 --- a/drivers/nvme/host/multipath.c +++ b/drivers/nvme/host/multipath.c @@ -421,6 +421,9 @@ static bool nvme_available_path(struct nvme_ns_head *head) { struct nvme_ns *ns; + if (!test_bit(NVME_NSHEAD_DISK_LIVE, &head->flags)) + return NULL; + list_for_each_entry_rcu(ns, &head->list, siblings) { if (test_bit(NVME_CTRL_FAILFAST_EXPIRED, &ns->ctrl->flags)) continue; @@ -967,11 +970,16 @@ void nvme_mpath_shutdown_disk(struct nvme_ns_head *head) { if (!head->disk) return; - kblockd_schedule_work(&head->requeue_work); - if (test_bit(NVME_NSHEAD_DISK_LIVE, &head->flags)) { + if (test_and_clear_bit(NVME_NSHEAD_DISK_LIVE, &head->flags)) { nvme_cdev_del(&head->cdev, &head->cdev_device); del_gendisk(head->disk); } + /* + * requeue I/O after NVME_NSHEAD_DISK_LIVE has been cleared + * to allow multipath to fail all I/O. + */ + synchronize_srcu(&head->srcu); + kblockd_schedule_work(&head->requeue_work); } void nvme_mpath_remove_disk(struct nvme_ns_head *head) -- 2.35.3