Skip to content

Commit 9f08ebc

Browse files
committed
fscache, cachefiles: Display stat of culling events
Add a stat counter of culling events whereby the cache backend culls a file to make space (when asked by cachefilesd in this case) and display in /proc/fs/fscache/stats. Signed-off-by: David Howells <[email protected]> Reviewed-by: Jeff Layton <[email protected]> cc: [email protected] Link: https://lore.kernel.org/r/163819654165.215744.3797804661644212436.stgit@warthog.procyon.org.uk/ # v1 Link: https://lore.kernel.org/r/163906961387.143852.9291157239960289090.stgit@warthog.procyon.org.uk/ # v2 Link: https://lore.kernel.org/r/163967168266.1823006.14436200166581605746.stgit@warthog.procyon.org.uk/ # v3 Link: https://lore.kernel.org/r/164021567619.640689.4339228906248763197.stgit@warthog.procyon.org.uk/ # v4
1 parent 3929eca commit 9f08ebc

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

fs/cachefiles/namei.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,7 @@ int cachefiles_cull(struct cachefiles_cache *cache, struct dentry *dir,
805805
if (ret < 0)
806806
goto error;
807807

808+
fscache_count_culled();
808809
dput(victim);
809810
_leave(" = 0");
810811
return 0;

fs/fscache/stats.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ atomic_t fscache_n_no_write_space;
4646
EXPORT_SYMBOL(fscache_n_no_write_space);
4747
atomic_t fscache_n_no_create_space;
4848
EXPORT_SYMBOL(fscache_n_no_create_space);
49+
atomic_t fscache_n_culled;
50+
EXPORT_SYMBOL(fscache_n_culled);
4951

5052
/*
5153
* display the general statistics
@@ -86,9 +88,10 @@ int fscache_stats_show(struct seq_file *m, void *v)
8688
atomic_read(&fscache_n_relinquishes_retire),
8789
atomic_read(&fscache_n_relinquishes_dropped));
8890

89-
seq_printf(m, "NoSpace: nwr=%u ncr=%u\n",
91+
seq_printf(m, "NoSpace: nwr=%u ncr=%u cull=%u\n",
9092
atomic_read(&fscache_n_no_write_space),
91-
atomic_read(&fscache_n_no_create_space));
93+
atomic_read(&fscache_n_no_create_space),
94+
atomic_read(&fscache_n_culled));
9295

9396
seq_printf(m, "IO : rd=%u wr=%u\n",
9497
atomic_read(&fscache_n_read),

include/linux/fscache-cache.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,18 @@ extern atomic_t fscache_n_read;
188188
extern atomic_t fscache_n_write;
189189
extern atomic_t fscache_n_no_write_space;
190190
extern atomic_t fscache_n_no_create_space;
191+
extern atomic_t fscache_n_culled;
191192
#define fscache_count_read() atomic_inc(&fscache_n_read)
192193
#define fscache_count_write() atomic_inc(&fscache_n_write)
193194
#define fscache_count_no_write_space() atomic_inc(&fscache_n_no_write_space)
194195
#define fscache_count_no_create_space() atomic_inc(&fscache_n_no_create_space)
196+
#define fscache_count_culled() atomic_inc(&fscache_n_culled)
195197
#else
196198
#define fscache_count_read() do {} while(0)
197199
#define fscache_count_write() do {} while(0)
198200
#define fscache_count_no_write_space() do {} while(0)
199201
#define fscache_count_no_create_space() do {} while(0)
202+
#define fscache_count_culled() do {} while(0)
200203
#endif
201204

202205
#endif /* _LINUX_FSCACHE_CACHE_H */

0 commit comments

Comments
 (0)