All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
From: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
To: andrey.zhadchenko@virtuozzo.com
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.1 v3 3/9] drivers/md/dm-qcow2: rename the ENOSPC delay list to a held request list
Date: Tue, 17 Nov 2026 11:43:23 +0100	[thread overview]
Message-ID: <20261117104329.3079812-4-alexander.ivanov@virtuozzo.com> (raw)
In-Reply-To: <20261117104329.3079812-1-alexander.ivanov@virtuozzo.com>

Requests that fail with ENOSPC are parked on tgt->enospc_qios and
resubmitted by a timer. The same mechanism is going to hold requests
failed with other errors, depending on the disk error policy, so
rename enospc_qios, enospc_timer and qcow2_try_delay_enospc() to
held_qios, held_timer and qcow2_try_hold_error(), and let the latter
decide whether a status is to be held.

Drop the WARN_ON_ONCE() for a non-write ENOSPC. A read can get ENOSPC
from the read_iter of an image on FUSE, and a WARN on an error of the
lower file system takes the node down with panic_on_warn. Such a read
is still held, as before.

No other functional change.

https://virtuozzo.atlassian.net/browse/VSTOR-152175
Feature: dm-qcow2: block device over QCOW2 files driver
Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
---
 drivers/md/dm-qcow2-map.c    | 31 ++++++++++++++++---------------
 drivers/md/dm-qcow2-target.c | 16 ++++++++--------
 drivers/md/dm-qcow2.h        |  6 +++---
 3 files changed, 27 insertions(+), 26 deletions(-)

diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c
index 32373114580e..b987d459863d 100644
--- a/drivers/md/dm-qcow2-map.c
+++ b/drivers/md/dm-qcow2-map.c
@@ -4566,14 +4566,18 @@ void do_qcow2_fsync_work(struct work_struct *ws)
 	current_restore_flags(pflags, PF_LOCAL_THROTTLE|PF_MEMALLOC_NOIO);
 }
 
-static bool qcow2_try_delay_enospc(struct qcow2_target *tgt, struct qcow2_rq *qrq, struct qio *qio)
+static bool qcow2_try_hold_error(struct qcow2_target *tgt, struct qcow2_rq *qrq,
+				 struct qio *qio, blk_status_t bi_status)
 {
-	bool delayed = true;
+	bool held = true;
 	unsigned long flags;
 
+	if (bi_status != BLK_STS_NOSPC)
+		return false;
+
 	spin_lock_irqsave(&tgt->event_lock, flags);
 	if (unlikely(tgt->wants_suspend)) {
-		delayed = false;
+		held = false;
 		goto unlock;
 	}
 
@@ -4582,15 +4586,15 @@ static bool qcow2_try_delay_enospc(struct qcow2_target *tgt, struct qcow2_rq *qr
 	pr_err_once(QCOW2_FMT("underlying disk is almost full"),
 			qcow2_device_name(tgt->ti));
 	tgt->event_enospc = true;
-	list_add_tail(&qio->link, &tgt->enospc_qios);
+	list_add_tail(&qio->link, &tgt->held_qios);
 unlock:
 	spin_unlock_irqrestore(&tgt->event_lock, flags);
 
-	if (delayed)
-		mod_timer(&tgt->enospc_timer, jiffies + ENOSPC_TIMEOUT_JI);
+	if (held)
+		mod_timer(&tgt->held_timer, jiffies + HOLD_TIMEOUT_JI);
 	schedule_work(&tgt->event_work);
 
-	return delayed;
+	return held;
 }
 
 static void qrq_endio(struct qcow2_target *tgt, struct qio *qio,
@@ -4602,18 +4606,15 @@ static void qrq_endio(struct qcow2_target *tgt, struct qio *qio,
 	if (qrq->bvec)
 		kvfree(qrq->bvec);
 	/*
-	 * Here is exit point for rq, and here we handle ENOSPC.
+	 * Here is exit point for rq, and here we handle errors.
 	 * Embedded qios will be reinitialized like they've just
 	 * came from upper dm level, and later resubmitted after
 	 * timeout. Note, that we do not handle merge here: merge
-	 * callers receive -ENOSPC synchronous without intermediaries.
+	 * callers receive errors synchronous without intermediaries.
 	 */
-	if (unlikely(bi_status == BLK_STS_NOSPC)) {
-		WARN_ON_ONCE(!op_is_write(qio->bi_op) &&
-			     qio->bi_op != REQ_OP_FLUSH);
-		if (qcow2_try_delay_enospc(tgt, qrq, qio))
-			return;
-	}
+	if (unlikely(bi_status != BLK_STS_OK) &&
+	    qcow2_try_hold_error(tgt, qrq, qio, bi_status))
+		return;
 
 	mempool_free(qrq, tgt->qrq_pool);
 	dm_complete_request(rq, bi_status);
diff --git a/drivers/md/dm-qcow2-target.c b/drivers/md/dm-qcow2-target.c
index aa0bbb6b4a97..89b12c4f971b 100644
--- a/drivers/md/dm-qcow2-target.c
+++ b/drivers/md/dm-qcow2-target.c
@@ -254,7 +254,7 @@ static void qcow2_tgt_destroy(struct qcow2_target *tgt)
 		destroy_workqueue(tgt->wq);
 	}
 	qcow2_merge_backward_cancel(tgt);
-	timer_shutdown_sync(&tgt->enospc_timer);
+	timer_shutdown_sync(&tgt->held_timer);
 	cancel_work_sync(&tgt->event_work);
 
 	mempool_destroy(tgt->qio_pool);
@@ -480,14 +480,14 @@ static void inflight_ref_exit1(struct percpu_ref *ref)
 	complete(&tgt->inflight_ref_comp);
 }
 
-static void qcow2_enospc_timer(struct timer_list *timer)
+static void qcow2_held_timer(struct timer_list *timer)
 {
-	struct qcow2_target *tgt = timer_container_of(tgt, timer, enospc_timer);
+	struct qcow2_target *tgt = timer_container_of(tgt, timer, held_timer);
 	unsigned long flags;
 	LIST_HEAD(list);
 
 	spin_lock_irqsave(&tgt->event_lock, flags);
-	list_splice_init(&tgt->enospc_qios, &list);
+	list_splice_init(&tgt->held_qios, &list);
 	spin_unlock_irqrestore(&tgt->event_lock, flags);
 
 	qcow2_submit_embedded_qios(tgt, &list);
@@ -542,8 +542,8 @@ static struct qcow2_target *alloc_qcow2_target(struct dm_target *ti)
 	init_rwsem(&tgt->seek_rwsem);
 	init_waitqueue_head(&tgt->service_wq);
 	INIT_WORK(&tgt->event_work, qcow2_event_work);
-	INIT_LIST_HEAD(&tgt->enospc_qios);
-	timer_setup(&tgt->enospc_timer, qcow2_enospc_timer, 0);
+	INIT_LIST_HEAD(&tgt->held_qios);
+	timer_setup(&tgt->held_timer, qcow2_held_timer, 0);
 	ti->private = tgt;
 	tgt->ti = ti;
 
@@ -1165,8 +1165,8 @@ static void qcow2_presuspend(struct dm_target *ti)
 
 	qcow2_set_service_operations(ti, false);
 	qcow2_set_wants_suspend(ti, true);
-	timer_delete_sync(&tgt->enospc_timer);
-	qcow2_enospc_timer(&tgt->enospc_timer);
+	timer_delete_sync(&tgt->held_timer);
+	qcow2_held_timer(&tgt->held_timer);
 }
 static void qcow2_presuspend_undo(struct dm_target *ti)
 {
diff --git a/drivers/md/dm-qcow2.h b/drivers/md/dm-qcow2.h
index 3f1d5b5eef26..ea6bc6258cb0 100644
--- a/drivers/md/dm-qcow2.h
+++ b/drivers/md/dm-qcow2.h
@@ -19,7 +19,7 @@
 
 #define MIN_QIOS 512
 #define WB_TIMEOUT_JI (60 * HZ)
-#define ENOSPC_TIMEOUT_JI (20 * HZ)
+#define HOLD_TIMEOUT_JI (20 * HZ)
 #define PREALLOC_SIZE (128ULL * 1024 * 1024)
 
 struct QCowHeader {
@@ -213,8 +213,8 @@ struct qcow2_target {
 	atomic_t service_qios;
 	struct wait_queue_head service_wq;
 
-	struct list_head enospc_qios; /* Delayed after ENOSPC */
-	struct timer_list enospc_timer;
+	struct list_head held_qios; /* Failed, waiting for resubmission */
+	struct timer_list held_timer;
 
 	struct work_struct event_work;
 	spinlock_t event_lock;
-- 
2.53.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

  parent reply	other threads:[~2026-11-17 10:45 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 10:43 [Devel] [PATCH hci-8.1 v3 0/9] dm-qcow2: support the werror/rerror policies for vhost-blk disks Alexander Ivanov
2026-11-17 10:43 ` [Devel] [PATCH hci-8.1 v3 1/9] drivers/md/dm-qcow2: cancel the event work and ENOSPC timer in the destructor Alexander Ivanov
2026-11-17 10:52   ` no-reply
2026-11-17 10:43 ` [Devel] [PATCH hci-8.1 v3 2/9] drivers/md/dm-qcow2: always resubmit delayed ENOSPC requests in presuspend Alexander Ivanov
2026-11-17 10:50   ` no-reply
2026-11-17 10:43 ` Alexander Ivanov [this message]
2026-11-17 10:51   ` [Devel] [PATCH hci-8.1 v3 3/9] drivers/md/dm-qcow2: rename the ENOSPC delay list to a held request list no-reply
2026-11-17 10:43 ` [Devel] [PATCH hci-8.1 v3 4/9] drivers/md/dm-qcow2: arm the hold timer only for the first held request Alexander Ivanov
2026-11-17 10:52   ` no-reply
2026-11-17 10:43 ` [Devel] [PATCH hci-8.1 v3 5/9] drivers/md/dm-qcow2: report held requests with an IO_ERROR uevent Alexander Ivanov
2026-11-17 10:53   ` no-reply
2026-11-17 10:43 ` [Devel] [PATCH hci-8.1 v3 6/9] drivers/md/dm-qcow2: add the resubmit and fail_held messages Alexander Ivanov
2026-11-17 10:54   ` no-reply
2026-11-17 10:43 ` [Devel] [PATCH hci-8.1 v3 7/9] drivers/md/dm-qcow2: add the error_policy table argument Alexander Ivanov
2026-11-17 10:56   ` no-reply
2026-11-17 10:43 ` [Devel] [PATCH hci-8.1 v3 8/9] drivers/md/dm-qcow2: requeue held requests on a noflush suspend Alexander Ivanov
2026-11-17 10:57   ` no-reply
2026-11-17 10:43 ` [Devel] [PATCH hci-8.1 v3 9/9] drivers/vhost/blk: fix a hang on release after the vhost worker is killed Alexander Ivanov
2026-11-17 11:01   ` no-reply
2026-11-17 11:25   ` Konstantin Khorenko
2026-11-17 11:25 ` [Devel] [PATCH hci-8.1 v3 0/9] dm-qcow2: support the werror/rerror policies for vhost-blk disks Konstantin Khorenko

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=20261117104329.3079812-4-alexander.ivanov@virtuozzo.com \
    --to=alexander.ivanov@virtuozzo.com \
    --cc=andrey.zhadchenko@virtuozzo.com \
    --cc=devel@openvz.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.