summaryrefslogtreecommitdiffstats
path: root/xlators/nfs/server
diff options
context:
space:
mode:
authorKrishna Srinivas <ksriniva@redhat.com>2012-04-05 18:42:25 +0530
committerVijay Bellur <vijay@gluster.com>2012-04-20 06:01:50 -0700
commitd10e17bf59966d66ebe4ea5627cf89b10bcd5fe8 (patch)
tree544e9eb154b15cca37c2691876537f5141bec7e9 /xlators/nfs/server
parent443806fcfa6332163e08a63620e54d2f6be3996e (diff)
nlm: register client name with statd for blocking, nonblocking and reclaim lock calls
Change-Id: If983f7b2f94703442e0745c5cbd2701edb2a972a BUG: 809362 Signed-off-by: Krishna Srinivas <ksriniva@redhat.com> Reviewed-on: http://review.gluster.com/3097 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vijay@gluster.com>
Diffstat (limited to 'xlators/nfs/server')
-rw-r--r--xlators/nfs/server/src/nlm4.c47
-rw-r--r--xlators/nfs/server/src/nlm4.h1
2 files changed, 39 insertions, 9 deletions
diff --git a/xlators/nfs/server/src/nlm4.c b/xlators/nfs/server/src/nlm4.c
index 9fd374b1f93..be577283707 100644
--- a/xlators/nfs/server/src/nlm4.c
+++ b/xlators/nfs/server/src/nlm4.c
@@ -255,6 +255,27 @@ nlm4_call_state_init (struct nfs3_state *s, rpcsvc_request_t *req)
return cs;
}
+int
+nlm_monitor (char *caller_name)
+{
+ nlm_client_t *nlmclnt = NULL;
+ int monitor = -1;
+
+ LOCK (&nlm_client_list_lk);
+ list_for_each_entry (nlmclnt, &nlm_client_list, nlm_clients) {
+ if (!strcmp(caller_name, nlmclnt->caller_name)) {
+ monitor = nlmclnt->nsm_monitor;
+ nlmclnt->nsm_monitor = 1;
+ break;
+ }
+ }
+ UNLOCK (&nlm_client_list_lk);
+ if (monitor == -1) {
+ gf_log (GF_NLM, GF_LOG_ERROR, "%s was not found in the nlmclnt list", caller_name);
+ }
+ return monitor;
+}
+
rpc_clnt_t *
nlm_get_rpc_clnt (char *caller_name)
{
@@ -465,15 +486,17 @@ nlm4_file_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
return 0;
}
-int nsm_monitor(char *host)
+void *
+nsm_monitor(void *arg)
{
CLIENT *clnt = NULL;
enum clnt_stat ret;
struct mon nsm_mon;
struct sm_stat_res res;
struct timeval tout = { 5, 0 };
- int retstat = -1;
+ char *host = NULL;
+ host = arg;
nsm_mon.mon_id.mon_name = gf_strdup(host);
nsm_mon.mon_id.my_id.my_name = gf_strdup("localhost");
nsm_mon.mon_id.my_id.my_prog = NLMCBK_PROGRAM;
@@ -508,13 +531,13 @@ int nsm_monitor(char *host)
clnt_sperrno(ret));
goto out;
}
- retstat = 0;
+
out:
GF_FREE(nsm_mon.mon_id.mon_name);
GF_FREE(nsm_mon.mon_id.my_id.my_name);
if (clnt != NULL)
clnt_destroy(clnt);
- return retstat;
+ return NULL;
}
nlm_client_t *
@@ -873,7 +896,6 @@ nlm4_establish_callback (void *csarg)
glusterfs_this_set (cs->nfsx);
caller_name = cs->args.nlm4_lockargs.alock.caller_name;
- nsm_monitor (caller_name);
rpc_transport_get_peeraddr (cs->trans, NULL, 0, &sa, sizeof (sa));
sockaddr = (struct sockaddr*) &sa;
@@ -1228,19 +1250,26 @@ nlm4svc_lock_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
nlm4_stats stat = nlm4_denied;
nfs3_call_state_t *cs = NULL;
int transit_cnt = -1;
+ char *caller_name = NULL;
+ pthread_t thr;
cs = frame->local;
-
+ caller_name = cs->args.nlm4_lockargs.alock.caller_name;
transit_cnt = nlm_dec_transit_count (cs->fd,
- cs->args.nlm4_lockargs.alock.caller_name);
+ caller_name);
if (op_ret == -1) {
if (transit_cnt == 0)
nlm_search_and_delete (cs->fd,
- cs->args.nlm4_lockargs.alock.caller_name);
+ caller_name);
stat = nlm4_errno_to_nlm4stat (op_errno);
goto err;
- } else
+ } else {
stat = nlm4_granted;
+ if (!nlm_monitor (caller_name)) {
+ /* FIXME: handle nsm_monitor failure */
+ pthread_create (&thr, NULL, nsm_monitor, (void*)caller_name);
+ }
+ }
err:
if (cs->args.nlm4_lockargs.block) {
diff --git a/xlators/nfs/server/src/nlm4.h b/xlators/nfs/server/src/nlm4.h
index 3c00186d971..db5874387f4 100644
--- a/xlators/nfs/server/src/nlm4.h
+++ b/xlators/nfs/server/src/nlm4.h
@@ -62,6 +62,7 @@ typedef struct nlm_client {
struct list_head fdes;
struct rpc_clnt *rpc_clnt;
char *caller_name;
+ int nsm_monitor;
} nlm_client_t;
typedef struct nlm_fde {