aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cachefiles/internal.h
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2022-01-14 14:13:59 +0000
committerDavid Howells <dhowells@redhat.com>2022-01-21 21:36:28 +0000
commit5638b067d370583c6c455f019129ce33340b4142 (patch)
tree1c92e035d914e2f2ae87414afe2986e4abed0230 /fs/cachefiles/internal.h
parentfscache: Fix the volume collision wait condition (diff)
downloadlinux-dev-5638b067d370583c6c455f019129ce33340b4142.tar.xz
linux-dev-5638b067d370583c6c455f019129ce33340b4142.zip
cachefiles: Calculate the blockshift in terms of bytes, not pages
Cachefiles keeps track of how much space is available on the backing filesystem and refuses new writes permission to start if there isn't enough (we especially don't want ENOSPC happening). It also tracks the amount of data pending in DIO writes (cache->b_writing) and reduces the amount of free space available by this amount before deciding if it can set up a new write. However, the old fscache I/O API was very much page-granularity dependent and, as such, cachefiles's cache->bshift was meant to be a multiplier to get from PAGE_SIZE to block size (ie. a blocksize of 512 would give a shift of 3 for a 4KiB page) - and this was incorrectly being used to turn the number of bytes in a DIO write into a number of blocks, leading to a massive over estimation of the amount of data in flight. Fix this by changing cache->bshift to be a multiplier from bytes to blocksize and deal with quantities of blocks, not quantities of pages. Fix also the rounding in the calculation in cachefiles_write() which needs a "- 1" inserting. Fixes: 047487c947e8 ("cachefiles: Implement the I/O routines") Signed-off-by: David Howells <dhowells@redhat.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> cc: linux-cachefs@redhat.com Link: https://lore.kernel.org/r/164251398954.3435901.7138806620218474123.stgit@warthog.procyon.org.uk/ # v1
Diffstat (limited to 'fs/cachefiles/internal.h')
-rw-r--r--fs/cachefiles/internal.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
index 8dd54d9375b6..c793d33b0224 100644
--- a/fs/cachefiles/internal.h
+++ b/fs/cachefiles/internal.h
@@ -86,7 +86,7 @@ struct cachefiles_cache {
unsigned bcull_percent; /* when to start culling (% blocks) */
unsigned bstop_percent; /* when to stop allocating (% blocks) */
unsigned bsize; /* cache's block size */
- unsigned bshift; /* min(ilog2(PAGE_SIZE / bsize), 0) */
+ unsigned bshift; /* ilog2(bsize) */
uint64_t frun; /* when to stop culling */
uint64_t fcull; /* when to start culling */
uint64_t fstop; /* when to stop allocating */