From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796300562; b=aJzMWNjeyZErnryP83n7OnPK4NTffLeEX+c19d+GIm6VU6yVXm5uyhKcQ8bejVUlSu04 PJSxfCATTfB4/XY0DMllJ3mkrJ0oNlRlz/46+/eOhRN8/zt9UC4WF7jhKE9UTtbe3LmP+ 7rJSuiwIHmIFSXarkw5hn0SRskF2WemOK+NHuI/mnPehUkkfh5gadzqmhLBBYUPDmgTrX qHsPf4xbcS56w7nK5/Xpml1LaiCslYvRFLy/J0vbrOodKZ7mHwlwERsxWxLYf5ygpuN3O 8Ox1I/jiD/5Fd5vxhL/SmzuMM9/MGdjnTu54BhuDWZPrD3a7cK1eoTSuV1sw9Gd0PUw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796300562; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=6ZGFZxzWStBU3yOO2FVLpgD+ZepPqKAjAw0z8Dov2Lo=; b=38IHB5BWwWipN8reXI9v5H1Y1iHea1PoR5h69dYGw/NL4zODcQN6QBxEjGY89zkwDmY6 z09ijAZm1qiMwS/i2kgPa9RZOgRZmVqDORhNqgTq5oTld9wm9PwcU1GsX1XhV7jXG/4E2 Kuf9AUqxiA3Hi68JF5UWJ0RiJsx/M3eRF55tVKdDz5oPeD0F+Af8agRInnF/VQo/31b+X XE+4OpJ3SkwnH9WucXL5pI6Xv/CqSEpqYjTWo4TABGdrAG8cXJOLYguktQuGJRt/BmHSR muA4IghbEqKlHQtCfj5I04nzPDysDg3tZVrhHow71Edex49I0fZSPuHn9JbbamYrK6w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=g8JY5dU9; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CF474606A332 for ; Thu, 3 Dec 2026 12:22:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=g8JY5dU9 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E2371F000C1; Thu, 3 Dec 2026 12:22:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796300562; bh=6ZGFZxzWStBU3yOO2FVLpgD+ZepPqKAjAw0z8Dov2Lo=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=g8JY5dU97vIHU3ssXDcHL2dpqMH5Mr2OKG5t3AoBflmNOZyM+ba3oEZlS+RFRy2Us k5LLYfkiHBXSsflcGcfBg8/gcYCYtqstiLfJRyDEfB3dnmsLGQPNRnoXN4ITvu44zG I82848EhlVwNOeJFMAfPcZmA+HqQbLazJUA1HcAtD0WnXDlCnIe8eQKWRxv5WPVW/3 sE6bSArmPlPjT9RbCoD5Ak6n3oGMAtD50tmKVD3jBR8mVQ9EV4qfULQqzUsMPxkXce nR5dE83J25EBdJUbclv5NnWgzykQTnjGzOpJtCfvddrW4SqfD/rDEs9H5Rv3ipI7Tw eogFmQUjlVC8A== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 2/2] ext4: punch hole beyond i_size Reply-To: sashiko-reviews@lists.linux.dev To: "Ding Feng" Cc: linux-ext4@vger.kernel.org, tytso@mit.edu In-Reply-To: <20261203115201.48810-3-dingf3ng@gmail.com> References: <20261203115201.48810-1-dingf3ng@gmail.com> <20261203115201.48810-3-dingf3ng@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 12:22:40 +0000 X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] ext4: ext4_punch_hole() drops EOF block round-up when end reaches i_size -- commit fa94f38a0bf415aa375c8cc034c22fb0d79dfa23 Author: Ding Feng ext4: punch hole beyond i_size This commit updates ext4_punch_hole() to remove extents allocated beyond i_size instead of returning early or stopping at the block containing i_size, while restricting partial block zeroing to holes starting below i_size. > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > index 26cf00ff8630a..7f491a7237357 100644 > --- a/fs/ext4/inode.c > +++ b/fs/ext4/inode.c [ ... ] > @@ -5371,19 +5372,16 @@ int ext4_punch_hole(struct file *file, loff_t off= set, loff_t length) > if (!ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) > max_end =3D EXT4_SB(sb)->s_bitmap_maxbytes - sb->s_blocksize; > =20 > - /* No need to punch hole beyond i_size */ > - if (offset >=3D inode->i_size || offset >=3D max_end) > + if (offset >=3D max_end) > return 0; > - > - /* > - * If the hole extends beyond i_size, set the hole to end after > - * the block that contains i_size to save pointless tail block zeroing. > - */ > - if (end >=3D inode->i_size) > - end =3D round_up(inode->i_size, sb->s_blocksize); > if (end > max_end) > end =3D max_end; > length =3D end - offset; > + /* > + * Blocks past i_size (from FALLOC_FL_KEEP_SIZE) are removed too, but > + * nothing after the block that contains i_size needs zeroing. > + */ > + zero_end =3D min_t(loff_t, end, round_up(inode->i_size, sb->s_blocksize= )); > =20 > ret =3D ext4_update_disksize_before_punch(inode, offset, length); > if (ret) > @@ -5394,9 +5392,12 @@ int ext4_punch_hole(struct file *file, loff_t offs= et, loff_t length) > if (ret) > return ret; > =20 > - ret =3D ext4_zero_partial_blocks(inode, offset, length, &partial_zeroed= ); > - if (ret) > - return ret; > + if (offset < inode->i_size) { > + ret =3D ext4_zero_partial_blocks(inode, offset, zero_end - offset, > + &partial_zeroed); > + if (ret) > + return ret; > + } [Severity: Medium] Does removing the upward round-up of end regress EOF block reclamation and reintroduce tail-block zeroing when end falls in [i_size, round_up(i_size, sb->s_blocksize))? The deleted check both clamped end downward and rounded it upward to the end of the EOF block, which commit d37a7ddd3a38 ("ext4: make ext4_punch_hole() support large block size") kept to free the EOF block and avoid pointless tail-block zeroing. With this change, punching [0, 5000) on a 5000-byte file with 4096-byte blocks leaves both end and zero_end at 5000. ext4_zero_partial_blocks() then reads, zeros, and dirties the EOF block, and end_lblk excludes that block so it stays allocated on disk instead of being freed. If the same file is punched over [0, 6000), zero_end stays at 6000 and ext4_zero_partial_blocks() also writes zeroes over [5000, 6000) past i_size while leaving the EOF block allocated. Preserving the upward round-up when end >=3D inode->i_size with end =3D max_t(loff_t, end, round_up(inode->i_size, sb->s_blocksize)) before clamping against max_end would still punch blocks past i_size without regressing EOF block reclamation or tail-block zeroing. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203115201.4881= 0-1-dingf3ng@gmail.com?part=3D2