From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.215.175 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796303181; b=IIT0nPaOnUMQzqoFbYFyIVp3ELALhEJCOpgunGoZF7nbn4LzBiDbHUwnilw7E3INwjrQ ShhZ3GEDUtqif6qERdkU88xLzURuZAL60RlPRHc6z3Hgx0wt7pZM/mHRB0i4k8h0nOiAS c5uveqPIU92PudYNk0R6uDjfBWDuiXOICzU24tzPfCkykWVp1zatBCtDDDsquHqR8DvCp u5dDw5Vb3t8n5pX22EIYwWIsd2Xqqo3GPhRuUGhViUX3UzXfp/Xaw7COtK4BroUh2IXMl 7wF2tB04M5HTQHY9tEtvEsAxs3QBWSoZXq4KHcdAEafV2EmOB6Lzz5A48vRL8vD6fXg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796303181; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=oIEyPnhCIOR+gRg75nmikSG6kGwClCzsvG4U1dWpA3M=; b=y2JIMlgTTnDcEhqOW2/TG4dztdNYrQTAWE5H+X5DsUk4K+Ozvrtsz98wGOuIFt5HtH25 Yse1goO3WdwTUgDt+Qh4D8mxVpMTjQ0g21b64ngqLKDNHE2rpz2g8c9EcoJhPn3S/A6hG KUfDmif7bIaWfXlb/Z+wFFTRygLwlSadNFw/qLh6BPfA//BefWBPZArMGuAQvs31CNd5m C5gH7pEUhZDt6I6//eBdEqhs2Iq/QJbwd7ZzxUwe+McqO+sgEd5NepLVAyd+lZ34pfm5M IIeYqusSroLGCEn1AH6ey4CmAd68tkSID4YQiLfF6H47S012Iq5234cC9H7MbWxwslQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=tHXiyJin; arc=none smtp.remote-ip=209.85.215.175 Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 738DB606A322 for ; Thu, 3 Dec 2026 13:06:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 738DB606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=tHXiyJin Received: by mail-pg1-f175.google.com with SMTP id 41be03b00d2f7-ce1186c9e40so273841a12.0 for ; Thu, 03 Dec 2026 05:06:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796303181; x=1796907981; darn=vger.kernel.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=oIEyPnhCIOR+gRg75nmikSG6kGwClCzsvG4U1dWpA3M=; b=tHXiyJinhgps/q3Dfr6lSDWZ/iA+UARlUPGMj1D0KSBwNxF0KWrtntc80mwukvkJIG jIrAEgQYVILeg7qTF/EQ6KyJRbXQNmGntHJhDpS6GD1zR7nyc0PTp5Shc7OR2QuCLmos wlgrZeciP7olZggbLWR3SLteRh/XJ52nguRjx1zy/C93LChyshb3HZgmyCKqvzLU3Yrh D9LmsprBNDXDiTl7CtvtB5PYEjD+m4QDctPQe0de0fS9srJt4F2Qodm1RiBHVgMqk5mE QER1MRLSFhvA7ZaPV0UCDEwB8PmfALdSqM+qXlfKuGtjtQQFkEfUENsxtiFch7vLllfR CGRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796303181; x=1796907981; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=oIEyPnhCIOR+gRg75nmikSG6kGwClCzsvG4U1dWpA3M=; b=ElUtWDeaSFxBTuZi1jxRRDWSGWuKTtWxp6csyiKiufNCpm9P012wk9DLcp4utZejcK L91uP6cau3tlsOcKOJsFn+lu4ht21oJUWanFqed4nAYxiRFGX2wDTpXgv8JBMH0O2iE0 gDeNWQJCLcbDzfdvL28A3Fe0NGq5cIbX8cb1biBP7KlSA05xXSGRd0SCn/Y4CwneczIW YBySTSYypIk4dbtXqyHa2qySmKjW6Negp7CyANrZHV9jAjufOVd5QdL+OKlfBwZbua+R SpVArVVH2RFQMCYqQ+1KhpHCxkVMQPRajqd5oKmWouUZCKwQRAoH8oGVAXWIhvzj1FAq 8TIA== X-Forwarded-Encrypted: i=1; AL+hErFTClMG3MiHgLHBUwBBApwpaxXlQP/InngZDp9h3FCqbHhzQTzr+XFLOWn/WCv/wStfk+GJmuYgD/ggP/Q=@vger.kernel.org X-Gm-Message-State: APuU4Z/wuvvGzMB7h1Vw0W/bEuL8g+E1l5Sxxa1TL4IjNyXJV7SMkBwj WTHgdeoD7aWrOJUwDVyNJsPuoN2AtOONsGHm7MtDtccOZdXKn8WGWqgY X-Gm-Gg: AZFdTZfT1D/5Fc94c8QavdarE5ALay3VAc2la14PI4aBy7r/cTQ3E+rTlIugypHajIl PBgRaPwm50P05yo1GUJieOSoT30MafoSSUiCa6GiDKzWUO5NuOBS/wAjxwIQ2//8Dd7T9Tvncp6 VrhKPEom34dwT66q6glMFMIwDbEwTRrozhgMM9XAyVqtM6oDofvjbvJm3PQQDavAFbAofCN4DfJ 9sY4mI8xx8ndI5zNMbzTsuLaVIY/CXvYD6ajLQa1WzbxHnj3sf+5dAl/Fwr1ZmAVEu3ySscO/FJ F6v2onBGZRJ2cHct0tcl/2Pxq3eZ8vNh2narrLBl0Agk/OIKBlLkpxHHMm4xPih58Qzziwt7C9o JDPD7O/lMJ2Hy6eBy2C3pXk9ThgRCv572n58ZOmWIB84rNJnG2X8632VVeNGsbinxNRo3JKxZ7f HajhI7grKXYMUSSYKCdQby8aC85vsV+VwNcgiHwXNGHrGwj9LPRUO6R2bIZfjnThmKPbEesyFTe bQLWPuB/jgFtdYroSjo3AEGIjWssn91Y+2mxRa5MuRo1O7+yMJKvFFYK7wm4q5ne+xFUvXhjwyU AK0CkScRptsYkg2HyFivD6saaBnIwpyIAC5+gxzH2jCXDi8= X-Received: by 2002:a17:90b:17cd:b0:3b0:bc3c:3e7 with SMTP id 98e67ed59e1d1-3b41c8ffaaamr41859059a91.10.1796303180529; Thu, 03 Dec 2026 05:06:20 -0800 (PST) Received: from localhost.localdomain ([2404:c140:2100:6::1b:9648]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-cde6d028a54sm22209945a12.18.2026.12.03.05.06.15 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 03 Dec 2026 05:06:20 -0800 (PST) From: Ding Feng To: tytso@mit.edu, adilger.kernel@dilger.ca Cc: jack@suse.cz, libaokun@linux.alibaba.com, ojaswin@linux.ibm.com, ritesh.list@gmail.com, yi.zhang@huawei.com, hughd@google.com, david@fromorbit.com, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 0/2] ext4: punch hole beyond i_size Date: Thu, 3 Dec 2026 21:06:06 +0800 Message-ID: <20261203130608.64892-1-dingf3ng@gmail.com> X-Mailer: git-send-email 2.55.0 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit ext4 cannot punch out blocks that FALLOC_FL_KEEP_SIZE allocated past EOF: ext4_punch_hole() returns early for a hole that starts at or past i_size, and ends any other hole at the block that holds i_size. Patch 2 lifts that limit. Patch 1 fixes the range the punch records for fast commit, which wraps to 0 once a hole can run to s_maxbytes. Changes since v2 [1], from the Sashiko review [2]: - Patch 2: keep rounding a hole that reaches i_size up to the end of the block that holds i_size. v2 dropped the round-up with the clamp, so punching [0, 5000) or [0, 6000) on a 5000-byte file zeroed the EOF block and left it allocated (st_blocks 8); with v3 it is freed (st_blocks 0), as on v7.4-rc5. Changes since v1 [3]: - New patch 1. With v1 on a fast_commit filesystem, punching [0, s_maxbytes) over a 1 MiB file, then fsync and a shutdown, brought the punched data back after replay; with v2 and v3 the blocks stay freed. Patch 1 also moves ext4_fc_track_inode() out of "if (end_lblk > start_lblk)", so a hole within one block still queues the inode, as the old call at the end did. - Patch 2: zero partial blocks only for a hole that starts below i_size, and Fixes: 2be4751b21ae instead of a4bb6b64e39a. Tested on v7.4-rc5, x86_64 under QEMU, ext4 with 4k blocks: - fstests -g punch: 24 run, 27 not run; generic/042 fails with and without the series, nothing else fails. - generic/811, "generic: punch a hole past EOF over preallocated blocks" [4], fails without the series and passes with it; it passes on XFS. - The fast commit crash check and the 5000-byte cases above. [1] https://lore.kernel.org/all/20261203115201.48810-1-dingf3ng@gmail.com/ [2] https://lore.kernel.org/all/sashiko-outbox-247711@kernel.org/ [3] https://lore.kernel.org/all/20261203091435.73786-1-dingf3ng@gmail.com/ [4] https://lore.kernel.org/all/20261203115229.50163-1-dingf3ng@gmail.com/ Ding Feng (2): ext4: fix the fast commit range of a punched hole ext4: punch hole beyond i_size fs/ext4/inode.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) -- 2.39.5