From: Michael Vrable Date: Tue, 30 Mar 2010 03:56:00 +0000 (-0700) Subject: Track number of unanswered RPC requests, for debugging. X-Git-Url: http://git.vrable.net/?p=bluesky.git;a=commitdiff_plain;h=d3c7929485ee2a0637e8fce739bad597ce11253d Track number of unanswered RPC requests, for debugging. --- diff --git a/bluesky/inode.c b/bluesky/inode.c index 1c89c29..4f970fe 100644 --- a/bluesky/inode.c +++ b/bluesky/inode.c @@ -366,7 +366,7 @@ void bluesky_inode_fetch(BlueSkyFS *fs, uint64_t inum) sprintf(key, "inode-%016"PRIx64, inum); BlueSkyInode *inode = bluesky_new_inode(inum, fs, BLUESKY_PENDING); - i->change_count = 0; + inode->change_count = 0; bluesky_inode_ref(inode); // Extra ref held by fetching process g_mutex_lock(inode->lock); bluesky_insert_inode(fs, inode); diff --git a/nfs3/rpc.c b/nfs3/rpc.c index 76de1cd..4dcd21e 100644 --- a/nfs3/rpc.c +++ b/nfs3/rpc.c @@ -27,6 +27,8 @@ #include "bluesky.h" extern BlueSkyFS *fs; +static int outstanding_rpcs = 0; + /* TCP port number to use for NFS protocol. (Should be 2049.) */ #define NFS_SERVICE_PORT 2051 @@ -128,6 +130,8 @@ async_rpc_send_failure(RPCRequest *req, enum accept_stat stat) { struct rpc_fail_reply header; + g_atomic_int_add(&outstanding_rpcs, -1); + header.xid = htonl(req->xid); header.type = htonl(1); /* REPLY */ header.stat = htonl(MSG_ACCEPTED); @@ -189,6 +193,8 @@ async_rpc_send_reply(RPCRequest *req, void *result) return; } + g_atomic_int_add(&outstanding_rpcs, -1); + struct rpc_reply header; header.xid = htonl(req->xid); header.type = htonl(1); /* REPLY */ @@ -489,6 +495,11 @@ static void sig_handler(int sig) static gboolean async_flushd(gpointer data) { + int rpc_count = g_atomic_int_get(&outstanding_rpcs); + if (rpc_count != 0) { + g_print("Currently outstanding RPC requests: %d\n", rpc_count); + } + if (fs_dump_requested) { bluesky_debug_dump(fs); fs_dump_requested = 0; @@ -568,6 +579,8 @@ static gboolean async_rpc_dispatch(RPCConnection *rpc) return FALSE; } + g_atomic_int_add(&outstanding_rpcs, 1); + RPCRequest *req = g_new0(RPCRequest, 1); req->connection = rpc; req->time_start = time_start; @@ -588,18 +601,24 @@ static gboolean async_rpc_dispatch(RPCConnection *rpc) buf += sizeof(struct rpc_call_header); for (i = 0; i < 2; i++) { struct rpc_auth *auth = (struct rpc_auth *)buf; - if (buf - msg->str + sizeof(struct rpc_auth) > msg->len) + if (buf - msg->str + sizeof(struct rpc_auth) > msg->len) { + g_atomic_int_add(&outstanding_rpcs, -1); return FALSE; + } gsize authsize = ntohl(auth->len) + sizeof(struct rpc_auth); - if (authsize > MAX_RPC_MSGSIZE) + if (authsize > MAX_RPC_MSGSIZE) { + g_atomic_int_add(&outstanding_rpcs, -1); return FALSE; + } buf += authsize; } - if (buf - msg->str > msg->len) + if (buf - msg->str > msg->len) { + g_atomic_int_add(&outstanding_rpcs, -1); return FALSE; + } req->raw_args = msg; req->raw_args_header_bytes = buf - msg->str;