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 74B2280BE1 for ; Thu, 22 Oct 2026 14:52:03 +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 69MEolik009789; Thu, 22 Oct 2026 17:50:48 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 69MEolik009789 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="BxqWlc0O" 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 69MEodlN009749 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Thu, 22 Oct 2026 17:50:39 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 69MEodlN009749 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-48b027578a4so1660174f8f.3 for ; Thu, 22 Oct 2026 07:50:39 -0700 (PDT) X-Forwarded-Encrypted: i=2; AKwUvBw8rbbsWfS9ZBBuopjzmpsIVaOE8tdGjCVSTSW8AIYVtLKakyjbtuSTQN6M77a/sjiYyYjsWQ==@openvz.org X-Gm-Message-State: AFq9FYJu0zecVppaX+5WGFKHBCztTCR8B/ZwGtbXfjlxIC3e6xFjNCyk wApzPmZEZzAQfnzTHrXripq0swfyELJ5Lg8Wq84P2tKqPg3DXNPWseI3yaDIo5N1FMCs0YbUA/+ Rfl4/aD7ApALPqR9u4EGka1NWp3rBOmNw5oXSAnhx5UoGRVIFd+Z6ug== X-Gm-Gg: AYBFou188GMPurJStA0aUDMCqHTTjOeuYKkLIVNGP/nPlyaZk1q98uFfGw+LFJeElBh J5NfWtGgRX3qoAdEJJgrMUTm1mYCyzyUkRjU86mpf+fxekdLAdldcaYi6UVRuoGZnysKbgo57oJ ueJd+CfCL3CpsKRtyYy4GtyuVf60d/65BP8Ud0eMX5yZP5dqKhE+mxSxF2c7gDDgBC7sHyfAEaw RzXUoIqfINUqg7aeZeJzGMaW1tkwY91Y7OKY61YBYpLIOPtMeW94fk7VngRap5QdxcDmaLQeNTM vCwtnCetmlALiyaVMglOZavpn8Z+dD7LtcOfYJqYtV2ZGOORmjRmdGtzi9PCYSoASk2y8Y9LT3d TIl7n3FZHRnmKYFA5L52R8NPZ2T3l X-Received: by 2002:a5d:6f14:0:b0:48e:10a7:40f with SMTP id ffacd0b85a97d-48e2647cd10mr9721133f8f.17.1792680639524; Thu, 22 Oct 2026 07:50:39 -0700 (PDT) X-Received: by 2002:a5d:6f14:0:b0:48e:10a7:40f with SMTP id ffacd0b85a97d-48e2647cd10mr9721063f8f.17.1792680638665; Thu, 22 Oct 2026 07:50:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1792680638; cv=none; d=google.com; s=arc-20260327; b=hRm7Xldi99IvfdKk7UyeqMgxcyCGiHpFCx63/uxHIcacYqGpYxwBk4RTGeTFhlxMmz JnwYr28VHmwxSdVGgCY1S/+gBn/a0oBCFuZuAej8gapxs9rVO03Jk6jops8MTkEfVVL+ 5rxM9wfqRgsE31KWP2IiHhjFtqlwK3FyEtpXKvTA7wlon0qEBOagEfKXLSzxxippw7pu cpGcFfEqveEOnwaWBzoTEhneRbAc0V6ytJ3sGN1Y7A3pn8UGDVBGofRuTaasknibbIsE 9fVyVTmB8RefVHV4CDZax0vcUa27YSXwINH2+V/kkAmWnByKq2uc8dFPzAITn9HtSAk/ Ib4g== 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=XQ8PdwXoqIjoKxxLUpdhGYWVOAXHWYhIJZNy3RSekcc=; fh=1MEQxOGYABaQPNQS1Ckioh0rrUOwgCYjd8t5csgx5as=; b=HARKDWSjvx6Mtpee9AU0xi0mXcDJdC4Tvruihszpdo2KzPvZP1KIJz/JJoqcqhUR21 I9+gsZ+5bGBNb7jZPfG1itWLvD8QAsUss1FT06t/YVAD+5IQl71Kxyt7cxc5DNFrwdwl QWyizdZfRTnxBAXWevRIdqUCmjgPzZoOhBXdyyjn7ekYZR2BVBTx35xWCid0+NNMq+71 TD6KWay22OpeuXfNkAIlK8/4MkyAj7kXQvjmZcOyZBdzK/dut0ZtNEO+up5Mq7+9z94l NXTpe1K8IouL9i5tDcmxskihwX/Ccya5Kw2dWro+h9KX2yiCJwY/DMPWEwlHYTXuE96+ Wveg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=BxqWlc0O; 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-48e2585751dsi12218756f8f.194.2026.10.22.07.50.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Oct 2026 07:50:38 -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=BxqWlc0O; 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=XQ8PdwXoqIjoKxxLUpdhGYWVOAXHWYhIJZNy3RSekcc=; b=BxqWlc0O1TyV rykfIzSdUdp/oexTQEfrJ4GtqLFJFRR8E6EWYcu2gbNCLc+vAMmdhoPyuEz2EqjTVpRn077BfUQ9V IY21HXmBx5GzGniZj0GB5dR0oqOmCwnlLmLttlJcId1nCcQSff1zsqftXCsMTQh5oVqrUJcdjXc4h JzZNBV0B9ogUdcwtC6hPBjooY/wtWnqz9WkAV1uRI+iYMqF/oZ6uyeAs1xz9357l4YuuqNUKhvHsw J/3LUAQtwto95zUoABdFgTyA/8ItL0PIXXHPKz4p88TXxn5cGcvPEa1I0KLB0jjBVLFWLDv/P3KMo krr9fLab6DrIniRo9Ehgxw==; 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 1xJu4C-00GYCQ-1k; Thu, 22 Oct 2026 16:50:35 +0200 From: Alexander Ivanov To: andrey.zhadchenko@virtuozzo.com Date: Thu, 22 Oct 2026 16:50:26 +0200 Message-ID: <20261022145032.2128679-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 v7 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 v7: - Patch 5: track whether the image was opened dirty in a new opened_dirty flag instead of checking the parsed header, which is reread on resume and may carry the bit set by the kernel itself (e.g. on the lower image of a cancelled backward merge). A new kernel_dirty_bit flag tells whether the bit on disk is the kernel's own. - Patch 6: use opened_dirty to skip the scan. 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 | 122 +++++++++++++++++++++++++++-------- drivers/md/dm-qcow2.h | 10 ++- 4 files changed, 205 insertions(+), 40 deletions(-) -- 2.53.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel