From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.215.181 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796307349; b=ZYhm4pphNW0F/a+BTUjbC1gB/sxbiFpJ7TFVPPE6zbS4nXc/i+SgBpLVErWXYM5wLfUj HCkzDqEtHnFYGU9lZhzzxW0xozM+hsbSfuFhfdAWA+5Q4VIOoBGZLvVpwjO/fxDG28r05 KbzGX4x7PuzKDR7Yk7GcVDvc+RwDm4J+tVX1ToOBwEtdV9aRttWp+vo2aKpHcH89N9xWg Z6s8rZ4x7jEaPxb2SQQ2DRkCtqBVYbsOzGcAS+sKFBnmJ5y+1O2B6L/rSfcVuWf6orG63 M4Kpo+1cyv15nqYJszmCZQ2/QLNLT8wOZ+i+eMrZAnMGSJy8CJe8zjMgkkMPpeSL4Gg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796307349; 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=ix5RjfvCQDa2D180z7yTQDxPH5erfyMFjVQKBMifXb0=; b=ush6TuAVP1+GElkhMYsDsbvS2ZeyFnkv7h8zFG6TZfZ1AU4R+WSQvvkTO51hh0NAQamp 5VszruSLsWLQsm481KLo1MvwBi0IMLyeXRe66oG1wRGe5ffm9+DTZf9HmkBGzqMudV94c eaaGDwNH8h1d913XCG9oS3eaHAOebbzIuXOmgnOhu0nd97rVTFbvOLmYy8FkMjntWoKjQ ILd9MzXS/5PYGFjOuldsd7H0TJwYrmcXwkeV+c+HEJaR0je36GVsQdLXzE0zattV99zso G8MVa3Fks4fv6zOuH3XPrZEN2WtoY3oFat9xMF6XWUTw4sf1kW4BdL9OKSjC+/gMyqQ== 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=kvbyEE8B; arc=none smtp.remote-ip=209.85.215.181 Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) (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 569FD606A32C for ; Thu, 3 Dec 2026 14:15:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 569FD606A32C 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) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=kvbyEE8B Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-cdadf7e248aso6568531a12.3 for ; Thu, 03 Dec 2026 06:15:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796307348; x=1796912148; 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=ix5RjfvCQDa2D180z7yTQDxPH5erfyMFjVQKBMifXb0=; b=kvbyEE8Bzrp4NiVilhpHepx7x+qy69DDGB1vv3UGZHFkWLdahGKXxh+szI4mLSrJAL K+lyZZQB7N6nZhIa+1RE7KthBMg6hghr5ZK23AUwfPEmi0iDmk4ZpYtrroJWXR71XdTZ sY9Emgne8KfO1+uvGvJLDTeR1j7ofYwAtNysdpkIXoY6UKPH/AOKQoi4TlxXTxL1R5+L TPohzZ6uFaTfG5jUE60yllDMpmR1IAeeBVXzlrephLWy6XU51Q7QRFcCwzrqWV+WqCYK GPabw1SZkBeZdAISmHcolcKuORDiqGYKOwOdP7xEKHO1LHSr6GcpClnH1KoiTRshM0l7 jcEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796307348; x=1796912148; 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=ix5RjfvCQDa2D180z7yTQDxPH5erfyMFjVQKBMifXb0=; b=XJRoEcqerpupcNYNP42we3LhcSilYYUrRn7dXpAyQApFhdAPK88NcVRLUTzHYOk+1g Lvry8XPMkNm2CbYd/fYIVuwYoWZPgi0xitgN5CvJ1lQTrqHfvk4kU4SWphMeGH7nv4Zn e5SZ2cddizS8pAtke+uTVMO5yx8SyL7ExnEj62mYXHggkC8HpqzDte6ncCq/pfpT+T/C zZiN6NahZj6MLHmnV5qXX3+BxNv1w5QESAic9OeOeobKlZVYKSAm2ma3H86apsufM0Or wphDUmLfid1LW0oTEaIdTw7gZGqj+NEsi0PzgfmYHGnimXOyWwSCDRfr8JqxiXnEEYRs 4RKg== X-Forwarded-Encrypted: i=1; AL+hErF3Ze+6v5dkaJFhDKTQYEymEbd4lYhUwotjrpefALFBQ5xYStesFhdz+s5/zUphoVCb/A0Mg1SaZ/iG@vger.kernel.org X-Gm-Message-State: APuU4Z+XJC64r798SdX69wabU0mlY3IAwlWH+jqsMqgvJtIC7r61CHF7 oy033cAKMqVxBYrTXJ2qZfBc8LSb6WvN1Td8BzK4bmhdeBY6O5AsDTuYY9sp1g== X-Gm-Gg: AZFdTZeo9tauGFMLNGRWRPlJHAaVLxfvzgPaFzznhecm1xtRDcTJGQzPhSd+RPn0eTA T6dwqqp2VB7kE7qwvTWjfKz5CPuTh9xwMT14fHqM9WG6/c85JlFdvFvdSAHRG+qa07eIoM8nO/P WY8KVoRrsc61CnJCb0PXTn0UriZjaoEMHdAzqjeS8RDdxo3dyHgyKwdM6hBtwFhtoDNXaaZ/NiC qfl6vt9bImcoShRYeAFDuI/zq6TnUhYgeN7+KOrJYsztHKtU8g2L/hXVVp3AxOky0wdhvnubzus 2T9ETOx3wgar/BMxkz6JOfKBtJXeeL/ZRCbDJ3HFs+dSYiV8E9TYk0p2HhP+Tgu5rkaAapV8CFU ZEtjAlRNj/KNmsoOl6gv4Pojvwe7luSl97w+1/G/nUTrLnnrqFQiz+sCAjYqFS3IV9TU2Mz5nGx Nde5pxIY/XtM9+v9Uk5ozMx4GG4QhJ9TLkASbEYZImbNzwX1bPwwXRF8G63olpxhLXd0yE9B5HW DeZ2k2uNIkoKwmQIBELdwBpSak4p7EITQtHlXxuW7FO7qrmUkt45i0I4cNyKDs8k2JPqpkr3Y9+ QXUwjB6h3AYJQrCplcG+yuNlenLpJlB67Hgc0WNvjgfONncogHTV7Cp32um0 X-Received: by 2002:a05:6a21:3a41:b0:3fa:caf6:a7 with SMTP id adf61e73a8af0-4014e74d619mr45248290637.67.1796307348396; Thu, 03 Dec 2026 06:15:48 -0800 (PST) Received: from localhost.localdomain ([64.118.140.61]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-cde6d03adafsm24544845a12.23.2026.12.03.06.15.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 03 Dec 2026 06:15:48 -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 v4 0/2] ext4: punch hole beyond i_size Date: Thu, 3 Dec 2026 22:15:34 +0800 Message-ID: <20261203141536.52700-1-dingf3ng@gmail.com> X-Mailer: git-send-email 2.55.0 X-Mailing-List: linux-ext4@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 v3 [1]: - Patch 2: call ext4_update_disksize_before_punch() only for a hole that starts below i_size (Sashiko [2]). Since v1, a punch at i_size moved i_disksize up to i_size ahead of writeback: after a buffered 1 MiB append, a punch at 1 MiB and a journal-only shutdown, v3 brought the file back as 1 MiB of zeros; v4, like v7.4-rc5, brings it back empty. - Patch 1: leave ext4_fc_track_inode() where it was. v2 and v3 moved it out of "if (end_lblk > start_lblk)" so that a hole within one block would still queue the inode, but ext4_mark_inode_dirty() queues it on every path, so the move changed nothing. - Patch 2: the changelog and a comment said that nothing past EOF is written and that the EOF block is freed. A hole that starts inside the EOF block zeroes it to its end and keeps it, as before; both now say so. The KUnit case "Punch past i_size is a no-op" is reworded to what it checks. Changes since v2 [3]: patch 2 keeps rounding a hole that reaches i_size up to the end of the EOF block, so the EOF block is still freed. Changes since v1 [4]: patch 1 is new; with v1 on a fast_commit filesystem, punching [0, s_maxbytes), fsync and a shutdown brought the punched data back after replay. Patch 2 zeroes nothing for a hole that starts past i_size and cites Fixes: 2be4751b21ae. Tested on v7.4-rc5, x86_64 under QEMU: - fstests -g punch on ext4 with 4k and 1k blocks: generic/042 fails with and without the series, nothing else fails. On ext4 without extents the 8 punch tests that run without falloc pass. - generic/811, "generic: punch a hole past EOF over preallocated blocks" [5], fails without the series and passes with it, on ext4 4k and 1k; it passes on XFS. - ext4 KUnit: 538 pass. W=1 adds no warnings. - The i_disksize and fast commit crash checks above, a 5000-byte file punched over [0, 5000) and [0, 6000) at 4k and 1k blocks (the EOF block is freed), and punches past EOF on indirect-block files (e2fsck clean). - Not tested: bigalloc, block sizes above 4k, DAX. [1] https://lore.kernel.org/all/20261203130608.64892-1-dingf3ng@gmail.com/ [2] https://lore.kernel.org/all/sashiko-outbox-247862@kernel.org/ [3] https://lore.kernel.org/all/20261203115201.48810-1-dingf3ng@gmail.com/ [4] https://lore.kernel.org/all/20261203091435.73786-1-dingf3ng@gmail.com/ [5] 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-test.c | 2 +- fs/ext4/inode.c | 35 ++++++++++++++++++++++------------- 2 files changed, 23 insertions(+), 14 deletions(-) -- 2.39.5