From: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
To: andrey.zhadchenko@virtuozzo.com
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.2 6/7] dm-qcow2: add the report_enospc table argument
Date: Fri, 27 Nov 2026 12:15:49 +0100 [thread overview]
Message-ID: <20261127111550.1151546-7-alexander.ivanov@virtuozzo.com> (raw)
In-Reply-To: <20261127111550.1151546-1-alexander.ivanov@virtuozzo.com>
A request failing with ENOSPC is delayed in dm-qcow2 and resubmitted
every 20 seconds, and the error is reported with a dm event. A
vhost-blk disk is controlled by QEMU, which cannot wait for dm events
or send dm messages without CAP_SYS_ADMIN. So for a VM the request
just hangs until space is freed, and the VM is never paused.
vhost-blk is to hold a request failed with ENOSPC itself and let QEMU
pause the VM and resubmit it on resume, as QEMU does for its own disks
with werror=enospc. That needs the error to reach vhost-blk.
With the optional first table argument report_enospc, such a request
is completed with BLK_STS_NOSPC at once, and no dm event is raised.
Without it nothing changes, which containers rely on.
A flag set by a message would be lost on every table reload, such as
a snapshot or a migration, as the reload creates a new target. So it
is a table argument, which userspace passes with every table it loads.
The table status gets a flags field like the one of dm-ploop: r for
report_enospc, s for an ENOSPC event not yet read by userspace, and o
when no flag is set.
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 | 11 ++++++-----
drivers/md/dm-qcow2-target.c | 25 ++++++++++++++++++++++---
drivers/md/dm-qcow2.h | 1 +
3 files changed, 29 insertions(+), 8 deletions(-)
diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c
index dfda7fe8bb8e..7a9d8a610a6e 100644
--- a/drivers/md/dm-qcow2-map.c
+++ b/drivers/md/dm-qcow2-map.c
@@ -4662,12 +4662,13 @@ static void qrq_endio(struct qcow2_target *tgt, struct qio *qio,
kvfree(qrq->bvec);
/*
* Here is exit point for rq, and here we handle ENOSPC.
- * 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.
+ * Unless report_enospc is set, 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.
*/
- if (unlikely(bi_status == BLK_STS_NOSPC) &&
+ if (unlikely(bi_status == BLK_STS_NOSPC) && !tgt->report_enospc &&
qcow2_try_delay_enospc(tgt, qrq, qio))
return;
diff --git a/drivers/md/dm-qcow2-target.c b/drivers/md/dm-qcow2-target.c
index f41fd1be4c00..46324ee35005 100644
--- a/drivers/md/dm-qcow2-target.c
+++ b/drivers/md/dm-qcow2-target.c
@@ -1024,6 +1024,17 @@ static int qcow2_ctr(struct dm_target *ti, unsigned int argc, char **argv)
tgt = alloc_qcow2_target(ti);
if (!tgt)
return -ENOMEM;
+
+ if (!strcmp(argv[0], "report_enospc")) {
+ tgt->report_enospc = true;
+ argc--;
+ argv++;
+ if (!argc) {
+ ti->error = "No image";
+ ret = -EINVAL;
+ goto err;
+ }
+ }
/*
* Userspace passes deltas in bottom, ..., top order,
* but we attach it vise versa: from top to bottom.
@@ -1139,6 +1150,7 @@ static void qcow2_status(struct dm_target *ti, status_type_t type,
{
struct qcow2_target *tgt = to_qcow2_target(ti);
struct QCowHeader *hdr;
+ char stat[4], *p = stat;
unsigned int sz = 0;
struct qcow2 *qcow2;
u8 ref_index;
@@ -1150,8 +1162,15 @@ static void qcow2_status(struct dm_target *ti, status_type_t type,
result[0] = '\0';
break;
case STATUSTYPE_TABLE:
- DMEMIT("%u v%u %llu", qcow2->img_id + 1, hdr->version,
- to_sector(qcow2->clu_size));
+ if (READ_ONCE(tgt->event_enospc))
+ *p++ = 's';
+ if (tgt->report_enospc)
+ *p++ = 'r';
+ if (p == stat)
+ *p++ = 'o';
+ *p = '\0';
+ DMEMIT("%u v%u %llu %s", qcow2->img_id + 1, hdr->version,
+ to_sector(qcow2->clu_size), stat);
break;
case STATUSTYPE_IMA:
result[0] = '\0';
@@ -1236,7 +1255,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 4acddbe7c95f..f0179b331097 100644
--- a/drivers/md/dm-qcow2.h
+++ b/drivers/md/dm-qcow2.h
@@ -209,6 +209,7 @@ struct qcow2_target {
bool md_writeback_error;
bool truncate_error;
bool event_enospc;
+ bool report_enospc;
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
next prev parent reply other threads:[~2026-11-27 11:17 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 11:15 [Devel] [PATCH hci-8.2 0/7] dm-qcow2, dm-ploop: report ENOSPC at once for vhost-blk disks Alexander Ivanov
2026-11-27 11:15 ` [Devel] [PATCH hci-8.2 1/7] dm-qcow2: always resubmit delayed ENOSPC requests in presuspend Alexander Ivanov
2026-11-27 11:15 ` [Devel] [PATCH hci-8.2 2/7] dm-qcow2: arm the ENOSPC timer only for the first delayed request Alexander Ivanov
2026-11-27 11:51 ` Konstantin Khorenko
2026-11-27 11:15 ` [Devel] [PATCH hci-8.2 3/7] dm-qcow2: drop the WARN on a read failing with ENOSPC Alexander Ivanov
2026-11-27 11:51 ` Konstantin Khorenko
2026-11-27 11:15 ` [Devel] [PATCH hci-8.2 4/7] dm-ploop: arm the ENOSPC timer only for the first delayed request Alexander Ivanov
2026-11-27 11:15 ` [Devel] [PATCH hci-8.2 5/7] dm-ploop: drop the WARN on a non-write request failing with ENOSPC Alexander Ivanov
2026-11-27 11:15 ` Alexander Ivanov [this message]
2026-11-27 11:51 ` [Devel] [PATCH hci-8.2 6/7] dm-qcow2: add the report_enospc table argument Konstantin Khorenko
2026-11-27 11:15 ` [Devel] [PATCH hci-8.2 7/7] dm-ploop: " Alexander Ivanov
2026-11-27 11:51 ` Konstantin Khorenko
2026-11-27 11:51 ` [Devel] [PATCH hci-8.2 0/7] dm-qcow2, dm-ploop: report ENOSPC at once for vhost-blk disks Konstantin Khorenko
2026-11-30 9:14 ` Alexander Ivanov
2026-11-30 16:27 ` 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=20261127111550.1151546-7-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox