diff options
| author | Hungyu Lin <dennylin0707@gmail.com> | 2026-11-04 07:10:02 +0000 |
|---|---|---|
| committer | Andrew Morton <akpm@linux-foundation.org> | 2026-11-22 22:24:09 -0800 |
| commit | 76e1b20670b51a6cb31dc65877fc9a10f06366a2 (patch) | |
| tree | 292e76615ba2aa78ae03e0ef8e3245eda09d6101 /tools/perf/scripts/python | |
| parent | ff056011e9f7604683694c9c4a3daf102c785921 (diff) | |
filemap: prefault writes starting beyond EOF
Since prefaulting moved to the slow write path, a buffered write can reach
->write_begin() and ->write_end() before discovering that its source
buffer is unreadable. Several filesystems can extend i_size in these
callbacks even when no data was copied. For example, a one-byte pwrite()
at offset 4096 into an empty file can fail with EFAULT but leave a
4096-byte file.
Prefault the source before ->write_begin() when the write position is
beyond EOF, and return EFAULT if no source bytes can be made readable.
Overwrites and appends continue to skip this prefault. Keep the existing
slow-path faulting for forward progress after a failed atomic copy.
This also leaves intentional zero-length ->write_end() calls used by
generic_cont_expand_simple() unchanged. As with the previous prefaulting
behavior, a concurrent userspace unmap can still race with the later copy.
Link: https://patch.msgid.link/20261104071002.49693-1-dennylin0707@gmail.com
Fixes: 665575cff098 ("filemap: move prefaulting out of hot write path")
Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Suggested-by: Kiryl Shutsemau <kas@kernel.org>
Link: https://lore.kernel.org/all/at-XtWBQg3jv3H8Z@thinkstation/
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Kiryl Shutsemau (Meta) <kas@kernel.org>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Pedro Falcato <pfalcato@suse.de>
Cc: <stable@vger.kernel.org>
mm/filemap.c | 10 ++++++++++
1 file changed, 10 insertions(+)
Diffstat (limited to 'tools/perf/scripts/python')
0 files changed, 0 insertions, 0 deletions
