diff options
author | David Howells <dhowells@redhat.com> | 2021-10-21 10:59:46 +0300 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2022-01-07 16:41:26 +0300 |
commit | 80f94f29f677d32a1edabc055acfe91c00803592 (patch) | |
tree | 23e578a123ba44c3564fbb66b5f94f4f0454f4e4 /fs/cachefiles/internal.h | |
parent | 8667d434b2a993b34a9dae6f6673bf93870fac25 (diff) | |
download | linux-80f94f29f677d32a1edabc055acfe91c00803592.tar.xz |
cachefiles: Provide a function to check how much space there is
Provide a function to check how much space there is. This also flips the
state on the cache and will signal the daemon to inform it of the change
and to ask it to do some culling if necessary.
We will also need to subtract the amount of data currently being written to
the cache (cache->b_writing) from the amount of available space to avoid
hitting ENOSPC accidentally.
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/163819629322.215744.13457425294680841213.stgit@warthog.procyon.org.uk/ # v1
Link: https://lore.kernel.org/r/163906930100.143852.1681026700865762069.stgit@warthog.procyon.org.uk/ # v2
Link: https://lore.kernel.org/r/163967140058.1823006.7781243664702837128.stgit@warthog.procyon.org.uk/ # v3
Link: https://lore.kernel.org/r/164021539957.640689.12477177372616805706.stgit@warthog.procyon.org.uk/ # v4
Diffstat (limited to 'fs/cachefiles/internal.h')
-rw-r--r-- | fs/cachefiles/internal.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h index 7fd5429715ea..3783a3e01027 100644 --- a/fs/cachefiles/internal.h +++ b/fs/cachefiles/internal.h @@ -39,6 +39,7 @@ struct cachefiles_cache { atomic_t gravecounter; /* graveyard uniquifier */ atomic_t f_released; /* number of objects released lately */ atomic_long_t b_released; /* number of blocks released lately */ + atomic_long_t b_writing; /* Number of blocks being written */ unsigned frun_percent; /* when to stop culling (% files) */ unsigned fcull_percent; /* when to start culling (% files) */ unsigned fstop_percent; /* when to stop allocating (% files) */ @@ -75,6 +76,12 @@ static inline void cachefiles_state_changed(struct cachefiles_cache *cache) } /* + * cache.c + */ +extern int cachefiles_has_space(struct cachefiles_cache *cache, + unsigned fnr, unsigned bnr); + +/* * daemon.c */ extern const struct file_operations cachefiles_daemon_fops; |