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 2565E8017D for ; Mon, 12 Oct 2026 13:28:22 +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 69CDR6x6022893; Mon, 12 Oct 2026 16:27:07 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 69CDR6x6022893 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="RMYKNRDc" 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 69CDQteh022841 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Mon, 12 Oct 2026 16:26:55 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 69CDQteh022841 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-48c427421f6so1302581f8f.2 for ; Mon, 12 Oct 2026 06:26:55 -0700 (PDT) X-Gm-Message-State: AFq9FYJM2WTM/iyHPhWrsHjLWsUYNlcVI4Rmp4JCd+flU+TuQz319wu+ UbK0bd6sXIRKsaWoubTua4Z4kzVatDER/6IjcsvERImHKVU6VhCu4mkdUeoE/zJuFXiLCLrTNRi r9cP4WmIRUg4wQaZB76MrsGxcbT2zKlj84csUlolFCDUIx2qkPHbhmA== X-Gm-Gg: AYBFou37jV1r1Lqwm+2lytE2itftWdCrLrZBvvPtoK5Cq3jbCj1HFx+E7kFs/zeTT7Z pzMLOhjsmHrVBhZedJTQiBjtJnj2UB2Is5T+b9soC2DTPVS3R1XZ1GT17jQWTiChUhlJmJ5sVsc 50SY2Zn2RY13yNN91/uepGxoF2FIZvaSdFQ0tQTPvTuRK/RzVXRBu66OvABMkuzngP7/iQlTF/L Q35Bgdjj6Vvf1veiephXk4GSG2PIbOjDo81/dEAYbZ+hcKeOKwhuaTRq+jePrhwcXtkvGdZSijE DK9AsAd5uYcrgukahqcvfkJJnQhvd4qtM5ULJ8OMHo7E0XEFUdrxzbTTytC2WODIlo0y6G2etGM iYc0DALeyfmKgf0eOc3zTe7d5qpEQ X-Received: by 2002:a05:600c:8105:b0:4a1:714d:eed with SMTP id 5b1f17b1804b1-4a18e4841c1mr169277825e9.14.1791811615221; Mon, 12 Oct 2026 06:26:55 -0700 (PDT) X-Received: by 2002:a05:600c:8105:b0:4a1:714d:eed with SMTP id 5b1f17b1804b1-4a18e4841c1mr169277035e9.14.1791811614456; Mon, 12 Oct 2026 06:26:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1791811614; cv=none; d=google.com; s=arc-20260327; b=BmKCJkLaSHhszI84+sieBntGJSwRk8rV0VGZDZ1ahfW/M6NNyE96omwUjTQ5dsXPJK QBiCCvhJUz3+Sk45MfuZUMimmi/2L+F8wKraYyQam2YNrFVcoFuZtYUa1vzN2vU5jTcC 32SwTh6WqMxW0jjmJMc53+AG6vAcR84uV+xSDVIcINoVcOdQdU6Xe79XzzVNXAZZXR00 UvLLEDXHXT3hSx18dpTE52kPxc1SHl0RA6WvKhquI4dMqW750o+Hfc/1SGwSXjwoRmZi 8aBV2RPyqbf5aWIM+72aqhyWluV9RP9WzXRxGQcxiv0edA2KK7erPAVYxyy1FPjSRcCh PzNg== 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=boB4mWV82Eg+aNoiIyORisKDuLzXK9LzyInlBmGd82k=; fh=M+TyAUhAp4+t7uzAVeqNdLHW5eNz2FQXSv4TjrRhpCk=; b=S53yXoDUrWkxYXNyirMxtntU7bJ9b8QcEZVh8+lzNuxIx3c3JX1A+nolNHaRkxCenh Y6OV0bjwBepi+iDDVXHYllk1Bs7tVyAyVt/3wO/4IoVBFIyQMJK6fBFdiwixvOvMCbck SNa19ke1CNmlfp2GQ0pM7/CuUI/0jHyeaExxLTU3ARlPOutEgnK58NomwkfS4BB0f3dA fVDRZUeRTbsgLTu0zZU+hwJsHKxopUqMkpknmqaasCLp5YKss3x4PNBmNBuWVFmGNO+9 os8/+40Lk54C5+DmH+f5tcCeb/9RjIqxCPyrzHx/YZss3oAGXNRa8zr0Cn/xBMgHNeS1 HOxA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=RMYKNRDc; 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-4a195e31a8esi203495875e9.5.2026.10.12.06.26.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 06:26:54 -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=RMYKNRDc; 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=boB4mWV82Eg+aNoiIyORisKDuLzXK9LzyInlBmGd82k=; b=RMYKNRDcmG4y sK52MJq9HJfzbLytIjNEiib6MOoASN83ZFoINUr4jT7brTq+86q61VINaFeCrnj4CrZXHOEYw7xdt NfEl8Elx/11Eo0TxM/u7gMFdy8DshrDyAnWzuxszk5RtN8eUavPJvqUIE7HbTvCSQZTnOdhi+vfDA pNZzWZmhgB7arbBQXzy4OMXYXXmVvoaXji2RL5P8ap9+NSxHY2V9jGnOwarHoBJrtFf4tOVQ6UAzH 4aeSFzyCq1aM+mnYHPvgZSGSUKZAmiHcUedj3zlDseH9XdHknzMOt1EA8/PyhzGhMrkOw5xIbiQpt g3q2E5QMPfMKzdYdgTsitg==; 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 1xGFzv-001WAY-0J; Mon, 12 Oct 2026 15:26:44 +0200 From: Alexander Ivanov To: den@openvz.org Date: Mon, 12 Oct 2026 15:26:35 +0200 Message-ID: <20261012132646.41494-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 v4 00/11] dm-ploop: give back unused tail of top delta 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 Preallocated space and clusters at the end of the top delta freed by discard are never given back, so the image file never shrinks. The last patch truncates the top delta to the end of its last used cluster on suspend. The next resumed ploop must see the new file size, so the previous patch reloads all the metadata (header, BAT, file sizes) on resume. This also fixes "dmsetup reload", after which the new ploop worked with metadata read in ploop_ctr() while the old one kept changing images. Patches 1-5 fix header validation and a lost wakeup in the allocator, which the reload would otherwise hit. Patches 6-9 prepare the reload and fix races on md pages and inflight_md that the new waits on suspend expose. The corresponding ploop userspace changes: https://bitbucket.org/openvz/ploop.ovz/pull-requests/486 https://virtuozzo.atlassian.net/browse/VSTOR-148171 v4: - Patch 1: was sent separately as "[PATCH hci-8.1] dm-ploop: fix u32 overflow of the delta BAT byte size", unchanged. - Patch 2 (was 1): drop the comment above set_current_state(), add Reviewed-by. - Patches 3, 4: new. Reject a top delta header whose BAT does not cover the target, and reject empty deltas, instead of skipping the mappings of an empty delta in patch 5. - Patch 5 (was 2): say that raw deltas have never worked since the driver was added; drop the empty delta handling, see patches 3, 4; add Reviewed-by. - Patch 6 (was 3): fix the stale comment of ploop_add_delta() about the order deltas are added in. - Patches 7, 8: split from patch 10. Patch 7 takes bat_lock around md page lookup in ploop_llseek_hole() to protect it from resize, so llseek doesn't wait for long control commands. - Patch 9: new, fixes a use-after-free of the ploop on the last inflight_md decrement from BAT write completion. - Patch 10 (was 4): - test MD_* flags with test_bit(), they are bit numbers; - keep the in-memory m_DiskInUse only after flip_upper_deltas, take it from disk otherwise, so the CBT written on umount isn't lost; - don't wait for preallocation on postsuspend in standby, and make the wait killable; skip the reload and prealloc on resume in standby or while preallocation is pending; - track standby per ploop, as ploop_ctr() of a new table clears the queue bit before the old table is suspended; - drop ctl_rwsem and the suspended check from ploop_llseek_hole(): dm core doesn't call it on a suspended device; - describe the new preresume failures in the commit message. - Patch 11 (was 5): don't truncate in standby, if the wait for preallocation was killed, or if the file size differs from top->file_size, i.e. another ploop writes to the top delta. Shorten the comments of ploop_calc_used_end(), which repeated the commit message. v3: - Split from the common series with dm-qcow2: dm-qcow2 patches are sent as a separate series. Patches 3-6 of v2 are patches 2-5 now. - Patch 1: new patch. - Patch 2: also skip applying the mappings of an empty delta, as BAT iterators can't handle nr_be == 0. - Patch 4: wait for inflight_md on postsuspend, as data bios are completed before BAT writeback is finished, and use wake_up() for inflight_md_wq; reload metadata under memalloc_noio_save(), as the device is suspended; restore m_Sig, m_Type and m_Sectors on reload failure. - Patch 5: don't truncate anything if m_FormatExtensionOffset is not cluster-aligned or out of range; truncate under memalloc_noio_save(). 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 (11): dm-ploop: fix u32 overflow of the delta BAT byte size dm-ploop: fix lost wakeup in ploop_allocator() dm-ploop: reject a delta header whose BAT does not cover the target dm-ploop: reject empty deltas dm-ploop: set delta is_raw before applying its mappings dm-ploop: factor out ploop_read_delta() from ploop_add_delta() dm-ploop: take bat_lock around md page lookup in ploop_llseek_hole() dm-ploop: use wake_up() for inflight_md_wq and dispatcher_wq_prealloc dm-ploop: fix use-after-free on the last inflight_md decrement dm-ploop: reload metadata on resume dm-ploop: truncate unused tail of top delta on suspend drivers/md/dm-ploop-bat.c | 280 ++++++++++++++++++++++++++++++++--- drivers/md/dm-ploop-cmd.c | 26 ++-- drivers/md/dm-ploop-map.c | 79 ++++++---- drivers/md/dm-ploop-target.c | 152 +++++++++++++++---- drivers/md/dm-ploop.h | 22 ++- 5 files changed, 469 insertions(+), 90 deletions(-) -- 2.53.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel