linux/fs/cachefiles
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
..
cache.c cachefiles: fix slab-use-after-free in cachefiles_withdraw_cookie() 2024-07-03 10:36:15 +02:00
daemon.c Merge patch series "cachefiles: random bugfixes" 2024-07-05 18:40:40 +02:00
error_inject.c cachefiles: Remove the now superfluous sentinel element from ctl_table array 2023-12-28 04:57:57 -08:00
interface.c cachefiles: extract ondemand info field from cachefiles_object 2023-11-25 16:03:57 +01:00
internal.h Merge patch series "cachefiles: random bugfixes" 2024-07-05 18:40:40 +02:00
io.c cachefiles, netfs: Fix write to partial block at EOF 2024-09-12 12:20:41 +02:00
Kconfig netfs, fscache: Combine fscache with netfs 2023-12-24 15:08:46 +00:00
key.c cachefiles: Implement key to filename encoding 2022-01-07 13:42:16 +00:00
main.c cachefiles: Implement object lifecycle funcs 2022-01-07 13:42:08 +00:00
Makefile cachefiles: notify the user daemon when looking up cookie 2022-05-18 00:11:17 +08:00
namei.c kernel_file_open(): get rid of inode argument 2024-04-15 16:03:24 -04:00
ondemand.c Merge patch series "cachefiles: random bugfixes" 2024-07-05 18:40:40 +02:00
security.c cachefiles: Add security derivation 2022-01-07 13:41:14 +00:00
volume.c cachefiles: fix slab-use-after-free in cachefiles_withdraw_cookie() 2024-07-03 10:36:15 +02:00
xattr.c cachefiles: Fix non-taking of sb_writers around set/removexattr 2024-09-05 11:00:40 +02:00