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 18FE280EC8 for ; Wed, 28 Oct 2026 15:08:31 +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 69SF7JEV021159; Wed, 28 Oct 2026 18:07:19 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 69SF7JEV021159 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="UqWCJO7w" Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 69SF6rIx021071 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Wed, 28 Oct 2026 18:06:53 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 69SF6rIx021071 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-48e0c896d05so899177f8f.1 for ; Wed, 28 Oct 2026 08:06:53 -0700 (PDT) X-Forwarded-Encrypted: i=2; AKwUvBxOwdPwZF0FG4wmYd9Qxg6w3vpc2Y8Q/KJCsatQAH4B5gRtipokkN0MJpTuzgBR3CkCHbAQVg==@openvz.org X-Gm-Message-State: AFq9FYJhUfGxETJ4grD8wNN4C1wC/66t3GjBGrORoZjpW3mR7wHIlcpk by/Em62RbkP71ccnB/V0FPfkH3+L4baw2UlhHixbfczexoQfqRmX0gDC/gMbW9in1tWd4cYDbZ+ SRnU/WOjSY7GWmdnZjbYnfR/bpq7pW95f6IKu/O9V0eZEmRStwnxhDA== X-Gm-Gg: AYBFou1Q4tq+Mrj9ocvhHY3CBi9gq59zbSWs1Oq+j31PO1qf8Fn4tsS/ueJPyucnsgD 4nS+ZlxHF/0aYAB6ITUyqJaoBzirYCWOUdjr/OP92PWv0Um+Rd85Y1oF/IqE/r5ImfKUgkYseDV V9fywaJLPJ62HihPK0+zRvSgKrMfNZyQzOQfvH9Q1UaUoVZZgwx9d41c3TQ2EknPX0QJa7XD+NN ELrybpKYTwRNXzx3q2gYmWshAYhanNAJVnSFoDZrZ2PyjaKYPWjBosOE9XCJx0/FUYpFK6AY62+ uh0XLK6o8cEpBqi12A1WTskBruU36Jui0r4wwRTYc6uAfF2DLoS6AKrMEl/9SofNyXwIFI1elee aCc7nw1LytZQ/hVbtjpKadraw6RE= X-Received: by 2002:a05:6000:4a0a:b0:48d:fd53:828d with SMTP id ffacd0b85a97d-48e5d2f22c7mr6912938f8f.30.1793200013180; Wed, 28 Oct 2026 08:06:53 -0700 (PDT) X-Received: by 2002:a05:6000:4a0a:b0:48d:fd53:828d with SMTP id ffacd0b85a97d-48e5d2f22c7mr6912841f8f.30.1793200012473; Wed, 28 Oct 2026 08:06:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1793200012; cv=none; d=google.com; s=arc-20260327; b=VE9XFEvXy82LNClLhwfDPZtLvEYPErc+dU/O/0ZK0uWIBwIQF0PskZxiTwE0tKg9k6 s/FgeqgRu0VJLbuMlptjnswyzl6QAvn6+SQ1VIbr6AFi0sJhAYnOI3auQNp3pNQyfSgs RcB2A9uDWMW0KGy/dTC0BpQnDpLXcuw421R5efTDEEgeAidoifYQbVkCACRhJAEbp6Uz sedFwApIitWr2amW0fLelkN1AatEFou8L7E5FBMmHBCjlY+t//DWmuR1I+zBEHeOFm4S 1q6t/sZRVdXlWunn5lJIYxH5mfi+ZCY9TFumdANjQdpl/xdMAE3hbXx8tDufr50LQUXj QrQQ== 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=+T4Q838G798iiAX/UFk6pt7LQTfGKdV2covnF1LRVmQ=; fh=CMILZ+goaghq6B4UpCDhf0EQp6kYD0LAlmOkUiVCOvs=; b=amjDL9namKZ10XHoxAKWe6i2kL991empolOQbtm6ZCTOjO7JD31gBNW6c7NwrfwZwC LNsUowGQ8pUMlszrdjHpOkw/RzCtMJdv04Y5mZ6Szv3QJ4NDsQGbFuBYpA7QRvjM9+Fp Y+Mzkx9J+J+9C8NVxq7WrQnKvR0KkplWNZ7aT8vk9Io5Wmmj/4Z4xV2Bg7A33fGrnonb 4h30tSS3yAICmSvPM3ndG47+eg34M6C8f9GZpTaGq/2uWnSVwkP0MqZP0IPCgh8wFdpa LRPR5e2jPyQLzhCC67B7484Bjhp4Z90cOJSbXhKgYTmoWOYt1RNJ1lAu1JZdmF79z/5k OKFA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=UqWCJO7w; 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-48e3ed2c5d1si34820683f8f.468.2026.10.28.08.06.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2026 08:06:52 -0700 (PDT) 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=UqWCJO7w; 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=+T4Q838G798iiAX/UFk6pt7LQTfGKdV2covnF1LRVmQ=; b=UqWCJO7wcqox /eKCYYzZ/atJ4SDrcDbGoGP142+vMzt3ooxUSlmwV0PdGNeJhgUGs6+MV5chvVKVXJ16ijBdztQ/c 2QPHuXa/IOcOg9WSzOSzstaeixD21odk1FfOtP9/I8pemxu38OyeBWhIqJCIRXH7v6bE+MVd8B7z1 vd24KN0C/yeZj710QBvoXlLcWokKlQmIAuPAlZzFxPjLijrJ1dIojhIVI86wPb3QWfw8J1H4pNvFD CZROlkIvtfSxnZh5OvuecyD8Ssxjq1OLqRppgDne18VmcCnmEikzrz0UaKz1dURGhS4pk3iRSJuD8 HyD1rTrzUBBuLeJNGIsMKg==; 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 1xM5B3-00AtLl-2l; Wed, 28 Oct 2026 16:06:51 +0100 From: Alexander Ivanov To: andrey.zhadchenko@virtuozzo.com Date: Wed, 28 Oct 2026 16:06:42 +0100 Message-ID: <20261028150645.3222391-8-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261028150645.3222391-1-alexander.ivanov@virtuozzo.com> References: <20261028150645.3222391-1-alexander.ivanov@virtuozzo.com> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.1 v9 07/10] dm-qcow2: fix md page cleanup on failed reftable relocation 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 relocate_refcount_table() inserts an md page for every page of the new reftable tail and of the new refblocks, starting at pos + old_clus * clu_size, but its error path erases only one page per cluster starting at end. The remaining pages stay in qcow2->md_pages. Since a failed relocation leaves the header and reftable_max_file_size unchanged, the next relocation picks the same pos, gets -EEXIST from md_page_try_insert() and fails with -EIO. So a single -ENOMEM or header write error makes every later relocation fail until the target is reloaded. Erase every page the allocation loop inserted. Failures after the in-memory header is switched to the new reftable also jumped there. At that point the new pages back the live reftable and may be dirty and linked in slow_wb_batch_list, so freeing them leaves writeback with freed pages. Just return -EIO on these paths, as freeing with the fixed range would also free the dirty reftable tail. https://virtuozzo.atlassian.net/browse/VSTOR-148171 Feature: dm-qcow2: block device over QCOW2 files driver Signed-off-by: Alexander Ivanov --- drivers/md/dm-qcow2-map.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c index fa63bd6acfb8..f6e66799bf27 100644 --- a/drivers/md/dm-qcow2-map.c +++ b/drivers/md/dm-qcow2-map.c @@ -2372,21 +2372,21 @@ 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_free_r2_pages */ + break; } spin_unlock_irq(&qcow2->md_pages_lock); if (i != nr_pages) - goto err_free_r2_pages; + return -EIO; /* Connect new R2 to new R1 */ for (i = end; i < r2_end; i += clu_size) { if (calc_refcounters_map(qcow2, i, &r1, &r2) < 0) { WARN_ON_ONCE(1); - goto err_free_r2_pages; + return -EIO; } ret = handle_md_page(qcow2, r1.page_id, NULL, &md); if (WARN_ON_ONCE(ret <= 0)) - goto err_free_r2_pages; + return -EIO; spin_lock_irq(&qcow2->md_pages_lock); set_u64_to_be_page(md->page, r1.index_in_page, i); qcow2_md_make_dirty(qcow2, md, true); @@ -2397,7 +2397,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_free_r2_pages; + return -EIO; mark_cluster_used(qcow2, r2.md, r2.index_in_page); } @@ -2405,14 +2405,15 @@ 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_free_r2_pages; + return -EIO; mark_cluster_unused(qcow2, r2.md, r2.index_in_page, i); } return 1; err_free_r2_pages: - for (i = end; i < r2_end; i += clu_size) { + while (i > pos + (u64)old_clus * clu_size) { + i -= PAGE_SIZE; ret = handle_md_page(qcow2, i >> PAGE_SHIFT, NULL, &md); if (ret <= 0) break; -- 2.53.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel