linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steve Dickson <SteveD@redhat.com>
To: Linux NFS Mailing list <linux-nfs@vger.kernel.org>
Subject: [PATCH 1/3] nfsstat: The --list option does not work on server stats.
Date: Wed, 08 Apr 2009 12:01:26 -0400	[thread overview]
Message-ID: <49DCCA56.9040208@RedHat.com> (raw)
In-Reply-To: <49DCB9DA.5000300-AfCzQyP5zfLQT0dZR+AlfA@public.gmane.org>

The print_stats_list() routine was using the client's
stats to decide whether to display any stats. This did
not work when there was only server stats.
    
This patch breaks up print_stats_list into two different
routines allowing both server and clients stats to be
listed.
    
Signed-off-by: Steve Dickson <steved@redhat.com>

diff --git a/utils/nfsstat/nfsstat.c b/utils/nfsstat/nfsstat.c
index 5adb571..7e9f327 100644
--- a/utils/nfsstat/nfsstat.c
+++ b/utils/nfsstat/nfsstat.c
@@ -170,7 +170,7 @@ DECLARE_CLT(cltinfo, _old);
 static void		print_all_stats(int, int, int);
 static void		print_server_stats(int, int);
 static void		print_client_stats(int, int);
-static void		print_stats_list(int);
+static void		print_stats_list(int, int, int);
 static void		print_numbers(const char *, unsigned int *,
 					unsigned int);
 static void		print_callstats(const char *, const char **,
@@ -436,7 +436,7 @@ main(int argc, char **argv)
 				diff_stats(clientinfo_tmp, clientinfo, 0);
 			}
 			if (opt_list) {
-				print_stats_list(opt_prt);
+				print_stats_list(opt_srv, opt_clt, opt_prt);
 			} else {
 				print_all_stats(opt_srv, opt_clt, opt_prt);
 			}
@@ -451,7 +451,7 @@ main(int argc, char **argv)
 		}	
 	} else {
 		if (opt_list) {
-			print_stats_list(opt_prt);
+			print_stats_list(opt_srv, opt_clt, opt_prt);
 		} else {
 			print_all_stats(opt_srv, opt_clt, opt_prt);
 		}
@@ -606,7 +606,7 @@ print_client_stats(int opt_clt, int opt_prt)
 			if (opt_sleep && !has_stats(cltproc3info)) {
 				;
 			} else {
-				print_callstats( LABEL_cltproc3,
+				print_callstats(LABEL_cltproc3,
 					nfsv3name, cltproc3info + 1, 
 					sizeof(nfsv3name)/sizeof(char *));
 			}
@@ -625,38 +625,89 @@ print_client_stats(int opt_clt, int opt_prt)
 }
 
 static void
-print_stats_list(int opt_prt) 
+print_clnt_list(int opt_prt) 
 {
 	if (opt_prt & PRNT_CALLS) {
-		if ((opt_prt & PRNT_V2) || ((opt_prt & PRNT_AUTO) && has_stats(cltproc2info))) {
-			print_callstats_list(
-			"nfs v2 server",
-			nfsv2name, srvproc2info + 1, sizeof(nfsv2name)/sizeof(char *));
-			print_callstats_list(
-			"nfs v2 client",
-			nfsv2name, cltproc2info + 1,  sizeof(nfsv2name)/sizeof(char *));
+		if ((opt_prt & PRNT_V2) || 
+				((opt_prt & PRNT_AUTO) && has_stats(cltproc2info))) {
+			if (opt_sleep && !has_stats(cltproc2info)) {
+				;
+			} else {
+				print_callstats_list("nfs v2 client",
+					nfsv2name, cltproc2info + 1,  
+					sizeof(nfsv2name)/sizeof(char *));
+			}
+		}
+		if ((opt_prt & PRNT_V3) || 
+				((opt_prt & PRNT_AUTO) && has_stats(cltproc3info))) {
+			if (opt_sleep && !has_stats(cltproc3info)) {
+				;
+			} else { 
+				print_callstats_list("nfs v3 client",
+					nfsv3name, cltproc3info + 1, 
+					sizeof(nfsv3name)/sizeof(char *));
+			}
+		}
+		if ((opt_prt & PRNT_V4) || 
+				((opt_prt & PRNT_AUTO) && has_stats(cltproc4info))) {
+			if (opt_sleep && !has_stats(cltproc4info)) {
+				;
+			} else {
+				print_callstats_list("nfs v4 ops",
+					nfssrvproc4opname, srvproc4opsinfo + 1, 
+					sizeof(nfssrvproc4opname)/sizeof(char *));
+				print_callstats_list("nfs v4 client",
+					nfscltproc4name, cltproc4info + 1,  
+					sizeof(nfscltproc4name)/sizeof(char *));
+			}
+		}
+	}
+}
+static void
+print_serv_list(int opt_prt) 
+{
+	if (opt_prt & PRNT_CALLS) {
+		if ((opt_prt & PRNT_V2) || 
+				((opt_prt & PRNT_AUTO) && has_stats(srvproc2info))) {
+			if (opt_sleep && !has_stats(srvproc2info)) {
+				;
+			} else {
+				print_callstats_list("nfs v2 server",
+					nfsv2name, srvproc2info + 1, 
+					sizeof(nfsv2name)/sizeof(char *));
+			}
 		}
-		if ((opt_prt & PRNT_V3) || ((opt_prt & PRNT_AUTO) && has_stats(cltproc3info))) {
-			print_callstats_list(
-			"nfs v3 server",
-			nfsv3name, srvproc3info + 1, sizeof(nfsv3name)/sizeof(char *));
-			print_callstats_list(
-			"nfs v3 client",
-			nfsv3name, cltproc3info + 1, sizeof(nfsv3name)/sizeof(char *));
+		if ((opt_prt & PRNT_V3) || 
+				((opt_prt & PRNT_AUTO) && has_stats(srvproc3info))) {
+			if (opt_sleep && !has_stats(srvproc3info)) {
+				;
+			} else {
+				print_callstats_list("nfs v3 server",
+					nfsv3name, srvproc3info + 1, 
+					sizeof(nfsv3name)/sizeof(char *));
+			}
 		}
-		if ((opt_prt & PRNT_V4) || ((opt_prt & PRNT_AUTO) && has_stats(cltproc4info))) {
-			print_callstats_list(
-			"nfs v4 server",
-			nfssrvproc4name, srvproc4info + 1, sizeof(nfssrvproc4name)/sizeof(char *));
-			print_callstats_list(
-			"nfs v4 ops",
-			nfssrvproc4opname, srvproc4opsinfo + 1, sizeof(nfssrvproc4opname)/sizeof(char *));
-			print_callstats_list(
-			"nfs v4 client",
-			nfscltproc4name, cltproc4info + 1,  sizeof(nfscltproc4name)/sizeof(char *));
+		if ((opt_prt & PRNT_V4) || 
+				((opt_prt & PRNT_AUTO) && has_stats(srvproc4opsinfo))) {
+			if (opt_sleep && !has_stats(srvproc4info)) {
+				;
+			} else {
+				print_callstats_list("nfs v4 ops",
+					nfssrvproc4opname, srvproc4opsinfo + 1, 
+					sizeof(nfssrvproc4opname)/sizeof(char *));
+			}
 		}
 	}
 }
+static void
+print_stats_list(int opt_srv, int opt_clt, int opt_prt) 
+{
+	if (opt_srv)
+		print_serv_list(opt_prt);
+
+	if (opt_clt)
+		print_clnt_list(opt_prt);
+}
 
 static statinfo *
 get_stat_info(const char *sp, struct statinfo *statp)

  parent reply	other threads:[~2009-04-08 16:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-08 14:51 [PATCH 0/3] nfsstat: Fixing and improving the new --sleep and --list options Steve Dickson
     [not found] ` <49DCB9DA.5000300-AfCzQyP5zfLQT0dZR+AlfA@public.gmane.org>
2009-04-08 16:01   ` Steve Dickson [this message]
2009-04-08 16:03   ` [PATCH 2/3] nfsstat: -Z showing incorrect server stats Steve Dickson
2009-04-08 16:05   ` [PATCH 3/3] nfsstat: Eliminate the displaying zero stats Steve Dickson
     [not found]     ` <49DCCB34.4080901-AfCzQyP5zfLQT0dZR+AlfA@public.gmane.org>
2009-04-12 17:23       ` J. Bruce Fields
2009-04-13 12:08         ` Steve Dickson
     [not found]           ` <49E32B4B.5060704-AfCzQyP5zfLQT0dZR+AlfA@public.gmane.org>
2009-04-13 17:02             ` Kevin Constantine
     [not found]               ` <49E3701E.40202-P5ys19MLBK/QT0dZR+AlfA@public.gmane.org>
2009-04-13 21:28                 ` Steve Dickson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49DCCA56.9040208@RedHat.com \
    --to=steved@redhat.com \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).