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 2B8A18017D for ; Thu, 22 Oct 2026 12:18: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 69MCHK7M008091; Thu, 22 Oct 2026 15:17:21 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 69MCHK7M008091 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="m1aCyQJR" Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 69MCHItj008064 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Thu, 22 Oct 2026 15:17:18 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 69MCHItj008064 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4a2065a2ef9so6928715e9.3 for ; Thu, 22 Oct 2026 05:17:18 -0700 (PDT) X-Forwarded-Encrypted: i=2; AKwUvBxcRB6S+jPcEUwsNSANVTQ88d/9VMBFoLzgtKYsoES9XK1dEA/HdE0/iRNIm3k9jGR///nOhQ==@openvz.org X-Gm-Message-State: AFq9FYK/Xp5ygFQe/iQp1SX0lTz8YyCMZEkHgkcGdMzU44Y+wx6//86a XLTeDRWPc3+WPAPbvjfkVTxlO7JC9oyZRPKofE8XK15GP7/egj6rCBQ7rloJvn6hwxSWNqIDvUm WinuFVQAeX8cVQ/JDIqZ1xxHmvaIANLQ8Icg4Xgnorl2NkICoDZOzDA== X-Gm-Gg: AYBFou2QO7eE6YRslnJ189e78n9k5U0C5thnIYaoL/RvroeZpPs9j8Wt6qWrLbleEH8 QyUgfeL3f5xck6cPB6xux8X7xFQLPxF5RDPIH6Jhfe6kaVS1Kq1zbLjbT9yufADvdLHhdg3BZA9 MFEAwRb30yd5MyUY2OglzsLjaFzgKIYZjT+IEMQZ+H3kuS2+BJUNp2WiByT4JbmIbs3tsh9bSlG a34UEljEAB3ToxAS/xOrgXjgny+pHUP5TEcP7Qre9lPs3n8BBE8mSaqY9h83XF/JVb7qVvmp3vr tbZl5JLAVlQ4Vk6vhc/n9sa1v0o2buJb2nm6frbjYGUP1HcbKZYzhJuzocD7s4GMm16xZluBX6G aSzJ0ahodpg9cX1DbUH6W5Qi2gaIa X-Received: by 2002:a05:600c:1f92:b0:4a1:688d:a41c with SMTP id 5b1f17b1804b1-4a1fdd2f5f7mr95907915e9.25.1792671438390; Thu, 22 Oct 2026 05:17:18 -0700 (PDT) X-Received: by 2002:a05:600c:1f92:b0:4a1:688d:a41c with SMTP id 5b1f17b1804b1-4a1fdd2f5f7mr95907265e9.25.1792671437752; Thu, 22 Oct 2026 05:17:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1792671437; cv=none; d=google.com; s=arc-20260327; b=lxXxSgwXOIPsnMux5P/95QTd5jXXFpRbQ2W8yvF/5Ci5ffwB7Ai7ywd0beFZeogOQY r+yVCviZ5Tqh9fPhMnTojwoApZjG40FgWb8kv76B0+0+3jPMSsa/huXD9ye/tVPKM11X WsBpBmfgI2dFJdeYKVIYR5Ly4D4L/+hYgbt0cVx+j+SF7aYvC43mKa4ZObKQFCynrt8g MxXNM/+VL0Z6iDtzrEwOBBOi1FOwkwZQ5r2RWrF5MPn/jVcyijqpvfTUad3BFCACT1OZ sC7KCXfqv9eIS2VCFp8kZplaSffuDRRewWXfpVb8zyScNpGP/3KM2ne4LNjFa3gulx/G gh4w== 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=n00rAHoW0oxevmF0iHxhNHzNFSj2oczBtOrNPio5YAM=; fh=1MEQxOGYABaQPNQS1Ckioh0rrUOwgCYjd8t5csgx5as=; b=bTUZtpaLrUl7DJbkVdioX0dbU0HMSsajfk+4KctEJF4BnRM/VmXSLQkQRc27YjLGzd Esu6FlqMm0wIFkMSVa5ekDrmqXdyFLxOWolLQBaYJJqFAcE28trwAy/JQ1fVgWMGTNrk c2/TnhRxiOg7CndyFdC5M/vlAyUDNkYPHLfkQ1vD3RyBVVCEm13J2303ussgPKxP2fBa wfrN0w9+IGUzniX7UYmd7vmymyFQXxqgME1HEfmQM0UxbMx+m9jwn72+1TMHaTLVOTIz onxF0cTRQsXce+XyUB07NX+WbEkSICv74a+QAdALSEqXaad287r3zycQ7dzFDbOk2yaZ Syfg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=m1aCyQJR; spf=pass (google.com: domain of alexander.ivanov@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=alexander.ivanov@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-48e25846fcdsi10454635f8f.76.2026.10.22.05.17.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Oct 2026 05:17:17 -0700 (PDT) Received-SPF: pass (google.com: domain of alexander.ivanov@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=m1aCyQJR; spf=pass (google.com: domain of alexander.ivanov@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=alexander.ivanov@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=n00rAHoW0oxevmF0iHxhNHzNFSj2oczBtOrNPio5YAM=; b=m1aCyQJRC9N6 quGsZAnrToJQApIy0N0IupZcg+PUzxBanlfBiz3b52S9GszjNRA61+Wh71nXDzLdjfuZ2MlUa6tYD TYlb8YPLxDWtbm3WSdVHDyx1zCs4/LnzsDCE6OMlnZG+3Vv7ubro9Z3DJufPvTQzOZgbFULphmhXW 7oVBjQwWs2Xx/w5DyJH82DuaiFOB15LOKxnIwbdbilz0NjZ/1gqt7MRuZEXldsXwm9bvrSy0An/I8 PxUZNB4xGSwL9tOduljU83oI9gNJRYSq40YRGVhf/NeHOwvkbKNo9LW047lG37nRUUaq0t0kahDYp 42NTgWbxJkSLZs3b0UC5Vg==; Received: from ch-vpn.virtuozzo.com ([130.117.225.6] helo=sky) by relay.virtuozzo.com with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1xJrfn-00Dc1n-1x; Thu, 22 Oct 2026 14:17:14 +0200 From: Alexander Ivanov To: andrey.zhadchenko@virtuozzo.com Date: Thu, 22 Oct 2026 14:17:00 +0200 Message-ID: <20261022121706.1890593-1-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.53.0 MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.1 v6 0/6] dm-qcow2: truncate unused tail of image on suspend 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 Discard punches holes in place of freed clusters, but doesn't change the file size. On postsuspend dm-qcow2 truncates the image file only down to file_preallocated_area_start, so if clusters at the end of the file are freed, the file never shrinks. This series makes postsuspend scan the refcount blocks backward and truncate the file to the end of the last used cluster. Close and reload to RO go through postsuspend too, so the file is shrunk in these cases as well. Patch 1 adds qcow2_md_page_read_sync() helper, which is needed by the scan. Patch 2 is a small cleanup of duplicate prefixes in QC_ERR/QC_INFO messages. Patches 3-5 fix existing cases where the refcounts or the dirty bit on disk don't reflect real cluster usage, which the scan relies on. Patch 6 does the actual truncation. https://virtuozzo.atlassian.net/browse/VSTOR-148171 v6: - Add Reviewed-by lines to patches 1 and 2. - Patch 2: fix "pase" typo in a message touched by the patch. - Patches 3-5: new patches. - Patch 6: drop Reviewed-by, as the patch changed a lot. - Patch 6: mark L1/L2 pages, whose failed writeback reverted refcounts of new clusters, with MD_LX_REVERTED and report it via the new lx_writeback_error flag, which skips the scan and is included in wants_check. Set md_writeback_error if relocate_refcount_table() fails after the new header is written, and clamp the scan start to reftable_max_file_size. Skip the scan for an image opened with the dirty bit set when kernel_sets_dirty_bit is enabled. Check the R1 entry before calc_r2_page_id(), so a corrupted one fails the scan without WARN. Reword the commit message to make clear that discard does free the clusters but doesn't shrink the file. v5: - Add Reviewed-by line. v4: - Patch 1: document in the comment that the caller must ensure no read of the page is in flight. - Patch 3: say in the commit message that close and reload to RO go through postsuspend too. v3: - Split from the common series with dm-ploop: dm-ploop patches are sent as a separate series. - Patch 1: rename qcow2_get_md_page_sync() to qcow2_md_page_read_sync(), reword commit message and comment. - Patch 2: new patch. - Patch 3: start the scan from file_preallocated_area_start instead of the end of the file and clamp the result to it, as the last cluster may be partial; print the scan error with %pe and drop the duplicate "dm-qcow2:" prefix from it. v2: - Add dm-ploop support (patches 3-6), as requested in v1 review. - dm-qcow2: move get_md_page_sync() to a separate patch as qcow2_md_page_read_sync() and use it in qcow2_parse_header() as well. - dm-qcow2: start the refcount scan below file_preallocated_area_start instead of the end of the file, and truncate to the used end directly instead of min(file_preallocated_area_start, used end). Alexander Ivanov (6): dm-qcow2: add qcow2_md_page_read_sync() helper dm-qcow2: drop duplicate prefix from QC_ERR/QC_INFO messages dm-qcow2: extend the file in place_r2() before linking the refblock dm-qcow2: complete wbd before ending the data qio dm-qcow2: keep the dirty bit of an image opened dirty dm-qcow2: truncate unused tail of image on suspend drivers/md/dm-qcow2-cmd.c | 4 +- drivers/md/dm-qcow2-map.c | 109 ++++++++++++++++++++++++++++++---- drivers/md/dm-qcow2-target.c | 112 +++++++++++++++++++++++++++-------- drivers/md/dm-qcow2.h | 8 ++- 4 files changed, 194 insertions(+), 39 deletions(-) -- 2.53.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel