From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 04F59606A31A for ; Mon, 30 Nov 2026 21:38:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=kSrdSpmV; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Qu5E4ekl DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Reply-To:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Date: Content-Transfer-Encoding:Content-Type:References:In-Reply-To:To:Subject:From :Message-ID:Cc:MIME-Version:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=+IIA3ljmXX8UrEbx02+jS6wkMyzGxoYpAsGdehMmMIw=; b=kSrdSpmV5c5advsb7IFGluidkq 3jGwokk9zlu2Wt7sq5NF9n56v4TgXXfE9w8u31ebhit7Qv3C/VWkJBTDjTHfHgvm4tnYAXwu+1Nut A2FFRfErwHuwihzubwXWYbRI6+ueZ1SPV4aiv+DYSHxG2h5SFcDYxJIpMaN2Hs3DDOkEzX6ry+kQ6 qm1tUi62E/K0sTkm0Pr2zA+gmZRsyPfUDu+fRVa7XSxST2tTngrhDBjjYOk6OszHp1wfmiHejmlre YTL1fR86CD8FaYYLdallNdLKMUI0/pBelmzkBe7kMXtbxTrO9YV9kLQNynr7ERgHVb9OXujDcMYpb aiYLctVA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xY957-00000005tet-3MC1; Mon, 30 Nov 2026 21:38:41 +0000 Received: from tor.source.kernel.org ([172.105.4.254]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xY956-00000005teF-13Hh for linux-nvme@lists.infradead.org; Mon, 30 Nov 2026 21:38:40 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id AFBF3622E3; Mon, 30 Nov 2026 21:38:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5276C1F00896; Mon, 30 Nov 2026 21:38:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796074719; bh=+IIA3ljmXX8UrEbx02+jS6wkMyzGxoYpAsGdehMmMIw=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=Qu5E4eklm8oJUvheUSIdY9ERo0hxoIJ/5mKFW3tys8I0HJV2sBx8fZr3RDR3g3a3i YA7K36TqIfsOLtpeVbEbE7/JYKnosdBlOjuyaoac0wIwH8YibArpTaH0559uMnAUrz NXTkl/wIOU2NOwbHfG9q6gABUMm/6IstCLHsG0vwZstdatoYKnQc5g0hLGgzN/z6Aw SEZJKYp3E+0Spf4MUDAEcTl3KBlQExj4fNBEUwXqZ7CFWcR1R0U7REQ6MO4pcBoiSl TC5tHht5UVUkymYDqwAb28RRykknvt537/PhnP53/R8itM+wkKbbNSxJuIWZAY5p3d gYRIuxQtzFQ3Q== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] nvme-multipath: flush every path that completed writes To: "Keith Busch" , linux-nvme@lists.infradead.org In-Reply-To: <20261130211438.556153-1-kbusch@meta.com> References: <20261130211438.556153-1-kbusch@meta.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 21:38:38 +0000 X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "Linux-nvme" X-Spam-Status: No, score=-10.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 6 potential issues to consider: - [High] nvme-multipath: flushing unhealthy sibling paths in nvme_mpath_flush_paths() - [High] nvme-multipath: mempool deadlock without rescuer in nvme_mpath_init() - [High] nvme-multipath: data write races sibling preflush in nvme_ns_head_submit_bio() - [Medium] nvme-multipath: premature NVME_NS_WRITTEN clear in nvme_mpath_flush_paths() - [Medium] nvme-multipath: NVME_NS_WRITTEN not cleared on ns in nvme_mpath_flush_paths() - [Medium] nvme-multipath: REQ_NOWAIT ignored for flushes in nvme_mpath_flush_paths() -- commit ac6211f78b685d8e139acbc7bde856f29907dd4e Author: Keith Busch nvme-multipath: flush every path that completed writes This commit tracks which namespace paths have completed writes with NVME_NS_WRITTEN and submits chained REQ_PREFLUSH bios to each written sibling path when a REQ_PREFLUSH bio is submitted to the multipath head. > diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c > index 27facdbb3d4c0..cb12f05d9b532 100644 > --- a/drivers/nvme/host/multipath.c > +++ b/drivers/nvme/host/multipath.c > @@ -203,6 +203,10 @@ void nvme_mpath_end_request(struct request *rq) > { > struct nvme_ns *ns =3D rq->q->queuedata; > =20 > + /* a Flush only covers writes completed by the controller it's sent to = */ > + if (op_is_write(req_op(rq)) && !test_bit(NVME_NS_WRITTEN, &ns->flags)) > + set_bit(NVME_NS_WRITTEN, &ns->flags); > + > if (nvme_req(rq)->flags & NVME_MPATH_CNT_ACTIVE) > atomic_dec_if_positive(&ns->ctrl->nr_active); > =20 > @@ -563,6 +567,30 @@ static bool nvme_available_path(struct nvme_ns_head = *head) > return nvme_mpath_queue_if_no_path(head); > } > =20 > +static struct bio_set nvme_mpath_flush_bs; > + > +static void nvme_mpath_flush_paths(struct nvme_ns_head *head, > + struct nvme_ns *ns, struct bio *bio) > + __must_hold_shared(&head->srcu) > +{ > + struct nvme_ns *sib; > + > + list_for_each_entry_srcu(sib, &head->list, siblings, > + srcu_read_lock_held(&head->srcu)) { > + struct bio *flush; > + > + if (sib =3D=3D ns || !test_bit(NVME_NS_WRITTEN, &sib->flags) || > + !test_and_clear_bit(NVME_NS_WRITTEN, &sib->flags)) > + continue; [Severity: Medium] Does clearing NVME_NS_WRITTEN on sib before the sibling flush bio completes let a concurrent flush finish before sib's volatile write cache is actually flushed? CPU0 CPU1 nvme_ns_head_submit_bio(bioA) nvme_mpath_flush_paths() test_and_clear_bit(..., &sib->flags) nvme_ns_head_submit_bio(bioB) nvme_mpath_flush_paths() test_bit(..., &sib->flags) =3D=3D 0 submit_bio_noacct(bioB) -> ns /* bioB completes on ns before flush on sib finishes */ submit_bio_noacct(flush) -> sib Similarly, if a write completes on sib in nvme_mpath_end_request() while NVME_NS_WRITTEN is still set, just before nvme_mpath_flush_paths() clears it for an already-issued flush, that write is left without NVME_NS_WRITTEN set. [Severity: Medium] Because sib =3D=3D ns short-circuits before test_and_clear_bit(NVME_NS_WRIT= TEN, &sib->flags), doesn't NVME_NS_WRITTEN remain set on the primary path ns that is receiving the REQ_PREFLUSH bio? If a later REQ_PREFLUSH bio selects a different path, nvme_mpath_flush_paths() will still see NVME_NS_WRITTEN set on ns and issue a redundant flush to it. > + > + flush =3D bio_alloc_bioset(sib->disk->part0, 0, > + REQ_OP_WRITE | REQ_PREFLUSH | REQ_SYNC, > + GFP_NOIO, &nvme_mpath_flush_bs); > + bio_chain(flush, bio); > + submit_bio_noacct(flush); > + } > +} [Severity: High] Can nvme_mpath_flush_paths() submit a chained flush bio to a sibling path that is resetting, connecting, dead, or in an inaccessible ANA state? Sibling namespaces remain on head->list while unavailable, and nvme_mpath_end_request() also sets NVME_NS_WRITTEN on failed writes (includ= ing when nvme_failover_req() zeroes nvme_req(req)->status and calls nvme_end_req()). Because flush is submitted without REQ_NVME_MPATH or a ch= eck on sib's state, nvme_fail_nonready_command() returns BLK_STS_RESOURCE when sib->ctrl is resetting or connecting (stalling the parent bio on the healthy path ns), or nvme_decide_disposition() completes flush with an error instead of failing over, propagating -EIO to the parent bio via bio_chain(). [Severity: Medium] Should nvme_mpath_flush_paths() propagate REQ_NOWAIT from the parent bio and avoid GFP_NOIO when REQ_NOWAIT is set? The multipath head disk advertises BLK_FEAT_NOWAIT, so allocating with GFP_NOIO or submitting flush without REQ_NOWAIT can sleep in reclaim, mempool allocation, or sibling queue submission for a non-blocking caller. > @@ -590,6 +618,8 @@ static void nvme_ns_head_submit_bio(struct bio *bio) > */ > bio_set_flag(bio, BIO_REMAPPED); > bio->bi_opf |=3D REQ_NVME_MPATH; > + if (bio->bi_opf & REQ_PREFLUSH) > + nvme_mpath_flush_paths(head, ns, bio); > trace_block_bio_remap(bio, disk_devt(ns->head->disk), > bio->bi_iter.bi_sector); > submit_bio_noacct(bio); [Severity: High] When bio carries data along with REQ_PREFLUSH (such as a filesystem journal commit write with REQ_OP_WRITE | REQ_PREFLUSH | REQ_FUA), doesn't submitting bio to ns concurrently with the sibling flushes allow bio's data write to r= each media on ns before sibling controllers finish flushing earlier writes? bio_chain(flush, bio) only delays bio_endio(bio); blk_insert_flush() on ns = does not wait for the flush bios in flight on sibling queues before issuing bio's data write. [ ... ] > @@ -1545,6 +1575,16 @@ void nvme_mpath_put_disk(struct nvme_ns_head *head) > put_disk(head->disk); > } > =20 > +int nvme_mpath_init(void) > +{ > + return bioset_init(&nvme_mpath_flush_bs, BIO_POOL_SIZE, 0, 0); > +} [Severity: High] Can bio_alloc_bioset() in nvme_mpath_flush_paths() deadlock when nvme_mpath_flush_bs is initialized without BIOSET_NEED_RESCUER? nvme_ns_head_submit_bio() runs inside __submit_bio_noacct() with current->bio_list active, so each submit_bio_noacct(flush) in nvme_mpath_flush_paths() queues flush onto current->bio_list[0] without dispatching it until nvme_ns_head_submit_bio() returns. If a namespace has more than BIO_POOL_SIZE (2) written sibling paths (or concurrent flushes sh= are the global pool) under memory pressure, punt_bios_to_rescuer() does nothing because bs->rescue_workqueue is NULL, and mempool_alloc() sleeps forever waiting for the flush bios still sitting on current->bio_list[0] while hold= ing srcu_read_lock(&head->srcu). --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130211438.5561= 53-1-kbusch@meta.com?part=3D1