linux-stable/fs/cachefiles
David Howells b08968f196 cachefiles: Fix incorrect length to fallocate()
When cachefiles_shorten_object() calls fallocate() to shape the cache
file to match the DIO size, it passes the total file size it wants to
achieve, not the amount of zeros that should be inserted.  Since this is
meant to preallocate that amount of storage for the file, it can cause
the cache to fill up the disk and hit ENOSPC.

Fix this by passing the length actually required to go from the current
EOF to the desired EOF.

Fixes: 7623ed6772 ("cachefiles: Implement cookie resize for truncate")
Reported-by: Jeffle Xu <jefflexu@linux.alibaba.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Tested-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
cc: linux-cachefs@redhat.com
Link: https://lore.kernel.org/r/164630854858.3665356.17419701804248490708.stgit@warthog.procyon.org.uk # v1
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2022-03-03 11:35:21 -08:00
..
cache.c cachefiles: Check that the backing filesystem supports tmpfiles 2022-01-21 21:36:28 +00:00
daemon.c cachefiles: set default tag name if it's unspecified 2022-01-21 21:36:28 +00:00
error_inject.c cachefiles: Add some error injection support 2022-01-07 13:40:56 +00:00
interface.c cachefiles: Fix incorrect length to fallocate() 2022-03-03 11:35:21 -08:00
internal.h cachefiles: Calculate the blockshift in terms of bytes, not pages 2022-01-21 21:36:28 +00:00
io.c netfs, cachefiles: Add a method to query presence of data in the cache 2022-02-01 10:29:18 -06:00
Kconfig cachefiles: Add some error injection support 2022-01-07 13:40:56 +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: Implement begin and end I/O operation 2022-01-07 13:42:44 +00:00
namei.c cachefiles: Trace active-mark failure 2022-01-21 21:36:28 +00:00
security.c cachefiles: Add security derivation 2022-01-07 13:41:14 +00:00
volume.c fscache, cachefiles: Store the volume coherency data 2022-01-07 13:43:03 +00:00
xattr.c fscache, cachefiles: Store the volume coherency data 2022-01-07 13:43:03 +00:00