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 3DE30803BB for ; Tue, 10 Nov 2026 22:30:24 +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 6AAMS1UF019061; Wed, 11 Nov 2026 01:28:04 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AAMS1UF019061 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=default; t=1794349687; bh=ZHCz+TGVd0hL8R/N/ctWalrH4nW+DEAkWoUktz2KWZ8=; h=From:To:Date:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe; b=YVgdL/w89CeqftzzKhMa9luf5PAZ9K9GgqArUG1cliDXXWm60vez9sSIc4lMgm8kx NAvEydKkE3ZnLgiCQxHa1NkS56jOdWtA5KZ2IGa4xQns29wUYstcJ2VY56GkzITvY6 Z9sjnk2hfnues1jfxCbL4EC2DAOIGQVBqeSoIaPyHP3aw//+dwtjy/bKZnU5BrXtUH VIiYf4RbwT1HquKM3J4zWIzc9YGj82fzyICtb2ahFqhIfyflke9UfnOpX/PDn7KFGq 3+AzLHvms+8/hnAtnxNfTBgqrNmZKqt+W546xENy1yIB5wsrr0gwwkPStu7mkPWbxN DSURycQ/oGSHQ== Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6AAMS0tx019051 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Wed, 11 Nov 2026 01:28:00 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AAMS0tx019051 Authentication-Results: mail.openvz.org; dkim=pass (2048-bit key) header.d=openvz.org header.i=@openvz.org header.b="VqiB+8mV" Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4b764ffc014so23245145e9.0 for ; Tue, 10 Nov 2026 14:28:00 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErGGo4u8jmVObYo3wneNGtfvgViI+xaPtXNxj6xT2S3rAMt8V3x3lSxfWGvSYqvjydHTxbehAg==@openvz.org X-Gm-Message-State: APuU4Z8C/zqyizYjofWJBVI7LdeDXsV+1rXpyQrmqubUhVaKAIx+E/a1 wgNhOjZRbUeZb94KWJcAkv7OWWrMrOBPc72QPRzlSdJfmPlKtAFb7dxIAkXieJAkoIRXPWImaj5 njN+x1rxfwJ6p4l2homSwe4VNRKJwFASmFSdDkrhFEPrZi7/trKuJcw== X-Gm-Gg: AYBFou2Uy09KpobhSyQEuRtu0WszveT0L18Ef7pr/gp/SPs/H1Bja10EAz98nRO8ApD tD6TskLRDO5QhQLRfW4l2YwVQWIDFabcp/7luBYBihZg4mQR3j7TZl5x2TBT290tCgQ2IhONPNH gTPfYeAnp/WFPyG1OP4E3BxXolYsATwbCaxzGobJuPPmzXQniv+xuJ2XBolFK7L92xJ/RF41lHf DIVeloO63RrxJQnuWUp/wCrOnF2pzJ3Ts6c1xU0xiiN2A6Tx2u7E1UU0uMl7n9eZJ9W44Xryrmv t79E0Eky9Q== X-Received: by 2002:a05:600c:4f84:b0:4a1:e92b:ae4a with SMTP id 5b1f17b1804b1-4ba093b9a3cmr7242055e9.21.1794349679806; Tue, 10 Nov 2026 14:27:59 -0800 (PST) X-Received: by 2002:a05:600c:4f84:b0:4a1:e92b:ae4a with SMTP id 5b1f17b1804b1-4ba093b9a3cmr7241945e9.21.1794349679479; Tue, 10 Nov 2026 14:27:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1794349679; cv=none; d=google.com; s=arc-20260327; b=mAvluUQZYfEs4fBXky/1EWTaasdC5Ff5SSxLk06jjcAAP9qgdYdT3T8Wfm3C84Cryv vK2a73Gpg4Vp+5Bx6PfPN5wuCW1Hi7g2XadIfru/66cSsskJge6pwvtvfbKvIoley2Ya IcXP2C9FEKjQw8mqgO23j6olYRFaprzKWmb6Iy6Prqr247sxNO6BjhNjp8Im6gNI4alN PYSMCMrlUpMNqc0hitc5yYC0N8GRSuwszw0B8l/RETPAplkqt9Cd0H5j6l+1JEAdoHaJ XS3lf79Be4B81Nh4KDWsnFcLzLi3OjL7o15syap/LXs3HT8TB+GJuVUe5M9H93gchALt VHIA== 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=+ZLVMzRnF58nAUc2EvzthpW4fVdWROYOvvihNr1Jmvk=; fh=Ik/2Pt6ylM9eKngJLGYk94quRjkQqsDI325nUuBoRdA=; b=iFDeA5kpRyRInmCpnejE5qRNLJaMdMTkM8JA+xe0LP5nghifCWNme+j6PN2WhvAKQF 7uB3hSlqHfWphLbM1CH53TVmwBRphxN5X4HZoUaoG4MGwZx5IestGpKOTkja1UQI6DVJ 1CaxUNsXbrNHNGQT635WYeCky/1hFpCfoiFhgWVQTw0R/POBcOcSPJo0tv4iBQ3lTZhY 8GMhnsTDB9c6X+yiU3CH8BHmtwyjpRnikEbg53q2+5YLxLKA/4Ved5uXYMK7mmlzPHSE 2yxz3seQUcOv5m7ktbY4hrQgJ6DVESKl+rD/QSzYEZB0o/Pc1EgWfaR4Pjm68nIhhliq KVTA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz.org header.s=google header.b=VqiB+8mV; spf=softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:4f78:6441:d0f1:22af as permitted sender) smtp.mailfrom=den@openvz.org; dara=neutral header.i=@openvz.org Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id 5b1f17b1804b1-4ba01ff225bsor9184725e9.10.2026.11.10.14.27.59 for (Google Transport Security); Tue, 10 Nov 2026 14:27:59 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:4f78:6441:d0f1:22af as permitted sender) client-ip=2a06:5b06:b600:300:4f78:6441:d0f1:22af; Authentication-Results: mx.google.com; dkim=pass header.i=@openvz.org header.s=google header.b=VqiB+8mV; spf=softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:4f78:6441:d0f1:22af as permitted sender) smtp.mailfrom=den@openvz.org; dara=neutral header.i=@openvz.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1794349679; x=1794954479; darn=openvz.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=+ZLVMzRnF58nAUc2EvzthpW4fVdWROYOvvihNr1Jmvk=; b=VqiB+8mVMLz6vHGS5sTohLuJNfai+CbiQiaux5bkboyUpNrZCiwtG2QH/nHE5KIOjZ JQ1TFSR+6NYwCs0BkqveEVMk9veuNNwuIzcda4oGfHOsw2iSbvhBdes+ezCpUOw5oOKK yM2Sa+B3OfQmnWlnnwMar2JlrC+A9XLEOHgtaZZAQg9pPkuUyTX/XGnEXiWErhnqoR/c P3nFM2Ju28QDhditYPntnk5DR+gF1uERMmoWWXy06zQVFqCQS4+zUVpLlylpqLCywglu 70n6Np5SPoMeG25bFFELuvH2Q3/4z++n04hrgTIhky3PuWgMOBDfgOC4EYA7sodx9FwC F4ew== X-Forwarded-Encrypted: i=1; AL+hErGq+tEMwdZMHHchLXMGhcb7j5Zs94SoDRbcPrslE8C08ZcHQWukEQ9f/L1Vp15WItGTelD/wQ==@openvz.org X-Received: by 2002:a05:600d:82e4:b0:4a1:da58:1ee with SMTP id 5b1f17b1804b1-4ba093cd6d3mr8118275e9.31.1794349679001; Tue, 10 Nov 2026 14:27:59 -0800 (PST) Received: from athena.sw.ru ([2a06:5b06:b600:300:4f78:6441:d0f1:22af]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4ba09536ebfsm8923155e9.5.2026.11.10.14.27.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2026 14:27:58 -0800 (PST) From: "Denis V. Lunev" To: khorenko@virtuozzo.com Date: Tue, 10 Nov 2026 23:27:52 +0100 Message-ID: <20261110222756.3236854-1-den@openvz.org> 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 v2 0/3] ext4, xfs: discard the balloon on FITRIM 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 The balloon holds filesystem space that never carries data, but its blocks are allocated, so FITRIM walks past them, and inflating the balloon is a plain fallocate() that does not discard either. Once the balloon is inflated over the blocks of removed files, e.g. on an online shrink of a Container disk, the ploop or qcow2 image keeps those clusters mapped for good, and compaction, which is FITRIM, does not give them back (VSTOR-153590). This series makes FITRIM discard the unwritten extents of the balloon after the free space, on ext4 (patch 2) and xfs (patch 3). The walk holds the inode locks of the balloon exclusively, after waiting for direct I/O and flushing its page cache, as punch hole does, so no block can be freed, reused or written under the discard. Physically adjacent extents are merged, so that the device below gets whole clusters, and a long run is discarded in interruptible chunks. A balloon inflated before this series is released by the next FITRIM, no userspace change is needed. Patch 1 fixes an inode reference leak in xfs_balloon_get() that FITRIM would now hit too. The ploop side is openvz/ploop.ovz PR 519: tests for this, and fixes of the ploop-balloon discard options found on the way: https://bitbucket.org/openvz/ploop.ovz/pull-requests/519 Changes since v1 (https://lore.virtuozzo.com/kernel/20261110212459.3158424-1-den@openvz.org/): - take the balloon inode locks exclusively, wait for direct I/O and flush the page cache before the walk; v1 held the shared lock, which did not keep writeback and direct I/O from converting an extent the walk had seen unwritten (Sashiko); - walk to the end of the file instead of i_size, as fallocate() with FALLOC_FL_KEEP_SIZE can leave unwritten extents past it (Sashiko); - discard a merged run in chunks aligned to the discard granularity, checking for fatal signals and freezing between them; - drop the read-only mount skip: ploop does not set balloon_ino on a read-only mount, and the free space pass does not skip one either; - ext4: do not count the balloon in the trimmed length, so fstrim -v no longer reports it as freed on every call; no 64-bit division on i_size any more (Sashiko); - xfs: fail FITRIM on an error reading the balloon inode, use GFP_KERNEL, and fix the xfs_balloon_get() leak in patch 1 (Sashiko); - every FITRIM still discards the balloon again: neither filesystem bumps a counter on fallocate() of the balloon that a skip could rely on, and a wrong skip would leave clusters mapped for good, while a repeated discard of unmapped clusters is cheap. Tested on 6.12.0-211.52.1.22.19.vz10 rebuilt with this series and the VSTOR-154159 max_discard_segments fixes: - ploop and qcow2 images with ext4 and xfs: write 2G, remove it without a trim, inflate the balloon over the free space, ploop-balloon discard. Stock: the image keeps mapping the removed 2G. Patched: the image maps about as much as when it was created, a kept file is intact, fsck and ploop check / qemu-img check are clean; - 16G removed under a balloon of about 38G: a full fstrim takes under 3 seconds, a SIGKILL one second into it ends fstrim at once, a repeated fstrim takes a fraction of a second, fsck is clean; - test_ploop_balloon.py from PR 519: green on ploop and qcow2. On the stock kernel only the tests for the space under the balloon fail. Not covered: ext4 bigalloc, a realtime xfs balloon (skipped). On ploop1 discard works on whole clusters, so up to two clusters at the ends of each contiguous piece of the balloon stay mapped, as do pieces shorter than the FITRIM minimum length. Denis V. Lunev (3): xfs: release the balloon inode when xfs_balloon_get() refuses it ext4: discard the balloon on FITRIM xfs: discard the balloon on FITRIM fs/ext4/mballoc.c | 126 +++++++++++++++++++++++++++++++++++++ fs/xfs/xfs_discard.c | 144 +++++++++++++++++++++++++++++++++++++++++++ fs/xfs/xfs_super.c | 4 +- 3 files changed, 273 insertions(+), 1 deletion(-) -- 2.53.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel