[PATCH 13/17] nfsd4: add per-operation server stats

Shankar Anand shanand at novell.com
Tue Jul 4 10:50:45 EDT 2006


Hi,

>>> On 6/28/2006 at 2:21 AM, "J.Bruce Fields" <bfields at fieldses.org>
wrote:
> On Tue, Jun 27, 2006 at 03:10:23PM -0400, Talpey, Thomas wrote:
>> Oh yeah. I guess I blotted that out of my mind, thanks. :-)
>> Op 2 was reserved because proc 2 is. (Yecch.) Of course,
>> OP_CB_GETATTR promptly reused OP_ACCESS.
>> 
>> I still agree with Neil - don't 3-base the stats.
> 
> OK.  Shankar, could you revise this patch and the nfs-utils patches?

The modified patch is attached with this e-mail.

Instead of tracking using NUMNFS4OPS, I have used FIRST_NFS4OP 
and LAST_NFS4OP (both defined in nfs4.h). This might help while
adding new operations in future.

Also now the v4 server stats array is 0-based and three inirial '0's
get printed in /proc/net/rpc/nfsd.

Shankar
-------------- next part --------------
This patch adds a nfs4 operations count array to nfsd_stats structure.
The count is  incremented in nfsd4_proc_compound() where all the operations
are handled by the nfsv4 server. This count of individual nfsv4 operations
is also entered into /proc filesystem. 

Signed-off-by: Shankar Anand<shanand at novell.com> 

diff -aurp linux-2.6.17-rc6.orig/fs/nfsd/nfs4proc.c linux-2.6.17-rc6/fs/nfsd/nfs4proc.c
--- linux-2.6.17-rc6.orig/fs/nfsd/nfs4proc.c	2006-06-06 06:27:02.000000000 +0530
+++ linux-2.6.17-rc6/fs/nfsd/nfs4proc.c	2006-07-04 19:46:08.000000000 +0530
@@ -721,6 +721,12 @@ nfsd4_proc_null(struct svc_rqst *rqstp, 
 	return nfs_ok;
 }
 
+static inline void nfsd4_increment_op_stats(u32 opnum)
+{
+	if (opnum >= FIRST_NFS4_OP && opnum <= LAST_NFS4_OP)
+		nfsdstats.nfs4_opcount[opnum]++;
+}
+
 
 /*
  * COMPOUND call.
@@ -930,6 +936,8 @@ encode_op:
 		/* XXX Ugh, we need to get rid of this kind of special case: */
 		if (op->opnum == OP_READ && op->u.read.rd_filp)
 			fput(op->u.read.rd_filp);
+
+		 nfsd4_increment_op_stats(op->opnum);
 	}
 
 out:
diff -aurp linux-2.6.17-rc6.orig/fs/nfsd/stats.c linux-2.6.17-rc6/fs/nfsd/stats.c
--- linux-2.6.17-rc6.orig/fs/nfsd/stats.c	2006-06-06 06:27:02.000000000 +0530
+++ linux-2.6.17-rc6/fs/nfsd/stats.c	2006-07-04 19:45:50.000000000 +0530
@@ -40,6 +40,37 @@ struct svc_stat		nfsd_svcstats = {
 	.program	= &nfsd_program,
 };
 
+#ifdef CONFIG_NFSD_V4
+
+static inline void nfsd4_show_opstats(struct seq_file *seq)
+{
+	int i;
+
+	/* Show count for individual nfsv4 operations */
+	/* Writing operation numbers 0 1 2 also for maintaining uniformity */
+	seq_printf(seq,"proc4ops %u", LAST_NFS4_OP + 1);
+	for (i=0; i<=LAST_NFS4_OP; i++)
+		seq_printf(seq, " %u", nfsdstats.nfs4_opcount[i]);
+
+       seq_putc(seq, '\n');
+}
+
+static inline void nfsd4_init_opstats(void)
+{
+	int i;
+
+	/* Initialising nfsv4 operations counters */
+	for (i=0; i<=LAST_NFS4_OP; i++)
+		nfsdstats.nfs4_opcount[i] = 0;
+}
+
+#else /* CONFIG_NFSD_V4 */
+static inline void nfsd4_show_opstats(struct seq_file *seq) {}
+static inline void nfsd4_init_opstats(void) {}
+#endif
+
+
+
 static int nfsd_proc_show(struct seq_file *seq, void *v)
 {
 	int i;
@@ -72,6 +103,8 @@ static int nfsd_proc_show(struct seq_fil
 	/* show my rpc info */
 	svc_seq_show(seq, &nfsd_svcstats);
 
+	 nfsd4_show_opstats(seq);
+
 	return 0;
 }
 
diff -aurp linux-2.6.17-rc6.orig/include/linux/nfs4.h linux-2.6.17-rc6/include/linux/nfs4.h
--- linux-2.6.17-rc6.orig/include/linux/nfs4.h	2006-06-06 06:27:02.000000000 +0530
+++ linux-2.6.17-rc6/include/linux/nfs4.h	2006-07-04 19:45:45.000000000 +0530
@@ -155,6 +155,12 @@ enum nfs_opnum4 {
 	OP_ILLEGAL = 10044,
 };
 
+/*Defining first and last NFS4 operations implemented.
+Needs to be updated if more operations are defined in future.*/
+
+#define FIRST_NFS4_OP	OP_ACCESS
+#define LAST_NFS4_OP 	OP_RELEASE_LOCKOWNER
+
 enum nfsstat4 {
 	NFS4_OK = 0,
 	NFS4ERR_PERM = 1,
diff -aurp linux-2.6.17-rc6.orig/include/linux/nfsd/stats.h linux-2.6.17-rc6/include/linux/nfsd/stats.h
--- linux-2.6.17-rc6.orig/include/linux/nfsd/stats.h	2006-06-06 06:27:02.000000000 +0530
+++ linux-2.6.17-rc6/include/linux/nfsd/stats.h	2006-07-04 20:03:40.000000000 +0530
@@ -9,6 +9,8 @@
 #ifndef LINUX_NFSD_STATS_H
 #define LINUX_NFSD_STATS_H
 
+#include <linux/nfs4.h>
+
 struct nfsd_stats {
 	unsigned int	rchits;		/* repcache hits */
 	unsigned int	rcmisses;	/* repcache hits */
@@ -27,6 +29,10 @@ struct nfsd_stats {
 	unsigned int	ra_size;	/* size of ra cache */
 	unsigned int	ra_depth[11];	/* number of times ra entry was found that deep
 					 * in the cache (10percentiles). [10] = not found */
+#ifdef  CONFIG_NFSD_V4
+	unsigned int    nfs4_opcount[LAST_NFS4_OP + 1];	/* count of individual nfsv4 operations */
+#endif
+
 };
 
 /* thread usage wraps very million seconds (approx one fortnight) */


More information about the NFSv4 mailing list