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 7C71E80474 for ; Wed, 28 Oct 2026 15:08:10 +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 69SF6tW2021093; Wed, 28 Oct 2026 18:06:56 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 69SF6tW2021093 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="F4862QSm" Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 69SF6orA021042 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Wed, 28 Oct 2026 18:06:50 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 69SF6orA021042 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4a20a40d3e9so8591585e9.0 for ; Wed, 28 Oct 2026 08:06:50 -0700 (PDT) X-Forwarded-Encrypted: i=2; AKwUvBwk8ye1PGakmUWdVHYRtpVuh893tg1sAhPpkoR9mHG5pcko3S3tPOlbEHVurDoV48idczxhAQ==@openvz.org X-Gm-Message-State: AFq9FYIIdnMOJlkYySEkE1NL2KrANpc7YMaKg7e+nyPLIGLu/CJVbBDb Iz4iNXhxCDjxCCJKziNqAzTSKBX42oMa9X+JzZwxOCXn47hiKF0adVzevtb5ABWmEPgmdmkoDto lX24/q6hYCtuSDMS66ZeExrbI4PrgdnIWy3Xvv0n70vjlhWqcnCDURQ== X-Gm-Gg: AYBFou1cSZ/fh1u5ZNqBCQVcn/67Qf7oB/VEkdebn1PKD6nb0ar2ZATMuGrL9RK1bHR e7l2I7m9IkdpW5XRrBIy4oKph2z8x72JEyeHGfsB1jH0eZzp/cXVz3Zpa7c8rRXtl7FVP9+vwyB 6ox2c1ZW64sV7DHwt7R2rZnzCRZ1q6N6XWek3jaEAQyZtd9EzrDKsgnvcJIgaEM6YJC5jy7hYqX MPB+1iPOFlK64SsSrc//Dwfn5Vy7F6bjI+jdGD87el6ojgUdqwqw0J5PnvqE9/V6bWBtu9IHlqJ 8pk4BBx3t47cFCc0lQbodjHVdsp4XBNuw7xOUX8RTJIt1AK18CZoPlglV4TmsqsP8btTvynSRx0 +3xzc0KRb/uGLAl/2y+nk+foro2zc X-Received: by 2002:a05:600c:811b:b0:4a3:59c9:a743 with SMTP id 5b1f17b1804b1-4a967e8d5afmr56927395e9.27.1793200010524; Wed, 28 Oct 2026 08:06:50 -0700 (PDT) X-Received: by 2002:a05:600c:811b:b0:4a3:59c9:a743 with SMTP id 5b1f17b1804b1-4a967e8d5afmr56926235e9.27.1793200009876; Wed, 28 Oct 2026 08:06:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1793200009; cv=none; d=google.com; s=arc-20260327; b=lYkNlTtSGCF/krjAi5UCUSxbhEtZ2XywNoq8A+D/7+b68MbMX2q08C28uXGEEJ4UTq 89jVCuylmnX5NqFtFtfRiiYCvsGNct7QlpJawOUzkUOjr0FPDjZR/xJ3L9GPiUm9VbX7 zjF50iQMwtnsH2/XZ4NUkzZdfn2Ylhuv72YxfKLCI39ZiiyTtzYLHIF6skpjJ6ZhcEcj e0irbbtW5OWkiqDdY2UJ5CDI+AUfObIDnBTp254IFKHWW2rwpFlZavI3GZ3FcYnxiaIz qHAcZkSMo/x5CP4JuzvXqklxR51D2Hjdl8UmNzcO/gxx/8CKM1S3Di/8ZoN25GRgy2ck 1wcQ== 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=WsoJk1DnVWvCBrUt+fA/M7PqQ2ehNPgDnl/Iuqv5rvA=; fh=CMILZ+goaghq6B4UpCDhf0EQp6kYD0LAlmOkUiVCOvs=; b=Lr0+8c0PbbiXrfaj0hfhIjfn3myuclejdYnYK2r/Pg42x9Xa8IdGb4Uw7u8jIZEaQ6 OqnQHd+xE+7Sv0oTs9ZtLs6utfjxHMljNr+MnJADDbvmvrECVqHWacAU+skTb+8aqYNP B2AF1nBHtmu4yySIpWJKDDILeGQjOevU+6GGxZNb8rXTQPrnopjFeFS5CA7gn+wyWE7u bBNIJxFh5J9rr50a0I4p6CyBQ/OMxNbu5DbWx/yZ3vH0DYQyN1KdmSltpKEB+2MaJ2d+ fY6LoH2IdN43MH18XU/hU+lc/UIVGZwZqncftynnaR31HgJcmf7rZjh8kqauPq6FnKn6 WhCg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=F4862QSm; 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 5b1f17b1804b1-4a97d578023si56229665e9.10.2026.10.28.08.06.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2026 08:06:49 -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=F4862QSm; 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=WsoJk1DnVWvCBrUt+fA/M7PqQ2ehNPgDnl/Iuqv5rvA=; b=F4862QSmlRsm l7W64LxzyB4SYU5AI+1xwEtcRt9asQXuqQAseZ7KCGUP3YqRqzpTV+MUaOMDZ+eM3vSqNIANKexxy JC8c+9ZrgLC1n/406MYltaeQdgYzMYZBJuKFOWG38Hr4A/4XIJF1IwNbyYdLvOlLmt6NnN8m3Saro J8CYoqSHDwbu58Ml+PGqse4CYtTni8hxW7QcMjMeWzO+b9jaJ5WGlyzLjGv9J6L6rkkyyxvg9oy3p +yfXtkijsLpay8Gj4xW+T5Eqj5ldAGcUXFOFQ1+UPguflIYzOsrEKOWlbOSwYrmYguK6CD5Dwf07U L8slT9e22j8A2NeC7+ji8g==; 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 1xM5B1-00AtLl-04; Wed, 28 Oct 2026 16:06:48 +0100 From: Alexander Ivanov To: andrey.zhadchenko@virtuozzo.com Date: Wed, 28 Oct 2026 16:06:35 +0100 Message-ID: <20261028150645.3222391-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 v9 00/10] 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-9 fix existing cases where the refcounts or the dirty bit on disk don't reflect real cluster usage, or where such an image is not flagged for check, which the scan relies on. Patch 10 does the actual truncation. https://virtuozzo.atlassian.net/browse/VSTOR-148171 v9: - Patch 5: new patch. - Patch 6: also keep the dirty bit while wants_check is set, as md_writeback_error is kept only in the target and is lost on table reload or host restart. Rename kernel_dirty_bit to kernel_dirty_bit_set. Retitled accordingly. - Patch 7: new patch. - Patches 8, 9: split from patch 10: setting md_writeback_error on a late reftable relocation failure and the MD_LX_REVERTED / lx_writeback_error tracking are separate fixes now. - Patch 10: rename qcow2_truncate_preallocations() to qcow2_truncate_unused_tail() and update the dm-ploop comment that refers to it. Move the rationale from code comments to the commit message. 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 (10): 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: flush lower metadata before clearing its dirty bit on merge failure dm-qcow2: keep the dirty bit of an image that needs check dm-qcow2: fix md page cleanup on failed reftable relocation dm-qcow2: flag the image for check if reftable relocation fails late dm-qcow2: flag the image for check after a reverted L1/L2 writeback dm-qcow2: truncate unused tail of image on suspend drivers/md/dm-ploop-target.c | 2 +- drivers/md/dm-qcow2-cmd.c | 5 +- drivers/md/dm-qcow2-map.c | 180 +++++++++++++++++++++++++---------- drivers/md/dm-qcow2-target.c | 119 +++++++++++++++++------ drivers/md/dm-qcow2.h | 10 +- 5 files changed, 234 insertions(+), 82 deletions(-) -- 2.53.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel