* [Devel] [PATCH hci-8.1 v2 0/9] dm-qcow2: support the werror/rerror policies for vhost-blk disks
@ 2026-11-17 10:10 Alexander Ivanov
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 1/9] drivers/md/dm-qcow2: cancel the event work and ENOSPC timer in the destructor Alexander Ivanov
` (8 more replies)
0 siblings, 9 replies; 19+ messages in thread
From: Alexander Ivanov @ 2026-11-17 10:10 UTC (permalink / raw)
To: andrey.zhadchenko; +Cc: devel
QEMU disks have the werror/rerror policies: on an I/O error either
report it to the guest, or pause the VM and retry the request on
resume. A vhost-blk disk completes requests to the guest from the
kernel, so QEMU never sees the error. This series lets dm-qcow2 hold
a failed request according to the policy, tell QEMU about it, and
retry or fail it on request from userspace.
Patches 1-2 fix the existing ENOSPC delay: a use-after-free of the
event work and timer on destroy, and a suspend stalled by a request
delayed while the timer callback runs.
Patches 3-4 rename the ENOSPC delay list to a held request list and
arm the retry timer once per hold, so new failures do not postpone
the retry of the held requests forever.
Patch 5 sends an IO_ERROR change uevent when requests get held, as
QEMU cannot wait for dm events without CAP_SYS_ADMIN.
Patch 6 adds the resubmit and fail_held messages, so libvirt can
retry the held requests on VM resume and drop them on VM destroy.
Patch 7 adds the error_policy=<read>,<write> table argument with the
report, enospc and stop policies. The default keeps the current
behaviour for writes.
Patch 8 requeues held requests to the dm queue on a noflush suspend,
so a table reload or a snapshot of a paused VM does not deliver the
error to the guest.
Patch 9 fixes a vhost-blk hang on release when the vhost worker was
killed with I/O in flight, which a VM destroyed while its requests
are held runs into.
v2:
- patches 1, 2, 4, 9: add Fixes tags
- patch 5: state that held ENOSPC reads are reported too, and that
every dm-qcow2 device whose storage stays full now gets a uevent on
each retry
- patch 7: drop the misleading "whatever the error" from the message
- patch 8: note that ploop needs the ploop.ovz change "lib: suspend
unpartitioned dm-qcow2 devices with noflush" to get the requeue on
a snapshot or resize
https://virtuozzo.atlassian.net/browse/VSTOR-152175
Alexander Ivanov (9):
drivers/md/dm-qcow2: cancel the event work and ENOSPC timer in the
destructor
drivers/md/dm-qcow2: always resubmit delayed ENOSPC requests in
presuspend
drivers/md/dm-qcow2: rename the ENOSPC delay list to a held request
list
drivers/md/dm-qcow2: arm the hold timer only for the first held
request
drivers/md/dm-qcow2: report held requests with an IO_ERROR uevent
drivers/md/dm-qcow2: add the resubmit and fail_held messages
drivers/md/dm-qcow2: add the error_policy table argument
drivers/md/dm-qcow2: requeue held requests on a noflush suspend
drivers/vhost/blk: fix a hang on release after the vhost worker is
killed
drivers/md/dm-push-backup.c | 2 +-
drivers/md/dm-qcow2-cmd.c | 32 +++++++++-
drivers/md/dm-qcow2-map.c | 110 +++++++++++++++++++++++++++++------
drivers/md/dm-qcow2-target.c | 104 ++++++++++++++++++++++++++++-----
drivers/md/dm-qcow2.h | 26 +++++++--
drivers/md/dm-rq.c | 4 +-
drivers/md/dm-rq.h | 2 +-
drivers/vhost/blk.c | 52 ++++++++++++-----
8 files changed, 274 insertions(+), 58 deletions(-)
--
2.53.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Devel] [PATCH hci-8.1 v2 1/9] drivers/md/dm-qcow2: cancel the event work and ENOSPC timer in the destructor
2026-11-17 10:10 [Devel] [PATCH hci-8.1 v2 0/9] dm-qcow2: support the werror/rerror policies for vhost-blk disks Alexander Ivanov
@ 2026-11-17 10:10 ` Alexander Ivanov
2026-11-17 10:22 ` no-reply
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 2/9] drivers/md/dm-qcow2: always resubmit delayed ENOSPC requests in presuspend Alexander Ivanov
` (7 subsequent siblings)
8 siblings, 1 reply; 19+ messages in thread
From: Alexander Ivanov @ 2026-11-17 10:10 UTC (permalink / raw)
To: andrey.zhadchenko; +Cc: devel
qcow2_try_delay_enospc() schedules tgt->event_work on the system
workqueue and arms tgt->enospc_timer, but qcow2_tgt_destroy() frees
the target without waiting for either. A work item queued just
before the device is suspended and removed runs on freed memory.
https://virtuozzo.atlassian.net/browse/VSTOR-152175
Fixes: 6e2ec304689f ("dm-qcow2: Pause IO and notify about ENOSPC events")
Feature: dm-qcow2: block device over QCOW2 files driver
Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
---
drivers/md/dm-qcow2-target.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/md/dm-qcow2-target.c b/drivers/md/dm-qcow2-target.c
index f4004f6095a7..c49b0f466867 100644
--- a/drivers/md/dm-qcow2-target.c
+++ b/drivers/md/dm-qcow2-target.c
@@ -254,6 +254,8 @@ static void qcow2_tgt_destroy(struct qcow2_target *tgt)
destroy_workqueue(tgt->wq);
}
qcow2_merge_backward_cancel(tgt);
+ timer_shutdown_sync(&tgt->enospc_timer);
+ cancel_work_sync(&tgt->event_work);
mempool_destroy(tgt->qio_pool);
mempool_destroy(tgt->qrq_pool);
--
2.53.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Devel] [PATCH hci-8.1 v2 2/9] drivers/md/dm-qcow2: always resubmit delayed ENOSPC requests in presuspend
2026-11-17 10:10 [Devel] [PATCH hci-8.1 v2 0/9] dm-qcow2: support the werror/rerror policies for vhost-blk disks Alexander Ivanov
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 1/9] drivers/md/dm-qcow2: cancel the event work and ENOSPC timer in the destructor Alexander Ivanov
@ 2026-11-17 10:10 ` Alexander Ivanov
2026-11-17 10:25 ` no-reply
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 3/9] drivers/md/dm-qcow2: rename the ENOSPC delay list to a held request list Alexander Ivanov
` (6 subsequent siblings)
8 siblings, 1 reply; 19+ messages in thread
From: Alexander Ivanov @ 2026-11-17 10:10 UTC (permalink / raw)
To: andrey.zhadchenko; +Cc: devel
qcow2_presuspend() skips resubmitting tgt->enospc_qios when
timer_delete_sync_try() finds qcow2_enospc_timer() running, assuming
the callback resubmits them. But the callback takes the list at its
start, so a request delayed after that stays on the list, and suspend
waits until the timer this request armed fires.
Wait for the callback with timer_delete_sync() and resubmit the list
unconditionally. wants_suspend is already set, so no request is
delayed after that.
https://virtuozzo.atlassian.net/browse/VSTOR-152175
Fixes: 2f9926b51be7 ("dm-qcow2: Rename MERGE_QIOS_MAX")
Feature: dm-qcow2: block device over QCOW2 files driver
Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
---
drivers/md/dm-qcow2-target.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/md/dm-qcow2-target.c b/drivers/md/dm-qcow2-target.c
index c49b0f466867..aa0bbb6b4a97 100644
--- a/drivers/md/dm-qcow2-target.c
+++ b/drivers/md/dm-qcow2-target.c
@@ -1165,8 +1165,8 @@ static void qcow2_presuspend(struct dm_target *ti)
qcow2_set_service_operations(ti, false);
qcow2_set_wants_suspend(ti, true);
- if (timer_delete_sync_try(&tgt->enospc_timer) != -1)
- qcow2_enospc_timer(&tgt->enospc_timer);
+ timer_delete_sync(&tgt->enospc_timer);
+ qcow2_enospc_timer(&tgt->enospc_timer);
}
static void qcow2_presuspend_undo(struct dm_target *ti)
{
--
2.53.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Devel] [PATCH hci-8.1 v2 3/9] drivers/md/dm-qcow2: rename the ENOSPC delay list to a held request list
2026-11-17 10:10 [Devel] [PATCH hci-8.1 v2 0/9] dm-qcow2: support the werror/rerror policies for vhost-blk disks Alexander Ivanov
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 1/9] drivers/md/dm-qcow2: cancel the event work and ENOSPC timer in the destructor Alexander Ivanov
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 2/9] drivers/md/dm-qcow2: always resubmit delayed ENOSPC requests in presuspend Alexander Ivanov
@ 2026-11-17 10:10 ` Alexander Ivanov
2026-11-17 10:25 ` no-reply
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 4/9] drivers/md/dm-qcow2: arm the hold timer only for the first held request Alexander Ivanov
` (5 subsequent siblings)
8 siblings, 1 reply; 19+ messages in thread
From: Alexander Ivanov @ 2026-11-17 10:10 UTC (permalink / raw)
To: andrey.zhadchenko; +Cc: devel
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
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Devel] [PATCH hci-8.1 v2 4/9] drivers/md/dm-qcow2: arm the hold timer only for the first held request
2026-11-17 10:10 [Devel] [PATCH hci-8.1 v2 0/9] dm-qcow2: support the werror/rerror policies for vhost-blk disks Alexander Ivanov
` (2 preceding siblings ...)
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 3/9] drivers/md/dm-qcow2: rename the ENOSPC delay list to a held request list Alexander Ivanov
@ 2026-11-17 10:10 ` Alexander Ivanov
2026-11-17 10:27 ` no-reply
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 5/9] drivers/md/dm-qcow2: report held requests with an IO_ERROR uevent Alexander Ivanov
` (4 subsequent siblings)
8 siblings, 1 reply; 19+ messages in thread
From: Alexander Ivanov @ 2026-11-17 10:10 UTC (permalink / raw)
To: andrey.zhadchenko; +Cc: devel
Every held request rearms tgt->held_timer, so while new requests keep
failing the held ones are never retried. A guest that keeps writing to
a full disk is enough to postpone the retry indefinitely.
Arm the timer when the held list turns non-empty, so the held requests
are retried a fixed period after the first of them failed.
https://virtuozzo.atlassian.net/browse/VSTOR-152175
Fixes: 6e2ec304689f ("dm-qcow2: Pause IO and notify about ENOSPC events")
Feature: dm-qcow2: block device over QCOW2 files driver
Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
---
drivers/md/dm-qcow2-map.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c
index b987d459863d..d6f8bcd98a39 100644
--- a/drivers/md/dm-qcow2-map.c
+++ b/drivers/md/dm-qcow2-map.c
@@ -4569,7 +4569,7 @@ void do_qcow2_fsync_work(struct work_struct *ws)
static bool qcow2_try_hold_error(struct qcow2_target *tgt, struct qcow2_rq *qrq,
struct qio *qio, blk_status_t bi_status)
{
- bool held = true;
+ bool held = true, first = false;
unsigned long flags;
if (bi_status != BLK_STS_NOSPC)
@@ -4586,11 +4586,12 @@ static bool qcow2_try_hold_error(struct qcow2_target *tgt, struct qcow2_rq *qrq,
pr_err_once(QCOW2_FMT("underlying disk is almost full"),
qcow2_device_name(tgt->ti));
tgt->event_enospc = true;
+ first = list_empty(&tgt->held_qios);
list_add_tail(&qio->link, &tgt->held_qios);
unlock:
spin_unlock_irqrestore(&tgt->event_lock, flags);
- if (held)
+ if (first)
mod_timer(&tgt->held_timer, jiffies + HOLD_TIMEOUT_JI);
schedule_work(&tgt->event_work);
--
2.53.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Devel] [PATCH hci-8.1 v2 5/9] drivers/md/dm-qcow2: report held requests with an IO_ERROR uevent
2026-11-17 10:10 [Devel] [PATCH hci-8.1 v2 0/9] dm-qcow2: support the werror/rerror policies for vhost-blk disks Alexander Ivanov
` (3 preceding siblings ...)
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 4/9] drivers/md/dm-qcow2: arm the hold timer only for the first held request Alexander Ivanov
@ 2026-11-17 10:10 ` Alexander Ivanov
2026-11-17 10:29 ` no-reply
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 6/9] drivers/md/dm-qcow2: add the resubmit and fail_held messages Alexander Ivanov
` (3 subsequent siblings)
8 siblings, 1 reply; 19+ messages in thread
From: Alexander Ivanov @ 2026-11-17 10:10 UTC (permalink / raw)
To: andrey.zhadchenko; +Cc: devel
QEMU is to pause the VM when dm-qcow2 holds a failed request, but it
cannot use dm_table_event(): waiting for dm events needs dm ioctls
and CAP_SYS_ADMIN, which QEMU does not have. libvirt already passes
QEMU a NETLINK_KOBJECT_UEVENT socket to watch the vhost-blk disk for
RESIZE=1 change events.
Send a change uevent on the dm disk with
IO_ERROR=1
IO_ERROR_OP=read|write
IO_ERROR_ERRNO=<positive errno>
when the held list turns non-empty. A periodic retry that fails
again repopulates the list, so the event is repeated while the error
persists and a lost netlink message is not fatal. This applies to
every dm-qcow2 device: a disk whose underlying storage stays full,
such as a container disk, now gets a change uevent and a udev probe
on every retry, that is every 20 seconds.
Only ENOSPC is held for now, for reads as well as writes; the op and
errno are reported so that other held errors need no new interface.
A flush is reported as a write, as QEMU does.
The event carries no DM_COOKIE, so udev handles it as a spurious
change and probes the disk, as it does after a close or a resize. A
cookie with the flags that disable the disk rules would avoid the probe
but makes 13-dm-disk.rules drop the by-id and by-uuid links, and the
flags stay in the udev database after the error is gone. The probe
only reads, but a read that fails with ENOSPC is held too, so the
probe may wait for the next retry like any other reader.
get_event keeps reporting a held ENOSPC as "event_ENOSPC", which
dm-ploop answers too, and reports other held errors as
"event_io_error <op> <errno>".
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-cmd.c | 11 ++++++++---
drivers/md/dm-qcow2-map.c | 8 +++++++-
drivers/md/dm-qcow2-target.c | 28 ++++++++++++++++++++++++++++
drivers/md/dm-qcow2.h | 5 ++++-
4 files changed, 47 insertions(+), 5 deletions(-)
diff --git a/drivers/md/dm-qcow2-cmd.c b/drivers/md/dm-qcow2-cmd.c
index 3bccce090f01..7af3ac154127 100644
--- a/drivers/md/dm-qcow2-cmd.c
+++ b/drivers/md/dm-qcow2-cmd.c
@@ -584,10 +584,15 @@ static int qcow2_get_event(struct qcow2_target *tgt, char *result, unsigned int
int ret = 0;
spin_lock_irq(&tgt->event_lock);
- if (tgt->event_enospc) {
- ret = (DMEMIT("event_ENOSPC\n")) ? 1 : 0;
+ if (tgt->event_io_error) {
+ if (tgt->event_errno == ENOSPC)
+ ret = (DMEMIT("event_ENOSPC\n")) ? 1 : 0;
+ else
+ ret = (DMEMIT("event_io_error %s %d\n",
+ tgt->event_write ? "write" : "read",
+ tgt->event_errno)) ? 1 : 0;
if (ret)
- tgt->event_enospc = false;
+ tgt->event_io_error = false;
}
spin_unlock_irq(&tgt->event_lock);
diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c
index d6f8bcd98a39..2a663eb652f4 100644
--- a/drivers/md/dm-qcow2-map.c
+++ b/drivers/md/dm-qcow2-map.c
@@ -4569,6 +4569,7 @@ void do_qcow2_fsync_work(struct work_struct *ws)
static bool qcow2_try_hold_error(struct qcow2_target *tgt, struct qcow2_rq *qrq,
struct qio *qio, blk_status_t bi_status)
{
+ bool write = op_is_write(qio->bi_op) || qio->bi_op == REQ_OP_FLUSH;
bool held = true, first = false;
unsigned long flags;
@@ -4585,8 +4586,13 @@ static bool qcow2_try_hold_error(struct qcow2_target *tgt, struct qcow2_rq *qrq,
pr_err_once(QCOW2_FMT("underlying disk is almost full"),
qcow2_device_name(tgt->ti));
- tgt->event_enospc = true;
+ tgt->event_io_error = true;
first = list_empty(&tgt->held_qios);
+ if (first) {
+ tgt->event_uevent = true;
+ tgt->event_write = write;
+ tgt->event_errno = -blk_status_to_errno(bi_status);
+ }
list_add_tail(&qio->link, &tgt->held_qios);
unlock:
spin_unlock_irqrestore(&tgt->event_lock, flags);
diff --git a/drivers/md/dm-qcow2-target.c b/drivers/md/dm-qcow2-target.c
index 89b12c4f971b..2a57f66fe25d 100644
--- a/drivers/md/dm-qcow2-target.c
+++ b/drivers/md/dm-qcow2-target.c
@@ -8,6 +8,7 @@
#include <linux/file.h>
#include <linux/fs.h>
#include <linux/error-injection.h>
+#include <linux/sched/mm.h>
#include "dm.h"
#include "dm-qcow2.h"
@@ -493,11 +494,38 @@ static void qcow2_held_timer(struct timer_list *timer)
qcow2_submit_embedded_qios(tgt, &list);
}
+static void qcow2_send_io_error_uevent(struct qcow2_target *tgt,
+ bool write, int err)
+{
+ struct mapped_device *md = dm_table_get_md(tgt->ti->table);
+ char op[24], errno_env[24];
+ char *envp[] = { "IO_ERROR=1", op, errno_env, NULL };
+ unsigned int noio_flag;
+
+ snprintf(op, sizeof(op), "IO_ERROR_OP=%s", write ? "write" : "read");
+ snprintf(errno_env, sizeof(errno_env), "IO_ERROR_ERRNO=%d", err);
+
+ noio_flag = memalloc_noio_save();
+ kobject_uevent_env(&disk_to_dev(dm_disk(md))->kobj, KOBJ_CHANGE, envp);
+ memalloc_noio_restore(noio_flag);
+}
+
static void qcow2_event_work(struct work_struct *ws)
{
struct qcow2_target *tgt = container_of(ws, struct qcow2_target, event_work);
+ bool uevent, write;
+ int err;
+
+ spin_lock_irq(&tgt->event_lock);
+ uevent = tgt->event_uevent;
+ tgt->event_uevent = false;
+ write = tgt->event_write;
+ err = tgt->event_errno;
+ spin_unlock_irq(&tgt->event_lock);
dm_table_event(tgt->ti->table);
+ if (uevent)
+ qcow2_send_io_error_uevent(tgt, write, err);
}
static struct qcow2_target *alloc_qcow2_target(struct dm_target *ti)
diff --git a/drivers/md/dm-qcow2.h b/drivers/md/dm-qcow2.h
index ea6bc6258cb0..03233090da23 100644
--- a/drivers/md/dm-qcow2.h
+++ b/drivers/md/dm-qcow2.h
@@ -208,7 +208,10 @@ struct qcow2_target {
bool wants_suspend;
bool md_writeback_error;
bool truncate_error;
- bool event_enospc;
+ bool event_io_error;
+ bool event_uevent;
+ bool event_write;
+ int event_errno;
atomic_t service_qios;
struct wait_queue_head service_wq;
--
2.53.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Devel] [PATCH hci-8.1 v2 6/9] drivers/md/dm-qcow2: add the resubmit and fail_held messages
2026-11-17 10:10 [Devel] [PATCH hci-8.1 v2 0/9] dm-qcow2: support the werror/rerror policies for vhost-blk disks Alexander Ivanov
` (4 preceding siblings ...)
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 5/9] drivers/md/dm-qcow2: report held requests with an IO_ERROR uevent Alexander Ivanov
@ 2026-11-17 10:10 ` Alexander Ivanov
2026-11-17 10:32 ` no-reply
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 7/9] drivers/md/dm-qcow2: add the error_policy table argument Alexander Ivanov
` (2 subsequent siblings)
8 siblings, 1 reply; 19+ messages in thread
From: Alexander Ivanov @ 2026-11-17 10:10 UTC (permalink / raw)
To: andrey.zhadchenko; +Cc: devel
Held requests are retried every 20 seconds. QEMU pauses the VM on
the IO_ERROR uevent, and the requests should be retried as soon as
the VM is resumed, and dropped if the VM is destroyed: vhost-blk waits
for all in-flight requests on release, so a request held while the
error persists leaves QEMU in D state.
QEMU has no CAP_SYS_ADMIN, so libvirt sends the messages:
resubmit - resubmit the held requests now
fail_held - fail the held requests and stop holding new ones
until resubmit or resume
fail_held has to be sticky: requests in flight when it arrives, a
timer resubmission included, fail later and would otherwise be held
again with the timer rearmed.
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-cmd.c | 21 +++++++++++++++++++++
drivers/md/dm-qcow2-map.c | 35 ++++++++++++++++++++++++++++++++++-
drivers/md/dm-qcow2-target.c | 16 +++++++---------
drivers/md/dm-qcow2.h | 4 ++++
4 files changed, 66 insertions(+), 10 deletions(-)
diff --git a/drivers/md/dm-qcow2-cmd.c b/drivers/md/dm-qcow2-cmd.c
index 7af3ac154127..ea9c69b454ea 100644
--- a/drivers/md/dm-qcow2-cmd.c
+++ b/drivers/md/dm-qcow2-cmd.c
@@ -643,6 +643,27 @@ int qcow2_message(struct dm_target *ti, unsigned int argc, char **argv,
}
ret = qcow2_get_event(tgt, result, maxlen);
goto out;
+ } else if (!strcmp(argv[0], "resubmit")) {
+ if (argc != 1) {
+ ret = -EINVAL;
+ goto out;
+ }
+ spin_lock_irq(&tgt->event_lock);
+ tgt->fail_held = false;
+ spin_unlock_irq(&tgt->event_lock);
+ timer_delete(&tgt->held_timer);
+ qcow2_resubmit_held_qios(tgt);
+ ret = 0;
+ goto out;
+ } else if (!strcmp(argv[0], "fail_held")) {
+ if (argc != 1) {
+ ret = -EINVAL;
+ goto out;
+ }
+ timer_delete(&tgt->held_timer);
+ qcow2_fail_held_qios(tgt);
+ ret = 0;
+ goto out;
} else if (!strcmp(argv[0], "merge_backward")) {
if (argc < 2) {
ret = -EINVAL;
diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c
index 2a663eb652f4..b2962c77cc15 100644
--- a/drivers/md/dm-qcow2-map.c
+++ b/drivers/md/dm-qcow2-map.c
@@ -4577,12 +4577,13 @@ static bool qcow2_try_hold_error(struct qcow2_target *tgt, struct qcow2_rq *qrq,
return false;
spin_lock_irqsave(&tgt->event_lock, flags);
- if (unlikely(tgt->wants_suspend)) {
+ if (unlikely(tgt->wants_suspend || tgt->fail_held)) {
held = false;
goto unlock;
}
init_qrq_and_embedded_qio(tgt, qrq->rq, qrq, qio);
+ qrq->held_status = bi_status;
pr_err_once(QCOW2_FMT("underlying disk is almost full"),
qcow2_device_name(tgt->ti));
@@ -4689,6 +4690,38 @@ void qcow2_submit_embedded_qios(struct qcow2_target *tgt, struct list_head *list
qcow2_submit_embedded_qio(tgt, qio);
}
+void qcow2_resubmit_held_qios(struct qcow2_target *tgt)
+{
+ unsigned long flags;
+ LIST_HEAD(list);
+
+ spin_lock_irqsave(&tgt->event_lock, flags);
+ list_splice_init(&tgt->held_qios, &list);
+ spin_unlock_irqrestore(&tgt->event_lock, flags);
+
+ qcow2_submit_embedded_qios(tgt, &list);
+}
+
+void qcow2_fail_held_qios(struct qcow2_target *tgt)
+{
+ struct qcow2_rq *qrq;
+ struct request *rq;
+ struct qio *qio;
+ LIST_HEAD(list);
+
+ spin_lock_irq(&tgt->event_lock);
+ tgt->fail_held = true;
+ list_splice_init(&tgt->held_qios, &list);
+ spin_unlock_irq(&tgt->event_lock);
+
+ while ((qio = qio_list_pop(&list)) != NULL) {
+ qrq = qio->endio_cb_data;
+ rq = qrq->rq;
+ dm_complete_request(rq, qrq->held_status);
+ mempool_free(qrq, tgt->qrq_pool);
+ }
+}
+
int qcow2_clone_and_map(struct dm_target *ti, struct request *rq,
union map_info *info, struct request **clone)
{
diff --git a/drivers/md/dm-qcow2-target.c b/drivers/md/dm-qcow2-target.c
index 2a57f66fe25d..590c2e6a4bec 100644
--- a/drivers/md/dm-qcow2-target.c
+++ b/drivers/md/dm-qcow2-target.c
@@ -484,14 +484,8 @@ static void inflight_ref_exit1(struct percpu_ref *ref)
static void qcow2_held_timer(struct timer_list *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->held_qios, &list);
- spin_unlock_irqrestore(&tgt->event_lock, flags);
-
- qcow2_submit_embedded_qios(tgt, &list);
+ qcow2_resubmit_held_qios(tgt);
}
static void qcow2_send_io_error_uevent(struct qcow2_target *tgt,
@@ -1247,8 +1241,12 @@ static int qcow2_preresume(struct dm_target *ti)
if (ret)
QC_ERR(ti, "Can't set features");
}
- if (!ret)
- qcow2_set_wants_suspend(ti, false);
+ if (!ret) {
+ spin_lock_irq(&tgt->event_lock);
+ tgt->fail_held = false;
+ tgt->wants_suspend = false;
+ spin_unlock_irq(&tgt->event_lock);
+ }
return ret;
}
diff --git a/drivers/md/dm-qcow2.h b/drivers/md/dm-qcow2.h
index 03233090da23..df20826c6060 100644
--- a/drivers/md/dm-qcow2.h
+++ b/drivers/md/dm-qcow2.h
@@ -206,6 +206,7 @@ struct qcow2_target {
bool service_operations_allowed;
bool wants_suspend;
+ bool fail_held;
bool md_writeback_error;
bool truncate_error;
bool event_io_error;
@@ -345,6 +346,7 @@ struct qio_ext {
struct qcow2_rq {
struct request *rq;
struct bio_vec *bvec;
+ blk_status_t held_status;
};
struct qio;
@@ -426,6 +428,8 @@ void qcow2_init_qio(struct qio *qio, unsigned int bi_op, struct qcow2 *qcow2);
void qcow2_dispatch_qios(struct qcow2 *qcow2, struct qio *qio,
struct list_head *qio_list);
void qcow2_submit_embedded_qios(struct qcow2_target *tgt, struct list_head *list);
+void qcow2_resubmit_held_qios(struct qcow2_target *tgt);
+void qcow2_fail_held_qios(struct qcow2_target *tgt);
struct qcow2 *qcow2_ref_inc(struct qcow2_target *tgt, u8 *ref_index);
void qcow2_ref_dec(struct qcow2_target *tgt, u8 ref_index);
int qcow2_inflight_ref_switch(struct qcow2_target *tgt);
--
2.53.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Devel] [PATCH hci-8.1 v2 7/9] drivers/md/dm-qcow2: add the error_policy table argument
2026-11-17 10:10 [Devel] [PATCH hci-8.1 v2 0/9] dm-qcow2: support the werror/rerror policies for vhost-blk disks Alexander Ivanov
` (5 preceding siblings ...)
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 6/9] drivers/md/dm-qcow2: add the resubmit and fail_held messages Alexander Ivanov
@ 2026-11-17 10:10 ` Alexander Ivanov
2026-11-17 10:34 ` no-reply
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 8/9] drivers/md/dm-qcow2: requeue held requests on a noflush suspend Alexander Ivanov
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 9/9] drivers/vhost/blk: fix a hang on release after the vhost worker is killed Alexander Ivanov
8 siblings, 1 reply; 19+ messages in thread
From: Alexander Ivanov @ 2026-11-17 10:10 UTC (permalink / raw)
To: andrey.zhadchenko; +Cc: devel
QEMU disks have the werror/rerror policies: report the error to the
guest, or pause the VM and retry the request on resume, either for
ENOSPC only (enospc) or for any error (stop). A vhost-blk disk
completes requests to the guest from the kernel, so the request has
to be held in dm-qcow2 for QEMU to have a chance to pause the VM.
Accept an optional first table argument
error_policy=<read>,<write>
where each policy is report, enospc or stop. Requests failed under
the enospc or stop policy are held, reported and resubmitted like
ENOSPC writes are now. All other table arguments are numeric fds, so
the option cannot be confused with an image.
With error_policy=stop for reads the udev probe that follows the
IO_ERROR uevent may be held too, and waits for resubmit, fail_held or
the next timer retry like any other reader. The timer retries and
reports every held error, not only ENOSPC, so a lost uevent is not
fatal and a transient error clears by itself; the VM stays paused
until cont regardless.
The default is read=report, write=enospc, which is the QEMU default
and keeps the current behaviour for writes. A read that fails with
ENOSPC, which only the image file's read_iter can return, is now
reported to the guest instead of being held.
Requests held at the same time may now fail with different errors.
get_event reports the op and errno of the first request held since the
previous get_event, so a later ENOSPC is not hidden behind an error
that was already read, and an unread one is kept when its request is
resubmitted. The uevent is still sent only when the held list turns
non-empty and carries the error of the request that made it so,
whatever get_event has read: QEMU keeps the first error as the
io-status too, and a uevent per distinct error would make udev probe
the disk each time.
get_event keeps the event_ENOSPC form for writes only. A held read is
reported as event_io_error, which userspace that sets a read policy
understands.
A flush follows the write policy and is reported as a write, as QEMU
does.
Requests failed with BLK_STS_NOTSUPP are not held either: a retry
fails the same way. A discard on a filesystem that cannot punch holes
would otherwise be held under the stop policy forever and pause the VM
again after every resume. QEMU ignores ENOTSUP from a discard for the
same reason.
The policy is appended to the table status if it is not the default,
after the fields that existing parsers read by position. The status
does not hold the table arguments anyway, so userspace that reloads
the table has to pass the policy back as the first argument.
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-cmd.c | 2 +-
drivers/md/dm-qcow2-map.c | 27 ++++++++++++++-----
drivers/md/dm-qcow2-target.c | 50 +++++++++++++++++++++++++++++++++---
drivers/md/dm-qcow2.h | 10 ++++++++
4 files changed, 79 insertions(+), 10 deletions(-)
diff --git a/drivers/md/dm-qcow2-cmd.c b/drivers/md/dm-qcow2-cmd.c
index ea9c69b454ea..6a56919bec73 100644
--- a/drivers/md/dm-qcow2-cmd.c
+++ b/drivers/md/dm-qcow2-cmd.c
@@ -585,7 +585,7 @@ static int qcow2_get_event(struct qcow2_target *tgt, char *result, unsigned int
spin_lock_irq(&tgt->event_lock);
if (tgt->event_io_error) {
- if (tgt->event_errno == ENOSPC)
+ if (tgt->event_errno == ENOSPC && tgt->event_write)
ret = (DMEMIT("event_ENOSPC\n")) ? 1 : 0;
else
ret = (DMEMIT("event_io_error %s %d\n",
diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c
index b2962c77cc15..adbebe728f99 100644
--- a/drivers/md/dm-qcow2-map.c
+++ b/drivers/md/dm-qcow2-map.c
@@ -4572,8 +4572,14 @@ static bool qcow2_try_hold_error(struct qcow2_target *tgt, struct qcow2_rq *qrq,
bool write = op_is_write(qio->bi_op) || qio->bi_op == REQ_OP_FLUSH;
bool held = true, first = false;
unsigned long flags;
+ u8 policy;
- if (bi_status != BLK_STS_NOSPC)
+ if (bi_status == BLK_STS_NOTSUPP)
+ return false;
+
+ policy = write ? tgt->write_policy : tgt->read_policy;
+ if (policy == QCOW2_ERROR_REPORT ||
+ (policy == QCOW2_ERROR_ENOSPC && bi_status != BLK_STS_NOSPC))
return false;
spin_lock_irqsave(&tgt->event_lock, flags);
@@ -4585,14 +4591,23 @@ static bool qcow2_try_hold_error(struct qcow2_target *tgt, struct qcow2_rq *qrq,
init_qrq_and_embedded_qio(tgt, qrq->rq, qrq, qio);
qrq->held_status = bi_status;
- pr_err_once(QCOW2_FMT("underlying disk is almost full"),
- qcow2_device_name(tgt->ti));
- tgt->event_io_error = true;
+ if (bi_status == BLK_STS_NOSPC)
+ pr_err_once(QCOW2_FMT("underlying disk is almost full"),
+ qcow2_device_name(tgt->ti));
+ else
+ pr_err_ratelimited(QCOW2_FMT("holding failed request, status %d"),
+ qcow2_device_name(tgt->ti),
+ blk_status_to_errno(bi_status));
first = list_empty(&tgt->held_qios);
- if (first) {
- tgt->event_uevent = true;
+ if (!tgt->event_io_error) {
tgt->event_write = write;
tgt->event_errno = -blk_status_to_errno(bi_status);
+ tgt->event_io_error = true;
+ }
+ if (first) {
+ tgt->event_uevent = true;
+ tgt->uevent_write = write;
+ tgt->uevent_errno = -blk_status_to_errno(bi_status);
}
list_add_tail(&qio->link, &tgt->held_qios);
unlock:
diff --git a/drivers/md/dm-qcow2-target.c b/drivers/md/dm-qcow2-target.c
index 590c2e6a4bec..b3365f92c7dd 100644
--- a/drivers/md/dm-qcow2-target.c
+++ b/drivers/md/dm-qcow2-target.c
@@ -513,8 +513,8 @@ static void qcow2_event_work(struct work_struct *ws)
spin_lock_irq(&tgt->event_lock);
uevent = tgt->event_uevent;
tgt->event_uevent = false;
- write = tgt->event_write;
- err = tgt->event_errno;
+ write = tgt->uevent_write;
+ err = tgt->uevent_errno;
spin_unlock_irq(&tgt->event_lock);
dm_table_event(tgt->ti->table);
@@ -559,6 +559,8 @@ static struct qcow2_target *alloc_qcow2_target(struct dm_target *ti)
}
init_completion(&tgt->inflight_ref_comp);
+ tgt->read_policy = QCOW2_ERROR_REPORT;
+ tgt->write_policy = QCOW2_ERROR_ENOSPC;
spin_lock_init(&tgt->event_lock);
mutex_init(&tgt->ctl_mutex);
init_rwsem(&tgt->seek_rwsem);
@@ -1029,6 +1031,32 @@ static int qcow2_parse_metadata(struct dm_target *ti, struct qcow2_target *tgt)
return ret;
}
+static const char * const qcow2_error_policy_names[] = {
+ [QCOW2_ERROR_REPORT] = "report",
+ [QCOW2_ERROR_ENOSPC] = "enospc",
+ [QCOW2_ERROR_STOP] = "stop",
+};
+
+static int qcow2_parse_error_policy(struct qcow2_target *tgt, const char *arg)
+{
+ char rd[8], wr[8], end;
+ int r, w;
+
+ if (sscanf(arg, "error_policy=%7[^,],%7s%c", rd, wr, &end) != 2)
+ return -EINVAL;
+
+ r = match_string(qcow2_error_policy_names,
+ ARRAY_SIZE(qcow2_error_policy_names), rd);
+ w = match_string(qcow2_error_policy_names,
+ ARRAY_SIZE(qcow2_error_policy_names), wr);
+ if (r < 0 || w < 0)
+ return -EINVAL;
+
+ tgt->read_policy = r;
+ tgt->write_policy = w;
+ return 0;
+}
+
static int qcow2_ctr(struct dm_target *ti, unsigned int argc, char **argv)
{
struct qcow2 *qcow2, *upper = NULL;
@@ -1041,6 +1069,17 @@ static int qcow2_ctr(struct dm_target *ti, unsigned int argc, char **argv)
tgt = alloc_qcow2_target(ti);
if (!tgt)
return -ENOMEM;
+
+ if (str_has_prefix(argv[0], "error_policy=")) {
+ ret = qcow2_parse_error_policy(tgt, argv[0]);
+ if (ret || argc < 2) {
+ ti->error = "Wrong error_policy";
+ ret = -EINVAL;
+ goto err;
+ }
+ argc--;
+ argv++;
+ }
/*
* Userspace passes deltas in bottom, ..., top order,
* but we attach it vise versa: from top to bottom.
@@ -1173,6 +1212,11 @@ static void qcow2_status(struct dm_target *ti, status_type_t type,
case STATUSTYPE_TABLE:
DMEMIT("%u v%u %llu", qcow2->img_id + 1, hdr->version,
to_sector(qcow2->clu_size));
+ if (tgt->read_policy != QCOW2_ERROR_REPORT ||
+ tgt->write_policy != QCOW2_ERROR_ENOSPC)
+ DMEMIT(" error_policy=%s,%s",
+ qcow2_error_policy_names[tgt->read_policy],
+ qcow2_error_policy_names[tgt->write_policy]);
break;
case STATUSTYPE_IMA:
result[0] = '\0';
@@ -1259,7 +1303,7 @@ static void qcow2_resume(struct dm_target *ti)
static struct target_type qcow2_target = {
.name = "qcow2",
- .version = {1, 0, 0},
+ .version = {1, 1, 0},
.features = DM_TARGET_SINGLETON,
.module = THIS_MODULE,
.ctr = qcow2_ctr,
diff --git a/drivers/md/dm-qcow2.h b/drivers/md/dm-qcow2.h
index df20826c6060..cd73314ee28c 100644
--- a/drivers/md/dm-qcow2.h
+++ b/drivers/md/dm-qcow2.h
@@ -188,6 +188,12 @@ struct qcow2_backward_merge {
long long max_progress;
};
+enum qcow2_error_policy {
+ QCOW2_ERROR_REPORT = 0,
+ QCOW2_ERROR_ENOSPC,
+ QCOW2_ERROR_STOP,
+};
+
struct qcow2_target {
struct dm_target *ti;
#define QCOW2_QRQ_POOL_SIZE 512 /* Twice nr_requests from blk_mq_init_sched() */
@@ -213,6 +219,10 @@ struct qcow2_target {
bool event_uevent;
bool event_write;
int event_errno;
+ bool uevent_write;
+ int uevent_errno;
+ u8 read_policy;
+ u8 write_policy;
atomic_t service_qios;
struct wait_queue_head service_wq;
--
2.53.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Devel] [PATCH hci-8.1 v2 8/9] drivers/md/dm-qcow2: requeue held requests on a noflush suspend
2026-11-17 10:10 [Devel] [PATCH hci-8.1 v2 0/9] dm-qcow2: support the werror/rerror policies for vhost-blk disks Alexander Ivanov
` (6 preceding siblings ...)
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 7/9] drivers/md/dm-qcow2: add the error_policy table argument Alexander Ivanov
@ 2026-11-17 10:10 ` Alexander Ivanov
2026-11-17 10:37 ` no-reply
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 9/9] drivers/vhost/blk: fix a hang on release after the vhost worker is killed Alexander Ivanov
8 siblings, 1 reply; 19+ messages in thread
From: Alexander Ivanov @ 2026-11-17 10:10 UTC (permalink / raw)
To: andrey.zhadchenko; +Cc: devel
A request failed under the enospc or stop policy cannot stay held
across a suspend: the suspend waits for it to complete. So presuspend
retries the held requests once, and a request that fails again is
completed with its error. A table reload or a snapshot taken while the
VM is paused on a held request then delivers the error that the policy
was meant to keep from the guest.
On a noflush suspend, requeue such a request to the dm queue instead.
It is dispatched through the new table on resume and is held again if
the error persists. This follows dm-mpath, which requeues on a noflush
suspend and fails the I/O queued for no paths on a flush suspend.
ploop suspends with flags 0, a flush suspend, for a snapshot and a
resize in ploop_suspend_device(), so it gets the requeue only with the
ploop.ovz change "lib: suspend unpartitioned dm-qcow2 devices with
noflush". A partitioned device keeps the flush suspend there and still
completes a held request with its error.
The noflush mode is recorded in presuspend rather than read with
dm_noflush_suspending(): an interrupted suspend clears
DMF_NOFLUSH_SUSPENDING and restarts the queue before presuspend_undo
runs, and a request failing in between would get its error although
the suspend was cancelled.
The request is requeued with a delay, as dm-mpath does for the no-path
case: until the queue is stopped, or after an interrupted suspend
restarts it, a request that keeps failing would otherwise be dispatched
and requeued in a loop. dm_requeue_original_rq() gets a delay argument
for that.
Requeued requests keep the device open: their submitter cannot drop
its last reference until they complete, so a remove fails with EBUSY
until the device is resumed with a working table or with an error
table, as dmsetup remove --force does. dm-mpath with queue_if_no_path
behaves the same way.
fail_held fails with EBUSY during a noflush suspend: the requeued
requests are out of the target's reach, and the flag would not
survive a table reload. Userspace sends it again after resume.
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-push-backup.c | 2 +-
drivers/md/dm-qcow2-cmd.c | 6 +++---
drivers/md/dm-qcow2-map.c | 22 +++++++++++++++++++---
drivers/md/dm-qcow2-target.c | 2 ++
drivers/md/dm-qcow2.h | 3 ++-
drivers/md/dm-rq.c | 4 ++--
drivers/md/dm-rq.h | 2 +-
7 files changed, 30 insertions(+), 11 deletions(-)
diff --git a/drivers/md/dm-push-backup.c b/drivers/md/dm-push-backup.c
index 4f6dc1f3c130..ca1f623f56a7 100644
--- a/drivers/md/dm-push-backup.c
+++ b/drivers/md/dm-push-backup.c
@@ -218,7 +218,7 @@ static void resubmit_pbios(struct push_backup *pb, struct list_head *list)
list_del_init(&pbio->list);
mempool_free(pbio, pb->pbio_pool);
- dm_requeue_original_rq(rq);
+ dm_requeue_original_rq(rq, false);
}
}
diff --git a/drivers/md/dm-qcow2-cmd.c b/drivers/md/dm-qcow2-cmd.c
index 6a56919bec73..9106ce65d355 100644
--- a/drivers/md/dm-qcow2-cmd.c
+++ b/drivers/md/dm-qcow2-cmd.c
@@ -660,9 +660,9 @@ int qcow2_message(struct dm_target *ti, unsigned int argc, char **argv,
ret = -EINVAL;
goto out;
}
- timer_delete(&tgt->held_timer);
- qcow2_fail_held_qios(tgt);
- ret = 0;
+ ret = qcow2_fail_held_qios(tgt);
+ if (!ret)
+ timer_delete(&tgt->held_timer);
goto out;
} else if (!strcmp(argv[0], "merge_backward")) {
if (argc < 2) {
diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c
index adbebe728f99..830e3af28730 100644
--- a/drivers/md/dm-qcow2-map.c
+++ b/drivers/md/dm-qcow2-map.c
@@ -4570,7 +4570,8 @@ static bool qcow2_try_hold_error(struct qcow2_target *tgt, struct qcow2_rq *qrq,
struct qio *qio, blk_status_t bi_status)
{
bool write = op_is_write(qio->bi_op) || qio->bi_op == REQ_OP_FLUSH;
- bool held = true, first = false;
+ bool held = true, first = false, requeue = false;
+ struct request *rq = qrq->rq;
unsigned long flags;
u8 policy;
@@ -4584,7 +4585,10 @@ static bool qcow2_try_hold_error(struct qcow2_target *tgt, struct qcow2_rq *qrq,
spin_lock_irqsave(&tgt->event_lock, flags);
if (unlikely(tgt->wants_suspend || tgt->fail_held)) {
- held = false;
+ if (!tgt->fail_held && tgt->noflush_suspend)
+ requeue = true;
+ else
+ held = false;
goto unlock;
}
@@ -4613,6 +4617,12 @@ static bool qcow2_try_hold_error(struct qcow2_target *tgt, struct qcow2_rq *qrq,
unlock:
spin_unlock_irqrestore(&tgt->event_lock, flags);
+ if (requeue) {
+ mempool_free(qrq, tgt->qrq_pool);
+ dm_requeue_original_rq(rq, true);
+ return true;
+ }
+
if (first)
mod_timer(&tgt->held_timer, jiffies + HOLD_TIMEOUT_JI);
schedule_work(&tgt->event_work);
@@ -4717,7 +4727,7 @@ void qcow2_resubmit_held_qios(struct qcow2_target *tgt)
qcow2_submit_embedded_qios(tgt, &list);
}
-void qcow2_fail_held_qios(struct qcow2_target *tgt)
+int qcow2_fail_held_qios(struct qcow2_target *tgt)
{
struct qcow2_rq *qrq;
struct request *rq;
@@ -4725,6 +4735,10 @@ void qcow2_fail_held_qios(struct qcow2_target *tgt)
LIST_HEAD(list);
spin_lock_irq(&tgt->event_lock);
+ if (tgt->noflush_suspend) {
+ spin_unlock_irq(&tgt->event_lock);
+ return -EBUSY;
+ }
tgt->fail_held = true;
list_splice_init(&tgt->held_qios, &list);
spin_unlock_irq(&tgt->event_lock);
@@ -4735,6 +4749,8 @@ void qcow2_fail_held_qios(struct qcow2_target *tgt)
dm_complete_request(rq, qrq->held_status);
mempool_free(qrq, tgt->qrq_pool);
}
+
+ return 0;
}
int qcow2_clone_and_map(struct dm_target *ti, struct request *rq,
diff --git a/drivers/md/dm-qcow2-target.c b/drivers/md/dm-qcow2-target.c
index b3365f92c7dd..dd74e7c84b75 100644
--- a/drivers/md/dm-qcow2-target.c
+++ b/drivers/md/dm-qcow2-target.c
@@ -36,6 +36,7 @@ static void qcow2_set_wants_suspend(struct dm_target *ti, bool wants)
spin_lock_irq(&tgt->event_lock);
tgt->wants_suspend = wants;
+ tgt->noflush_suspend = wants && dm_noflush_suspending(ti);
spin_unlock_irq(&tgt->event_lock);
}
@@ -1289,6 +1290,7 @@ static int qcow2_preresume(struct dm_target *ti)
spin_lock_irq(&tgt->event_lock);
tgt->fail_held = false;
tgt->wants_suspend = false;
+ tgt->noflush_suspend = false;
spin_unlock_irq(&tgt->event_lock);
}
diff --git a/drivers/md/dm-qcow2.h b/drivers/md/dm-qcow2.h
index cd73314ee28c..6b719113aeb6 100644
--- a/drivers/md/dm-qcow2.h
+++ b/drivers/md/dm-qcow2.h
@@ -212,6 +212,7 @@ struct qcow2_target {
bool service_operations_allowed;
bool wants_suspend;
+ bool noflush_suspend;
bool fail_held;
bool md_writeback_error;
bool truncate_error;
@@ -439,7 +440,7 @@ void qcow2_dispatch_qios(struct qcow2 *qcow2, struct qio *qio,
struct list_head *qio_list);
void qcow2_submit_embedded_qios(struct qcow2_target *tgt, struct list_head *list);
void qcow2_resubmit_held_qios(struct qcow2_target *tgt);
-void qcow2_fail_held_qios(struct qcow2_target *tgt);
+int qcow2_fail_held_qios(struct qcow2_target *tgt);
struct qcow2 *qcow2_ref_inc(struct qcow2_target *tgt, u8 *ref_index);
void qcow2_ref_dec(struct qcow2_target *tgt, u8 ref_index);
int qcow2_inflight_ref_switch(struct qcow2_target *tgt);
diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c
index 5a8cd59ec257..b2fb6f853a41 100644
--- a/drivers/md/dm-rq.c
+++ b/drivers/md/dm-rq.c
@@ -204,11 +204,11 @@ static void dm_requeue_original_request(struct dm_rq_target_io *tio, bool delay_
rq_completed(md);
}
-void dm_requeue_original_rq(struct request *rq)
+void dm_requeue_original_rq(struct request *rq, bool delay)
{
struct dm_rq_target_io *tio = tio_from_request(rq);
- dm_requeue_original_request(tio, false);
+ dm_requeue_original_request(tio, delay);
}
EXPORT_SYMBOL(dm_requeue_original_rq);
diff --git a/drivers/md/dm-rq.h b/drivers/md/dm-rq.h
index 53abc3cf9aee..d04cdb8adda2 100644
--- a/drivers/md/dm-rq.h
+++ b/drivers/md/dm-rq.h
@@ -46,6 +46,6 @@ ssize_t dm_attr_rq_based_seq_io_merge_deadline_store(struct mapped_device *md,
const char *buf, size_t count);
void dm_complete_request(struct request *rq, blk_status_t error);
-void dm_requeue_original_rq(struct request *rq);
+void dm_requeue_original_rq(struct request *rq, bool delay);
#endif
--
2.53.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Devel] [PATCH hci-8.1 v2 9/9] drivers/vhost/blk: fix a hang on release after the vhost worker is killed
2026-11-17 10:10 [Devel] [PATCH hci-8.1 v2 0/9] dm-qcow2: support the werror/rerror policies for vhost-blk disks Alexander Ivanov
` (7 preceding siblings ...)
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 8/9] drivers/md/dm-qcow2: requeue held requests on a noflush suspend Alexander Ivanov
@ 2026-11-17 10:10 ` Alexander Ivanov
2026-11-17 10:42 ` no-reply
8 siblings, 1 reply; 19+ messages in thread
From: Alexander Ivanov @ 2026-11-17 10:10 UTC (permalink / raw)
To: andrey.zhadchenko; +Cc: devel
When the owner is killed, vhost_worker_killed() detaches the worker
from the vqs. A bio completing after that fails to queue the
completion work, so its request stays on llhead and is never removed
from req_inflight. vhost_blk_flush() on release then waits forever
and the process is stuck in D state. Any kill of a VM with I/O in
flight can hit this.
If the work cannot be queued, drop the completed requests right in
the bio end_io: forget them without writing a status, as there is no
guest left to see it. llist_del_all() makes sure a request is dropped
once even if it races with the last run of the host kick handler.
forget_request() can now run in irq context, so take flush_lock with
interrupts disabled. The end_io may run in atomic context and the
request buffers may be vmalloc'ed, so free them on release instead:
a dropped request is the one left with ->inflight set.
Once a request is on llhead, a concurrent consumer may forget it and
let release free the request array and blk while the end_io is still
using blk_vq. Keep the end_io tail in an RCU read-side section and
wait for a grace period before freeing the requests. The same window
existed before with the host kick handler as the consumer.
https://virtuozzo.atlassian.net/browse/VSTOR-152175
Fixes: c57a98d65796 ("drivers/vhost: vhost-blk accelerator for virtio-blk guests")
Feature: vhost-blk: in-kernel accelerator for virtio-blk guests
Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
---
drivers/vhost/blk.c | 52 +++++++++++++++++++++++++++++++++------------
1 file changed, 39 insertions(+), 13 deletions(-)
diff --git a/drivers/vhost/blk.c b/drivers/vhost/blk.c
index b95358cdf3bc..b67255580031 100644
--- a/drivers/vhost/blk.c
+++ b/drivers/vhost/blk.c
@@ -146,6 +146,8 @@ static inline int vhost_blk_set_status(struct vhost_blk_req *req, u8 status)
return 0;
}
+static void vhost_blk_drop_completed(struct vhost_blk_vq *blk_vq);
+
static void vhost_blk_req_done(struct bio *bio)
{
struct vhost_blk_req *req = bio->bi_private;
@@ -168,8 +170,14 @@ static void vhost_blk_req_done(struct bio *bio)
}
if (atomic_dec_and_test(&req->bio_nr)) {
- llist_add(&req->llnode, &req->blk_vq->llhead);
- vhost_vq_work_queue(&req->blk_vq->vq, &req->blk_vq->work);
+ struct vhost_blk_vq *blk_vq = req->blk_vq;
+
+ /* req and blk may be freed once req is on llhead */
+ rcu_read_lock();
+ llist_add(&req->llnode, &blk_vq->llhead);
+ if (!vhost_vq_work_queue(&blk_vq->vq, &blk_vq->work))
+ vhost_blk_drop_completed(blk_vq);
+ rcu_read_unlock();
}
}
@@ -394,22 +402,34 @@ static inline void vhost_blk_bio_send(struct vhost_blk_req *req)
static inline void note_request(struct vhost_blk_req *req)
{
- spin_lock(&req->blk->flush_lock);
+ spin_lock_irq(&req->blk->flush_lock);
req->req_bin = req->blk->new_req_bin;
atomic_inc(&req->blk->req_inflight[req->req_bin]);
- spin_unlock(&req->blk->flush_lock);
+ spin_unlock_irq(&req->blk->flush_lock);
}
static inline void forget_request(struct vhost_blk_req *req)
{
struct vhost_blk *blk = req->blk;
+ unsigned long flags;
int zero;
- spin_lock(&blk->flush_lock);
+ spin_lock_irqsave(&blk->flush_lock, flags);
zero = atomic_dec_and_test(&blk->req_inflight[req->req_bin]);
if (zero && blk->during_flush)
wake_up(&blk->flush_wait);
- spin_unlock(&blk->flush_lock);
+ spin_unlock_irqrestore(&blk->flush_lock, flags);
+}
+
+/* Called when the worker is killed: nobody will complete these to the guest */
+static void vhost_blk_drop_completed(struct vhost_blk_vq *blk_vq)
+{
+ struct vhost_blk_req *req, *tmp;
+ struct llist_node *llnode;
+
+ llnode = llist_del_all(&blk_vq->llhead);
+ llist_for_each_entry_safe(req, tmp, llnode, llnode)
+ forget_request(req);
}
static int vhost_blk_req_submit(struct vhost_blk_req *req)
@@ -688,12 +708,12 @@ static void vhost_blk_flush(struct vhost_blk *blk)
{
int flush_bin;
- spin_lock(&blk->flush_lock);
+ spin_lock_irq(&blk->flush_lock);
WARN_ON(blk->during_flush);
blk->during_flush = 1;
flush_bin = blk->new_req_bin;
blk->new_req_bin = !blk->new_req_bin;
- spin_unlock(&blk->flush_lock);
+ spin_unlock_irq(&blk->flush_lock);
vhost_dev_flush(&blk->dev);
/*
@@ -707,15 +727,15 @@ static void vhost_blk_flush(struct vhost_blk *blk)
*/
wait_event(blk->flush_wait, !atomic_read(&blk->req_inflight[flush_bin]));
- spin_lock(&blk->flush_lock);
+ spin_lock_irq(&blk->flush_lock);
blk->during_flush = 0;
- spin_unlock(&blk->flush_lock);
+ spin_unlock_irq(&blk->flush_lock);
}
static void vhost_blk_drop_backend(struct vhost_blk *blk)
{
struct vhost_virtqueue *vq;
- int i;
+ int i, j;
if (!blk->backend)
return;
@@ -729,10 +749,16 @@ static void vhost_blk_drop_backend(struct vhost_blk *blk)
}
vhost_blk_flush(blk);
+ synchronize_rcu();
for (i = 0; i < VHOST_BLK_VQ_MAX; i++) {
- kvfree(blk->vqs[i].req);
- blk->vqs[i].req = NULL;
+ struct vhost_blk_vq *blk_vq = &blk->vqs[i];
+
+ for (j = 0; blk_vq->req && j < blk_vq->vq.num; j++)
+ if (blk_vq->req[j].inflight)
+ vhost_blk_req_cleanup(&blk_vq->req[j]);
+ kvfree(blk_vq->req);
+ blk_vq->req = NULL;
}
fput(blk->backend);
--
2.53.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Devel] [PATCH hci-8.1 v2 1/9] drivers/md/dm-qcow2: cancel the event work and ENOSPC timer in the destructor
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 1/9] drivers/md/dm-qcow2: cancel the event work and ENOSPC timer in the destructor Alexander Ivanov
@ 2026-11-17 10:22 ` no-reply
0 siblings, 0 replies; 19+ messages in thread
From: no-reply @ 2026-11-17 10:22 UTC (permalink / raw)
To: Alexander Ivanov, andrey.zhadchenko; +Cc: devel
> qcow2_try_delay_enospc() schedules tgt->event_work on the system
> workqueue and arms tgt->enospc_timer, but qcow2_tgt_destroy() frees
> the target without waiting for either. A work item queued just
> before the device is suspended and removed runs on freed memory.
>
> https://virtuozzo.atlassian.net/browse/VSTOR-152175
>
> Fixes: 6e2ec304689f ("dm-qcow2: Pause IO and notify about ENOSPC events")
> Feature: dm-qcow2: block device over QCOW2 files driver
> Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261117101026.3071579-1-alexander.ivanov@virtuozzo.com?part=1
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Devel] [PATCH hci-8.1 v2 2/9] drivers/md/dm-qcow2: always resubmit delayed ENOSPC requests in presuspend
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 2/9] drivers/md/dm-qcow2: always resubmit delayed ENOSPC requests in presuspend Alexander Ivanov
@ 2026-11-17 10:25 ` no-reply
0 siblings, 0 replies; 19+ messages in thread
From: no-reply @ 2026-11-17 10:25 UTC (permalink / raw)
To: Alexander Ivanov, andrey.zhadchenko; +Cc: devel
> qcow2_presuspend() skips resubmitting tgt->enospc_qios when
> timer_delete_sync_try() finds qcow2_enospc_timer() running, assuming
> the callback resubmits them. But the callback takes the list at its
> start, so a request delayed after that stays on the list, and suspend
> waits until the timer this request armed fires.
>
> Wait for the callback with timer_delete_sync() and resubmit the list
> unconditionally. wants_suspend is already set, so no request is
> delayed after that.
>
> https://virtuozzo.atlassian.net/browse/VSTOR-152175
>
> Fixes: 2f9926b51be7 ("dm-qcow2: Rename MERGE_QIOS_MAX")
> Feature: dm-qcow2: block device over QCOW2 files driver
> Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261117101026.3071579-1-alexander.ivanov@virtuozzo.com?part=2
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Devel] [PATCH hci-8.1 v2 3/9] drivers/md/dm-qcow2: rename the ENOSPC delay list to a held request list
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 3/9] drivers/md/dm-qcow2: rename the ENOSPC delay list to a held request list Alexander Ivanov
@ 2026-11-17 10:25 ` no-reply
0 siblings, 0 replies; 19+ messages in thread
From: no-reply @ 2026-11-17 10:25 UTC (permalink / raw)
To: Alexander Ivanov, andrey.zhadchenko; +Cc: devel
> 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>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261117101026.3071579-1-alexander.ivanov@virtuozzo.com?part=3
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Devel] [PATCH hci-8.1 v2 4/9] drivers/md/dm-qcow2: arm the hold timer only for the first held request
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 4/9] drivers/md/dm-qcow2: arm the hold timer only for the first held request Alexander Ivanov
@ 2026-11-17 10:27 ` no-reply
0 siblings, 0 replies; 19+ messages in thread
From: no-reply @ 2026-11-17 10:27 UTC (permalink / raw)
To: Alexander Ivanov, andrey.zhadchenko; +Cc: devel
> Every held request rearms tgt->held_timer, so while new requests keep
> failing the held ones are never retried. A guest that keeps writing to
> a full disk is enough to postpone the retry indefinitely.
>
> Arm the timer when the held list turns non-empty, so the held requests
> are retried a fixed period after the first of them failed.
>
> https://virtuozzo.atlassian.net/browse/VSTOR-152175
>
> Fixes: 6e2ec304689f ("dm-qcow2: Pause IO and notify about ENOSPC events")
> Feature: dm-qcow2: block device over QCOW2 files driver
> Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261117101026.3071579-1-alexander.ivanov@virtuozzo.com?part=4
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Devel] [PATCH hci-8.1 v2 5/9] drivers/md/dm-qcow2: report held requests with an IO_ERROR uevent
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 5/9] drivers/md/dm-qcow2: report held requests with an IO_ERROR uevent Alexander Ivanov
@ 2026-11-17 10:29 ` no-reply
0 siblings, 0 replies; 19+ messages in thread
From: no-reply @ 2026-11-17 10:29 UTC (permalink / raw)
To: Alexander Ivanov, andrey.zhadchenko; +Cc: devel
> QEMU is to pause the VM when dm-qcow2 holds a failed request, but it
> cannot use dm_table_event(): waiting for dm events needs dm ioctls
> and CAP_SYS_ADMIN, which QEMU does not have. libvirt already passes
> QEMU a NETLINK_KOBJECT_UEVENT socket to watch the vhost-blk disk for
> RESIZE=1 change events.
>
> Send a change uevent on the dm disk with
>
> IO_ERROR=1
> IO_ERROR_OP=read|write
> IO_ERROR_ERRNO=<positive errno>
>
> when the held list turns non-empty. A periodic retry that fails
> again repopulates the list, so the event is repeated while the error
> persists and a lost netlink message is not fatal. This applies to
> [ ... ]
> "event_io_error <op> <errno>".
>
> 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>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261117101026.3071579-1-alexander.ivanov@virtuozzo.com?part=5
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Devel] [PATCH hci-8.1 v2 6/9] drivers/md/dm-qcow2: add the resubmit and fail_held messages
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 6/9] drivers/md/dm-qcow2: add the resubmit and fail_held messages Alexander Ivanov
@ 2026-11-17 10:32 ` no-reply
0 siblings, 0 replies; 19+ messages in thread
From: no-reply @ 2026-11-17 10:32 UTC (permalink / raw)
To: Alexander Ivanov, andrey.zhadchenko; +Cc: devel
> Held requests are retried every 20 seconds. QEMU pauses the VM on
> the IO_ERROR uevent, and the requests should be retried as soon as
> the VM is resumed, and dropped if the VM is destroyed: vhost-blk waits
> for all in-flight requests on release, so a request held while the
> error persists leaves QEMU in D state.
>
> QEMU has no CAP_SYS_ADMIN, so libvirt sends the messages:
>
> resubmit - resubmit the held requests now
> fail_held - fail the held requests and stop holding new ones
> until resubmit or resume
>
> fail_held has to be sticky: requests in flight when it arrives, a
> timer resubmission included, fail later and would otherwise be held
> again with the timer rearmed.
>
> 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>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261117101026.3071579-1-alexander.ivanov@virtuozzo.com?part=6
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Devel] [PATCH hci-8.1 v2 7/9] drivers/md/dm-qcow2: add the error_policy table argument
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 7/9] drivers/md/dm-qcow2: add the error_policy table argument Alexander Ivanov
@ 2026-11-17 10:34 ` no-reply
0 siblings, 0 replies; 19+ messages in thread
From: no-reply @ 2026-11-17 10:34 UTC (permalink / raw)
To: Alexander Ivanov, andrey.zhadchenko; +Cc: devel
> QEMU disks have the werror/rerror policies: report the error to the
> guest, or pause the VM and retry the request on resume, either for
> ENOSPC only (enospc) or for any error (stop). A vhost-blk disk
> completes requests to the guest from the kernel, so the request has
> to be held in dm-qcow2 for QEMU to have a chance to pause the VM.
>
> Accept an optional first table argument
>
> error_policy=<read>,<write>
>
> where each policy is report, enospc or stop. Requests failed under
> the enospc or stop policy are held, reported and resubmitted like
> ENOSPC writes are now. All other table arguments are numeric fds, so
> the option cannot be confused with an image.
>
> [ ... ]
> the table has to pass the policy back as the first argument.
>
> 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>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261117101026.3071579-1-alexander.ivanov@virtuozzo.com?part=7
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Devel] [PATCH hci-8.1 v2 8/9] drivers/md/dm-qcow2: requeue held requests on a noflush suspend
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 8/9] drivers/md/dm-qcow2: requeue held requests on a noflush suspend Alexander Ivanov
@ 2026-11-17 10:37 ` no-reply
0 siblings, 0 replies; 19+ messages in thread
From: no-reply @ 2026-11-17 10:37 UTC (permalink / raw)
To: Alexander Ivanov, andrey.zhadchenko; +Cc: devel
> A request failed under the enospc or stop policy cannot stay held
> across a suspend: the suspend waits for it to complete. So presuspend
> retries the held requests once, and a request that fails again is
> completed with its error. A table reload or a snapshot taken while the
> VM is paused on a held request then delivers the error that the policy
> was meant to keep from the guest.
>
> On a noflush suspend, requeue such a request to the dm queue instead.
> It is dispatched through the new table on resume and is held again if
> the error persists. This follows dm-mpath, which requeues on a noflush
> suspend and fails the I/O queued for no paths on a flush suspend.
>
> ploop suspends with flags 0, a flush suspend, for a snapshot and a
> resize in ploop_suspend_device(), so it gets the requeue only with the
> ploop.ovz change "lib: suspend unpartitioned dm-qcow2 devices with
> [ ... ]
> survive a table reload. Userspace sends it again after resume.
>
> 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>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261117101026.3071579-1-alexander.ivanov@virtuozzo.com?part=8
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Devel] [PATCH hci-8.1 v2 9/9] drivers/vhost/blk: fix a hang on release after the vhost worker is killed
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 9/9] drivers/vhost/blk: fix a hang on release after the vhost worker is killed Alexander Ivanov
@ 2026-11-17 10:42 ` no-reply
0 siblings, 0 replies; 19+ messages in thread
From: no-reply @ 2026-11-17 10:42 UTC (permalink / raw)
To: Alexander Ivanov, andrey.zhadchenko; +Cc: devel
> When the owner is killed, vhost_worker_killed() detaches the worker
> from the vqs. A bio completing after that fails to queue the
> completion work, so its request stays on llhead and is never removed
> from req_inflight. vhost_blk_flush() on release then waits forever
> and the process is stuck in D state. Any kill of a VM with I/O in
> flight can hit this.
>
> If the work cannot be queued, drop the completed requests right in
> the bio end_io: forget them without writing a status, as there is no
> guest left to see it. llist_del_all() makes sure a request is dropped
> once even if it races with the last run of the host kick handler.
> forget_request() can now run in irq context, so take flush_lock with
> interrupts disabled. The end_io may run in atomic context and the
> request buffers may be vmalloc'ed, so free them on release instead:
> a dropped request is the one left with ->inflight set.
>
> Once a request is on llhead, a concurrent consumer may forget it and
> let release free the request array and blk while the end_io is still
> using blk_vq. Keep the end_io tail in an RCU read-side section and
> wait for a grace period before freeing the requests. The same window
> existed before with the host kick handler as the consumer.
>
> https://virtuozzo.atlassian.net/browse/VSTOR-152175
>
> Fixes: c57a98d65796 ("drivers/vhost: vhost-blk accelerator for virtio-blk guests")
> Feature: vhost-blk: in-kernel accelerator for virtio-blk guests
> Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261117101026.3071579-1-alexander.ivanov@virtuozzo.com?part=9
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2026-11-17 10:44 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-17 10:10 [Devel] [PATCH hci-8.1 v2 0/9] dm-qcow2: support the werror/rerror policies for vhost-blk disks Alexander Ivanov
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 1/9] drivers/md/dm-qcow2: cancel the event work and ENOSPC timer in the destructor Alexander Ivanov
2026-11-17 10:22 ` no-reply
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 2/9] drivers/md/dm-qcow2: always resubmit delayed ENOSPC requests in presuspend Alexander Ivanov
2026-11-17 10:25 ` no-reply
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 3/9] drivers/md/dm-qcow2: rename the ENOSPC delay list to a held request list Alexander Ivanov
2026-11-17 10:25 ` no-reply
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 4/9] drivers/md/dm-qcow2: arm the hold timer only for the first held request Alexander Ivanov
2026-11-17 10:27 ` no-reply
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 5/9] drivers/md/dm-qcow2: report held requests with an IO_ERROR uevent Alexander Ivanov
2026-11-17 10:29 ` no-reply
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 6/9] drivers/md/dm-qcow2: add the resubmit and fail_held messages Alexander Ivanov
2026-11-17 10:32 ` no-reply
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 7/9] drivers/md/dm-qcow2: add the error_policy table argument Alexander Ivanov
2026-11-17 10:34 ` no-reply
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 8/9] drivers/md/dm-qcow2: requeue held requests on a noflush suspend Alexander Ivanov
2026-11-17 10:37 ` no-reply
2026-11-17 10:10 ` [Devel] [PATCH hci-8.1 v2 9/9] drivers/vhost/blk: fix a hang on release after the vhost worker is killed Alexander Ivanov
2026-11-17 10:42 ` no-reply
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.