Re: [PATCH v2] ext4: skip eof zeroing when the zero range covers the eof block

From: Theodore Ts'o

Date: Thu Nov 19 2026 - 09:48:52 EST



On Thu, 22 Oct 2026 20:26:25 +0800, Baokun Li wrote:
> ext4_zero_range() drops the page cache of the range before allocating,
> to avoid exposing stale cached data. However, the dropped page can be
> read back by the eof zeroing:
>
> fallocate(fd, FALLOC_FL_ZERO_RANGE, 0, 4096)
> ext4_zero_range()
> ext4_truncate_page_cache_block_range(0, 4096)
> truncate_pagecache_range(0, 4095)
> truncate_inode_pages_range()
> delete_from_page_cache_batch() # drops the page
> ext4_alloc_file_blocks(..., 4096)
> ext4_block_zero_eof(512, LLONG_MAX) # not block aligned
> ext4_load_tail_bh()
> __filemap_get_folio(FGP_WRITEBEGIN | FGP_ACCESSED)
> # FGP_CREAT reads the dropped page back
> # zeroes [512,1024), marks the buffer dirty
> ext4_map_blocks(...) # converts the extent to unwritten
> ext4_update_inode_size(4096)
>
> [...]

Applied, thanks!

[1/1] ext4: skip eof zeroing when the zero range covers the eof block
commit: 3c498dda252e1729e831c48300f17d1e6a7abb71

Best regards,
--
Theodore Ts'o <tytso@xxxxxxx>