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 505FF811BB for ; Wed, 4 Nov 2026 18:50:38 +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 6A4InN89026078; Wed, 4 Nov 2026 21:49:24 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A4InN89026078 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=default; t=1793818165; bh=d/4fKBFCMEQgry0aS7rNe+CJTFxmQsU8kegN6/lVSPA=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe; b=LW9GeMomtRcn78+Ddzgg9nKL9wqjZ+ql/M5a6gSpW6qDqGQfwVogwJ67T35m8a/bQ YNl5AlcLNamlTuX0dtu0jdBlViQ3izXd4sito8Ck514WvKGXNqALgiOT7I6K4u65tS I5jQ3P7jYmF52wcBs7u4rmgfQdDGixJ2R/aLda7oFPO9+WEIfmnRcOxliSCBGNjAPU iCx7NSTy472U81xrHdmsyUMhqOys9t3cs4QufX6Lm9Kvd+8IYSS32rqjXFZK8FlSCT EPIPygCViXWvqRtRp/NlPw2RkL4oRB8rGURo5GK3dcHF/SKb+Py8js6ZvMoyPaxGNR Ln3szvvPvA22Q== Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6A4InLPs026074 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Wed, 4 Nov 2026 21:49:21 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A4InLPs026074 Authentication-Results: mail.openvz.org; dkim=pass (2048-bit key) header.d=openvz.org header.i=@openvz.org header.b="U8dBJHeb" Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-c40bbd26f74so114087366b.0 for ; Wed, 04 Nov 2026 10:49:21 -0800 (PST) X-Forwarded-Encrypted: i=2; AKwUvBytoOTXpBT9BT/kOW32am7o6mvlPTykUUORJE5cL3RjyPwoKkSAjE2FIN09e/sMLS726z3jxA==@openvz.org X-Gm-Message-State: APuU4Z85NDt3m894YpEkRzCkfh9Oav/rceBzREIm6dvqVa8DchVXb2Hq OVCUlSwoi2EmNDIpPk1Yd0RpanY7LkXBklRc37xfq1fqAKnDJNIiNl6jb4fQj7Bv6XINflsJedq PiOZergdgWSG0gR+BnNiFhEuW/jvjVTm0DgzSvhNKQHcvQRQMVLHd2g== X-Gm-Gg: AYBFou133sAKnJKJmfArmM0NrdW5VlWwdu4u1S4bS3BGf81OUxkW5RKQQeETi7SxSuC T6JE+L6APnQhc2NSxkWBZP/PZ2waNx+Fzl7Y4f+GlJh7OYUMQrGN3fHkGR4kKQHNVZ/LDZDytc9 cbv1+cIM3Clr+SdOYANtqPID4+9ghpCDoSSuGm+yeO6QJlDDQCzhaMtz9DhbiDyX7eZdNXzOWpc Jc6r8M3jHBNsvAZY4nD0xCCmqZpNPVn8EIdFlHpOvYQqRaFWINSzH35P4bVcEvkLsABIqdL0h8n 1m08rii/TA== X-Received: by 2002:a5d:5d13:0:b0:48e:47e6:fdfb with SMTP id ffacd0b85a97d-48e6e302699mr31883079f8f.13.1793815274534; Wed, 04 Nov 2026 10:01:14 -0800 (PST) X-Received: by 2002:a5d:5d13:0:b0:48e:47e6:fdfb with SMTP id ffacd0b85a97d-48e6e302699mr31883036f8f.13.1793815274060; Wed, 04 Nov 2026 10:01:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1793815274; cv=none; d=google.com; s=arc-20260327; b=OS+UvJZxj+RysfD+9JDfB6LcgC6X6Rv29J/Fpy2/OEn5li9U7ORiWrU/7eEf0THJD/ uHdhUjnv1JLJb6TfyMTUAuFeAYmigwkeYIZiTYLcPvdVzqwc2CB7kK7zAgd11f9mgNL1 2VbKwZGMzqcORcwFipVB+g4JQG3QyubHao0edGuSDNhhfzpVBSOypLqNr56f6smoovdJ boxflXo7ODu9WR9BugnNUkdLXiwwPlggvgVquPO8cLkDgVYS9CM06e4AdYTM0urZ4xHU G/ValXEpKiAq9AyWfU60DZZZi//AI18zJ1z4fP4KvWlL9oQ6Zye4kD+QW1ppZP6Enaj6 r47g== 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=AWNiIcHvpdiVWV60EhAmVRFwn3oQ7BBxWfVUNd7h0ac=; fh=xsjxCyMXt+Dj/kLknW2rI278j87DGnPqw3coQ8mtP7g=; b=RyPdOQ7uxc4wtbTbq2aRwbxVDpX1xe3PR4lYOcLUzJYynG4JWSxoqUstNq9KN7yGfX aDg4bOB6Ac7T4UMWbdX5m0Yzk476JhVhDmpMi0SJovkHEy9y+r0vEOQroiH90tKULFS/ 2Ct+LLMjXfDJ1l2XwJcp1ZOd5syd2klrVKpXrnGXP0+L4R1ywPNkCqymTf3xX0JObUdT 7Lf5E6tqMdD4iUORNZ20gT9mifWedZykUDnOfv0XVgjWUXZBw+SUfFNDOfgYT0vQ21Qe 5QL8iuwxWxLNoLUr6EJwX9TOySPdjyWyYta4DFvDBQyF0bT+LR5xLOUf+gzXEliOdr0B I9JA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz.org header.s=google header.b=U8dBJHeb; spf=softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:162e:5a6e:fd46:18b7 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-48fedc0a414sor820584f8f.11.2026.11.04.10.01.14 for (Google Transport Security); Wed, 04 Nov 2026 10:01:14 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:162e:5a6e:fd46:18b7 as permitted sender) client-ip=2a06:5b06:b600:300:162e:5a6e:fd46:18b7; Authentication-Results: mx.google.com; dkim=pass header.i=@openvz.org header.s=google header.b=U8dBJHeb; spf=softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:162e:5a6e:fd46:18b7 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=1793815274; x=1794420074; 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=AWNiIcHvpdiVWV60EhAmVRFwn3oQ7BBxWfVUNd7h0ac=; b=U8dBJHebmvrpfZFYFsQCwqlUryHOVLapZAYAGlQzn5toI0lhTfHLjCOUtVehltY46Z iMHBh52ElMmbhkXenrONSuxLVBn4TnZkMOe7w9777chjLkdaZuglJUyP1lWxFievvr5s bugfjNKnNMDdHTp5dRebnG/nP+P2FBV1rAtn769vujGLKC576EYSXbaKp7ZDAthsS3KV Ebz+yFLiuJYRxuJHZ3eEmydpD25W81HkWgOvXiVDhBj1QmXAkfI+eJQe/WYAxTSj2i38 LrJ0np7jy7JjXx0MRoMK9w/9taYrdQc6zG5djkqCVHiQ0obs1dWKKHpncge0hiz2gpPR pPYA== X-Forwarded-Encrypted: i=1; AKwUvBxAdn8HE1jX4oAjxIdoZfiL8ENyGTZ5EBlFX8KjrvodovGFvXGcvN0RxWfR6n5ZsYOmHOx0NA==@openvz.org X-Received: by 2002:a5d:5d13:0:b0:48e:47e6:fdfb with SMTP id ffacd0b85a97d-48e6e302699mr31882988f8f.13.1793815273531; Wed, 04 Nov 2026 10:01:13 -0800 (PST) Received: from athena.sw.ru ([2a06:5b06:b600:300:162e:5a6e:fd46:18b7]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48feda20521sm5050716f8f.53.2026.11.04.10.01.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2026 10:01:13 -0800 (PST) From: "Denis V. Lunev" To: andrey.zhadchenko@virtuozzo.com Date: Wed, 4 Nov 2026 19:01:05 +0100 Message-ID: <20261104180105.1807820-6-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261104180105.1807820-1-den@openvz.org> References: <20261104180105.1807820-1-den@openvz.org> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.1 v3 5/5] dm-qcow2: fix a refcount table relocation failing on a valid image 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() puts the new reftable at pos, the start of the first refcount group the old table does not cover, and the new refblocks right after it. It then gives each new refblock to the group the refblock itself sits in. When the new reftable fills the group of pos by itself, the refblocks all land in the next group, and the group of pos gets none. Marking the reftable clusters used then fails with a WARN, and every allocating write past the old refcount coverage fails with EIO. A valid image gets there: with 4K clusters and refcount_bits=64 a refcount group is 512 clusters, and the reftable reaches 512 clusters when the image file grows to about 511G; with refcount_bits=32, at about 2T. Give the new refblocks to the groups the new reftable and refblocks span, one each, in order. pos is group-aligned, and r2_clus is computed for the refblocks to count both themselves and the new table, so there is a refblock for each of these groups. Fixes: 222b6f1291c1 ("dm-qcow2: Introduce driver to create block devices over QCOW2 files") Reported-by: Konstantin Khorenko https://virtuozzo.atlassian.net/browse/VSTOR-153421 Feature: dm-qcow2: block device over QCOW2 files driver Signed-off-by: Denis V. Lunev --- drivers/md/dm-qcow2-map.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c index eee865989ef7..34d9d9810f60 100644 --- a/drivers/md/dm-qcow2-map.c +++ b/drivers/md/dm-qcow2-map.c @@ -2277,7 +2277,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; + loff_t new_md_start, new_md_end, group_size, r2_pos; u32 old_clus, clus, clu_size = qcow2->clu_size; u32 r2_clus, bits = qcow2->refblock_bits; unsigned long nr_pages, index; @@ -2385,8 +2385,11 @@ static int relocate_refcount_table(struct qcow2 *qcow2, struct qio **qio) if (i != nr_pages) goto err_eio; - /* Connect new R2 to new R1 */ - for (i = end; i < r2_end; i += clu_size) { + /* 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; @@ -2395,7 +2398,7 @@ static int relocate_refcount_table(struct qcow2 *qcow2, struct qio **qio) if (WARN_ON_ONCE(ret <= 0)) goto err_eio; spin_lock_irq(&qcow2->md_pages_lock); - set_u64_to_be_page(md->page, r1.index_in_page, i); + set_u64_to_be_page(md->page, r1.index_in_page, r2_pos); qcow2_md_make_dirty(qcow2, md, true); spin_unlock_irq(&qcow2->md_pages_lock); } -- 2.53.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel