* FAILED: patch "[PATCH] dm: fail a REQ_PREFLUSH bio with data when its preflush fails" failed to apply to 6.12-stable tree
@ 2026-11-25 11:18 gregkh
2026-11-26 5:03 ` [PATCH 6.12.y 1/2] dm: optimize REQ_PREFLUSH with data when using the linear target Sasha Levin
0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2026-11-25 11:18 UTC (permalink / raw)
To: daejun7.park, mpatocka, tj; +Cc: stable
The patch below does not apply to the 6.12-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
git checkout FETCH_HEAD
git cherry-pick -x e92cd41e8e5ee5616c6c7cd4378661d942f0a7c0
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026112516-prude-hurried-f333@gregkh' --subject-prefix 'PATCH 6.12.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From e92cd41e8e5ee5616c6c7cd4378661d942f0a7c0 Mon Sep 17 00:00:00 2001
From: Daejun Park <daejun7.park@samsung.com>
Date: Thu, 12 Nov 2026 10:35:29 +0900
Subject: [PATCH] dm: fail a REQ_PREFLUSH bio with data when its preflush fails
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>
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index a73355c0125c..38eaae8ac9b4 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);
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 6.12.y 1/2] dm: optimize REQ_PREFLUSH with data when using the linear target
2026-11-25 11:18 FAILED: patch "[PATCH] dm: fail a REQ_PREFLUSH bio with data when its preflush fails" failed to apply to 6.12-stable tree gregkh
@ 2026-11-26 5:03 ` Sasha Levin
2026-11-26 5:03 ` [PATCH 6.12.y 2/2] dm: fail a REQ_PREFLUSH bio with data when its preflush fails Sasha Levin
0 siblings, 1 reply; 3+ messages in thread
From: Sasha Levin @ 2026-11-26 5:03 UTC (permalink / raw)
To: stable; +Cc: Mikulas Patocka, Bart Van Assche, Sasha Levin
From: Mikulas Patocka <mpatocka@redhat.com>
[ Upstream commit 2b1c6d7a890aeaeabfeabd1cef5a4808043dc1a4 ]
If the table has only linear targets and there is just one underlying
device, we can optimize REQ_PREFLUSH with data - we don't have to split
it to two bios - a flush and a write. We can pass it to the linear target
directly.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Tested-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Stable-dep-of: e92cd41e8e5e ("dm: fail a REQ_PREFLUSH bio with data when its preflush fails")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/md/dm-core.h | 1 +
drivers/md/dm.c | 32 ++++++++++++++++++++++++--------
2 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/drivers/md/dm-core.h b/drivers/md/dm-core.h
index 391c1df19a764..9f3250d596d85 100644
--- a/drivers/md/dm-core.h
+++ b/drivers/md/dm-core.h
@@ -295,6 +295,7 @@ struct dm_io {
struct dm_io *next;
struct dm_stats_aux stats_aux;
blk_status_t status;
+ bool requeue_flush_with_data;
atomic_t io_count;
struct mapped_device *md;
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 1df8a808d279e..755d8fd6760c7 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -488,18 +488,13 @@ u64 dm_start_time_ns_from_clone(struct bio *bio)
}
EXPORT_SYMBOL_GPL(dm_start_time_ns_from_clone);
-static inline bool bio_is_flush_with_data(struct bio *bio)
-{
- return ((bio->bi_opf & REQ_PREFLUSH) && bio->bi_iter.bi_size);
-}
-
static inline unsigned int dm_io_sectors(struct dm_io *io, struct bio *bio)
{
/*
* If REQ_PREFLUSH set, don't account payload, it will be
* submitted (and accounted) after this flush completes.
*/
- if (bio_is_flush_with_data(bio))
+ if (io->requeue_flush_with_data)
return 0;
if (unlikely(dm_io_flagged(io, DM_IO_WAS_SPLIT)))
return io->sectors;
@@ -588,6 +583,7 @@ static struct dm_io *alloc_io(struct mapped_device *md, struct bio *bio, gfp_t g
io = container_of(tio, struct dm_io, tio);
io->magic = DM_IO_MAGIC;
io->status = BLK_STS_OK;
+ io->requeue_flush_with_data = false;
/* one ref is for submission, the other is for completion */
atomic_set(&io->io_count, 2);
@@ -955,6 +951,7 @@ static void __dm_io_complete(struct dm_io *io, bool first_stage)
struct mapped_device *md = io->md;
blk_status_t io_error;
bool requeued;
+ bool requeue_flush_with_data;
requeued = dm_handle_requeue(io, first_stage);
if (requeued && first_stage)
@@ -971,6 +968,7 @@ static void __dm_io_complete(struct dm_io *io, bool first_stage)
__dm_start_io_acct(io);
dm_end_io_acct(io);
}
+ requeue_flush_with_data = io->requeue_flush_with_data;
free_io(io);
smp_wmb();
this_cpu_dec(*md->pending_io);
@@ -983,7 +981,7 @@ static void __dm_io_complete(struct dm_io *io, bool first_stage)
if (requeued)
return;
- if (bio_is_flush_with_data(bio)) {
+ if (unlikely(requeue_flush_with_data)) {
/*
* Preflush done for flush with data, reissue
* without REQ_PREFLUSH.
@@ -2022,12 +2020,30 @@ static void dm_split_and_process_bio(struct mapped_device *md,
}
init_clone_info(&ci, io, map, bio, is_abnormal);
- if (bio->bi_opf & REQ_PREFLUSH) {
+ if (unlikely((bio->bi_opf & REQ_PREFLUSH) != 0)) {
+ /*
+ * The "flush_bypasses_map" is set on targets where it is safe
+ * to skip the map function and submit bios directly to the
+ * underlying block devices - currently, it is set for dm-linear
+ * and dm-stripe.
+ *
+ * If we have just one underlying device (i.e. there is one
+ * linear target or multiple linear targets pointing to the same
+ * device), we can send the flush with data directly to it.
+ */
+ if (map->flush_bypasses_map) {
+ struct list_head *devices = dm_table_get_devices(map);
+ if (devices->next == devices->prev)
+ goto send_preflush_with_data;
+ }
+ if (bio->bi_iter.bi_size)
+ io->requeue_flush_with_data = true;
__send_empty_flush(&ci);
/* dm_io_complete submits any data associated with flush */
goto out;
}
+send_preflush_with_data:
if (static_branch_unlikely(&zoned_enabled) &&
(bio_op(bio) == REQ_OP_ZONE_RESET_ALL)) {
error = __send_zone_reset_all(&ci);
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 6.12.y 2/2] dm: fail a REQ_PREFLUSH bio with data when its preflush fails
2026-11-26 5:03 ` [PATCH 6.12.y 1/2] dm: optimize REQ_PREFLUSH with data when using the linear target Sasha Levin
@ 2026-11-26 5:03 ` Sasha Levin
0 siblings, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2026-11-26 5:03 UTC (permalink / raw)
To: stable; +Cc: Daejun Park, Tejun Heo, Mikulas Patocka, Sasha Levin
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>
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 755d8fd6760c7..3bc41230a1db0 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -981,7 +981,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.
@@ -989,7 +989,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);
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-26 5:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 11:18 FAILED: patch "[PATCH] dm: fail a REQ_PREFLUSH bio with data when its preflush fails" failed to apply to 6.12-stable tree gregkh
2026-11-26 5:03 ` [PATCH 6.12.y 1/2] dm: optimize REQ_PREFLUSH with data when using the linear target Sasha Levin
2026-11-26 5:03 ` [PATCH 6.12.y 2/2] dm: fail a REQ_PREFLUSH bio with data when its preflush fails Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox