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 6D0DB80027 for ; Mon, 23 Nov 2026 18:39:41 +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 6ANIcLd3005755; Mon, 23 Nov 2026 21:38:22 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6ANIcLd3005755 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=default; t=1795459103; bh=92D5weP12IGoXS+U4DpsM9KqXvc6JBwttNDTFpuFtRY=; h=From:To:Date:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe; b=AhIvrzBB5yxj+oI6rT1PdPpAnQgVg6ltaVAfqu9Ps2jQs2grWmwV4rfNk7lnC3iSn 9A5JTl3y3fT6I4zhBe5EzpQclF+ca7PAUarMzdupbCiQEIwMFlGzWQXuhk6IRd9UEF RDTnF0+E9I7ZFyFqdaPglruAs5xc9YJih2OFkIAtiF0OZ66qJCaDpkGXgcT0I4gxwl 8OVQzSl3b0Rhw7SkT4c+kQB9n9kkDwOYQ0lV9NM9P6Q8hyC3vXME17cGD7wIHege53 evUXpgZxfXf6kNGJiU9kVvLQg9l/vf+t88q64nKW+aTIRMBHBMf+0M1BEuzil+7pC5 pYnNayud2/mIw== Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6ANIcKRC005748 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Mon, 23 Nov 2026 21:38:20 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6ANIcKRC005748 Authentication-Results: mail.openvz.org; dkim=pass (2048-bit key) header.d=openvz.org header.i=@openvz.org header.b="olyrvrFS" Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-490c1867460so2202883f8f.2 for ; Mon, 23 Nov 2026 10:38:20 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErEPAL0ScguPe1rCI/cbPdB1F9deh3sxSrcQOzBCZxAggNdq2bOfaC9aX8CNkPza/OClWKXA2g==@openvz.org X-Gm-Message-State: APuU4Z+WIXwYng60XkupO0yfGNe/pWqe2RKEZrmGPHjwpxG5RKKYZ29L k3Qb32fBCbcWlhHtaZm0DoXK65TBbQeNdEAR3OpOl5okS2Fzcs5uMLvHgr13tyRszDND+Nu4+8l ukSH+QebYqr+w3Lchag7QpEz1dx1uMWpD/lLVX5qqORsCUlpfUzIb3w== X-Gm-Gg: AZFdTZdfw5Ge6U/F6UVxy5O4IV8S4oukppnLJLRPNhKDRnZy0QrZNWQbsaFafPRUgIW lDu1VI4+xoetZi4gyMCtCczYPjZJqlWkQut9HC4Hc5A5AqseV2A+b4my0M0lwpbvDUg/qixNCPl ro8I3OM7kfQc8OtVDuRduz/w3n/XoaTayp3x3u595Q0793fZ2EHIUK7pJ7JP+JHS9Xpg11ZKQOC DvWtM3vjjYMlWQsleNrDDGSfiZoVd5YJfwVR5j5a3sJiMYfWQPV+0mDbkQltTzvNEnHMjY4Xerr KxpaaLPEvQ== X-Received: by 2002:a05:600c:46cc:b0:4bb:6f41:399f with SMTP id 5b1f17b1804b1-4bb888236a3mr259540685e9.24.1795459099850; Mon, 23 Nov 2026 10:38:19 -0800 (PST) X-Received: by 2002:a05:600c:46cc:b0:4bb:6f41:399f with SMTP id 5b1f17b1804b1-4bb888236a3mr259540435e9.24.1795459099474; Mon, 23 Nov 2026 10:38:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1795459099; cv=none; d=google.com; s=arc-20260327; b=gX+yXaCpdcEWNLzOrVnvxhhJcKr4U35x2rTd8UtyfUCdhekvtUXq+dAT+kF4jCTL3k WkECvku5eOIsM9QAnMuXVRbOg6JVIJ2ealSYRABGVBucqJwxL/CeHX3AKxQBqcg7zpJA J+Ocgejds90xs/Pum3Hy4Yyhbw5Dpch6dHe/dWy9R+uWAEwRRP3tuaeS73Zdyp9Ty/r/ LVZs+6xFETTtbM3rEYx5CHznovw/7CGEMnMY9ZXOHAiBFCfut0wWXUthfDqW7L9lIBkT k/TT/uLIpOugRTlL8anA8jG7fdm/Om5Sv63oqZ8FBYeKb1Vb6R35bKGkjbhpMOPM49vG 3cUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=FAYYGFsmIFY7ITElUzAvG9T6VHx9wz32FUKMLfwjdDE=; fh=EEByrYlE7QeFCSIJrHu4Ie+whCLZ4Ognd8jdI+j3p+k=; b=hFE3v9rupYLPe97FcuzixUmWMQID9YMf65h+61sWW46BnMzXnPY+hL4BcYHpV/wB2X 1G6XC4mMTBjQnemyy8k3f+481B/VFZcqY3IynylTN7FHKPKQtr5KrjikiIEHR2lB2l2n UFgEMbZVQ0lCrY/zzndVwvE/l6fN2bxu6yh2TBGbGSRXgn99Vmh1e7czXQVlT/CV6YSv rPZJ3z3CUMCtg5bZtJsgj7z7KetPTgxj/bEz76mg5bfsoe94RfwR3Ga6ycVKW6ssAp0Y d8U7Q2vmi1KWJw4NGwnWvfDE9/qUnIL2lONsAiTKkiccxm0XI3uyWOM/leFlHxpiqUNY 9wkw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz.org header.s=google header.b=olyrvrFS; spf=softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:62d2:2eda:8655:4219 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 5b1f17b1804b1-4bb884865f9sor18702965e9.14.2026.11.23.10.38.19 for (Google Transport Security); Mon, 23 Nov 2026 10:38:19 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:62d2:2eda:8655:4219 as permitted sender) client-ip=2a06:5b06:b600:300:62d2:2eda:8655:4219; Authentication-Results: mx.google.com; dkim=pass header.i=@openvz.org header.s=google header.b=olyrvrFS; spf=softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:62d2:2eda:8655:4219 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=1795459099; x=1796063899; darn=openvz.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=FAYYGFsmIFY7ITElUzAvG9T6VHx9wz32FUKMLfwjdDE=; b=olyrvrFSqXGGXXtlMdWqzZWPQbh5QNG8Nat5F+6UcUw0hBmZuG6G1P/Qm/7b6aSRpD pjH+xwuGZJwKQFuR1MBBz8GfAur1jL6JgNG5Jk0nB+vKTKTg2cY5Kb+/tprnZQWwDd8R PNUOnS7U0XnH4cAyezAO7NoI6jUHeX0G/k6Zq3TqaoqxRyKq7X0CsfbGMr2ZymBMoa1A jP/jBR2M66bPecIcSoDZYCKBrAS6ldSG/x7Vyird0Vaanq3tuiYv3DH+aiSQOZpYNuoC +4jSUWYLJaj9qMH8J4dlu8WfxKaikIyO4NvDV8kcYev6ZzKrW1GRLyNUia+Lw3uIQ1sO NWCQ== X-Forwarded-Encrypted: i=1; AL+hErFbKEkrKbqteXmrv7NASrneh04axvuBEnTJADQ5YANgOjfprD70X4PMdWegholdPNI+4UrvAQ==@openvz.org X-Received: by 2002:a05:600c:4584:b0:4a7:c366:d791 with SMTP id 5b1f17b1804b1-4bb887e266amr245460535e9.1.1795459098930; Mon, 23 Nov 2026 10:38:18 -0800 (PST) Received: from artemis.sw.ru ([2a06:5b06:b600:300:62d2:2eda:8655:4219]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6bc8ce06sm23178028f8f.47.2026.11.23.10.38.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2026 10:38:18 -0800 (PST) From: "Denis V. Lunev" To: andrey.zhadchenko@virtuozzo.com, alexander.ivanov@virtuozzo.com, vasileios.almpanis@virtuozzo.com Date: Mon, 23 Nov 2026 19:38:16 +0100 Message-ID: <20261123183816.190058-1-den@openvz.org> X-Mailer: git-send-email 2.55.0 MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.2] dm-qcow2: fix a zeroed cluster under allocation reading as backing data 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 On an image without extended L2 entries, parse_l2() zero-fills a read of a cluster whose L2 entry is dirty or under writeback and returns as for an unallocated cluster: the map takes the zero flag from the new entry, which has none, and leaves data_clu_alloced unset. process_read_qio() then sends the read to the backing image, which overwrites the zeroes. So for a cluster that reads as zeroes through the zero flag, with or without a preallocated host cluster, a read racing the allocating write returns data of the backing image, which the cluster never held. Take the zero flag from the old entry instead. Only entries changed by prepare_l1l2_allocation() get here, as the replacing updates lock the index until their writeback is done. Such an entry was 0, or it had the zero flag and was saved in pe_page, which is where revert_l_entries_update() takes the old entries from. A read of a zero flagged cluster now returns zeroes, and one of an unallocated cluster still reads through to the backing image, its old content. process_read_qio() does the zero-fill, so parse_l2() no longer does it. Delaying the read until the writeback is done would also work, but it would lose the fast zero-fill of a cluster under allocation. https://virtuozzo.atlassian.net/browse/VSTOR-156741 Fixes: 222b6f1291c1 ("dm-qcow2: Introduce driver to create block devices over QCOW2 files") Feature: dm-qcow2: block device over QCOW2 files driver Signed-off-by: Denis V. Lunev --- Depends on "dm-qcow2: fix a SEEK_DATA/SEEK_HOLE oops on a cluster under allocation": http://lore.virtuozzo.com/kernel/20261123153805.128513-1-den@openvz.org/ drivers/md/dm-qcow2-map.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c index 06902a4830b7..248c79705a43 100644 --- a/drivers/md/dm-qcow2-map.c +++ b/drivers/md/dm-qcow2-map.c @@ -1952,22 +1952,27 @@ static loff_t parse_l2(struct qcow2 *qcow2, struct qcow2_map *map, qio, wants_alloc)) goto out; /* - * When cluster is under allocation, READ should see zeroes. - * On writeback, we could delay READ like for WRITE is done, - * but fast zeroing may be useful optimizations on big - * clusters (say, 1Mb). + * When cluster is under allocation, READ sees the old content: + * zeroes, or the lower delta if the old entry was unallocated. + * The old entry is in pe_page if it had the zero flag, and it + * is 0 otherwise. * In case of md is dirty, WRITE is not delayed. It becomes * referred to md->wbd in perform_rw_mapped(), and it runs * in parallel with md writeback (accompanying qio). */ if (!write && dirty_or_writeback(qcow2, l2->md, l2->index_in_page)) { + struct page *pe_page = l2->md->wbd->pe_page; + u64 old = 0; + if ((*qio)->queue_list_id == QLIST_SEEK) { /* No pages to zero: wait for the entry to settle */ list_add_tail(&(*qio)->link, &l2->md->wait_list); *qio = NULL; - } else { - perform_zero_read(*qio, (*qio)->bi_iter.bi_size); + goto out; } + if (pe_page) + old = get_u64_from_be_page(pe_page, l2->index_in_page); + map->all_zeroes = old & L2_READS_ALL_ZEROES; goto out; } } else { -- 2.55.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel