linux/fs/netfs
Paulo Alcantara dd05add7b2 netfs: zero the tail of a short DIO/unbuffered read
The buffered read collector zero-fills the tail of a short read that
stops below the inode's i_size (netfs_clear_unread()), so a read that
races an extending write still returns the expected number of bytes.
The non-buffered collector path does no such thing: it just records
how much was transferred.

Add the same zero-fill for the non-buffered case, gated on
NETFS_SREQ_CLEAR_TAIL: a subreq's source sets that flag when a short
result from it is known to be safe to treat as a hole, as opposed to
NETFS_SREQ_HIT_EOF, which means the read genuinely ran off the end of
the file and should be reported short as-is. Only CLEAR_TAIL should
zero-fill here; a real EOF must stay a real short read.

No source currently sets CLEAR_TAIL on an unbuffered/DIO subrequest,
so this is inert on its own -- a following change teaches cifs to set
it in the one case that needs it.

Fixes: e2d46f2ec3 ("netfs: Change the read result collector to only use one work item")
Reviewed-by: David Howells <dhowells@redhat.com>
Reviewed-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Paulo Alcantara <pc@manguebit.org>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Cc: Shyam Prasad N <sprasad@microsoft.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Bharath SM <bharathsm@microsoft.com>
Cc: stable@vger.kernel.org
2026-09-30 14:24:12 -03:00
..
buffered_read.c netfs: zero gaps in read-gaps folio to avoid writing back stale data 2026-09-30 14:23:58 -03:00
buffered_write.c netfs: clear post-EOF pagecache when extending a file via write 2026-09-30 14:22:44 -03:00
direct_read.c netfs: Fix cancellation of a DIO and single read subrequests 2026-05-12 14:42:29 +02:00
direct_write.c netfs: clear post-EOF pagecache when extending a file via write 2026-09-30 14:22:44 -03:00
fscache_cache.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
fscache_cookie.c netfs: Mark __nonstring lookup tables 2025-04-17 10:13:46 +02:00
fscache_internal.h
fscache_io.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
fscache_main.c fscache: delete fscache_cookie_lru_timer when fscache exits to avoid UAF 2024-09-01 10:30:25 +02:00
fscache_proc.c netfs: Fix proc/fs/fscache symlink to point to "netfs" not "../netfs" 2024-01-04 13:15:32 +00:00
fscache_stats.c netfs: Fix interaction between write-streaming and cachefiles culling 2024-01-05 15:42:25 +00:00
fscache_volume.c Convert 'alloc_flex' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
internal.h netfs: clear post-EOF pagecache when extending a file via write 2026-09-30 14:22:44 -03:00
iterator.c netfs: Fix overrun check in netfs_extract_user_iter() 2026-05-12 14:42:30 +02:00
Kconfig netfs: clean up after renaming FSCACHE_DEBUG config 2024-08-12 22:03:26 +02:00
locking.c netfs: Replace wb_lock with a bit lock for asynchronicity 2026-07-01 15:26:29 +02:00
main.c netfs: Fix folio_queue ENOMEM in writeback by adding a mempool 2026-07-28 15:42:31 +02:00
Makefile netfs: Add support for caching single monolithic objects such as AFS dirs 2024-12-20 22:34:06 +01:00
misc.c netfs: clear post-EOF pagecache when extending a file via write 2026-09-30 14:22:44 -03:00
objects.c netfs: Fix missing alloc tagging of direct mempool allocations 2026-09-25 17:30:39 +02:00
read_collect.c netfs: zero the tail of a short DIO/unbuffered read 2026-09-30 14:24:12 -03:00
read_pgpriv2.c netfs: Mark folios with COPY_TO_CACHE whilst issuing subreqs 2026-08-31 09:54:38 +02:00
read_retry.c netfs: Mark folios with COPY_TO_CACHE whilst issuing subreqs 2026-08-31 09:54:38 +02:00
read_single.c netfs: Fix read progress reporting 2026-08-31 09:54:38 +02:00
rolling_buffer.c netfs: Fix missing alloc tagging of direct mempool allocations 2026-09-25 17:30:39 +02:00
stats.c netfs: Add retry stat counters 2025-02-13 16:00:48 +01:00
write_collect.c netfs: Replace wb_lock with a bit lock for asynchronicity 2026-07-01 15:26:29 +02:00
write_issue.c netfs: break unbuffered write when netfs_alloc_subrequest() fails 2026-08-31 09:54:38 +02:00
write_retry.c netfs: Fix barriering when walking subrequest list 2026-07-03 11:52:41 +02:00