[PATCH] dm clone: balance ios_in_flight on fail-mode I/O kills
From: Samuel Moelius
Date: Mon Jun 08 2026 - 20:20:31 EST
dm-clone increments ios_in_flight before mapping a bio. When the target
is in fail mode, map() returns DM_MAPIO_KILL and the device-mapper core
completes the bio without calling the target end_io hook.
That leaves ios_in_flight permanently elevated for each killed bio. The
target can then wait for in-flight I/O that will never complete.
Drop the ios_in_flight reference before returning DM_MAPIO_KILL from the
fail-mode path.
Assisted-by: Codex:gpt-5.5-cyber-preview
Signed-off-by: Samuel Moelius <sam.moelius@xxxxxxxxxxxxxxx>
---
drivers/md/dm-clone-target.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/md/dm-clone-target.c b/drivers/md/dm-clone-target.c
index c0f9b93983d4..701e03dc2685 100644
--- a/drivers/md/dm-clone-target.c
+++ b/drivers/md/dm-clone-target.c
@@ -1316,11 +1316,11 @@ static int clone_map(struct dm_target *ti, struct bio *bio)
struct clone *clone = ti->private;
unsigned long region_nr;
- atomic_inc(&clone->ios_in_flight);
-
if (unlikely(get_clone_mode(clone) == CM_FAIL))
return DM_MAPIO_KILL;
+ atomic_inc(&clone->ios_in_flight);
+
/*
* REQ_PREFLUSH bios carry no data:
*
--
2.43.0