From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (mail.openvz.org [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id 2B3058017D for ; Mon, 16 Nov 2026 15:43:09 +0000 (UTC) Received: from mail.openvz.org (localhost [127.0.0.1]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6AGFfvdo027433; Mon, 16 Nov 2026 18:41:57 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AGFfvdo027433 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="B6VtkqDg" Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6AGFfRKD027356 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Mon, 16 Nov 2026 18:41:27 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AGFfRKD027356 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-c50e035a2d5so109458166b.3 for ; Mon, 16 Nov 2026 07:41:27 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErEo9jlK+hO4j1R3zpu1FZO6rosSuO9qXVvnPs58oD7S6M+8vZO+hMPzXamplXQH48V/hnLmxA==@openvz.org X-Gm-Message-State: APuU4Z+Tf654QlLaG6lQtXI1Xqus6qNQ1d5wk/SDgkLGtrKK4gxcyEyS scxmNj7lI7N8RBfJbwS7XzO0C+w+njH/5Gnh/XbGV9dVhFUHV3jhDFkjEbxlB6JiEvVuIjDGvQD NcfQmvMHZR8K/kEZSsIdURwt2bu9Nt07RjAF++HWm5Q0+Tiv44IzEsA== X-Gm-Gg: AYBFou370qlz3ZrcA92pisACPPkHtVCg7pr06aywaXA3Y63kPllddphYSKfkNg8/dof tkckztwYuy6p4hdjY3dpX+t5ZbvHT9IUznXcTH7bpnTAIguymH5x0ZskJGttglpwe/4LbxCf6WI eEXnU/AkfoD25GDrHW8NJLrmaYsDg3FCJpJpIt5ZylRQy5MtDpdpHi1bh98ynk+w1ywxkCm5pZ5 g12XqeY3aJqhrGzIJ+AkMjdLZCD/6cZvLn1d9W1o2CKNkaz9UL+cfX8vu2cQePY40guLznKbooa wY38xTDfue+t14swFlolv9f3fdWorL1xcxchild2Spd1i3vzAklCNshcvPKEFggdXMls1qYfbXP nrtGq9eNGEmhUt2PNRdAraX4wjeA= X-Received: by 2002:a17:907:ea8d:b0:c50:8d2b:4391 with SMTP id a640c23a62f3a-c50963d4702mr833829866b.37.1794843686770; Mon, 16 Nov 2026 07:41:26 -0800 (PST) X-Received: by 2002:a17:907:ea8d:b0:c50:8d2b:4391 with SMTP id a640c23a62f3a-c50963d4702mr833825966b.37.1794843686047; Mon, 16 Nov 2026 07:41:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1794843686; cv=none; d=google.com; s=arc-20260327; b=T3rAXruaAMF4b99CLcVHnD+nHbAI87VqSj/IyIAvEh15ZUM8BrydZUxNvgc7djFzy3 xIr0kcLCd1kK1txW/B+rjyplUppkGKfcYhuimKDkvfGPFHXB3Sb/l4+pQIUIcdTtUH6R ZpFtjeuXVzLH0oeBvG81c5hAmNGuvavnhTAKEA2ZNqfWanpL6D8bTLr2qLkvGU4X574V rV4ol7bVrlV5Xp/tiU3Pfw/okzfXqh8/YbUNEku/k6E1SkrKj2LWGLFmdSHmKWe4Q5Z1 +j+zPGn8ZDOL4RPk3G7vj+OvMsgRYnMroncL7QC5RYO7kV2zHi+ZrueON0lNGP9FgU/v 88+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=QWRYmH6Y+HS01zETuyVnZM3LE1+S8o164kwM6BKqr6Q=; fh=CMILZ+goaghq6B4UpCDhf0EQp6kYD0LAlmOkUiVCOvs=; b=NCbujo6hiSP9Ojf7MaMluQb4s85zYe0wU21Xsa2WUASPEgFNpFn7n1xKSmoQhyZFKn xAphprsAnPQtuQSFW9PG5ZSmuYjNUXCLa2myfIsdq53ZErMCAKA32jPyrVRcIPpWIWe3 0COvTlerJ0UtVXIHTI47Tq5PkAIv1M9V3j6NAji89uL2VaBQZkvXprdCO695zgYQrMex h5IEwcNmSzXoCBY3+Ej/MIK0ajRbsx1VEXricHuL/h2BnLo8f+c/8m07drv82MGcMVhZ R25rZTjVSx7glojpFR4pj1kbZ6OFqkKDXoVD5w1iqFYwiOD5LU0FhV0Gz2wH3NqaS7Vo ASCA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=B6VtkqDg; spf=pass (google.com: domain of alexander.ivanov@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=alexander.ivanov@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: from relay.virtuozzo.com (relay.virtuozzo.com. [130.117.225.111]) by mx.google.com with ESMTPS id ffacd0b85a97d-49c63123076si22858681f8f.131.2026.11.16.07.41.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Nov 2026 07:41:26 -0800 (PST) Received-SPF: pass (google.com: domain of alexander.ivanov@virtuozzo.com designates 130.117.225.111 as permitted sender) client-ip=130.117.225.111; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=B6VtkqDg; spf=pass (google.com: domain of alexander.ivanov@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=alexander.ivanov@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-ID:Date:Subject:From: Content-Type; bh=QWRYmH6Y+HS01zETuyVnZM3LE1+S8o164kwM6BKqr6Q=; b=B6VtkqDgQyv+ 5mc/38Zd7Bw9RGaokQa0+FgsBoowFY5os98OSCTZlVxCKejj9LRwE8A2TCPxI9AP+2JRKk/XoJtXl G36pJp8dkKriweL6afOfjnSTF0VDbPDIjTg70ZB4AS4a+CYVNy0MFfPyxXR4ES+KZtELdDvimiLBi 8ZcSobIXm1CG7fcCFuQKIrb/cb0FYafo9jnewZB5bU7ZQSHVkBKE3eJCxI0YXLzKS0XXNTvqGy8wG XD2YxEbOH/ZNvBGn3JYJuihcjtvYl6eMXqT++8HsFvUviI1bwZplhho97LqbhmKsXSNUMcTwu/kHt CgGxyrbg1XbawSaFuSHiNw==; Received: from ch-vpn.virtuozzo.com ([130.117.225.6] helo=sky) by relay.virtuozzo.com with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1xSylS-005tLh-1o; Mon, 16 Nov 2026 16:41:17 +0100 From: Alexander Ivanov To: andrey.zhadchenko@virtuozzo.com Date: Mon, 16 Nov 2026 16:41:17 +0100 Message-ID: <20261116154119.2979718-8-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261116154119.2979718-1-alexander.ivanov@virtuozzo.com> References: <20261116154119.2979718-1-alexander.ivanov@virtuozzo.com> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.1 7/9] drivers/md/dm-qcow2: add the error_policy table argument X-BeenThere: devel@openvz.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: OpenVZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: devel-bounces@openvz.org Errors-To: devel-bounces@openvz.org 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=, 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, whatever the error. 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 --- 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