11e1236b8SDavid Howells // SPDX-License-Identifier: GPL-2.0-or-later
21e1236b8SDavid Howells /* FS-Cache statistics viewing interface
31e1236b8SDavid Howells *
41e1236b8SDavid Howells * Copyright (C) 2021 Red Hat, Inc. All Rights Reserved.
51e1236b8SDavid Howells * Written by David Howells (dhowells@redhat.com)
61e1236b8SDavid Howells */
71e1236b8SDavid Howells
81e1236b8SDavid Howells #define FSCACHE_DEBUG_LEVEL CACHE
91e1236b8SDavid Howells #include <linux/module.h>
101e1236b8SDavid Howells #include <linux/proc_fs.h>
111e1236b8SDavid Howells #include <linux/seq_file.h>
121e1236b8SDavid Howells #include "internal.h"
131e1236b8SDavid Howells
141e1236b8SDavid Howells /*
151e1236b8SDavid Howells * initialise the /proc/fs/fscache/ directory
161e1236b8SDavid Howells */
fscache_proc_init(void)171e1236b8SDavid Howells int __init fscache_proc_init(void)
181e1236b8SDavid Howells {
191e1236b8SDavid Howells if (!proc_mkdir("fs/fscache", NULL))
201e1236b8SDavid Howells goto error_dir;
211e1236b8SDavid Howells
229549332dSDavid Howells if (!proc_create_seq("fs/fscache/caches", S_IFREG | 0444, NULL,
239549332dSDavid Howells &fscache_caches_seq_ops))
249549332dSDavid Howells goto error;
259549332dSDavid Howells
2662ab6335SDavid Howells if (!proc_create_seq("fs/fscache/volumes", S_IFREG | 0444, NULL,
2762ab6335SDavid Howells &fscache_volumes_seq_ops))
2862ab6335SDavid Howells goto error;
2962ab6335SDavid Howells
30*7f3283abSDavid Howells if (!proc_create_seq("fs/fscache/cookies", S_IFREG | 0444, NULL,
31*7f3283abSDavid Howells &fscache_cookies_seq_ops))
32*7f3283abSDavid Howells goto error;
33*7f3283abSDavid Howells
341e1236b8SDavid Howells #ifdef CONFIG_FSCACHE_STATS
351e1236b8SDavid Howells if (!proc_create_single("fs/fscache/stats", S_IFREG | 0444, NULL,
361e1236b8SDavid Howells fscache_stats_show))
371e1236b8SDavid Howells goto error;
381e1236b8SDavid Howells #endif
391e1236b8SDavid Howells
401e1236b8SDavid Howells return 0;
411e1236b8SDavid Howells
421e1236b8SDavid Howells error:
431e1236b8SDavid Howells remove_proc_entry("fs/fscache", NULL);
441e1236b8SDavid Howells error_dir:
451e1236b8SDavid Howells return -ENOMEM;
461e1236b8SDavid Howells }
471e1236b8SDavid Howells
481e1236b8SDavid Howells /*
491e1236b8SDavid Howells * clean up the /proc/fs/fscache/ directory
501e1236b8SDavid Howells */
fscache_proc_cleanup(void)511e1236b8SDavid Howells void fscache_proc_cleanup(void)
521e1236b8SDavid Howells {
531e1236b8SDavid Howells remove_proc_subtree("fs/fscache", NULL);
541e1236b8SDavid Howells }
55