summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRajesh Amaravathi <rajesh@redhat.com>2012-05-23 14:08:37 +0530
committerVijay Bellur <vbellur@redhat.com>2012-07-16 02:24:54 -0700
commitc0a5348af37c634cc61fa72251e029a3a0301eca (patch)
treecc96a004d7be9db41892f5d3d31940c184d91604
parent1e1a162fa7ea5b6275a0212273ca96b4de410c00 (diff)
nfs/nlm: statedump of locks
This change allows statedump of nlm locks giving number of clients, number of locks each client holds and the files on which lock(s) is/are held. Change-Id: I6341c12ec58005ef71b93b316b527e610ff7ee8f BUG: 824804 Signed-off-by: Rajesh Amaravathi <rajesh@redhat.com> Reviewed-on: http://review.gluster.com/3492 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Pranith Kumar Karampuri <pranithk@gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r--xlators/nfs/server/src/nfs.c11
-rw-r--r--xlators/nfs/server/src/nlm4.c45
2 files changed, 56 insertions, 0 deletions
diff --git a/xlators/nfs/server/src/nfs.c b/xlators/nfs/server/src/nfs.c
index 6e9a274d9..6ed361429 100644
--- a/xlators/nfs/server/src/nfs.c
+++ b/xlators/nfs/server/src/nfs.c
@@ -965,6 +965,16 @@ out:
return ret;
}
+extern int32_t
+nlm_priv (xlator_t *this);
+
+int32_t
+nfs_priv (xlator_t *this)
+{
+ return nlm_priv (this);
+}
+
+
struct xlator_cbks cbks = {
.forget = nfs_forget,
};
@@ -972,6 +982,7 @@ struct xlator_cbks cbks = {
struct xlator_fops fops = { };
struct xlator_dumpops dumpops = {
+ .priv = nfs_priv,
.priv_to_dict = nfs_priv_to_dict,
};
diff --git a/xlators/nfs/server/src/nlm4.c b/xlators/nfs/server/src/nlm4.c
index 08aaef0be..2901ab3f4 100644
--- a/xlators/nfs/server/src/nlm4.c
+++ b/xlators/nfs/server/src/nlm4.c
@@ -48,6 +48,7 @@
#include <rpc/pmap_clnt.h>
#include <rpc/rpc.h>
#include <rpc/xdr.h>
+#include <statedump.h>
/* TODO:
* 1) 2 opens racing .. creating an fd leak.
@@ -2404,3 +2405,47 @@ nlm4svc_init(xlator_t *nfsx)
err:
return NULL;
}
+
+int32_t
+nlm_priv (xlator_t *this)
+{
+ int32_t ret = -1;
+ uint32_t client_count = 0;
+ uint64_t file_count = 0;
+ nlm_client_t *client = NULL;
+ nlm_fde_t *fde = NULL;
+ char key[GF_DUMP_MAX_BUF_LEN] = {0};
+ char gfid_str[64] = {0};
+
+ gf_proc_dump_add_section("nfs.nlm");
+
+ if (TRY_LOCK (&nlm_client_list_lk))
+ return ret;
+
+ list_for_each_entry (client, &nlm_client_list, nlm_clients) {
+
+ gf_proc_dump_build_key (key, "client",
+ "%d.hostname", client_count);
+ gf_proc_dump_write (key, "%s\n", client->caller_name);
+
+ file_count = 0;
+ list_for_each_entry (fde, &client->fdes, fde_list) {
+ gf_proc_dump_build_key (key, "file",
+ "%"PRIu64".gfid", file_count);
+ memset (gfid_str, 0, 64);
+ uuid_utoa_r (fde->fd->inode->gfid, gfid_str);
+ gf_proc_dump_write (key, "%s", gfid_str);
+ file_count++;
+ }
+
+ gf_proc_dump_build_key (key, "client", "files-locked");
+ gf_proc_dump_write (key, "%"PRIu64"\n", file_count);
+ client_count++;
+ }
+ UNLOCK (&nlm_client_list_lk);
+
+ gf_proc_dump_build_key (key, "nlm", "client-count");
+ gf_proc_dump_write (key, "%d", client_count);
+
+ return ret;
+}