mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daejun Park via B4 Relay <devnull+daejun7.park.samsung.com@kernel.org>
To: Alasdair Kergon <agk@redhat.com>,
	Mike Snitzer <snitzer@kernel.org>,
	 Mikulas Patocka <mpatocka@redhat.com>,
	 Benjamin Marzinski <bmarzins@redhat.com>,
	dm-devel@lists.linux.dev
Cc: Tejun Heo <tj@kernel.org>, Brian Foster <bfoster@redhat.com>,
	 linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	 stable@vger.kernel.org, Daejun Park <daejun7.park@samsung.com>
Subject: [PATCH] dm: fail a REQ_PREFLUSH bio with data when its preflush fails
Date: Thu, 12 Nov 2026 10:35:29 +0900	[thread overview]
Message-ID: <20261112-dm-flush-data-error-v1-1-c83d3f8f3ac4@samsung.com> (raw)

From: Daejun Park <daejun7.park@samsung.com>

For a bio with REQ_PREFLUSH and data, dm core may send an empty flush
first. If the flush fails, __dm_io_complete() still reissues the bio
without REQ_PREFLUSH and drops the error. When that write succeeds,
the XFS log keeps running and fsync() can return 0.

End the bio with the flush error instead of writing the data, as
blk-mq does.

Fixes: 6a8736d10cb4 ("dm: relax ordering of bio-based flush implementation")
Cc: stable@vger.kernel.org
Signed-off-by: Daejun Park <daejun7.park@samsung.com>
---
Tested on v7.4-rc2: XFS on a two-device linear table whose second
device (dm-flakey, no data) fails every flush. Before, 200 of 200
fsyncs of one writer return 0. After, the log write fails with -EIO
and XFS shuts down.

Kernels before v6.18 have a different condition here and need a
separate backport.

fstests xfs/438 uses dm-flakey targets around a linear target for the
log to fail writes. dm-flakey fails the flush clones too. With this
patch, XFS shuts down on the first log write with REQ_PREFLUSH after
the errors start, before a metadata write fails. The test still
passes. A series for fstests moves xfs/438 to the buf_ioerror error
tag.
---
 drivers/md/dm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 1881d86111f..0f6934e0008 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -983,7 +983,7 @@ static void __dm_io_complete(struct dm_io *io, bool first_stage)
 	if (requeued)
 		return;
 
-	if (unlikely(requeue_flush_with_data)) {
+	if (unlikely(requeue_flush_with_data) && !io_error) {
 		/*
 		 * Preflush done for flush with data, reissue
 		 * without REQ_PREFLUSH.
@@ -991,7 +991,7 @@ static void __dm_io_complete(struct dm_io *io, bool first_stage)
 		bio->bi_opf &= ~REQ_PREFLUSH;
 		queue_io(md, bio);
 	} else {
-		/* done with normal IO or empty flush */
+		/* done with normal IO, empty flush or failed preflush */
 		if (io_error)
 			bio->bi_status = io_error;
 		bio_endio(bio);

---
base-commit: 7475ea8b58616b33c04afb976cf0fbaad9dd63fb
change-id: 20261111-dm-flush-data-error-5687385d8c0c

Best regards,
-- 
Daejun Park <daejun7.park@samsung.com>



                 reply	other threads:[~2026-11-12  1:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261112-dm-flush-data-error-v1-1-c83d3f8f3ac4@samsung.com \
    --to=devnull+daejun7.park.samsung.com@kernel.org \
    --cc=agk@redhat.com \
    --cc=bfoster@redhat.com \
    --cc=bmarzins@redhat.com \
    --cc=daejun7.park@samsung.com \
    --cc=dm-devel@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=mpatocka@redhat.com \
    --cc=snitzer@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®