Improve statistics gathered.
[bluesky.git] / nfs3 / rpc.c
index dbe0a64..5341f20 100644 (file)
@@ -28,6 +28,7 @@
 extern BlueSkyFS *fs;
 
 static int outstanding_rpcs = 0;
+static struct bluesky_stats *rpc_recv_stats, *rpc_send_stats;
 
 /* TCP port number to use for NFS protocol.  (Should be 2049.) */
 #define NFS_SERVICE_PORT 2051
@@ -194,6 +195,7 @@ async_rpc_send_reply(RPCRequest *req, void *result)
     }
 
     g_atomic_int_add(&outstanding_rpcs, -1);
+    bluesky_stats_add(rpc_send_stats, str->len);
 
     struct rpc_reply header;
     header.xid = htonl(req->xid);
@@ -569,6 +571,8 @@ static gboolean async_rpc_dispatch(RPCConnection *rpc)
     GString *msg = rpc->msgbuf;
     const char *buf = msg->str;
 
+    bluesky_stats_add(rpc_recv_stats, msg->len);
+
     if (msg->len < sizeof(struct rpc_call_header)) {
         fprintf(stderr, "Short RPC message: only %zd bytes!\n", msg->len);
         return FALSE;
@@ -861,6 +865,9 @@ void register_rpc()
 {
     SVCXPRT *transp;
 
+    rpc_recv_stats = bluesky_stats_new("NFS RPC Messages In");
+    rpc_send_stats = bluesky_stats_new("NFS RPC Messages Out");
+
     async_rpc_init();
 
     /* MOUNT protocol */