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 B49188017D for ; Wed, 18 Nov 2026 13:11:57 +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 6AIDAdYo025431; Wed, 18 Nov 2026 16:10:39 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AIDAdYo025431 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="TWmjrGbp" 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 6AIDAbNe025395 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Wed, 18 Nov 2026 16:10:37 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AIDAbNe025395 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-4916bd6e3baso655496f8f.0 for ; Wed, 18 Nov 2026 05:10:37 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErHktkAqW3pDssr6F1x21vSGEPHD/Xy60FEJJKdwJFouPud4mYp2/Zlfq7PDZAzVMHERyxf83w==@openvz.org X-Gm-Message-State: APuU4Z/34H7XB2L/7aie9PTWsoB7T30vmQktaTDiV3fhq2d7Yhzogq0E r631PaFIC6lKGzGc1GFEQFJTuivnHrGVrds3vlSxjOr/WDFwMpwQZg46Rp/W1Uan+dz8hZfy6xb hUPn+uRnSneSu4JoB95SHbHGiTwep3uwmf7eZ8WqrfkZ1MVWbCJlbbQ== X-Gm-Gg: AZFdTZe/ADJu7YgvXr2a7GUsY6Y37UHSgxqxbIgewv73wHmS0hji1IjD0PmSwBqgTdl uLLsD8DpY8gseIi8dlBgifHEo/7kqRFslaXOBTOIuweMvowEFyRPGFLlLu6ehELEk3NcLHc/BQl ABfG5tQCuQ84F6Tir6rM2tPiIZmypcNswGuAJZbuKluz5xS9oNuItdegeSbTjVLL8zxVZCeSx2N /BEOxB/Wia+jtry+mXSpT0vDgeaf5bt+9ASVm8JtopXTt9QKo/sObrvt9GTIZK38M25oBl2NsxR N0t7+lRgw8s53lr6NMxfnWNoOPyu5JvOlMcrnWhiNlU9c07oGf3LUSZQCQNzXdXjMr+PmCQxiKW FCv0LCZQMQKdOOAX/CYvyYHmwiBo= X-Received: by 2002:a05:6000:4b1e:b0:48b:9ed:b81f with SMTP id ffacd0b85a97d-4a638339891mr5589755f8f.10.1795007436668; Wed, 18 Nov 2026 05:10:36 -0800 (PST) X-Received: by 2002:a05:6000:4b1e:b0:48b:9ed:b81f with SMTP id ffacd0b85a97d-4a638339891mr5589704f8f.10.1795007436175; Wed, 18 Nov 2026 05:10:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1795007436; cv=none; d=google.com; s=arc-20260327; b=QB5RK9vralsB21YcEou8DF3TBxi9aeplaPbKhz+Unxm7ez/UU8iRYeAJ3zCbdH4P9E 5vIMd3F0tfzff/EmY0BfZEuLVlhJpoiALDfHts5FjyGn5pWBLKgrWzQhqMg0iX4Q+x4T 2Y9OMYBsSo/YmaoKWzYtAj0hlUJpHC2V07qDa/2urpVQjirAzSpMoe9pvwBqxLvbPHuH 0XH9JLc/hJll2B9gJ+UqIkCfOLXhhkOgHWxFmBRdq8cFuUPAJH09vJObZsFoAVUi1mum 1fclTa5y1g1JqB7okRik5xD3smCRJH5Vp5AUnJ2nXvZvJI4K9GaTaUGrg+AuyGdiUjNH u9kA== 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=RjETU5ARb8IxOY3k1k99XSlmgg6013lpYG9NXTgasQU=; fh=CMILZ+goaghq6B4UpCDhf0EQp6kYD0LAlmOkUiVCOvs=; b=Vf6cT7oi3ARdXMKLdy8yeKSu3Gfl0KJnLDWiispuUTYXnCCXx8BnklrytVvY3SIEzj PLgHF1QV+1iIk5DEpEMFhkc9pVPg/HXaQGoIgA0u9rZ7+19B+T/0lgCj5JAmZShjePrV GggzrrZcbmtoCzZCvgrv3UFfhZmZX6v/zuxra7aWVvgB27G1d3iBExv+PywM2MJjFW/u VT8NphpI0x3mqjBZrOJtgkX+F3XEdNLBubmLJCTGGmjGIWvL9YmIaZVYApphXcICltq9 2w6NmGmE58axo3KDKmuVqGHyJ34LdW0sI8Zi7i1+zn+W7nDnIcGtXtCWBCG9D9BBX2q4 eIeg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=TWmjrGbp; 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-4a65a1bb04esi4905498f8f.365.2026.11.18.05.10.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Nov 2026 05:10:36 -0800 (PST) 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=TWmjrGbp; 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=RjETU5ARb8IxOY3k1k99XSlmgg6013lpYG9NXTgasQU=; b=TWmjrGbpO2Gi Cghug9sbZpdpFP9NxxZhcdE5+iCGjzzxHdjSWYYgUQu9hXlZoBWZpU0U7ayyxFRFz9clSrhVUEpDm RK2FlOsbsA//NK8UFXOQtEhMS9Q8LUf0khiVEXy76mftWJw+/TLTXeLZJlQUzf64YYuJ450wTN54B RwXDh3U0yEj5flO1cebABbiWUkclecIaf/liV77GF+zXelO6Ey69vbDm/RDN9lXY1xC/8zLPIynQg 4xPE4ftBNdaaDDKt9GVntihLMvOHPy2VDdkgaFqboNC7IXlVLyIHR1JJ7fWt0YUsBds/VG9XNy5r/ axuC68Se8DUM8CtvHgejJQ==; 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 1xTfMX-004oHD-25; Wed, 18 Nov 2026 14:10:35 +0100 From: Alexander Ivanov To: andrey.zhadchenko@virtuozzo.com Date: Wed, 18 Nov 2026 14:10:23 +0100 Message-ID: <20261118131032.3372996-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.2 v8 0/9] 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-3 fix header validation, which the reload would otherwise hit. Patches 4-6 prepare the reload and fix races on md pages and inflight_md that the new waits on suspend expose. Patch 7 fixes flip_upper_deltas racing with resume in ploop_preresume(), where the reload goes. The corresponding ploop userspace changes: https://bitbucket.org/openvz/ploop.ovz/pull-requests/486 https://virtuozzo.atlassian.net/browse/VSTOR-148171 v8: - Add Fixes tags to patches 1-3 and 5-7. - Patch 3: drop the wrong hash of the driver commit from the message, it is in the Fixes tag now. - Drop patch 6 ("dm-ploop: use wake_up() for inflight_md_wq"): patch 6 (was 7) replaces these wakeups with wake_up_locked(), which wakes uninterruptible waiters too. - Patch 6 (was 7): only ploop_destroy() takes inflight_md_wq.lock after the wait, leave the wait in ploop_resize() as is. - Patch 8 (was 9): - keep the waits for preallocation and BAT writeback in postsuspend uninterruptible and skip both in standby; drop ploop_wait_prealloc(); - drop pending prealloc requests while suspended (prealloc_stopped), so after a skipped wait the old allocator doesn't resize the top delta under a ploop of a reloaded table; - wait for BAT writeback in preresume too, as a resize of the suspended device may leave it in flight; - keep dirty metadata on resume without WARN_ON_ONCE(); - drop the stale comment that ploop_preallocate_cluster() is the only place to change file_size. - Patch 9 (was 10): take ctl_rwsem after the waits, so a stuck top delta doesn't block status and messages; skip the truncation without WARN_ON_ONCE() if md pages are dirty; describe the truncation on removal of a live device and the best-effort size check in the message. v7: - Rebase on the current hci-8.1. - Drop patch 1, it is merged as 932bd3ae4705 ("dm-ploop: fix u32 overflow of the delta BAT byte size"). - Drop patch 2, the same lost wakeup is fixed by 50651c191a31 ("dm-ploop: fix a lost wakeup of the ploop_allocator() thread"). - Patch 6 (was 8): drop the dispatcher_wq_prealloc part, a5836033b8fe ("dm-ploop: wait for the ploop_allocator() thread before changing deltas[]") already wakes it with wake_up(). - Patch 7 (was 9): keep the wait for preallocation that a5836033b8fe added to ploop_suspend_submitting_pios() after the inflight_md one. - Patch 8 (was 10): add the missing Jira link, Feature and Signed-off-by. - Patch 9 (was 11): ploop_postsuspend() already waits for preallocation since a5836033b8fe; make that wait killable and skip it in standby instead of adding a new one. v6: - Patch 10: new. Clear ->suspended in ploop_preresume() under the same ctl_rwsem as the noresume check, so that flip_upper_deltas can't pass its check between them. - Patch 11 (was 10): rebase on patch 10; mark a new ploop suspended in ploop_ctr(), as it is not live until the first successful resume. - Patch 12 (was 11): fsync the top delta before the truncation, as BAT writeback finished after ploop_presuspend() is not durable yet; drop ploop_set_suspended(), which is unused now. v5: - Patch 9: in ploop_destroy(), wait for inflight_md with wait_event() and then take and drop inflight_md_wq.lock to wait for ploop_dec_inflight_md() to release it, instead of waiting with wait_event_lock_irq() under the lock. Reword the comment of ploop_dec_inflight_md() and the commit message accordingly. 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 (9): 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: fix use-after-free on the last inflight_md decrement dm-ploop: fix flip_upper_deltas racing with resume dm-ploop: reload metadata on resume dm-ploop: truncate unused tail of top delta on suspend drivers/md/dm-ploop-bat.c | 255 +++++++++++++++++++++++++++++++++-- drivers/md/dm-ploop-cmd.c | 1 + drivers/md/dm-ploop-map.c | 31 ++++- drivers/md/dm-ploop-target.c | 179 +++++++++++++++++++----- drivers/md/dm-ploop.h | 16 ++- 5 files changed, 425 insertions(+), 57 deletions(-) -- 2.53.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel