fscache: make the procfs cookie listing optional
Subsystems (2)
PATCH 1/1 fscache: make the procfs cookie listing optional
Add FSCACHE_COOKIE_PROC, enabled by default, to omit the diagnostic cookie list and its maintenance when not needed. Caching and counters are unaffected. Disabling it reduces the size of the struct by 16 bytes.
Signed-off-by Max Kellermann <[email protected]>
--- fs/netfs/Kconfig | 10 ++++++++++ fs/netfs/fscache_cookie.c | 8 +++++++- fs/netfs/fscache_proc.c | 2 ++ fs/netfs/internal.h | 2 ++ include/linux/fscache.h | 2 ++ 5 files changed, 23 insertions(+), 1 deletion(-)
fs/netfs/Kconfig +10 -0
@@ -44,6 +44,16 @@ config FSCACHE See Documentation/filesystems/caching/fscache.rst for more information. +config FSCACHE_COOKIE_PROC + bool "List FS-Cache cookies in procfs" + depends on FSCACHE && PROC_FS + default y + help + Provide the diagnostic /proc/fs/netfs/cookies listing (also + available through /proc/fs/fscache/cookies). Disabling this saves + two pointers per cookie and avoids maintaining the global list. + Caching and statistics remain available. + config FSCACHE_STATS bool "Gather statistical information on local caching" depends on FSCACHE && PROC_FS
fs/netfs/fscache_cookie.c +7 -1
@@ -23,8 +23,10 @@ static void fscache_perform_invalidation(struct fscache_cookie *cookie);#define fscache_cookie_hash_shift 15static struct hlist_bl_head fscache_cookie_hash[1 << fscache_cookie_hash_shift]; +#ifdef CONFIG_FSCACHE_COOKIE_PROC static LIST_HEAD (fscache_cookies);static DEFINE_RWLOCK (fscache_cookies_lock); +#endif static LIST_HEAD (fscache_cookie_lru);static DEFINE_SPINLOCK (fscache_cookie_lru_lock);DEFINE_TIMER (fscache_cookie_lru_timer, fscache_cookie_lru_timed_out);
@@ -68,9 +70,11 @@ static void fscache_free_cookie(struct fscache_cookie *cookie)return ; } +#ifdef CONFIG_FSCACHE_COOKIE_PROC write_lock (&fscache_cookies_lock);list_del (&cookie->proc_link);write_unlock (&fscache_cookies_lock); +#endif if (cookie->aux_len >sizeof (cookie->inline_aux))kfree (cookie->aux);if (cookie->key_len >sizeof (cookie->inline_key))
@@ -363,9 +367,11 @@ static struct fscache_cookie *fscache_alloc_cookie(INIT_WORK (&cookie->work, fscache_cookie_worker);__fscache_set_cookie_state (cookie,FSCACHE_COOKIE_STATE_QUIESCENT ); +#ifdef CONFIG_FSCACHE_COOKIE_PROC write_lock (&fscache_cookies_lock);list_add_tail (&cookie->proc_link, &fscache_cookies);write_unlock (&fscache_cookies_lock); +#endif fscache_see_cookie (cookie, fscache_cookie_new_acquire);return cookie;
@@ -1104,7 +1110,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie, }EXPORT_SYMBOL (__fscache_invalidate); -#ifdef CONFIG_PROC_FS +#ifdef CONFIG_FSCACHE_COOKIE_PROC /* * Generate a list of extant cookies in /proc/fs/fscache/cookies */
fs/netfs/fscache_proc.c +2 -0
@@ -27,9 +27,11 @@ int __init fscache_proc_init(void) &fscache_volumes_seq_ops)) goto error; +#ifdef CONFIG_FSCACHE_COOKIE_PROC if (!proc_create_seq ("fs/netfs/cookies" ,S_IFREG |0444 ,NULL , &fscache_cookies_seq_ops)) goto error; +#endif return 0 ; error:
fs/netfs/internal.h +2 -0
@@ -406,8 +406,10 @@ static inline bool fscache_set_cache_state_maybe(struct fscache_cache *cache,*/ extern struct kmem_cache *fscache_cookie_jar;#ifdef CONFIG_PROC_FS +#ifdef CONFIG_FSCACHE_COOKIE_PROC extern const struct seq_operations fscache_cookies_seq_ops;#endif +#endif extern struct timer_list fscache_cookie_lru_timer;extern void fscache_print_cookie (struct fscache_cookie *cookie,char prefix);
include/linux/fscache.h +2 -0
@@ -109,7 +109,9 @@ struct fscache_cookie {struct fscache_volume *volume;/* Parent volume of this file. */ void *cache_priv;/* Cache-side representation */ struct hlist_bl_node hash_link;/* Link in hash table */ +#ifdef CONFIG_FSCACHE_COOKIE_PROC struct list_head proc_link;/* Link in proc list */ +#endif struct list_head commit_link;/* Link in commit queue */ struct work_struct work;/* Commit/relinq/withdraw work */ uoff_t object_size;/* Size of the netfs object */
Signature · 1 line
2.53.0