filecache.c (29d4bdbbb910f33d6058d2c51278f00f656df325) filecache.c (d63293272abb51c02457f1017dfd61c3270d9ae3)
1/*
2 * Open file cache.
3 *
4 * (c) 2015 - Jeff Layton <jeff.layton@primarydata.com>
5 */
6
7#include <linux/hash.h>
8#include <linux/slab.h>

--- 30 unchanged lines hidden (view full) ---

39 struct hlist_head nfb_head;
40 spinlock_t nfb_lock;
41 unsigned int nfb_count;
42 unsigned int nfb_maxcount;
43};
44
45static DEFINE_PER_CPU(unsigned long, nfsd_file_cache_hits);
46static DEFINE_PER_CPU(unsigned long, nfsd_file_acquisitions);
1/*
2 * Open file cache.
3 *
4 * (c) 2015 - Jeff Layton <jeff.layton@primarydata.com>
5 */
6
7#include <linux/hash.h>
8#include <linux/slab.h>

--- 30 unchanged lines hidden (view full) ---

39 struct hlist_head nfb_head;
40 spinlock_t nfb_lock;
41 unsigned int nfb_count;
42 unsigned int nfb_maxcount;
43};
44
45static DEFINE_PER_CPU(unsigned long, nfsd_file_cache_hits);
46static DEFINE_PER_CPU(unsigned long, nfsd_file_acquisitions);
47static DEFINE_PER_CPU(unsigned long, nfsd_file_releases);
47
48struct nfsd_fcache_disposal {
49 struct work_struct work;
50 spinlock_t lock;
51 struct list_head freeme;
52};
53
54static struct workqueue_struct *nfsd_filecache_wq __read_mostly;

--- 136 unchanged lines hidden (view full) ---

191 return nf;
192}
193
194static bool
195nfsd_file_free(struct nfsd_file *nf)
196{
197 bool flush = false;
198
48
49struct nfsd_fcache_disposal {
50 struct work_struct work;
51 spinlock_t lock;
52 struct list_head freeme;
53};
54
55static struct workqueue_struct *nfsd_filecache_wq __read_mostly;

--- 136 unchanged lines hidden (view full) ---

192 return nf;
193}
194
195static bool
196nfsd_file_free(struct nfsd_file *nf)
197{
198 bool flush = false;
199
200 this_cpu_inc(nfsd_file_releases);
201
199 trace_nfsd_file_put_final(nf);
200 if (nf->nf_mark)
201 nfsd_file_mark_put(nf->nf_mark);
202 if (nf->nf_file) {
203 get_file(nf->nf_file);
204 filp_close(nf->nf_file, NULL);
205 fput(nf->nf_file);
206 flush = true;

--- 838 unchanged lines hidden (view full) ---

1045
1046/*
1047 * Note that fields may be added, removed or reordered in the future. Programs
1048 * scraping this file for info should test the labels to ensure they're
1049 * getting the correct field.
1050 */
1051static int nfsd_file_cache_stats_show(struct seq_file *m, void *v)
1052{
202 trace_nfsd_file_put_final(nf);
203 if (nf->nf_mark)
204 nfsd_file_mark_put(nf->nf_mark);
205 if (nf->nf_file) {
206 get_file(nf->nf_file);
207 filp_close(nf->nf_file, NULL);
208 fput(nf->nf_file);
209 flush = true;

--- 838 unchanged lines hidden (view full) ---

1048
1049/*
1050 * Note that fields may be added, removed or reordered in the future. Programs
1051 * scraping this file for info should test the labels to ensure they're
1052 * getting the correct field.
1053 */
1054static int nfsd_file_cache_stats_show(struct seq_file *m, void *v)
1055{
1053 unsigned long hits = 0, acquisitions = 0;
1056 unsigned long hits = 0, acquisitions = 0, releases = 0;
1054 unsigned int i, count = 0, longest = 0;
1055 unsigned long lru = 0;
1056
1057 /*
1058 * No need for spinlocks here since we're not terribly interested in
1059 * accuracy. We do take the nfsd_mutex simply to ensure that we
1060 * don't end up racing with server shutdown
1061 */

--- 5 unchanged lines hidden (view full) ---

1067 }
1068 lru = list_lru_count(&nfsd_file_lru);
1069 }
1070 mutex_unlock(&nfsd_mutex);
1071
1072 for_each_possible_cpu(i) {
1073 hits += per_cpu(nfsd_file_cache_hits, i);
1074 acquisitions += per_cpu(nfsd_file_acquisitions, i);
1057 unsigned int i, count = 0, longest = 0;
1058 unsigned long lru = 0;
1059
1060 /*
1061 * No need for spinlocks here since we're not terribly interested in
1062 * accuracy. We do take the nfsd_mutex simply to ensure that we
1063 * don't end up racing with server shutdown
1064 */

--- 5 unchanged lines hidden (view full) ---

1070 }
1071 lru = list_lru_count(&nfsd_file_lru);
1072 }
1073 mutex_unlock(&nfsd_mutex);
1074
1075 for_each_possible_cpu(i) {
1076 hits += per_cpu(nfsd_file_cache_hits, i);
1077 acquisitions += per_cpu(nfsd_file_acquisitions, i);
1078 releases += per_cpu(nfsd_file_releases, i);
1075 }
1076
1077 seq_printf(m, "total entries: %u\n", count);
1078 seq_printf(m, "longest chain: %u\n", longest);
1079 seq_printf(m, "lru entries: %lu\n", lru);
1080 seq_printf(m, "cache hits: %lu\n", hits);
1081 seq_printf(m, "acquisitions: %lu\n", acquisitions);
1079 }
1080
1081 seq_printf(m, "total entries: %u\n", count);
1082 seq_printf(m, "longest chain: %u\n", longest);
1083 seq_printf(m, "lru entries: %lu\n", lru);
1084 seq_printf(m, "cache hits: %lu\n", hits);
1085 seq_printf(m, "acquisitions: %lu\n", acquisitions);
1086 seq_printf(m, "releases: %lu\n", releases);
1082 return 0;
1083}
1084
1085int nfsd_file_cache_stats_open(struct inode *inode, struct file *file)
1086{
1087 return single_open(file, nfsd_file_cache_stats_show, NULL);
1088}
1087 return 0;
1088}
1089
1090int nfsd_file_cache_stats_open(struct inode *inode, struct file *file)
1091{
1092 return single_open(file, nfsd_file_cache_stats_show, NULL);
1093}