Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: Daejun Park <daejun7.park@samsung.com>, Tejun Heo <tj@kernel.org>,
	Mikulas Patocka <mpatocka@redhat.com>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH 5.15.y] dm: fail a REQ_PREFLUSH bio with data when its preflush fails
Date: Thu, 26 Nov 2026 00:13:42 -0500	[thread overview]
Message-ID: <20261126051332.2129618-1-sashal@kernel.org> (raw)
In-Reply-To: <2026112517-confetti-saloon-c0b5@gregkh>

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

[ Upstream commit e92cd41e8e5ee5616c6c7cd4378661d942f0a7c0 ]

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>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
[ sashal: Changed the reissue condition to use bio_is_flush_with_data(bio) && !io_error inside dm_io_dec_pending(), since the upstream __dm_io_complete() and requeue_flush_with_data don't exist here. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 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 820af6e250f49..47c7ed0048d93 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -853,7 +853,7 @@ void dm_io_dec_pending(struct dm_io *io, blk_status_t error)
 		if (io_error == BLK_STS_DM_REQUEUE)
 			return;
 
-		if (bio_is_flush_with_data(bio)) {
+		if (bio_is_flush_with_data(bio) && !io_error) {
 			/*
 			 * Preflush done for flush with data, reissue
 			 * without REQ_PREFLUSH.
@@ -861,7 +861,7 @@ void dm_io_dec_pending(struct dm_io *io, blk_status_t error)
 			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);
-- 
2.53.0


      reply	other threads:[~2026-11-26  5:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 11:18 FAILED: patch "[PATCH] dm: fail a REQ_PREFLUSH bio with data when its preflush fails" failed to apply to 5.15-stable tree gregkh
2026-11-26  5:13 ` Sasha Levin [this message]

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=20261126051332.2129618-1-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=daejun7.park@samsung.com \
    --cc=mpatocka@redhat.com \
    --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