[Devel] [PATCH hci-8.2 2/2] dm-qcow2: arm enospc_timer under event_lock so suspend leaves none behind

Denis V. Lunev den at openvz.org
Thu Nov 19 02:37:05 MSK 2026


From: Denis V. Lunev <den at openvz.org>

qcow2_try_delay_enospc() queues the qio on enospc_qios under event_lock
but arms enospc_timer and queues event_work only after the unlock. An
endio that stalls in between lets qcow2_presuspend() set wants_suspend,
take the qio and resubmit it, and the retry fail and complete the
request. The endio then arms the timer on the suspended target with
nothing left to retry. postsuspend waits for the endio through its
inflight reference, but not for the timer, so the timer stays armed for
ENOSPC_TIMEOUT_JI after the suspend.

Arm the timer and queue the work before dropping event_lock.
qcow2_set_wants_suspend() sets wants_suspend under the same lock, so
either presuspend finds the qio with the timer already armed and runs
it, or the endio sees the flag and its caller completes the request.
The path runs only on ENOSPC.

https://virtuozzo.atlassian.net/browse/VSTOR-155933

Feature: dm-qcow2: block device over QCOW2 files driver
Signed-off-by: Denis V. Lunev <den at openvz.org>
---
 drivers/md/dm-qcow2-map.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c
index 32373114580e..ec07bcce6150 100644
--- a/drivers/md/dm-qcow2-map.c
+++ b/drivers/md/dm-qcow2-map.c
@@ -4584,11 +4584,10 @@ static bool qcow2_try_delay_enospc(struct qcow2_target *tgt, struct qcow2_rq *qr
 	tgt->event_enospc = true;
 	list_add_tail(&qio->link, &tgt->enospc_qios);
 unlock:
-	spin_unlock_irqrestore(&tgt->event_lock, flags);
-
 	if (delayed)
 		mod_timer(&tgt->enospc_timer, jiffies + ENOSPC_TIMEOUT_JI);
 	schedule_work(&tgt->event_work);
+	spin_unlock_irqrestore(&tgt->event_lock, flags);
 
 	return delayed;
 }
-- 
2.55.0



More information about the Devel mailing list