linux/fs/netfs
David Howells c4f1450ecc
cachefiles, netfs: Fix write to partial block at EOF
Because it uses DIO writes, cachefiles is unable to make a write to the
backing file if that write is not aligned to and sized according to the
backing file's DIO block alignment.  This makes it tricky to handle a write
to the cache where the EOF on the network file is not correctly aligned.

To get around this, netfslib attempts to tell the driver it is calling how
much more data there is available beyond the EOF that it can use to pad the
write (netfslib preclears the part of the folio above the EOF).  However,
it tries to tell the cache what the maximum length is, but doesn't
calculate this correctly; and, in any case, cachefiles actually ignores the
value and just skips the block.

Fix this by:

 (1) Change the value passed to indicate the amount of extra data that can
     be added to the operation (now ->submit_extendable_to).  This is much
     simpler to calculate as it's just the end of the folio minus the top
     of the data within the folio - rather than having to account for data
     spread over multiple folios.

 (2) Make cachefiles add some of this data if the subrequest it is given
     ends at the network file's i_size if the extra data is sufficient to
     pad out to a whole block.

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Jeff Layton <jlayton@kernel.org>
cc: netfs@lists.linux.dev
cc: linux-fsdevel@vger.kernel.org
Link: https://lore.kernel.org/r/20240814203850.2240469-22-dhowells@redhat.com/ # v2
Signed-off-by: Christian Brauner <brauner@kernel.org>
2024-09-12 12:20:41 +02:00
..
buffered_read.c netfs: Speed up buffered reading 2024-09-12 12:20:41 +02:00
buffered_write.c netfs, cifs: Move CIFS_INO_MODIFIED_ATTR to netfs_inode 2024-09-05 11:00:41 +02:00
direct_read.c netfs: Speed up buffered reading 2024-09-12 12:20:41 +02:00
direct_write.c netfs: Revert "netfs: Switch debug logging to pr_debug()" 2024-07-24 10:15:37 +02:00
fscache_cache.c netfs: Revert "netfs: Switch debug logging to pr_debug()" 2024-07-24 10:15:37 +02:00
fscache_cookie.c fs/netfs/fscache_cookie: add missing "n_accesses" check 2024-08-12 22:03:26 +02:00
fscache_internal.h netfs, fscache: Combine fscache with netfs 2023-12-24 15:08:46 +00:00
fscache_io.c netfs: Revert "netfs: Switch debug logging to pr_debug()" 2024-07-24 10:15:37 +02: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 netfs: Revert "netfs: Switch debug logging to pr_debug()" 2024-07-24 10:15:37 +02:00
internal.h netfs: Speed up buffered reading 2024-09-12 12:20:41 +02:00
iterator.c netfs: Speed up buffered reading 2024-09-12 12:20:41 +02:00
Kconfig netfs: clean up after renaming FSCACHE_DEBUG config 2024-08-12 22:03:26 +02:00
locking.c netfs: Implement unbuffered/DIO vs buffered I/O locking 2023-12-24 15:08:52 +00:00
main.c netfs: Speed up buffered reading 2024-09-12 12:20:41 +02:00
Makefile netfs: Speed up buffered reading 2024-09-12 12:20:41 +02:00
misc.c netfs: Provide an iterator-reset function 2024-09-12 12:20:40 +02:00
objects.c netfs: Speed up buffered reading 2024-09-12 12:20:41 +02:00
read_collect.c netfs: Speed up buffered reading 2024-09-12 12:20:41 +02:00
read_pgpriv2.c cachefiles, netfs: Fix write to partial block at EOF 2024-09-12 12:20:41 +02:00
read_retry.c netfs: Speed up buffered reading 2024-09-12 12:20:41 +02:00
stats.c netfs: Speed up buffered reading 2024-09-12 12:20:41 +02:00
write_collect.c netfs: Speed up buffered reading 2024-09-12 12:20:41 +02:00
write_issue.c cachefiles, netfs: Fix write to partial block at EOF 2024-09-12 12:20:41 +02:00