mirror of
https://github.com/lkl/linux.git
synced 2025-12-19 16:13:19 +09:00
fscache: Provide a function to resize a cookie
Provide a function to change the size of the storage attached to a cookie, to match the size of the file being cached when it's changed by truncate or fallocate: void fscache_resize_cookie(struct fscache_cookie *cookie, loff_t new_size); This acts synchronously and is expected to run under the inode lock of the caller. 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/163819621839.215744.7895597119803515402.stgit@warthog.procyon.org.uk/ # v1 Link: https://lore.kernel.org/r/163906922387.143852.16394459879816147793.stgit@warthog.procyon.org.uk/ # v2 Link: https://lore.kernel.org/r/163967128998.1823006.10740669081985775576.stgit@warthog.procyon.org.uk/ # v3 Link: https://lore.kernel.org/r/164021527861.640689.3466382085497236267.stgit@warthog.procyon.org.uk/ # v4
This commit is contained in:
@@ -122,6 +122,9 @@ extern atomic_t fscache_n_relinquishes;
|
||||
extern atomic_t fscache_n_relinquishes_retire;
|
||||
extern atomic_t fscache_n_relinquishes_dropped;
|
||||
|
||||
extern atomic_t fscache_n_resizes;
|
||||
extern atomic_t fscache_n_resizes_null;
|
||||
|
||||
static inline void fscache_stat(atomic_t *stat)
|
||||
{
|
||||
atomic_inc(stat);
|
||||
|
||||
@@ -291,3 +291,28 @@ abandon:
|
||||
term_func(term_func_priv, ret, false);
|
||||
}
|
||||
EXPORT_SYMBOL(__fscache_write_to_cache);
|
||||
|
||||
/*
|
||||
* Change the size of a backing object.
|
||||
*/
|
||||
void __fscache_resize_cookie(struct fscache_cookie *cookie, loff_t new_size)
|
||||
{
|
||||
struct netfs_cache_resources cres;
|
||||
|
||||
trace_fscache_resize(cookie, new_size);
|
||||
if (fscache_begin_operation(&cres, cookie, FSCACHE_WANT_WRITE,
|
||||
fscache_access_io_resize) == 0) {
|
||||
fscache_stat(&fscache_n_resizes);
|
||||
set_bit(FSCACHE_COOKIE_NEEDS_UPDATE, &cookie->flags);
|
||||
|
||||
/* We cannot defer a resize as we need to do it inside the
|
||||
* netfs's inode lock so that we're serialised with respect to
|
||||
* writes.
|
||||
*/
|
||||
cookie->volume->cache->ops->resize_cookie(&cres, new_size);
|
||||
fscache_end_operation(&cres);
|
||||
} else {
|
||||
fscache_stat(&fscache_n_resizes_null);
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL(__fscache_resize_cookie);
|
||||
|
||||
@@ -35,6 +35,9 @@ atomic_t fscache_n_relinquishes;
|
||||
atomic_t fscache_n_relinquishes_retire;
|
||||
atomic_t fscache_n_relinquishes_dropped;
|
||||
|
||||
atomic_t fscache_n_resizes;
|
||||
atomic_t fscache_n_resizes_null;
|
||||
|
||||
atomic_t fscache_n_read;
|
||||
EXPORT_SYMBOL(fscache_n_read);
|
||||
atomic_t fscache_n_write;
|
||||
@@ -69,8 +72,10 @@ int fscache_stats_show(struct seq_file *m, void *v)
|
||||
seq_printf(m, "Invals : n=%u\n",
|
||||
atomic_read(&fscache_n_invalidates));
|
||||
|
||||
seq_printf(m, "Updates: n=%u\n",
|
||||
atomic_read(&fscache_n_updates));
|
||||
seq_printf(m, "Updates: n=%u rsz=%u rsn=%u\n",
|
||||
atomic_read(&fscache_n_updates),
|
||||
atomic_read(&fscache_n_resizes),
|
||||
atomic_read(&fscache_n_resizes_null));
|
||||
|
||||
seq_printf(m, "Relinqs: n=%u rtr=%u drop=%u\n",
|
||||
atomic_read(&fscache_n_relinquishes),
|
||||
|
||||
Reference in New Issue
Block a user