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 45CB98017D for ; Tue, 6 Oct 2026 15:54:14 +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 696Fqsmu026048; Tue, 6 Oct 2026 18:52:55 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 696Fqsmu026048 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="O4DzeSem" Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 696Fqru2026044 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Tue, 6 Oct 2026 18:52:53 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 696Fqru2026044 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-48c430f0f01so2687938f8f.1 for ; Tue, 06 Oct 2026 08:52:53 -0700 (PDT) X-Forwarded-Encrypted: i=2; AKwUvBxS4/KKtMpLVzeCNRaGohEJ7xAnXAY1bXVbyeUjFGYWkq5Vkpt/Grmphr60OSLqBXqSGfpkbg==@openvz.org X-Gm-Message-State: AFq9FYLzB1lILN7LaDhe4QqCxlg6Mw/gsJO9xBGPLOo94mfwpLXySjmA HNt0ef/Gu5k0iY+8XjRpIzUAJL+w1PPbG9CqhDymzJqpc4k2f0v5u1luSW9tCP81dQwW9lChJUZ FdguUrfoeW0SGboUZIZjtE6cR9OfvMUEJnZpWeYBzab1a4PuLW/huFA== X-Gm-Gg: AYBFou35d9B+adWBrnMNFY5AF/4xolMx1kJunM8VHVTtXCryoU2T6yVmXlXWxpJQjjB y0AIb2dqLEgqI+11gcJsu52oyzwQXZ3NR+p6scD15jlz9RkPMeYvB+F95oM6vc6JvrZ77/eMazX T7TsOKv0Yqa7NR2DdRq1ARlP3Q5DKrViJXGWQQkemXFcEFHsn9hev680hDF1u26VUD5t0wYLEIC xY3ZEZjcojA4zb36eklJnP+VUsNN6lr7xwf1SccNEmusa/lGfBcbSRB8XxIe9GX677s4+FCacAz Jcmurq2ehwUHiwGYeqJYwqKDcB4bn9Ry+jJqfPsaa/VRFQjHra7BfH7654b3i/MefzSFLKJsd7A E6E8GVXO5LP9rEmWP X-Received: by 2002:a5d:5c04:0:b0:48b:f08:8159 with SMTP id ffacd0b85a97d-48c6d1a2ce9mr3586156f8f.40.1791301972952; Tue, 06 Oct 2026 08:52:52 -0700 (PDT) X-Received: by 2002:a5d:5c04:0:b0:48b:f08:8159 with SMTP id ffacd0b85a97d-48c6d1a2ce9mr3586111f8f.40.1791301972423; Tue, 06 Oct 2026 08:52:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1791301972; cv=none; d=google.com; s=arc-20260327; b=byBQIHBrTjDjn242Y2GkFRk0JhhqBtCOCiUwNH+59D8DWVOZsLjbJt9zlvusYPIxAi ueFbJMihaNP+O4rIVkSauZwr1jn9stDWUO2Ff8Q1e6y0GjW09TlVuDYouc0Ufw8XxD5u /aKX4kY3CM3lhzqUXy88ca2KtynxSBUMvDQsCIayJ9vam7lV1eeeYlw9ubt8zksWlhij Cpv0gvEo9LluVotoIEoXhScdZGlxOFFwOnPE5wko0HB9Ge9atjFSfbbI7BQDRzp+NG/0 eWW2EbFWbOc9N1vRgl/xnWf0cRpprhYDyoS2E68qTD9bz6Ri5Yy63UNSbLlLlip4Z0nE JJiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=message-id:date:references:in-reply-to:cc:to:from:subject :content-transfer-encoding:mime-version:dkim-signature; bh=Tk8G7z7A7eh+mIjCmP7Mbxg/WgfCHjo3Md5i1XOhq2o=; fh=QnYPVdomkS75kOFyWHmY/BN6LkMKbJuZG3WzTgxD+vs=; b=EErerOPWXoRiiCpxBNgj8mvdT1AOET8+DgReObqUTmZdKvT7NXTVcqD1oPfqwr2MHT EiFF5d/6s8TZAFk32zuZ6Tlfs7alJNimjeiSKtuEghBGBIkPaBqnyEPeEw3vpcPo3K+6 qc+GJsSg7c6q7OkWZuPv2FExy+CeY4zfHOJlh+xbYOA3MDZXa1eBd2hHR4mtkL2I3LiZ xmcRtDNJ1A1vGvZq6SmSOVxgTe3iwIpltA6jRYevqxhkMniGz0ilHpCiAn1211gJ4oje cjx6K7JrlRekgODChRHHt9aJnfITYTjt9W5trU48NV4HP0TwXJDo+uNoNCtHWIl1PK1c i2SA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=O4DzeSem; spf=pass (google.com: domain of khorenko@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=khorenko@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-48c724962ffsi53950f8f.277.2026.10.06.08.52.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Oct 2026 08:52:52 -0700 (PDT) Received-SPF: pass (google.com: domain of khorenko@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=O4DzeSem; spf=pass (google.com: domain of khorenko@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=khorenko@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=Message-Id:Date:From:Subject:Content-Type: MIME-Version; bh=Tk8G7z7A7eh+mIjCmP7Mbxg/WgfCHjo3Md5i1XOhq2o=; b=O4DzeSemddvR uicIgjHxFpIj2gwQyQMBEyEr9lZ7V/3CJ4wfkfabvZt8y/509UKeBJ82BVLkV73h3GBe19v7sZq91 zLdU5e+B6m6j4wL2f2wPascfbHcgibZoZ1FLdvkcnARcyOdmnK2ISoYENWyZnu0iGfE4+eGlEa1ep sfv9FZK1DOAYzzwH1GaEf8nM7q6WOjPahCjdVNAChyAf4gw6uQ9bkDcRx5N4R47xPHbCMOwBnSN3t hcLI9KTwJgGnGbmx6PDQnKe5YjrZ0z/gWoqP5T7DyVcgB84SgEr1ah2/+Ik8C5THfDhtsh+E7LUo4 kVHGysRfR4SpQoGsl22RMA==; Received: from ch-demo-asa.virtuozzo.com ([130.117.225.8] helo=f0.sw.ru) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1xE7Q2-00EtVg-39; Tue, 06 Oct 2026 17:52:41 +0200 MIME-Version: 1.0 From: Konstantin Khorenko To: Alexander Ivanov In-Reply-To: <20261006144428.341824-1-alexander.ivanov@virtuozzo.com> References: <20261006144428.341824-1-alexander.ivanov@virtuozzo.com> Date: Tue, 06 Oct 2026 17:52:46 +0200 Message-Id: <179130196660.914346.14420180134509591837.b4-review@b4> X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2418; i=khorenko@virtuozzo.com; h=from:subject:message-id; bh=1TZCsEpunoZKK+cN+ilLG+gRCszLFh+clYCnyikqi5Y=; b=owEBbQKS/ZANAwAKAVGWCkf5YVwqAcsmYgBqxRlTPBmRjF65tThon2PYNe6I/MuTMLFkbORzk Mx1PURSx8KJAjMEAAEKAB0WIQRWD23IPcXT0GO9CCxRlgpH+WFcKgUCasUZUwAKCRBRlgpH+WFc KtcID/9kXSEMSa7kYfEE7mexr2BigvV9MhUX+86yHo7UwdYpjqTYmviXItu5X82f1exKuEN7RE0 z/7UhpsjFRoKtUQr0WkSIc111pK3srx0t9i0w54Gs6FSSLmgTBMr9UZa+RvDPjf7B94lYaKArts IANpn0sW/zvx81pcNtbCjENFG9QgLreYvTNLqqXXS5bUZWbMSeAGuGoXio2zTbXOycoWBUA3EEe GEMdyPOWjZyVyLVGrTinUmKr+dSPZ1O2xpw370Jl4LFtz4Gmomk6a9phGcxzEwEjmicDxF4FPpp yULc+V35mw0O2NvUa1LGp0+25FCPbKQpEd1rtZSZwP6GFNjJn3EItRM/970KGYulCT/IzBilBcr 2PqKYqxtNRz6n1pjp98fF0YgbARvDenyZx3Rw8FeZwtBDM8qPGR9QMCWHb8h22DwtB+BlJ7wq18 EeuCR1SROVgnpywo9IRigDey+YRGrlqa4Jhab/osdL0KWuewVt+RGGgzadzAclMhsFC6f0B7ktY kE3VwJWbEDfgaK+Z92ALt8rPzNPq4rFfCyz7c1RMtLOx/g6RVmYjFcnk+409l85/rWzGT+/ma12 hKM55503O/ztBLsW3/EzNqmFPcIKhbvdGcUXqG3uL3nhORxgayJ8cp9JBzhEudsrHgOzROjCjJr UFHvLDn0ZfiIuBA== X-Developer-Key: i=khorenko@virtuozzo.com; a=openpgp; fpr=560F6DC83DC5D3D063BD082C51960A47F9615C2A X-OZ-Fwd: true Cc: den@virtuozzo.com, devel@openvz.org Subject: Re: [Devel] [PATCH hci-8.1] drivers/md/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 > drivers/md/dm-qcow2: truncate unused tail of image on suspend ... > Truncate the file to min(file_preallocated_area_start, used end). > Skip the scan if md writeback failed, as refcounts on disk are stale > then, and fall back to the old behaviour on scan error. There is one more case of stale refcounts on disk: an image with INCOMPATIBLE_FEATURES_DIRTY_BIT set. qcow2_check_convert_hdr() accepts it (the check is commented out), and with qemu lazy refcounts that bit means refcounts were not written for the last allocations, so they are too low. Today such an image loses data only when the allocator hands out a cluster whose refcount is zero but which L2 still references. After this patch the first suspend truncates live clusters at the tail without a single write to the device. The image is already invalid per spec, so this is not a regression in the strict sense, but either the commit message should say that a dirty image is not supported, or the dirty-bit check in qcow2_check_convert_hdr() should come back. > +static int get_md_page_sync(struct qcow2 *qcow2, u64 id, struct md_page **md) > +{ > + int ret; > + > + spin_lock_irq(&qcow2->md_pages_lock); > + *md = qcow2_md_page_find_or_postpone(qcow2, id, NULL); > + spin_unlock_irq(&qcow2->md_pages_lock); > + if (*md) > + return 0; > + > + ret = qcow2_alloc_and_insert_md_page(qcow2, id, md); > + if (ret) > + return ret; > + > + ret = qcow2_rw_page_sync(READ, qcow2, id, (*md)->page); qcow2_attach_file() does the same alloc + qcow2_rw_page_sync(READ) + MD_UPTODATE sequence by hand for page 0, minus the erase on failure. If this helper lives in dm-qcow2-target.c next to the other md page helpers and is exported through dm-qcow2.h, that call site can use it as well. > + pos = round_down(qcow2->file_size - 1, clu_size); > + while (pos >= 0) { Everything at or above file_preallocated_area_start is unused by construction: allocate_cluster() moves it past every cluster it hands out, and relocate_refcount_table() goes through truncate_prealloc_safe(), which sets it to the requested length. Starting from file_size scans the R2 entries covering the preallocated area (up to PREALLOC_SIZE) on every suspend for nothing. Start from file_preallocated_area_start - 1 instead. -- Konstantin Khorenko _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel