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 521AE80E7E for ; Tue, 3 Nov 2026 08:38:30 +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 6A38bGFt002637; Tue, 3 Nov 2026 11:37:17 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A38bGFt002637 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=default; t=1793695039; bh=kKDByZnGeAYcynvWxgqgn/i9j11/PwtQF0/gQxeFSDE=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe; b=riLiLHH3JS19XcZTW+ZknkAFBYgbQJkQ4GqeL4BLmfXvLXCUZVslcd+smdCuSeMWv ET/YRwBJcuCdH+dTbvfUt176u+0y05uvR7TmGts3ww5YharB1M+gxsKL34KxbGKwFc OOhQLhnEhKUlPwbFNrzkpl8C2IsCU8HwCQruSiXKaIcK5QcJKiDRUgGwAIKenXIbxc 5wQWFrifUgewiTBNGxlObAEGJHUhBlP3yhGpWHKwjxi7TOkSiXssuMkU8J16eggEXz WYr7r5L67jPhm2b+yJU/i92KmMncx83DoFQiU7gAZwtRvWU+3Ll+UGGI7rScUlplp2 OZY4N4rFOIVZg== Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6A38bCAM002618 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Tue, 3 Nov 2026 11:37:12 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A38bCAM002618 Authentication-Results: mail.openvz.org; dkim=pass (2048-bit key) header.d=openvz.org header.i=@openvz.org header.b="kd2vbGiL" Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4a211bff50bso26877075e9.2 for ; Tue, 03 Nov 2026 00:37:12 -0800 (PST) X-Forwarded-Encrypted: i=2; AKwUvBwoqgzsKhsgp0CZXTXmVAe3WkiFhSVkzHbhjpO0SZlhIxSVEFIWgKIMCoFdU/S8x6kz5Z9wig==@openvz.org X-Gm-Message-State: APuU4Z/jSphygzDcqQZi7YfkJfr9GJGvHOmJsjQe3pvUbLIQl7p8JeXD r3Y18qNXNtwpnzGVuhk9gq6wBXj4cplJkEWyTkXI0PL1/lLz+4ox3JcUWgwiSWaHv8VWRadfYti WIxV/BMV4qiAfCb3AQ3mJnYg3QXXIV1gk4/XZt9nwvnB/0VvRO3B3Vw== X-Gm-Gg: AYBFou1gp6xNpwTUAwuy7bhrXL0R1ez/MMtJ7LgCu1/bAJvA64uyK+CgQkcJkjWR7lZ +gUt1h1Mud/IrkOqDCUQ875xtYUf+eMikqbTDkpT1qCEJMj/vf11vq8LdRwR06NG+Lr7tJR0MSL QbSYeaem3J2s6gEBKTntd9ZFCIv8HwCm3Dkl1VnVDXY3kBLJKqRGva0DmJgb6P4o4Az3AdlSn2e RdwJB36FdHuRHIFwGMtyaiYQxVXleCo+ht/g3FDZzV9KnQ4174X3UMeiubSIxuJCwUbtuSEkEl3 Sbb/IeUczA== X-Received: by 2002:a05:600c:8b6a:b0:4a1:f720:74cd with SMTP id 5b1f17b1804b1-4ac18c73d01mr274090385e9.24.1793695032397; Tue, 03 Nov 2026 00:37:12 -0800 (PST) X-Received: by 2002:a05:600c:8b6a:b0:4a1:f720:74cd with SMTP id 5b1f17b1804b1-4ac18c73d01mr274089965e9.24.1793695031897; Tue, 03 Nov 2026 00:37:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1793695031; cv=none; d=google.com; s=arc-20260327; b=DcjkkEs09pr2W/Bvjuo0SB0xIOdTNaybg9HHLazgW7Bz4tDWY+TA2Yl+WsutbWpnUO UDI47lyTaYli7ShV0UesAN8CabfCblrI8mxDZke9SAgEnCrE67f4ls5Z4tUq+o56fgVr qmt5SD7/BDX7pzC2aAyqGHf+IzpH/awTCHBrCRSHLbbl0FgFZKbzxbc/6ZGgpyIta1GA S1OWtkhzB5wUqpN6x6XEm1XMvjrfaRtkKDcGvlV8kYC0yhIjYHKoGnLy4aIqTyIeKoHp wvqG7Ov2YrgjTLo3cPAQ67XGl13Qvm1RvLXC0A5ZZy0phOVNRLq9OKoxuDqHQhSARlhz nsZw== 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=nx04fzJZ7Lxl/22pKYq2YgkW47zmfLa75fcN1ygTKpA=; fh=pVdH0/nmN1ogQ6mGoand6Pvaxe0VZoE6BulVE3WGKko=; b=qmLSCKpp6arD5xuQxjraQc59f6wfReiAMXTrRHtFOpjTaPaCRo0AEBtoT99qBrHOc0 HVJ8n4BIvJIzQG6UI4uWoyezXjGiZx96A8oRln/Ls/gZBaDsHdDtanKGPTjMG4/U0XPp dgHzhCRiI/sk+owoUFZlJ6tpfwid/x4j1Q3e8Xbeq1l0JpoH4yNu/Bswrpi33cph7E8N 8e/w6azNEhiJOuDZ8EggnMqVKf0Ynoul4E1p5ktlHNXlcsAlrNpLn42AHqcjuVNnwUhZ tzSGVkghczNNqcywogG6Z9f7Qpv93/xO92orvOOYsai6OHxYkdc2U6yTzxa1XVJtlIqi 7cYA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz.org header.s=google header.b=kd2vbGiL; spf=softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:c789:8bc5:fa8e:d502 as permitted sender) smtp.mailfrom=den@openvz.org; dara=neutral header.i=@openvz.org Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id ffacd0b85a97d-48e8a2acc1csor356421f8f.16.2026.11.03.00.37.11 for (Google Transport Security); Tue, 03 Nov 2026 00:37:11 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:c789:8bc5:fa8e:d502 as permitted sender) client-ip=2a06:5b06:b600:300:c789:8bc5:fa8e:d502; Authentication-Results: mx.google.com; dkim=pass header.i=@openvz.org header.s=google header.b=kd2vbGiL; spf=softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:c789:8bc5:fa8e:d502 as permitted sender) smtp.mailfrom=den@openvz.org; dara=neutral header.i=@openvz.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1793695031; x=1794299831; darn=openvz.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=nx04fzJZ7Lxl/22pKYq2YgkW47zmfLa75fcN1ygTKpA=; b=kd2vbGiLAPxHx5NigPZCMR5LPD49+2eqH2CoxQwj/dsNQjGaxl6fOUUc/himezhkYO aKavD1Ic5PY1GE81xhRYsMD9i81a+yw/Ms9wMK8tBlCxv37IpahL9Av72l2iiBHXd38F Tq9qKP3PRegeUx8HWSv5BV5USu5jvnPIjUaBcOzxjKiaG/zRtfsijeWPluib1OUxkHeD tDC71VHwaoIW+w3qafjRUpxLVr7zGruBKz0zXDJi26wzricOXmAjmQaNSebAs6DL9BMg 9VwDGRRn3mqj8SDWPPNJft28cJeT9xiaq5xeECBthkaeYKnyXMJWemHIqS3yh3GhYk1u ZOpg== X-Forwarded-Encrypted: i=1; AKwUvBweFLbpD2JWkFMJq35lx5HlQs+eWbMksxaNhyNB2/Q/F/d5uwwh1KBPdiD05o7KmQP2DT1LYA==@openvz.org X-Received: by 2002:a05:6000:250c:b0:48e:1299:c00f with SMTP id ffacd0b85a97d-48e6e2db606mr28302232f8f.3.1793695031405; Tue, 03 Nov 2026 00:37:11 -0800 (PST) Received: from athena.sw.ru ([2a06:5b06:b600:300:c789:8bc5:fa8e:d502]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e71b9b54dsm23304588f8f.47.2026.11.03.00.37.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2026 00:37:11 -0800 (PST) From: "Denis V. Lunev" To: andrey.zhadchenko@virtuozzo.com Date: Tue, 3 Nov 2026 09:37:06 +0100 Message-ID: <20261103083708.131379-2-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261103083708.131379-1-den@openvz.org> References: <20261103083708.131379-1-den@openvz.org> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.1 1/3] dm-qcow2: fix a failed refcount table relocation leaking md pages 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 From: Denis V. Lunev relocate_refcount_table() inserts md pages for the last cluster of the new reftable and for the new refblocks, one page at a time from pos + old_clus * clu_size up to r2_end. On error it frees pages from end only, one per cluster, so the pages of the new reftable cluster and all but the first page of each refblock cluster bigger than a page stay in md_pages. The header is rolled back, so the next allocation past the old refcount coverage relocates the table again. Its first insert finds a leaked page and fails with -EEXIST, the relocation returns -EIO, and every allocating write beyond the old coverage fails with an I/O error until the device is suspended and resumed or the table is reloaded. A failed page allocation or a failed header write is enough to get there. Free exactly the pages the allocation loop inserted. Fixes: 222b6f1291c1 ("dm-qcow2: Introduce driver to create block devices over QCOW2 files") https://virtuozzo.atlassian.net/browse/VSTOR-153051 Feature: dm-qcow2: block device over QCOW2 files driver Signed-off-by: Denis V. Lunev --- drivers/md/dm-qcow2-map.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c index 78ee7cf5e881..8ab7cb472560 100644 --- a/drivers/md/dm-qcow2-map.c +++ b/drivers/md/dm-qcow2-map.c @@ -2279,6 +2279,7 @@ static void set_reftable_in_raw_hdr(struct page *page0, loff_t pos, loff_t clus) static int relocate_refcount_table(struct qcow2 *qcow2, struct qio **qio) { loff_t i, old_pos, old_end, pos, end, r2_end, delta; + loff_t new_md_start, new_md_end; u32 old_clus, clus, clu_size = qcow2->clu_size; u32 r2_clus, bits = qcow2->refblock_bits; unsigned long nr_pages, index; @@ -2342,8 +2343,9 @@ static int relocate_refcount_table(struct qcow2 *qcow2, struct qio **qio) return ret; /* Alloc R1/R2 pages covering clusters of new R1 and new R2 */ - for (i = pos + (u64)old_clus * clu_size; i < r2_end; i += PAGE_SIZE) { - ret = qcow2_alloc_and_insert_md_page(qcow2, i >> PAGE_SHIFT, &md); + new_md_start = pos + (u64)old_clus * clu_size; + for (new_md_end = new_md_start; new_md_end < r2_end; new_md_end += PAGE_SIZE) { + ret = qcow2_alloc_and_insert_md_page(qcow2, new_md_end >> PAGE_SHIFT, &md); if (ret < 0) goto err_free_r2_pages; spin_lock_irq(&qcow2->md_pages_lock); @@ -2419,7 +2421,7 @@ static int relocate_refcount_table(struct qcow2 *qcow2, struct qio **qio) return 1; err_free_r2_pages: - for (i = end; i < r2_end; i += clu_size) { + for (i = new_md_start; i < new_md_end; 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