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 D39C38006A for ; Thu, 27 Aug 2026 16:11:13 +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 67RGA276001755; Thu, 27 Aug 2026 19:10:02 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 67RGA276001755 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="iCLZODDB" Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 67RGA0sM001749 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Thu, 27 Aug 2026 19:10:00 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 67RGA0sM001749 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-47f6db77430so5450f8f.0 for ; Thu, 27 Aug 2026 09:10:00 -0700 (PDT) X-Gm-Message-State: AFuF++numhkMFvhg7WRNLie4iwEERMfrHCNOPL5MaSCLdliOGU/IaYGY QvsLmGQvHGLs82gWhd5zBzhmUOYZsQsrHMtU9XKvMgwZLe2HZMMxi3P9N4kcDtnMcItHlV9U4/V /X+MkH3gjG6/qObwl7gYxmsIcWn7bQLOsFMP95vYKQSeDbpiJkz9X/Q== X-Gm-Gg: AR+sD10nKO3GRRN6iTWdRXAR/6Vv0sPqr5svnK1gPyLcU5qgz2ZW4kCqNaeB82rK//1 3rhj16UAVtCrWdE37aS8ao1iIXL9fnCaMo6uGCajXx14kj/+nMt34i+rY4YQDCBJ+0yxr8bJ2d/ RIGvjsAxYMKpg2JSn3htGdHnMwWBrQ/NNcjnK3tzsklS2T8V+gStLzZH3kJoSuaKkVwJ84UTm42 +sH6Uw57idZk825KmTxkWfxIxBxX2FtPOm9IyNnHEiHHdwxxzIuS5+9Dvw8eX5IScs6O21FPIQD +wg7CcAHHY33We3d0Fm/LG5tumWRxjt/h1jiFmacio7xGJSAPJ7cSHRw3InpB6p4iYuqVmQP2xK fcVTmzqXtjApSNaKExaV+hFImCDIi X-Received: by 2002:a05:600c:c48e:b0:499:9240:9a1c with SMTP id 5b1f17b1804b1-499dc82ced5mr182975525e9.15.1787847000133; Thu, 27 Aug 2026 09:10:00 -0700 (PDT) X-Received: by 2002:a05:600c:c48e:b0:499:9240:9a1c with SMTP id 5b1f17b1804b1-499dc82ced5mr182974445e9.15.1787846999620; Thu, 27 Aug 2026 09:09:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1787846999; cv=none; d=google.com; s=arc-20260327; b=gbASKFCK+A1L7SXjQHPEYqWN1AW6lDTJ3HnYGlLq8+TU3ig8iOi+Rx0VrcnHgdUv4W R43A6iMPfbcPbcYQ7pTvFYBE6Z+4b69XkvqTSmUtoTTQiiQ0vtWraf9GpQE0uDjzCkRE qY3DamGedzafFFA4nfFqB77ymDEE4zM2ea1l66cfOu5cMmjK0VrOLIFd4ibiPXr6o06F 4hAKt/R6aTmxysOlbEUymIgw2HPKvtS8qKmaMc5zqJT23ZRtwfw6lvLbi06kMwnKTT6H ao4nUF3rJHvhzUp+EorUymV6WFJxoUCmYNrRhvAWa93z8VhyGILakQHBDHwqbnvNDnL9 RMOQ== 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=6WeF/MtKkNuOZsTy1FhQ91w4ds88+lWK5GgeKqWuQaM=; fh=0/brz1B8ohImS2ERrXZY0dPGpSEyX2H6iLC7bneXJkE=; b=lOkOjNaM/ZQARVSpsHcKuOnuEQS5gDiBYBGTq586A25uzmEHDdvXV5F4cd/WbzPZxy CkQsUy/vJB7TQdOQb1n2P9D/1MWeT4S4/x4HLSc70CpF4RZgOlDXIm7kWGM7Egg8VBab wqPbcfxBRqHu0Ex/XVvxpAmB2i20KJKj6CWVebVLA3bY6TtHaB0jJ8NcGii4/8lcXX+7 9K8O3aIYQwpL6rN4BuPQJL8+CggdbMgP//S8ZUUgr3oz4UBpDn+ywjYfR7yqDiWSX5Ha nUSTlD9XDgA2cEvpuEha9NqVxQ5+zHGBhtBaQF2CmOhGESRpli2QFloI6JfkScVF7Bkd RyJg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=iCLZODDB; spf=pass (google.com: domain of andrey.zhadchenko@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=andrey.zhadchenko@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-482e290d9ecsi8122047f8f.501.2026.08.27.09.09.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Aug 2026 09:09:59 -0700 (PDT) Received-SPF: pass (google.com: domain of andrey.zhadchenko@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=iCLZODDB; spf=pass (google.com: domain of andrey.zhadchenko@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=andrey.zhadchenko@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=6WeF/MtKkNuOZsTy1FhQ91w4ds88+lWK5GgeKqWuQaM=; b=iCLZODDBp7I3 jC0rOWstIflG/6CzGdojx/8Diy5mjeKwXoWfG0zOTYybw3chv4CQds8HAaF64PAIu6nh5Pn6DhwZH A6rIlSCHnTOMmMRI2SsuBmK3PIjsUbGUrCfMQoSS33Dugz/hscqfcR1FIzVGvwEN/LI8NR1L9TuxF pA+/cTgoeFzn/8fJi7BphyGNrk4Cd5xYFA2yne5t53P5zheb8Jjf1egGMLYGbGAwu4UbCfemp2Gun c5FRGIRjWijZCaavuPrBeeVPTY7Iq6Jk2lskOFIT4qr0JhpDWR+4OK54axpOZBYy0y7lPlJ2Y4gLu 0mN1V34/DiEG3dr4LA7Zgw==; Received: from [130.117.225.5] (helo=vz9-demens-1.aci.vzint.dev) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1wzccs-00FHQJ-1s; Thu, 27 Aug 2026 18:09:08 +0200 From: Andrey Zhadchenko To: ptikhomirov@virtuozzo.com, vasileios.almpanis@virtuozzo.com Date: Thu, 27 Aug 2026 19:06:19 +0300 Message-ID: <20260827160619.303398-12-andrey.zhadchenko@virtuozzo.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20260827160619.303398-1-andrey.zhadchenko@virtuozzo.com> References: <20260827160619.303398-1-andrey.zhadchenko@virtuozzo.com> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH VZ10 v4 11/11] drivers/md/dm-qcow2: respect zeroes during merge 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 The merge machinery used to skip unallocated clusters, therefore breaking all clusters with zero bits and non-zero backing. Technically this bug was present even before discard changes, as qcow2 image could have 'reads as zero' bits before being inserted into dm-qcow2. Properly commit all zero clusters (albeit with data for now). https://virtuozzo.atlassian.net/browse/VSTOR-138288 Feature: dm-qcow2: block device over QCOW2 files driver Signed-off-by: Andrey Zhadchenko --- drivers/md/dm-qcow2-map.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c index 2661ceeea8d21..ab340fecfc81a 100644 --- a/drivers/md/dm-qcow2-map.c +++ b/drivers/md/dm-qcow2-map.c @@ -2744,6 +2744,13 @@ static void requeue_if_ok(struct qcow2_target *tgt, struct qio *unused, qcow2_dispatch_qios(qio->qcow2, qio, NULL); } +static bool clu_zeroes_present(struct qcow2 *qcow2, struct qcow2_map *map) +{ + if (qcow2->ext_l2) + return (map->ext_l2 >> 32) != 0; + return map->all_zeroes; +} + static int prepare_backward_merge(struct qcow2 *qcow2, struct qio **qio, struct qcow2_map *map, bool write) { @@ -2761,7 +2768,7 @@ static int prepare_backward_merge(struct qcow2 *qcow2, struct qio **qio, } } - if (!map->data_clu_alloced) { + if (!map->data_clu_alloced && !clu_zeroes_present(qcow2, map)) { /* Strange COW at L1, except the merge from RO image */ WARN_ON_ONCE(map->clu_is_cow && qio_may_modify_image(qcow2, *qio)); if (fake_merge_qio(*qio)) { @@ -2808,7 +2815,7 @@ static int prepare_backward_merge(struct qcow2 *qcow2, struct qio **qio, goto endio; } - if (!map->clu_is_cow) { + if (!map->clu_is_cow && map->data_clu_alloced) { /* Forced set these to unuse them after discard */ (*qio)->ext->unuse_clu_pos = map->data_clu_pos; (*qio)->ext->unuse_clu_end = map->data_clu_pos + qcow2->clu_size; -- 2.43.5 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel