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 682A781377 for ; Mon, 9 Nov 2026 12:00:42 +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 6A9BxUHn031398; Mon, 9 Nov 2026 14:59:31 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A9BxUHn031398 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="qUq06JWt" Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6A9Bx3uu031326 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Mon, 9 Nov 2026 14:59:03 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A9Bx3uu031326 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4a16dc2323cso6266895e9.3 for ; Mon, 09 Nov 2026 03:59:03 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErFR28FL6Wp4CBBHBL11mRutH/gL3n7m+4qBnRe2cK7b2pj6uXS7IC1uLkn0Ye8K+JJpxajwDg==@openvz.org X-Gm-Message-State: APuU4Z+UAESbY5D0GWcplkxm2yMdWxPnvld8f6SwO1DgSKimcc6DxmNU wLThZuTV0Tj2wkg5waKxZ3Mi/T3QApNK3PsUc9Dlswpx7PFmsfL6Vuf0zcCLD/1FNjDWywSaN/x ZU+Irk7h0NIerNUJNgaJaGkBuIKPQ0od0dbt4HK5XmTURUoQKlWMmHg== X-Gm-Gg: AYBFou2khY6gaEilXKkK299Mh73ZmyDfLOXQIVBO41Nm10UPA1/cBWBFxqhxQyLKS76 rpcHUfKudrt2ke/U5Mp1hVE3VhXmA3QuNKATtmwOanjpoiy7iuDEQu7mxQYZWhi9QPQ9NqjeP8S ctihClxpiAspA35FEI5GKGv07dyjfmBfJFiJ0Ujx9eAUvIu5ED2txqA4+IYGv8vEWohgH6bZoeL IF4S2htdrCsvlbJ4pnDbKGRXYeCcfl3yLlk9HFsxwXZJp/4DZZ3oxe3736Kx9ZBRLUzPE4+3VkM lOcOi3gfiJU9tK9eAxMC+Ld2bWXE3kxpGpco8eqQz7Y2bLLlKJEC3bSZCWNhfBw0oosLVYfK0LD uiMXzZN/5UW2lCaDq+dx3qoFws+oK X-Received: by 2002:a05:600c:3f1a:b0:4a1:c6fd:4db0 with SMTP id 5b1f17b1804b1-4b963c87ffdmr70628155e9.19.1794225543468; Mon, 09 Nov 2026 03:59:03 -0800 (PST) X-Received: by 2002:a05:600c:3f1a:b0:4a1:c6fd:4db0 with SMTP id 5b1f17b1804b1-4b963c87ffdmr70627825e9.19.1794225542983; Mon, 09 Nov 2026 03:59:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1794225542; cv=none; d=google.com; s=arc-20260327; b=hafOue3UsU/yD4RWZVU2C892wMDKYIrDQPnB+UhlOXPaRjO3yMVO/z3czFcHCveYps CpeIbpjb6S7SOTVj6RRTu3kruNFxwv1j/ihb/j5Yb3iykg8S9LgGvf9Mm4Xtsz/C1J7E S6WFAXUMsuGJnbfaBPJuNrq3zYTnpRU0PkaWWh2hl8+33WqM7kkFxm7QqfzQvlfQgb99 J82ig5r9YO+Q8qLeCCeH8n6gzFJ7xTe519623trC1WSN4Sogg1edXoOMvtOjN/D6YL7/ 4JCOl6vXLs3pIjTRM8L1HVNixMUIVBI79VwLHM3Qv7yh4QTR7+0cAociFAkL4pexyywA KBmQ== 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=fPXUGDjAhma9ggfBwm4SVxRmK9aiBbths14xheEbLyY=; fh=CMILZ+goaghq6B4UpCDhf0EQp6kYD0LAlmOkUiVCOvs=; b=UNmSwmQUG5RjoClWd+YaRfAJTb347BLHRwj1Ze0KbZP7b6LLhluCQpuE3WojAprC2I u8I5j9iz4pcGaxXs6jGFWi3WG8cW7bjxz/vBqxExKuenQTMFyUuBkvpbxaNvxNyydyZJ qYU5/3pH43X0G+VO20OFnkoBePjrdbP/lCtaWjoC+WMpUXXrXAN90H6tS/nGTjrcfiGh TqKuXME1EmKBRbMahIH/H/pMBglMoLk7g2xAGppQH/mx3yaH+GSKw7gBo6L0YrAo1hTi PNoT3j9Q8HX/uYToCPNqZx3yYC+Chv8Vouyz9BUys04/Ue5cQduJZKOwuLFj6ubwAyNz 59qg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=qUq06JWt; 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-49597652c2asi8681875f8f.194.2026.11.09.03.59.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2026 03:59:02 -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=qUq06JWt; 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=fPXUGDjAhma9ggfBwm4SVxRmK9aiBbths14xheEbLyY=; b=qUq06JWtnIJd JS42KvNN3i15Zg5rN30t7JqryRJMbMwvRASG9w9/ZYdwJ8msDFRUmYtQcsZgmL7EXXjb62Ze2S0ge QSpR/Kt4oComeWsyoaYz5U20V2DIolOgVBNevA6smvq4GUZ1LwFKMxqjpqj3KuPXDw15RRnwzm18H ty/WDg3qMH9RmwwjzLQ6bzo3Ze6GWHMqsRCPLND9tuoROADIG4czKSrusFF7gYeGTkkO0uSXUH5Yl JK54uA0yBANXJH30pNhaZbukPY4Jdni09fy8uoyWxbd6/zQ1Xg0fkk27oechMwwDzqzxE5NhUW/od sZwbEX6tEqAQJqpOkvwO3w==; 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 1xQNxa-003a4R-1T; Mon, 09 Nov 2026 12:58:54 +0100 From: Alexander Ivanov To: andrey.zhadchenko@virtuozzo.com Date: Mon, 9 Nov 2026 12:58:53 +0100 Message-ID: <20261109115856.1362416-8-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261109115856.1362416-1-alexander.ivanov@virtuozzo.com> References: <20261109115856.1362416-1-alexander.ivanov@virtuozzo.com> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.1 v10 07/10] dm-qcow2: flag the image for check if reftable relocation fails late 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 Once relocate_refcount_table() has issued the header write pointing to the new reftable, any failure returns -EIO. The header on disk may already point to the new reftable even if its own write fails: a short write is reported as -ENODATA, and the old reftable position is restored only in the cached header page, which a v2 image never rewrites on suspend. The new reftable on disk may then be unfilled or miss the new refblocks, while refcounts of the new and old reftable clusters may not be updated. Refcounts no longer match the header, but nothing reports that, so the device can be resumed and the image reopened as if it were consistent. Set md_writeback_error on these paths, so wants_check reports the image and resume is refused until it is checked, and log the failure. https://virtuozzo.atlassian.net/browse/VSTOR-148171 Feature: dm-qcow2: block device over QCOW2 files driver Fixes: 222b6f1291c1c ("dm-qcow2: Introduce driver to create block devices over QCOW2 files") Signed-off-by: Alexander Ivanov --- drivers/md/dm-qcow2-map.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c index 7866c791325b..cd46a99f81a7 100644 --- a/drivers/md/dm-qcow2-map.c +++ b/drivers/md/dm-qcow2-map.c @@ -2351,6 +2351,10 @@ static int relocate_refcount_table(struct qcow2 *qcow2, struct qio **qio) if (ret) { /* Restore old R1 */ set_reftable_in_raw_hdr(md0->page, old_pos, old_clus); + QC_ERR(qcow2->tgt->ti, + "failed to write header with relocated refcount table: %d", + ret); + qcow2->tgt->md_writeback_error = true; goto err_free_r2_pages; } @@ -2372,24 +2376,25 @@ static int relocate_refcount_table(struct qcow2 *qcow2, struct qio **qio) if (!WARN_ON_ONCE(!md)) qcow2_md_make_dirty(qcow2, md, true); if (!md) - break; /* goto err_eio */ + break; } spin_unlock_irq(&qcow2->md_pages_lock); - if (i != nr_pages) - goto err_eio; + if (i != nr_pages) { + ret = -ENOENT; + goto err_hdr_written; + } /* Connect new R2 to new R1: one for each group new R1 and R2 span */ group_size = (u64)qcow2->refblock_entries * clu_size; for (i = pos, r2_pos = end; i < r2_end; i += group_size, r2_pos += clu_size) { if (WARN_ON_ONCE(r2_pos >= r2_end)) - goto err_eio; - if (calc_refcounters_map(qcow2, i, &r1, &r2) < 0) { - WARN_ON_ONCE(1); - goto err_eio; - } + goto err_hdr_written; + ret = calc_refcounters_map(qcow2, i, &r1, &r2); + if (WARN_ON_ONCE(ret < 0)) + goto err_hdr_written; ret = handle_md_page(qcow2, r1.page_id, NULL, &md); if (WARN_ON_ONCE(ret <= 0)) - goto err_eio; + goto err_hdr_written; spin_lock_irq(&qcow2->md_pages_lock); set_u64_to_be_page(md->page, r1.index_in_page, r2_pos); qcow2_md_make_dirty(qcow2, md, true); @@ -2400,7 +2405,7 @@ static int relocate_refcount_table(struct qcow2 *qcow2, struct qio **qio) for (i = pos; i < r2_end; i += clu_size) { ret = qcow2_handle_r1r2_maps(qcow2, i, NULL, &r1, &r2, false); if (WARN_ON_ONCE(ret <= 0)) - goto err_eio; + goto err_hdr_written; mark_cluster_used(qcow2, r2.md, r2.index_in_page); } @@ -2408,12 +2413,18 @@ static int relocate_refcount_table(struct qcow2 *qcow2, struct qio **qio) for (i = old_pos; i < old_end; i += clu_size) { ret = qcow2_handle_r1r2_maps(qcow2, i, NULL, &r1, &r2, false); if (WARN_ON_ONCE(ret <= 0)) - goto err_eio; + goto err_hdr_written; mark_cluster_unused(qcow2, r2.md, r2.index_in_page, i); } return 1; +err_hdr_written: + /* 0: md page is not cached */ + QC_ERR(qcow2->tgt->ti, "failed to fill relocated refcount table: %d", + ret ?: -ENOENT); + qcow2->tgt->md_writeback_error = true; + return -EIO; err_free_r2_pages: for (i = new_md_start; i < new_md_end; i += PAGE_SIZE) { ret = handle_md_page(qcow2, i >> PAGE_SHIFT, NULL, &md); @@ -2424,7 +2435,6 @@ static int relocate_refcount_table(struct qcow2 *qcow2, struct qio **qio) spin_unlock_irq(&qcow2->md_pages_lock); qcow2_free_md_page(md); } -err_eio: /* TODO: switch to RO */ return -EIO; } -- 2.53.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel