Skip to contentSkip to conversation

PATCH [1/2] Capture nfsv4 server operations statistics

PATCH Shankar Anand 2 participants 5 messages May 16, 2006 – May 30, 2006 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

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.

Submitted by: Shankar Anand <[email protected]>

diff -aurp linux-2.6.17-rc2.old/fs/nfsd/nfs4proc.c linux-2.6.17-rc2/fs/nfsd/nfs4proc.c
--- linux-2.6.17-rc2.old/fs/nfsd/nfs4proc.c 2006-04-19
08:30:49.000000000 +0530
+++ linux-2.6.17-rc2/fs/nfsd/nfs4proc.c 2006-05-15
21:05:00.000000000 +0530
@@ -54,6 +54,7 @@
#include <linux/nfsd/state.h>
#include <linux/nfsd/xdr4.h>
#include <linux/nfs4_acl.h>
+#include <linux/nfsd/stats.h>

#define NFSDDBG_FACILITY NFSDDBG_PROC

@@ -930,6 +931,10 @@ 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);
+
+ /* Maintaining count for each nfsv4 operation */
+ if ( (op->opnum >= OP_ACCESS) && ( (op->opnum -
OP_ACCESS) < NFS4_NUMOPS) )
+ nfsdstats.nfs4_opcount[op->opnum -
OP_ACCESS]++;
}

out:
diff -aurp linux-2.6.17-rc2.old/fs/nfsd/stats.c linux-2.6.17-rc2/fs/nfsd/stats.c
--- linux-2.6.17-rc2.old/fs/nfsd/stats.c 2006-04-19
08:30:49.000000000 +0530
+++ linux-2.6.17-rc2/fs/nfsd/stats.c 2006-05-15 21:13:31.000000000
+0530
@@ -72,6 +72,12 @@ static int nfsd_proc_show(struct seq_fil
/* show my rpc info */
svc_seq_show(seq, &nfsd_svcstats);

+ /* show count for individual nfsv4 operations */
+ seq_printf(seq,"proc4ops %u", NFS4_NUMOPS);
+ for (i=0; i<NFS4_NUMOPS; i++)
+ seq_printf(seq, " %u", nfsdstats.nfs4_opcount[i]);
+
+ seq_putc(seq, '\n');
return 0;
}

@@ -91,7 +97,12 @@ static const struct file_operations nfsd
void
nfsd_stat_init(void)
{
+ int i;
svc_proc_register(&nfsd_svcstats, &nfsd_proc_fops);
+
+ /* Initialising nfsv4 operations counters */
+ for (i=0; i<NFS4_NUMOPS; i++)
+ nfsdstats.nfs4_opcount[i] = 0;
}

void
diff -aurp linux-2.6.17-rc2.old/include/linux/nfsd/stats.h linux-2.6.17-rc2/include/linux/nfsd/stats.h
--- linux-2.6.17-rc2.old/include/linux/nfsd/stats.h 2006-04-19
08:30:49.000000000 +0530
+++ linux-2.6.17-rc2/include/linux/nfsd/stats.h 2006-05-15
18:12:30.000000000 +0530
@@ -9,6 +9,8 @@
#ifndef LINUX_NFSD_STATS_H
#define LINUX_NFSD_STATS_H

+#define NFS4_NUMOPS 37
+
struct nfsd_stats {
unsigned int rchits; /* repcache hits */
unsigned int rcmisses; /* repcache hits */
@@ -27,6 +29,7 @@ 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 */
+ unsigned int nfs4_opcount[NFS4_NUMOPS]; /* count of
individual nfsv4 operations */
};

/* thread usage wraps very million seconds (approx one fortnight) */

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.

Submitted by: Shankar Anand <[email protected]>

fs/nfsd/nfs4proc.c +5 -0
diff -aurp linux-2.6.17-rc2.old/fs/nfsd/nfs4proc.c linux-2.6.17-rc2/fs/nfsd/nfs4proc.c
@@ -54,6 +54,7 @@
 #include <linux/nfsd/state.h>
 #include <linux/nfsd/xdr4.h>
 #include <linux/nfs4_acl.h>
+#include <linux/nfsd/stats.h>
 
 #define NFSDDBG_FACILITY		NFSDDBG_PROC
 
@@ -930,6 +931,10 @@ 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);
+		
+		/* Maintaining count for each nfsv4 operation */
+		if ( (op->opnum >= OP_ACCESS) && ( (op->opnum - OP_ACCESS) < NFS4_NUMOPS) )
+			nfsdstats.nfs4_opcount[op->opnum - OP_ACCESS]++;
 	}
 
 out:
fs/nfsd/stats.c +11 -0
diff -aurp linux-2.6.17-rc2.old/fs/nfsd/stats.c linux-2.6.17-rc2/fs/nfsd/stats.c
@@ -72,6 +72,12 @@ static int nfsd_proc_show(struct seq_fil
 	/* show my rpc info */
 	svc_seq_show(seq, &nfsd_svcstats);
 
+	/* show count for individual nfsv4 operations */
+	seq_printf(seq,"proc4ops %u", NFS4_NUMOPS);
+	for (i=0; i<NFS4_NUMOPS; i++)
+		seq_printf(seq, " %u", nfsdstats.nfs4_opcount[i]);
+
+	seq_putc(seq, '\n');
 	return 0;
 }
 
@@ -91,7 +97,12 @@ static const struct file_operations nfsd
 void
 nfsd_stat_init(void)
 {
+	int i;
 	svc_proc_register(&nfsd_svcstats, &nfsd_proc_fops);
+
+	/* Initialising nfsv4 operations counters */
+	for (i=0; i<NFS4_NUMOPS; i++)
+		nfsdstats.nfs4_opcount[i] = 0;
 }
 
 void
include/linux/nfsd/stats.h +3 -0
diff -aurp linux-2.6.17-rc2.old/include/linux/nfsd/stats.h linux-2.6.17-rc2/include/linux/nfsd/stats.h
@@ -9,6 +9,8 @@
 #ifndef LINUX_NFSD_STATS_H
 #define LINUX_NFSD_STATS_H
 
+#define NFS4_NUMOPS	37	 
+
 struct nfsd_stats {
 	unsigned int	rchits;		/* repcache hits */
 	unsigned int	rcmisses;	/* repcache hits */
@@ -27,6 +29,7 @@ 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 */
+	unsigned int	nfs4_opcount[NFS4_NUMOPS];	/* count of individual nfsv4 operations */
 };
 
 /* thread usage wraps very million seconds (approx one fortnight) */
#3 lore raw
In reply to a message not in the archive

Hi,

Attaching the new patch with changes according to Bruce's comments.

Quoted 1 line

On 5/18/2006 at 3:06:38 am "J. Bruce Fields" <[email protected]>

Quoted 2 lines · wrote:
Quoted 1 line · Shankar Anand

This patch adds a nfs4 operations count array to nfsd_stats

structure.

Quoted 2 lines
Quoted 2 lines

The count is incremented in nfsd4_proc_compound() where all the operations are handled by the nfsv4 server. This count of

individual

Quoted 5 lines
Quoted 3 lines

nfsv4 operations is also entered into /proc filesystem.

Submitted by: Shankar Anand <[email protected]>

Note that should be "Signed-off-by:"; see the "Developer's

Certificate

Quoted 1 line

of Origin" in Documentation/SubmittingPatches.

Changed.

Quoted 6 lines
Quoted 6 lines
(quoted diff) +1 -0
@@ -91,7 +97,12 @@ static const struct file_operations nfsd
 void
 nfsd_stat_init(void)
 {
+	int i;
 	svc_proc_register(&nfsd_svcstats, &nfsd_proc_fops);
Quoted 8 lines

Review static const struct file_operations nfsd · line 106

Quoted 5 lines
(quoted diff) +4 -0
+
+	/* Initialising nfsv4 operations counters */
+	for (i=0; i<NFS4_NUMOPS; i++)
+		nfsdstats.nfs4_opcount[i] = 0;
 }

Hm. Have you checked whether this compiles when NFSv4 is configured out?

Verified compilation when nfsv4 is configured out. And also made changes so that the nfsv4 operation statistics are captured only when nfsv4 is configured.

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.

fs/nfsd/nfs4proc.c +5 -0
diff -aurp linux-2.6.17-rc2.old/fs/nfsd/nfs4proc.c linux-2.6.17-rc2/fs/nfsd/nfs4proc.c
@@ -54,6 +54,7 @@
 #include <linux/nfsd/state.h>
 #include <linux/nfsd/xdr4.h>
 #include <linux/nfs4_acl.h>
+#include <linux/nfsd/stats.h>
 
 #define NFSDDBG_FACILITY		NFSDDBG_PROC
 
@@ -930,6 +931,10 @@ 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);
+		
+		/* Maintaining count for each nfsv4 operation */
+		if ( (op->opnum >= OP_ACCESS) && ( (op->opnum - OP_ACCESS) < NFS4_NUMOPS) )
+			nfsdstats.nfs4_opcount[op->opnum - OP_ACCESS]++;
 	}
 
 out:
fs/nfsd/stats.c +14 -0
diff -aurp linux-2.6.17-rc2.old/fs/nfsd/stats.c linux-2.6.17-rc2/fs/nfsd/stats.c
@@ -72,6 +72,14 @@ static int nfsd_proc_show(struct seq_fil
 	/* show my rpc info */
 	svc_seq_show(seq, &nfsd_svcstats);
 
+#ifdef	CONFIG_NFS_V4
+	/* show count for individual nfsv4 operations */
+	seq_printf(seq,"proc4ops %u", NFS4_NUMOPS);
+	for (i=0; i<NFS4_NUMOPS; i++)
+		seq_printf(seq, " %u", nfsdstats.nfs4_opcount[i]);
+
+	seq_putc(seq, '\n');
+#endif
 	return 0;
 }
 
@@ -91,6 +99,12 @@ static const struct file_operations nfsd
 void
 nfsd_stat_init(void)
 {
+#ifdef	CONFIG_NFS_V4
+	int i;
+	/* Initialising nfsv4 operations counters */
+	for (i=0; i<NFS4_NUMOPS; i++)
+		nfsdstats.nfs4_opcount[i] = 0;
+#endif
 	svc_proc_register(&nfsd_svcstats, &nfsd_proc_fops);
 }
 
include/linux/nfsd/stats.h +7 -0
diff -aurp linux-2.6.17-rc2.old/include/linux/nfsd/stats.h linux-2.6.17-rc2/include/linux/nfsd/stats.h
@@ -9,6 +9,10 @@
 #ifndef LINUX_NFSD_STATS_H
 #define LINUX_NFSD_STATS_H
 
+#ifdef	CONFIG_NFSD_V4
+#define NFS4_NUMOPS	37
+#endif
+
 struct nfsd_stats {
 	unsigned int	rchits;		/* repcache hits */
 	unsigned int	rcmisses;	/* repcache hits */
@@ -27,6 +31,9 @@ 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[NFS4_NUMOPS];	/* count of individual nfsv4 operations */
+#endif
 };
 
 /* thread usage wraps very million seconds (approx one fortnight) */

_______________________________________________
NFSv4 mailing list
[email protected]
http://linux-nfs.org/cgi-bin/mailman/listinfo/nfsv4

#4 lore raw
Quoted 3 lines · Shankar Anand

Verified compilation when nfsv4 is configured out. And also made changes so that the nfsv4 operation statistics are captured only when nfsv4 is configured.

Thanks! Looks fine to me.

One last thing I wonder about--the current /proc/net/rpc/nfsd ends with lines like:

proc2 18 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 proc3 22 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 proc4 2 4 172

where the two operations counted on the last line are NULL and COMPOUND. You're appending one more line, to make:

proc2 18 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
proc3 22 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
proc4 2 4 172
proc4ops 37 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

I like the fact that that doesn't bother the preexisting proc4 line. On the other hand, as far as we know nobody's ever used the data on that line, and it's hard to see how they would in the future (the number of NULL calls to the server isn't very important), so may it would be simplest just to replace the proc4 line entirely, as was done on the client side.

Any strong opinions from anyone else?

--b.

#5 lore raw

Hi,

Quoted 25 lines

On 5/19/2006 at 9:57:47 pm,
"J. Bruce Fields" <[email protected]> wrote:

Quoted 3 lines · Shankar Anand

Verified compilation when nfsv4 is configured out. And also=20 made changes so that the nfsv4 operation statistics are captured only when nfsv4 is configured.

=20
Thanks! Looks fine to me.
=20
One last thing I wonder about--the current /proc/net/rpc/nfsd ends with lines like:
=20
proc2 18 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
proc3 22 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
proc4 2 4 172
=20
where the two operations counted on the last line are NULL and COMPOUND. You're appending one more line, to make:
=20
proc2 18 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
proc3 22 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
proc4 2 4 172
proc4ops 37 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
=20

Quoted 8 lines

I like the fact that that doesn't bother the preexisting proc4 line. On the other hand, as far as we know nobody's ever used the data on that line, and it's hard to see how they would in the future (the number of NULL calls to the server isn't very important), so may it would be simplest just to replace the proc4 line entirely, as was done on the client side.
=20
Any strong opinions from anyone else?

There are some small issues in doing that.

The proc2, proc3 and proc4 lines get written into the /proc file by=20 rpc_proc_show() function in sunrpc library unlike the proc4ops line = that=20
I have written now, which gets written into /proc file at nfs level in=20 nfs_proc_show().

All the procedures that are registered as rpc procedures, get their = statistics=20
recorded in the /proc file in the sunrpc rpc_proc_show() function. If = we=20
have to avoid the original proc4 line, we will have to introduce a special = case=20
to specifically refrain from writing v4 rpc statistics into the /proc = file,=20
which may not be appropriate.

In the client, all the procedures are registered as rpc procedures in = nfs4xdr.c.
Hence, the proc4 line for the client contains all the v4 procedures.

Cheers,
Shankar

-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

#6 lore raw

Hi,

Quoted 1 line

On 5/20/2006 at 1:37:34 pm, "Shankar Anand" <[email protected]>

Quoted 12 lines · wrote:

Hi,

Quoted 10 lines

On 5/19/2006 at 9:57:47 pm,
"J. Bruce Fields" <[email protected]> wrote:

Quoted 3 lines · Shankar Anand

Verified compilation when nfsv4 is configured out. And also made changes so that the nfsv4 operation statistics are captured only when nfsv4 is configured.

Thanks! Looks fine to me.

One last thing I wonder about--the current /proc/net/rpc/nfsd ends

with

Quoted 7 lines
Quoted 7 lines

lines like:

proc2 18 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 proc3 22 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 proc4 2 4 172

where the two operations counted on the last line are NULL and

COMPOUND.

Quoted 6 lines
Quoted 6 lines

You're appending one more line, to make:

proc2 18 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
proc3 22 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 proc4 2 4 172
proc4ops 37 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

0 0

Quoted 3 lines
Quoted 3 lines

0 0 0 0 0 0 0

I like the fact that that doesn't bother the preexisting proc4 line.

On

Quoted 1 line
Quoted 1 line

the other hand, as far as we know nobody's ever used the data on

that

Quoted 1 line
Quoted 1 line

line, and it's hard to see how they would in the future (the number

of

Quoted 2 lines
Quoted 2 lines

NULL calls to the server isn't very important), so may it would be simplest just to replace the proc4 line entirely, as was done on

the

Quoted 8 lines
Quoted 3 lines

client side.

Any strong opinions from anyone else?

There are some small issues in doing that.

The proc2, proc3 and proc4 lines get written into the /proc file by rpc_proc_show() function in sunrpc library unlike the proc4ops line

that

Quoted 1 line

I have written now, which gets written into /proc file at nfs level

in

Quoted 5 lines

nfs_proc_show().

All the procedures that are registered as rpc procedures, get their statistics
recorded in the /proc file in the sunrpc rpc_proc_show() function. If

we

Quoted 1 line

have to avoid the original proc4 line, we will have to introduce a

special

Quoted 2 lines

case
to specifically refrain from writing v4 rpc statistics into the /proc

file,

Quoted 6 lines

which may not be appropriate.

In the client, all the procedures are registered as rpc procedures in

nfs4xdr.c.
Hence, the proc4 line for the client contains all the v4 procedures.

Is adding the proc4ops line ok? Are these patches ok with everyone? Please get back if you have comments.

Cheers,
Shankar