From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (unknown [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id 5E5018006A for ; Fri, 28 Aug 2026 17:05:25 +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 67SH4BkG011590; Fri, 28 Aug 2026 20:04:12 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 67SH4BkG011590 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="GYQhuCnz" 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 67SH3sna011526 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Fri, 28 Aug 2026 20:03:55 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 67SH3sna011526 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-490a767b782so8416105e9.2 for ; Fri, 28 Aug 2026 10:03:55 -0700 (PDT) X-Gm-Message-State: AFuF++lqiEMTwUFSANtuFqVIR82gXxANFMVlkL0p/dfaC2fxlOMImnjA +sG8WXDqaFtB1nvykF9CQAMnEVfI/8gmxsv18IJlplZpRmh7xzUl3S3uo1T3shxijk6eF9qqCA5 gvsGc3eHneLwKkv+YG2PAY4tf0rZYbAJjExmnKm8Xz27cFKbT/4X71w== X-Gm-Gg: AR+sD13xfX57XGhjjejsuqtqHrzv2CHmIDiETnfGL1kTvkxMAr4Hap24YCSTeKjArph bO8BnCDzxS/jNu09OUe+xszcM23FQBjC1olY+LB8lWjJnZvFzZJPYYeYUNeNU8MOc1TlSqN3yjw MMgKeCIPy27IcxsjGserFY8Lse3LD2SuCht7Oi8ZA/3G8QvWPoTyTrHrBxiCAB/4VgL+J9EETFT uOSWkpTTf3UN1R7XzZzcc7HlTTpzG8/T7Du5obAk3P7qkqxL0u8HlcUW/VLFLJgB29U+qBFE/m7 Cy4malsowGajYhrS0jkzkiWdNg/KNkgr0u4ouDwcJdyvGBMeJN1iiK8866RG777DnNFCdV87rQZ o4Y2ytvm0kP0phsM4 X-Received: by 2002:a05:600c:4fd2:b0:496:c9cd:e7ab with SMTP id 5b1f17b1804b1-49b91c22421mr136018275e9.5.1787936634567; Fri, 28 Aug 2026 10:03:54 -0700 (PDT) X-Received: by 2002:a05:600c:4fd2:b0:496:c9cd:e7ab with SMTP id 5b1f17b1804b1-49b91c22421mr136017125e9.5.1787936634045; Fri, 28 Aug 2026 10:03:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1787936634; cv=none; d=google.com; s=arc-20260327; b=oNuaEE+/wUPS0XrXbFXeLTciWqU7Jq8z1xR9oKI70fyri6DPH0Kh9muBEO0j5w8XT5 TQAbxW1DP8r375IN8j+DYDfusZb7gqZW0htxvpHsj8esGVIZXc6EosIA9kCK9jANmlp6 wqFb/i1Oz8faP3a/6w1+5cus7mPYTtiv3MJcuy0mMD32qyabp0nMdVYwSkTzGqMTxW5P sheBBB5UOL4Mv0CQz8MYQK/8t8+lgOLgsAZYiZlMET8V9y79zbwCKLwmcsX30ivGPSVi bBMi1xZTVYIhX1s5GmdtzuMKgoKTk53CYcEW10SBuEi1v+0ECPO8Le6WeihL+aASDIJB hfLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=subject:in-reply-to:cc:to:from:message-id:date:dkim-signature; bh=BrkdMOesWB1H6/Q7+uh4X8kH/r8Miam21H1bJtQ7rFI=; fh=Vum9jOrhj7HN5ByxRUgrKjNRrylYGqSqAPC0VlAu4Lc=; b=EfGhzkpTi+B6BzqahvxjH6ecAP9qxn9TVp7Cpg6g9OhlvfGQNqAQF+EiIOnxZyf6L1 1i30MaMjZL/sDpm2BT5h7joXiZIVvIHrU793tFJfHIBnhQs9tb8MpFoCo0YiYWMTCOpG UbU25EY/q9X5MiDB7ou1L684Xf/YKFWH/od+aWYuEkiAC5KyyXnp9NhMOt6hsNX3rx1s 5C3+NdsejuzzNUdicpiSTMhfuFqHGYNCUoCgm2g9RY3hvDKH704yP14i7btXgJPaEEpa paeBE9SFtGoSvgBkTBMq3YiM+oZlUvQGHXO9d52MlnEboxKOfskAHCTZgReoQ1HQh3z2 NNjg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=GYQhuCnz; spf=pass (google.com: domain of khorenko@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=khorenko@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 5b1f17b1804b1-49b49dbdcadsi95183805e9.8.2026.08.28.10.03.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Aug 2026 10:03:53 -0700 (PDT) Received-SPF: pass (google.com: domain of khorenko@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=GYQhuCnz; spf=pass (google.com: domain of khorenko@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=khorenko@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=Subject:From:Message-Id:Date:Content-Type: MIME-Version; bh=BrkdMOesWB1H6/Q7+uh4X8kH/r8Miam21H1bJtQ7rFI=; b=GYQhuCnzp+Ce Q0GgRs3HYae/gMMiitdvX5m/88at+X6Un2Qiqx/A1J1utsadJAdkdOjxcpk3Rzl5B2vW1W+ACclFA 2sz+4TLSWhPlbjs1O2yUkP5Y+vcU6u8RVlYfCNyh3gjYVzUDcND3JxPAaaFw4tsahHbpEoS9sUkWo FNkuMHugwGGgY0Cu0r+Bq4dBaljPJmzp7LIjRDqrLxsfZ5/72Fcoww6LjcreS321W5dN6QTX4CAEM Kg44pu/q7gMSAY+n7ZfFK4aMN9OHNLd9n9ygH6YuCjisIs+k3Uxo/u7XWAPyANx6sTugNMDRLWQbE 9THFBYbsj79U5Ulaxzco0g==; Received: from ch-demo-asa.virtuozzo.com ([130.117.225.8] helo=f0.sw.ru) by relay.virtuozzo.com with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wzzxL-008du7-2G; Fri, 28 Aug 2026 19:03:49 +0200 Received: from f0.sw.ru (localhost [127.0.0.1]) by f0.sw.ru (8.18.1/8.18.1/Debian-2) with ESMTP id 67SH3q4L1064068; Fri, 28 Aug 2026 19:03:52 +0200 Received: (from kostja@localhost) by f0.sw.ru (8.18.1/8.18.1/Submit) id 67SH3q7t1064067; Fri, 28 Aug 2026 19:03:52 +0200 Date: Fri, 28 Aug 2026 19:03:52 +0200 Message-Id: <202608281703.67SH3q7t1064067@f0.sw.ru> X-Authentication-Warning: f0.sw.ru: kostja set sender to khorenko@virtuozzo.com using -f From: Konstantin Khorenko To: Andrey Zhadchenko In-Reply-to: <20260827160619.303398-7-andrey.zhadchenko@virtuozzo.com> X-OZ-Fwd: true Cc: OpenVZ devel Subject: Re: [Devel] [PATCH RHEL10 COMMIT] drivers/md/dm-qcow2: set L2_READS_ALL_ZEROES after some discards 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: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: devel-bounces@openvz.org Errors-To: devel-bounces@openvz.org The commit is pushed to "branch-rh10-6.12.0-211.39.1.16.x.vz10-ovz" and will appear at git@bitbucket.org:openvz/vzkernel.git after rh10-6.12.0-211.39.1.16.11.vz10 ------> commit 1e432a95dec2de142feca1838b1ebd4dfe3379ba Author: Andrey Zhadchenko Date: Thu Aug 27 19:06:14 2026 +0300 drivers/md/dm-qcow2: set L2_READS_ALL_ZEROES after some discards Discard does not guarantee zero data. Therefore, to safely erase data, users may write zeroes and then discard. Imagine we have a backing file. If we write zeroes and do the discard, next read will give the stale data from backing image. Probably this is rather an edge case, but to be sure let's just set L2 entry to L2_READS_ALL_ZEROES so the device looks more consistent to users. Feature: dm-qcow2: block device over QCOW2 files driver https://virtuozzo.atlassian.net/browse/VSTOR-139406 Signed-off-by: Andrey Zhadchenko Reviewed-by: Pavel Tikhomirov Reviewed-by: Vasileios Almpanis Reviewed-by: Konstantin Khorenko --- drivers/md/dm-qcow2-map.c | 24 +++++++++++++++++++++--- drivers/md/dm-qcow2.h | 1 + 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c index 90229cdb5b006..0a164c6f56c2d 100644 --- a/drivers/md/dm-qcow2-map.c +++ b/drivers/md/dm-qcow2-map.c @@ -1309,6 +1309,7 @@ static void revert_l_entries_update(struct qcow2 *qcow2, struct wb_desc *wbd) struct page *pe_page; bool skip_odd; u64 pos, old; + bool cleared; int i, ret; skip_odd = qcow2->ext_l2 && wbd->lx_level == L2_LEVEL; @@ -1317,6 +1318,8 @@ static void revert_l_entries_update(struct qcow2 *qcow2, struct wb_desc *wbd) for_each_set_bit(i, wbd->changed_indexes, LX_INDEXES_PER_PAGE) { pos = get_u64_from_be_page(wbd->md->page, i); + cleared = !(pos & ~(u64)L2_READS_ALL_ZEROES); + /* Here we restore prealloced and compressed clu mappings */ pe_page = wbd->pe_page; if (pe_page) { /* Only L2 has this. */ @@ -1330,7 +1333,7 @@ static void revert_l_entries_update(struct qcow2 *qcow2, struct wb_desc *wbd) set_u64_to_be_page(wbd->md->page, i, 0); if (skip_odd && (i & 1)) continue; /* pos contains ext_l2 part of L2 entry */ - if (!pos) + if (cleared) continue; /* no cluster was allocated */ spin_unlock(&qcow2->md_pages_lock); @@ -3368,14 +3371,18 @@ static bool qio_discard_updates_metadata(struct qcow2 *qcow2, struct qio *qio, * * Discard covering the whole cluster replaces the entry and unuses * the discarded (or COW source) cluster. + * If the backing is present, set 'reads as zeroes' to avoid exposing + * stale data. */ static int prepare_cluster_discard(struct qcow2 *qcow2, struct qio **qio, struct qcow2_map *map) { + bool zeroes = maybe_mapped_in_lower_delta(qcow2, *qio); u32 index_in_page = map->l2.index_in_page; struct md_page *md = map->l2.md; loff_t unuse_pos, unuse_end; struct qio_ext *ext; + u64 new_ext_l2 = 0; int ret; WARN_ON_ONCE(!(map->level & L2_LEVEL) || !map->data_clu_alloced); @@ -3399,6 +3406,8 @@ static int prepare_cluster_discard(struct qcow2 *qcow2, struct qio **qio, unuse_pos = map->data_clu_pos; unuse_end = map->data_clu_pos + qcow2->clu_size; } + if (zeroes && qcow2->ext_l2) + new_ext_l2 = (u64)U32_MAX << 32; ret = prepare_l_entry_replace(qcow2, map, *qio, md, index_in_page, unuse_pos, unuse_end, L2_LEVEL); @@ -3408,6 +3417,10 @@ static int prepare_cluster_discard(struct qcow2 *qcow2, struct qio **qio, ext = (*qio)->ext; ext->lx_md = md; + ext->new_ext_l2 = new_ext_l2; + if (zeroes && !qcow2->ext_l2) + ext->set_all_zeroes = true; + (*qio)->flags |= QIO_IS_DISCARD_FL; return 1; } @@ -4053,6 +4066,7 @@ static void process_indexes_write(struct qcow2 *qcow2, struct qio *qio; bool discard; u32 arg_mask; + u64 entry; int ret; while (1) { @@ -4076,11 +4090,15 @@ static void process_indexes_write(struct qcow2 *qcow2, goto set_ext_l2; } + entry = ext->allocated_clu_pos; + if (unlikely(ext->set_all_zeroes)) + entry = L2_READS_ALL_ZEROES; + /* XXX: check prealloced_pos ==> revert */ ret = prepare_l_entry_update(qcow2, qio, lx_md, ext->lx_index_in_page, - &ext->allocated_clu_pos, - arg_mask, ext->lx_level); + &entry, arg_mask, + ext->lx_level); if (ret < 0) { qio->bi_status = errno_to_blk_status(ret); qio_endio(qio); diff --git a/drivers/md/dm-qcow2.h b/drivers/md/dm-qcow2.h index 8a24e04130e4d..0f006f1ae48cc 100644 --- a/drivers/md/dm-qcow2.h +++ b/drivers/md/dm-qcow2.h @@ -312,6 +312,7 @@ struct qio_ext { u64 new_ext_l2; u32 cow_mask; bool only_set_ext_l2:1; + bool set_all_zeroes:1; u8 lx_level; _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel