summaryrefslogtreecommitdiff
path: root/fs/fscache/stats.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2021-10-20 17:53:34 +0300
committerDavid Howells <dhowells@redhat.com>2022-01-07 12:22:19 +0300
commitd24af13e2e2358a602740c7817ea90da43d3e740 (patch)
tree344a8b83aff3845d17f46eaa8fae751351b9a233 /fs/fscache/stats.c
parent12bb21a29c19aae50cfad4e2bb5c943108f34a7d (diff)
downloadlinux-d24af13e2e2358a602740c7817ea90da43d3e740.tar.xz
fscache: Implement cookie invalidation
Add a function to invalidate the cache behind a cookie: void fscache_invalidate(struct fscache_cookie *cookie, const void *aux_data, loff_t size, unsigned int flags) This causes any cached data for the specified cookie to be discarded. If the cookie is marked as being in use, a new cache object will be created if possible and future I/O will use that instead. In-flight I/O should be abandoned (writes) or reconsidered (reads). Each time it is called cookie->inval_counter is incremented and this can be used to detect invalidation at the end of an I/O operation. The coherency data attached to the cookie can be updated and the cookie size should be reset. One flag is available, FSCACHE_INVAL_DIO_WRITE, which should be used to indicate invalidation due to a DIO write on a file. This will temporarily disable caching for this cookie. Changes ======= ver #2: - Should only change to inval state if can get access to cache. 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/163819602231.215744.11206598147269491575.stgit@warthog.procyon.org.uk/ # v1 Link: https://lore.kernel.org/r/163906909707.143852.18056070560477964891.stgit@warthog.procyon.org.uk/ # v2 Link: https://lore.kernel.org/r/163967107447.1823006.5945029409592119962.stgit@warthog.procyon.org.uk/ # v3 Link: https://lore.kernel.org/r/164021512640.640689.11418616313147754172.stgit@warthog.procyon.org.uk/ # v4
Diffstat (limited to 'fs/fscache/stats.c')
-rw-r--r--fs/fscache/stats.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
index 5aa4bd9fe207..cdbb672a274f 100644
--- a/fs/fscache/stats.c
+++ b/fs/fscache/stats.c
@@ -26,6 +26,8 @@ atomic_t fscache_n_acquires;
atomic_t fscache_n_acquires_ok;
atomic_t fscache_n_acquires_oom;
+atomic_t fscache_n_invalidates;
+
atomic_t fscache_n_updates;
EXPORT_SYMBOL(fscache_n_updates);
@@ -59,6 +61,9 @@ int fscache_stats_show(struct seq_file *m, void *v)
timer_pending(&fscache_cookie_lru_timer) ?
fscache_cookie_lru_timer.expires - jiffies : 0);
+ seq_printf(m, "Invals : n=%u\n",
+ atomic_read(&fscache_n_invalidates));
+
seq_printf(m, "Updates: n=%u\n",
atomic_read(&fscache_n_updates));