[Devel] [PATCH hci-8.2 7/7] dm-ploop: add the report_enospc table argument

Alexander Ivanov alexander.ivanov at virtuozzo.com
Fri Nov 27 14:15:50 MSK 2026


A request failing with ENOSPC is delayed in dm-ploop 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. That needs the error to reach
vhost-blk.

With the optional 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, as the
reload creates a new target. So it is a table argument, which
userspace passes with every table it loads. The table status shows it
as the 'r' flag.

https://virtuozzo.atlassian.net/browse/VSTOR-152175
Feature: dm-ploop: ploop target driver
Signed-off-by: Alexander Ivanov <alexander.ivanov at virtuozzo.com>
---
 drivers/md/dm-ploop-map.c    | 10 ++++++----
 drivers/md/dm-ploop-target.c |  9 ++++++++-
 drivers/md/dm-ploop.h        |  1 +
 3 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index 131102da4c0a..66939a6f5d4b 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -214,12 +214,14 @@ static void ploop_prq_endio(struct pio *pio, void *prq_ptr,
 		css_put(prq->css);
 	/*
 	 * Here is exit point for rq, and here we handle ENOSPC.
-	 * Embedded pios 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 pios 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) &&
+	    !pio->ploop->report_enospc &&
 	    ploop_try_delay_enospc(prq, pio))
 		return;
 
diff --git a/drivers/md/dm-ploop-target.c b/drivers/md/dm-ploop-target.c
index aefb69e8a40b..872bf481281d 100644
--- a/drivers/md/dm-ploop-target.c
+++ b/drivers/md/dm-ploop-target.c
@@ -615,6 +615,11 @@ static int ploop_ctr(struct dm_target *ti, unsigned int argc, char **argv)
 			EAT_ARG(argc, argv);
 			continue;
 		}
+		if (strcmp(argv[0], "report_enospc") == 0) {
+			ploop->report_enospc = true;
+			EAT_ARG(argc, argv);
+			continue;
+		}
 #define PLOOP_MD_DELAY_ARG "metadata_delay="
 		if (strncmp(argv[0], PLOOP_MD_DELAY_ARG, sizeof(PLOOP_MD_DELAY_ARG) - 1) == 0) {
 			if (kstrtou64(argv[0] + sizeof(PLOOP_MD_DELAY_ARG) - 1, 10,
@@ -722,6 +727,8 @@ static void ploop_status(struct dm_target *ti, status_type_t type,
 			*p++ = 'n';
 		if (READ_ONCE(ploop->event_enospc))
 			*p++ = 's';
+		if (ploop->report_enospc)
+			*p++ = 'r';
 		if (p == stat)
 			*p++ = 'o';
 		if (ploop->skip_off)
@@ -812,7 +819,7 @@ ALLOW_ERROR_INJECTION(ploop_preresume, ERRNO);
 
 static struct target_type ploop_target = {
 	.name = "ploop",
-	.version = {1, 0, 0},
+	.version = {1, 1, 0},
 	.features = DM_TARGET_SINGLETON,
 	.module = THIS_MODULE,
 	.ctr = ploop_ctr,
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index 093b7f9397a4..fbfecf8139f5 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -266,6 +266,7 @@ struct ploop {
 	struct timer_list enospc_timer;
 	bool submit_enospc; /* timer expired run pios from dispatcher */
 	bool event_enospc;
+	bool report_enospc;
 
 	loff_t prealloc_size;
 	loff_t prealloc_in_progress;
-- 
2.53.0



More information about the Devel mailing list