Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2AFB3BAD9B; Sat, 17 Oct 2026 18:13:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792260785; cv=none; b=d9PI+mdQjFUQE51LgxQMgN2LtFFTQeTQ+rXhpM5VsRHfLGHYFWhTza1pK2WPPrK6g1Ut89fsYe9ylxenpgbSbatZOLsMsy3Tj/1rAlb1Y0yfHO8Vh9GCKaoUAiast+2fiD79heGi080aH/TNugER2FYrkgS4AYTVANjgbDmwgZ8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792260785; c=relaxed/simple; bh=yOkIglc1q7M9GN791LeiTDr6iRK+U0cSS59CckEv3Ao=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YDKqSW4F+elKO1+bzsXKoMKG2pPnRJ4ExwgM4CkPcA4bnWaKmSjFImb/M9N0x7YZliGjHU1TLWGumMWHa845Kejqi9e6IFWjaafYx1m/wT86Jn07m41Ko12lWhi6yr25NmDZ0QF7FLE8Il7IqF7arq7eOikZHdnCTNahlq7vD5U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=KeaBqqKc; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="KeaBqqKc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 066DA1F000C4; Sat, 17 Oct 2026 18:13:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1792260784; bh=Ehh8ngZ8ZEtwK3M7mWeHfhcOxKRtyUmhL1cxAJAA/88=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=KeaBqqKcvPJ0vYurumuPtkmjB681yFy1eYpDFhbMuzffif5K/glDcdlY+MKni0FW7 +hjqcSF5xdkK7YoAwAembRod4fEconsDTLiYFkRPLmp0xMe602z+k9SDL+FsoVGr1p CKOaab+xAqsLwTDzP8P/+ZKboiDdSaYgM4QhKClc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Li Chen , "Michael S. Tsirkin" , Sasha Levin Subject: [PATCH 6.6 1658/1674] nvdimm: pmem: keep PREFLUSH before data writes Date: Sat, 17 Oct 2026 18:05:30 +0200 Message-ID: <20261017160513.628494750@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261017160431.119607952@linuxfoundation.org> References: <20261017160431.119607952@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Li Chen [ Upstream commit c644a2f8fef5618fcf453c591177700fd07dd024 ] pmem_submit_bio() records a REQ_PREFLUSH error, but continues to copy the bio data and can later overwrite the error with a successful REQ_FUA flush. That lets data writes run after a failed preflush and can complete the bio successfully despite the failed ordering barrier. Run the REQ_PREFLUSH flush synchronously before touching the bio data and complete the bio with the flush error if it fails. Keep asynchronous flush chaining for REQ_FUA. At that point, data copy has completed and the parent bio can wait for the chained flush bio. Signed-off-by: Li Chen Signed-off-by: Michael S. Tsirkin Message-ID: <20260630092338.2094628-3-me@linux.beauty> Signed-off-by: Sasha Levin --- drivers/nvdimm/pmem.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index 4e8fdcb3f1c82..e82c8e7ec3720 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -209,8 +209,14 @@ static void pmem_submit_bio(struct bio *bio) struct pmem_device *pmem = bio->bi_bdev->bd_disk->private_data; struct nd_region *nd_region = to_region(pmem); - if (bio->bi_opf & REQ_PREFLUSH) - ret = nvdimm_flush(nd_region, bio); + if (bio->bi_opf & REQ_PREFLUSH) { + ret = nvdimm_flush(nd_region, NULL); + if (ret) { + bio->bi_status = errno_to_blk_status(ret); + bio_endio(bio); + return; + } + } do_acct = blk_queue_io_stat(bio->bi_bdev->bd_disk->queue); if (do_acct) @@ -230,7 +236,7 @@ static void pmem_submit_bio(struct bio *bio) if (do_acct) bio_end_io_acct(bio, start); - if (bio->bi_opf & REQ_FUA) + if ((bio->bi_opf & REQ_FUA) && !bio->bi_status) ret = nvdimm_flush(nd_region, bio); if (ret) -- 2.53.0