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 DAD5280D0E for ; Mon, 26 Oct 2026 14:43:48 +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 69QEgX0A011673; Mon, 26 Oct 2026 17:42:34 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 69QEgX0A011673 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="rndJL/cz" 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 69QEgSWO011640 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Mon, 26 Oct 2026 17:42:28 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 69QEgSWO011640 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-48e0461e040so2431226f8f.0 for ; Mon, 26 Oct 2026 07:42:28 -0700 (PDT) X-Forwarded-Encrypted: i=2; AKwUvBw84M7J1wGAIkDseNkNzkqoDtv7TarqqigEy/8rbo5Qy7BXEf03RvH0FA9ygKXEAlesnbjX3Q==@openvz.org X-Gm-Message-State: AFq9FYIyuTpqR0v5/sk3gL2tpCcpuJcZmXxMIJO+Z6LVi6cgVgabwFAV /iMi+Yekc9A2U4ERivEYlDmPbuK49ESaEiiJ3sOikc8ZVGkljYrxvKZJDy6JA7kJWXRGsEPaeBE 1oBLf57nOHCkASnLLWwgbicsGjAgptzsnet7FiIT5Hcp85eAJaKW5bA== X-Gm-Gg: AYBFou0T7Gyn6zIUl8QFL9CPMmrRN4a1QsevrwMZkKx7z9NW9Smfcb7XELVbjZzgQmP ss04mqlI5L+TJ/x5rwJguRG+u4NERzDw8Za/YtzpaWpBPDr7yhxjaloFwj9IXNpYeMGqiq3NI30 2l/ALXncbc6yIsuhLP8c2hQjdQ4+S3wVaLqjvxcS+ox7YvBq+7BTF3zHQKrCCFLDaSKnThIBAeG u2AvaQLM1ZtSrkdqSkpJC22EBQOHdKJIShepuSh+8SpfY1gdGeFpcjIx13RSnEEYkJtlF8syE3x Tw+PFRxbJeRbwQpSTUJHySqKwPOiRqMRNHhpzCoRZIra6K+4H7GmRDiNcy+VvsRqwadQMPn33TD 9LvNn84rvxKs1cdKHJk4k/tSG/b4= X-Received: by 2002:a05:6000:290b:b0:48b:f08:8159 with SMTP id ffacd0b85a97d-48e3eb7bd30mr15052064f8f.40.1793025747936; Mon, 26 Oct 2026 07:42:27 -0700 (PDT) X-Received: by 2002:a05:6000:290b:b0:48b:f08:8159 with SMTP id ffacd0b85a97d-48e3eb7bd30mr15051994f8f.40.1793025747206; Mon, 26 Oct 2026 07:42:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1793025747; cv=none; d=google.com; s=arc-20260327; b=mgUwlbGvGul+0yew+4z3IvGSfoKZaCTREh7jaNnLHvLkVlCKBiC/IfIE55jkHWcK4/ NFTEtLnP4voJ0cK25sUi+CZC/eNbFkrC/raPQiHui5Hfg9Ghh0RK4RNszNrJ7PbfKUz9 nrJSPY/uGVdPW0dvtXI1COxWjZsOKGhnuoJkxXSfj+5ZSYlWExZIlCj13FGnROPSvD6z fhHj5VjD7Hrn5xo5YU0WMVcqKdg9DwNJo5b/p6pYX5u+xGxSCh5StglMW02QYTtGxwp4 KYggYaq4FWuHW9ivOTexthgJfE6MqRdAuGbMyzuI0Az/YWpuzdYsEYSsD16+ykLEkXnF CjCg== 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=0XLyGlfzkonfmaUpO6hSnvr93Cz01myaJ+R9PnpYBVw=; fh=1MEQxOGYABaQPNQS1Ckioh0rrUOwgCYjd8t5csgx5as=; b=VOJPVkpL/DRYpAuWgDJC+/qCnPtQ6Jp1FNJiTZRSKmdYwNzE6HlU8mgmRFhlQNuBO2 dtlhqH9QQbsDMcXA4b/05Myw+mIfBpsFT+upqMFj9RIbC9FHUE1YU9rtdcGUftoU7/PD zqoZxfCmx1EWuYZVVZyQJig2KI0A4ANaGxcx7W3zN/ZPFsec63KlLfkTaS8bHB5ix9Ol DF8dyaoyDcsTFNPRUimfbmbufaf3DyJCdP20403VFYHgoViMUROk2cjYh1EBN8NxeIXD EblPaxD1zhr+I9R+pFPwCEJXfjqHgJsSUoOTaF8iphihwS5lE+c8KQdWUKK4Fx1f6Tf9 uWig==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b="rndJL/cz"; 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-48e3ecdb010si14778369f8f.115.2026.10.26.07.42.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2026 07:42:27 -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="rndJL/cz"; 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=0XLyGlfzkonfmaUpO6hSnvr93Cz01myaJ+R9PnpYBVw=; b=rndJL/czHi1q pHCuUGXEc/OenWSe4oxdtPaKlfR7Bw/FpZd5BrW9t+AtbsE/F93+hxhNS2tscZOfgwTQFnH8LXZr8 qSMSsph6gOuXQvViVgtB5MF6ZawwyvgJPKXDzVUU5/UTwcCboEWRYRyOXaxTnFXETgxHUa/O1Plt2 wnqaf+/EOU2dvfpOabqIPUpFxKWUkL0SDM9NjyAX/ND5a75Unkk6MgfNdXB7wyl5yGzitbj3mM5+m C26ibj0DAZboEPY9DDVjFDyI3gBvLbVPbPnLyYTJY9vus0wnv2xBCABuMGXP9b/+FTJ3aLpmA2lzR Zk0A5C0m40X2s62zy374WQ==; 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 1xLLqN-004nT9-0q; Mon, 26 Oct 2026 15:42:18 +0100 From: Alexander Ivanov To: andrey.zhadchenko@virtuozzo.com Date: Mon, 26 Oct 2026 15:42:17 +0100 Message-ID: <20261026144223.2787145-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 v8 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 v8: - Patch 3: instead of extending the file in place_r2(), make find_unused_cluster() return the position for the new refblock and let allocate_cluster() prepare it the same way as a data cluster (punch, extend, watermark update moved into prepare_unused_cluster()) before calling place_r2(). Retitled accordingly. 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 for a new refblock in allocate_cluster() 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 | 189 ++++++++++++++++++++++++++--------- drivers/md/dm-qcow2-target.c | 122 +++++++++++++++++----- drivers/md/dm-qcow2.h | 10 +- 4 files changed, 247 insertions(+), 78 deletions(-) -- 2.53.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel