]> git.baikalelectronics.ru Git - kernel.git/commit
cachefiles: Fix incorrect length to fallocate()
authorDavid Howells <dhowells@redhat.com>
Thu, 3 Mar 2022 13:05:18 +0000 (13:05 +0000)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 3 Mar 2022 19:35:21 +0000 (11:35 -0800)
commit6fe50d52d7b085c58a992ee270a6a9554b1714e1
treed4149e996a676d087f9b0ff8417c1345de2abb18
parent3def75fdef9ec2f6cf3498fcbd09fbf7257110ee
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: d32b2a7eb8ec ("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
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/cachefiles/interface.c