summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2018-04-06 09:17:24 -0400
committerDavid Howells <dhowells@redhat.com>2018-04-09 16:53:54 -0400
commitd55b4da4331efdfe2be1bcc7bc217bd3f7c47870 (patch)
tree05318157503c9621feda308c0ef95bc2ffce36f7 /fs
parent888b33846111927d94dee6d8187c72515160edd3 (diff)
afs: Introduce a statistics proc file
Introduce a proc file that displays a bunch of statistics for the AFS filesystem in the current network namespace. Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/afs/dir.c3
-rw-r--r--fs/afs/inode.c3
-rw-r--r--fs/afs/internal.h15
-rw-r--r--fs/afs/proc.c37
4 files changed, 57 insertions, 1 deletions
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index b073976db8d2..538ca18efe0d 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -206,6 +206,7 @@ bool afs_dir_check_page(struct inode *dir, struct page *page)
206 } 206 }
207 207
208checked: 208checked:
209 afs_stat_v(vnode, n_read_dir);
209 SetPageChecked(page); 210 SetPageChecked(page);
210 return true; 211 return true;
211 212
@@ -868,6 +869,7 @@ static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry,
868 dentry->d_name.name[dentry->d_name.len - 1] == 's') 869 dentry->d_name.name[dentry->d_name.len - 1] == 's')
869 return afs_lookup_atsys(dir, dentry, key); 870 return afs_lookup_atsys(dir, dentry, key);
870 871
872 afs_stat_v(dvnode, n_lookup);
871 inode = afs_do_lookup(dir, dentry, key); 873 inode = afs_do_lookup(dir, dentry, key);
872 if (IS_ERR(inode)) { 874 if (IS_ERR(inode)) {
873 ret = PTR_ERR(inode); 875 ret = PTR_ERR(inode);
@@ -1062,6 +1064,7 @@ static int afs_d_revalidate(struct dentry *dentry, unsigned int flags)
1062 goto out_valid; /* the dir contents are unchanged */ 1064 goto out_valid; /* the dir contents are unchanged */
1063 1065
1064 _debug("dir modified"); 1066 _debug("dir modified");
1067 afs_stat_v(dir, n_reval);
1065 1068
1066 /* search the directory for this vnode */ 1069 /* search the directory for this vnode */
1067 ret = afs_do_lookup_one(&dir->vfs_inode, dentry, &fid, key); 1070 ret = afs_do_lookup_one(&dir->vfs_inode, dentry, &fid, key);
diff --git a/fs/afs/inode.c b/fs/afs/inode.c
index d5db9dead18c..f4e62964efcb 100644
--- a/fs/afs/inode.c
+++ b/fs/afs/inode.c
@@ -366,6 +366,9 @@ void afs_zap_data(struct afs_vnode *vnode)
366{ 366{
367 _enter("{%x:%u}", vnode->fid.vid, vnode->fid.vnode); 367 _enter("{%x:%u}", vnode->fid.vid, vnode->fid.vnode);
368 368
369 if (S_ISDIR(vnode->vfs_inode.i_mode))
370 afs_stat_v(vnode, n_inval);
371
369#ifdef CONFIG_AFS_FSCACHE 372#ifdef CONFIG_AFS_FSCACHE
370 fscache_invalidate(vnode->cache); 373 fscache_invalidate(vnode->cache);
371#endif 374#endif
diff --git a/fs/afs/internal.h b/fs/afs/internal.h
index 27150bbc50d8..ca65f121d2cc 100644
--- a/fs/afs/internal.h
+++ b/fs/afs/internal.h
@@ -257,9 +257,15 @@ struct afs_net {
257 struct mutex lock_manager_mutex; 257 struct mutex lock_manager_mutex;
258 258
259 /* Misc */ 259 /* Misc */
260 struct proc_dir_entry *proc_afs; /* /proc/net/afs directory */ 260 struct proc_dir_entry *proc_afs; /* /proc/net/afs directory */
261 struct afs_sysnames *sysnames; 261 struct afs_sysnames *sysnames;
262 rwlock_t sysnames_lock; 262 rwlock_t sysnames_lock;
263
264 /* Statistics counters */
265 atomic_t n_lookup; /* Number of lookups done */
266 atomic_t n_reval; /* Number of dentries needing revalidation */
267 atomic_t n_inval; /* Number of invalidations by the server */
268 atomic_t n_read_dir; /* Number of directory pages read */
263}; 269};
264 270
265extern const char afs_init_sysname[]; 271extern const char afs_init_sysname[];
@@ -777,6 +783,13 @@ static inline void afs_put_net(struct afs_net *net)
777{ 783{
778} 784}
779 785
786static inline void __afs_stat(atomic_t *s)
787{
788 atomic_inc(s);
789}
790
791#define afs_stat_v(vnode, n) __afs_stat(&afs_v2net(vnode)->n)
792
780/* 793/*
781 * misc.c 794 * misc.c
782 */ 795 */
diff --git a/fs/afs/proc.c b/fs/afs/proc.c
index 76f6df32cde0..8bffb17f9728 100644
--- a/fs/afs/proc.c
+++ b/fs/afs/proc.c
@@ -152,6 +152,8 @@ static const struct file_operations afs_proc_sysname_fops = {
152 .write = afs_proc_sysname_write, 152 .write = afs_proc_sysname_write,
153}; 153};
154 154
155static const struct file_operations afs_proc_stats_fops;
156
155/* 157/*
156 * initialise the /proc/fs/afs/ directory 158 * initialise the /proc/fs/afs/ directory
157 */ 159 */
@@ -166,6 +168,7 @@ int afs_proc_init(struct afs_net *net)
166 if (!proc_create("cells", 0644, net->proc_afs, &afs_proc_cells_fops) || 168 if (!proc_create("cells", 0644, net->proc_afs, &afs_proc_cells_fops) ||
167 !proc_create("rootcell", 0644, net->proc_afs, &afs_proc_rootcell_fops) || 169 !proc_create("rootcell", 0644, net->proc_afs, &afs_proc_rootcell_fops) ||
168 !proc_create("servers", 0644, net->proc_afs, &afs_proc_servers_fops) || 170 !proc_create("servers", 0644, net->proc_afs, &afs_proc_servers_fops) ||
171 !proc_create("stats", 0644, net->proc_afs, &afs_proc_stats_fops) ||
169 !proc_create("sysname", 0644, net->proc_afs, &afs_proc_sysname_fops)) 172 !proc_create("sysname", 0644, net->proc_afs, &afs_proc_sysname_fops))
170 goto error_tree; 173 goto error_tree;
171 174
@@ -897,3 +900,37 @@ static int afs_proc_sysname_show(struct seq_file *m, void *v)
897 seq_printf(m, "%s\n", sysnames->subs[i]); 900 seq_printf(m, "%s\n", sysnames->subs[i]);
898 return 0; 901 return 0;
899} 902}
903
904/*
905 * Display general per-net namespace statistics
906 */
907static int afs_proc_stats_show(struct seq_file *m, void *v)
908{
909 struct afs_net *net = afs_seq2net(m);
910
911 seq_puts(m, "kAFS statistics\n");
912
913 seq_printf(m, "dir-mgmt: look=%u reval=%u inval=%u\n",
914 atomic_read(&net->n_lookup),
915 atomic_read(&net->n_reval),
916 atomic_read(&net->n_inval));
917
918 seq_printf(m, "dir-data: rdpg=%u\n",
919 atomic_read(&net->n_read_dir));
920 return 0;
921}
922
923/*
924 * Open "/proc/fs/afs/stats" to allow reading of the stat counters.
925 */
926static int afs_proc_stats_open(struct inode *inode, struct file *file)
927{
928 return single_open(file, afs_proc_stats_show, NULL);
929}
930
931static const struct file_operations afs_proc_stats_fops = {
932 .open = afs_proc_stats_open,
933 .read = seq_read,
934 .llseek = seq_lseek,
935 .release = single_release,
936};