glusterfs  8.2
About: GlusterFS is a network/cluster filesystem. The storage server (or each in a cluster) runs glusterfsd and the clients use mount command or glusterfs client to mount the exported filesystem. Release series 8.x (latest version).
  Fossies Dox: glusterfs-8.2.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

nlm4.c
Go to the documentation of this file.
1 /*
2  Copyright (c) 2012 Gluster, Inc. <http://www.gluster.com>
3  This file is part of GlusterFS.
4 
5  This file is licensed to you under your choice of the GNU Lesser
6  General Public License, version 3 or any later version (LGPLv3 or
7  later), or the GNU General Public License, version 2 (GPLv2), in all
8  cases as published by the Free Software Foundation.
9 */
10 
11 #include <glusterfs/defaults.h>
12 #include "rpcsvc.h"
13 #include <glusterfs/dict.h>
14 #include <glusterfs/xlator.h>
15 #include "nfs.h"
16 #include <glusterfs/mem-pool.h>
17 #include <glusterfs/logging.h>
18 #include <glusterfs/syscall.h>
19 #include "nfs-fops.h"
20 #include "mount3.h"
21 #include "nfs3.h"
22 #include "nfs-mem-types.h"
23 #include "nfs3-helpers.h"
24 #include "nfs3-fh.h"
25 #include "nlm4.h"
26 #include "nlm4-xdr.h"
27 #include "msg-nfs3.h"
28 #include "nfs-generics.h"
29 #include "rpc-clnt.h"
30 #include "nsm-xdr.h"
31 #include <glusterfs/run.h>
32 #include "nfs-messages.h"
33 #include <unistd.h>
34 #include <rpc/pmap_clnt.h>
35 #include <rpc/rpc.h>
36 #include <rpc/xdr.h>
37 #include <glusterfs/statedump.h>
38 
39 #define KILLALL_CMD "pkill"
40 
41 /* TODO:
42  * 1) 2 opens racing .. creating an fd leak.
43  * 2) use GF_REF_* for nlm_clnt_t
44  */
45 
46 typedef ssize_t (*nlm4_serializer)(struct iovec outmsg, void *args);
47 
48 extern void
50 
53 
56 
57 /* race on this is harmless */
59 
61 
62 #define nlm4_validate_nfs3_state(request, state, status, label, retval) \
63  do { \
64  state = rpcsvc_request_program_private(request); \
65  if (!state) { \
66  gf_msg(GF_NLM, GF_LOG_ERROR, errno, NFS_MSG_STATE_MISSING, \
67  "NFSv3 state " \
68  "missing from RPC request"); \
69  rpcsvc_request_seterr(req, SYSTEM_ERR); \
70  status = nlm4_failed; \
71  goto label; \
72  } \
73  } while (0);
74 
75 #define nlm4_handle_call_state_init(nfs3state, calls, rq, opstat, errlabel) \
76  do { \
77  calls = nlm4_call_state_init((nfs3state), (rq)); \
78  if (!calls) { \
79  gf_msg(GF_NLM, GF_LOG_ERROR, errno, NFS_MSG_INIT_CALL_STAT_FAIL, \
80  "Failed to " \
81  "init call state"); \
82  opstat = nlm4_failed; \
83  rpcsvc_request_seterr(req, SYSTEM_ERR); \
84  goto errlabel; \
85  } \
86  } while (0)
87 
88 #define nlm4_validate_gluster_fh(handle, status, errlabel) \
89  do { \
90  if (!nfs3_fh_validate(handle)) { \
91  status = nlm4_stale_fh; \
92  goto errlabel; \
93  } \
94  } while (0)
95 
96 xlator_t *
97 nfs3_fh_to_xlator(struct nfs3_state *nfs3, struct nfs3_fh *fh);
98 
99 #define nlm4_map_fh_to_volume(nfs3state, handle, req, volume, status, label) \
100  do { \
101  char exportid[256], gfid[256]; \
102  rpc_transport_t *trans = NULL; \
103  volume = nfs3_fh_to_xlator((nfs3state), &handle); \
104  if (!volume) { \
105  gf_uuid_unparse(handle.exportid, exportid); \
106  gf_uuid_unparse(handle.gfid, gfid); \
107  trans = rpcsvc_request_transport(req); \
108  gf_msg(GF_NLM, GF_LOG_ERROR, errno, NFS_MSG_FH_TO_VOL_FAIL, \
109  "Failed to map " \
110  "FH to vol: client=%s, exportid=%s, gfid=%s", \
111  trans->peerinfo.identifier, exportid, gfid); \
112  gf_msg(GF_NLM, GF_LOG_ERROR, errno, NFS_MSG_VOLUME_ERROR, \
113  "Stale nfs client %s must be trying to " \
114  "connect to a deleted volume, please " \
115  "unmount it.", \
116  trans->peerinfo.identifier); \
117  status = nlm4_stale_fh; \
118  goto label; \
119  } else { \
120  gf_msg_trace(GF_NLM, 0, "FH to Volume: %s", volume->name); \
121  rpcsvc_request_set_private(req, volume); \
122  } \
123  } while (0);
124 
125 #define nlm4_volume_started_check(nfs3state, vlm, rtval, erlbl) \
126  do { \
127  if ((!nfs_subvolume_started(nfs_state(nfs3state->nfsx), vlm))) { \
128  gf_msg(GF_NLM, GF_LOG_ERROR, 0, NFS_MSG_VOL_DISABLE, \
129  "Volume is disabled: %s", vlm->name); \
130  rtval = RPCSVC_ACTOR_IGNORE; \
131  goto erlbl; \
132  } \
133  } while (0)
134 
135 #define nlm4_check_fh_resolve_status(cst, nfstat, erlabl) \
136  do { \
137  xlator_t *xlatorp = NULL; \
138  char buf[256], gfid[GF_UUID_BUF_SIZE]; \
139  rpc_transport_t *trans = NULL; \
140  if ((cst)->resolve_ret < 0) { \
141  trans = rpcsvc_request_transport(cst->req); \
142  xlatorp = nfs3_fh_to_xlator(cst->nfs3state, &cst->resolvefh); \
143  gf_uuid_unparse(cst->resolvefh.gfid, gfid); \
144  snprintf(buf, sizeof(buf), "(%s) %s : %s", \
145  trans->peerinfo.identifier, \
146  xlatorp ? xlatorp->name : "ERR", gfid); \
147  gf_msg(GF_NLM, GF_LOG_ERROR, 0, NFS_MSG_RESOLVE_FH_FAIL, \
148  "Unable to resolve FH" \
149  ": %s", \
150  buf); \
151  nfstat = nlm4_errno_to_nlm4stat(cst->resolve_errno); \
152  goto erlabl; \
153  } \
154  } while (0)
155 
156 void
157 nlm4_prep_nlm4_testargs(nlm4_testargs *args, struct nfs3_fh *fh,
158  nlm4_lkowner_t *oh, char *cookiebytes)
159 {
160  memset(args, 0, sizeof(*args));
161  args->alock.fh.nlm4_netobj_val = (void *)fh;
162  args->alock.oh.nlm4_netobj_val = (void *)oh;
163  args->cookie.nlm4_netobj_val = (void *)cookiebytes;
164 }
165 
166 void
167 nlm4_prep_nlm4_lockargs(nlm4_lockargs *args, struct nfs3_fh *fh,
168  nlm4_lkowner_t *oh, char *cookiebytes)
169 {
170  memset(args, 0, sizeof(*args));
171  args->alock.fh.nlm4_netobj_val = (void *)fh;
172  args->alock.oh.nlm4_netobj_val = (void *)oh;
173  args->cookie.nlm4_netobj_val = (void *)cookiebytes;
174 }
175 
176 void
177 nlm4_prep_nlm4_cancargs(nlm4_cancargs *args, struct nfs3_fh *fh,
178  nlm4_lkowner_t *oh, char *cookiebytes)
179 {
180  memset(args, 0, sizeof(*args));
181  args->alock.fh.nlm4_netobj_val = (void *)fh;
182  args->alock.oh.nlm4_netobj_val = (void *)oh;
183  args->cookie.nlm4_netobj_val = (void *)cookiebytes;
184 }
185 
186 void
187 nlm4_prep_nlm4_unlockargs(nlm4_unlockargs *args, struct nfs3_fh *fh,
188  nlm4_lkowner_t *oh, char *cookiebytes)
189 {
190  memset(args, 0, sizeof(*args));
191  args->alock.fh.nlm4_netobj_val = (void *)fh;
192  args->alock.oh.nlm4_netobj_val = (void *)oh;
193  args->cookie.nlm4_netobj_val = (void *)cookiebytes;
194 }
195 
196 void
197 nlm4_prep_shareargs(nlm4_shareargs *args, struct nfs3_fh *fh,
198  nlm4_lkowner_t *oh, char *cookiebytes)
199 {
200  memset(args, 0, sizeof(*args));
201  args->share.fh.nlm4_netobj_val = (void *)fh;
202  args->share.oh.nlm4_netobj_val = (void *)oh;
203  args->cookie.nlm4_netobj_val = (void *)cookiebytes;
204 }
205 
206 void
208 {
209  memset(args, 0, sizeof(*args));
210  args->name = (void *)oh;
211 }
212 
213 void
214 nlm_copy_lkowner(gf_lkowner_t *dst, nlm4_netobj *src)
215 {
216  dst->len = src->nlm4_netobj_len;
217  memcpy(dst->data, src->nlm4_netobj_val, dst->len);
218 }
219 
220 int
222 {
223  if (!a || !b) {
225  "invalid args");
226  return -1;
227  }
228 
229  return (a->len == b->nlm4_netobj_len &&
230  !memcmp(a->data, b->nlm4_netobj_val, a->len));
231 }
232 
233 nlm4_stats
235 {
236  nlm4_stats stat = nlm4_denied;
237 
238  switch (errnum) {
239  case 0:
240  stat = nlm4_granted;
241  break;
242  case EROFS:
243  stat = nlm4_rofs;
244  break;
245  case ESTALE:
246  stat = nlm4_stale_fh;
247  break;
248  case ENOLCK:
249  stat = nlm4_failed;
250  break;
251  default:
252  stat = nlm4_denied;
253  break;
254  }
255 
256  return stat;
257 }
258 
261 {
262  nfs3_call_state_t *cs = NULL;
263 
264  if ((!s) || (!req))
265  return NULL;
266 
267  cs = nfs3_call_state_init(s, req, NULL);
268  if (!cs)
269  return NULL;
270 
271  cs->monitor = 1;
272 
273  return cs;
274 }
275 
276 int
277 nlm_monitor(char *caller_name)
278 {
279  nlm_client_t *nlmclnt = NULL;
280  int monitor = -1;
281 
283  list_for_each_entry(nlmclnt, &nlm_client_list, nlm_clients)
284  {
285  if (!strcmp(caller_name, nlmclnt->caller_name)) {
286  monitor = nlmclnt->nsm_monitor;
287  nlmclnt->nsm_monitor = 1;
288  break;
289  }
290  }
292 
293  if (monitor == -1)
295  "%s was not found in the nlmclnt list", caller_name);
296 
297  return monitor;
298 }
299 
300 rpc_clnt_t *
301 nlm_get_rpc_clnt(char *caller_name)
302 {
303  nlm_client_t *nlmclnt = NULL;
304  int nlmclnt_found = 0;
305  rpc_clnt_t *rpc_clnt = NULL;
306 
308  list_for_each_entry(nlmclnt, &nlm_client_list, nlm_clients)
309  {
310  if (!strcmp(caller_name, nlmclnt->caller_name)) {
311  nlmclnt_found = 1;
312  break;
313  }
314  }
315  if (!nlmclnt_found)
316  goto ret;
317  if (nlmclnt->rpc_clnt)
318  rpc_clnt = rpc_clnt_ref(nlmclnt->rpc_clnt);
319 ret:
321  return rpc_clnt;
322 }
323 
324 static void
326 {
327  nlm_fde_t *fde = NULL, *tmp = NULL;
328 
329  gf_msg_trace(GF_NLM, 0, "removing nlm-client %s from the list",
330  nlmclnt->caller_name);
331 
332  list_for_each_entry_safe(fde, tmp, &nlmclnt->fdes, fde_list)
333  {
334  fd_unref(fde->fd);
335  list_del(&fde->fde_list);
336  GF_FREE(fde);
337  }
338 
339  list_del(&nlmclnt->fdes);
340  list_del(&nlmclnt->nlm_clients);
341  list_del(&nlmclnt->shares);
342 
343  GF_FREE(nlmclnt->caller_name);
344 
345  if (nlmclnt->rpc_clnt) {
346  /* cleanup the saved-frames before last unref */
348  /* rpc_clnt_connection_cleanup() calls rpc_clnt_unref() */
349  }
350 
351  GF_FREE(nlmclnt);
352 }
353 
354 int
356 {
357  nlm_client_t *nlmclnt = NULL;
358  int nlmclnt_found = 0;
359  int ret = -1;
360 
362  list_for_each_entry(nlmclnt, &nlm_client_list, nlm_clients)
363  {
364  if (!strcmp(caller_name, nlmclnt->caller_name)) {
365  nlmclnt_found = 1;
366  break;
367  }
368  }
369 
370  if (!nlmclnt_found) {
371  nlmclnt = GF_CALLOC(1, sizeof(*nlmclnt), gf_nfs_mt_nlm4_nlmclnt);
372  if (nlmclnt == NULL)
373  goto ret;
374 
375  INIT_LIST_HEAD(&nlmclnt->fdes);
376  INIT_LIST_HEAD(&nlmclnt->nlm_clients);
377  INIT_LIST_HEAD(&nlmclnt->shares);
378 
379  list_add(&nlmclnt->nlm_clients, &nlm_client_list);
380  nlmclnt->caller_name = gf_strdup(caller_name);
381  }
382 
383  if (nlmclnt->rpc_clnt == NULL) {
384  nlmclnt->rpc_clnt = rpc_clnt_ref(rpc_clnt);
385  }
386  ret = 0;
387 ret:
389  return ret;
390 }
391 
392 int
394 {
395  nlm_client_t *nlmclnt = NULL;
396 
398  list_for_each_entry(nlmclnt, &nlm_client_list, nlm_clients)
399  {
400  if (rpc == nlmclnt->rpc_clnt) {
401  nlm_client_free(nlmclnt);
402  break;
403  }
404  }
406 
407  return 0;
408 }
409 
410 int
411 nlm_add_nlmclnt(char *caller_name)
412 {
413  nlm_client_t *nlmclnt = NULL;
414  int nlmclnt_found = 0;
415  int ret = -1;
416 
418  list_for_each_entry(nlmclnt, &nlm_client_list, nlm_clients)
419  {
420  if (!strcmp(caller_name, nlmclnt->caller_name)) {
421  nlmclnt_found = 1;
422  break;
423  }
424  }
425  if (!nlmclnt_found) {
426  nlmclnt = GF_CALLOC(1, sizeof(*nlmclnt), gf_nfs_mt_nlm4_nlmclnt);
427  if (nlmclnt == NULL) {
429  "malloc error");
430  goto ret;
431  }
432 
433  INIT_LIST_HEAD(&nlmclnt->fdes);
434  INIT_LIST_HEAD(&nlmclnt->nlm_clients);
435  INIT_LIST_HEAD(&nlmclnt->shares);
436 
437  list_add(&nlmclnt->nlm_clients, &nlm_client_list);
438  nlmclnt->caller_name = gf_strdup(caller_name);
439  }
440  ret = 0;
441 ret:
443  return ret;
444 }
445 
446 int
448 {
449  struct iovec outmsg = {
450  0,
451  };
452  struct iobuf *iob = NULL;
453  struct nfs3_state *nfs3 = NULL;
454  int ret = -1;
455  ssize_t msglen = 0;
456  struct iobref *iobref = NULL;
457 
458  if (!req)
459  return -1;
460 
461  nfs3 = (struct nfs3_state *)rpcsvc_request_program_private(req);
462  if (!nfs3) {
464  "mount state not found");
465  goto ret;
466  }
467 
468  /* First, get the io buffer into which the reply in arg will
469  * be serialized.
470  */
471  iob = iobuf_get(nfs3->iobpool);
472  if (!iob) {
474  "Failed to get iobuf");
475  goto ret;
476  }
477 
478  iobuf_to_iovec(iob, &outmsg);
479  /* Use the given serializer to translate the give C structure in arg
480  * to XDR format which will be written into the buffer in outmsg.
481  */
482  msglen = sfunc(outmsg, arg);
483  if (msglen < 0) {
485  "Failed to encode message");
486  goto ret;
487  }
488  outmsg.iov_len = msglen;
489 
490  iobref = iobref_new();
491  if (iobref == NULL) {
493  "Failed to get iobref");
494  goto ret;
495  }
496 
497  ret = iobref_add(iobref, iob);
498  if (ret) {
500  "Failed to add iob to iobref");
501  goto ret;
502  }
503 
504  /* Then, submit the message for transmission. */
505  ret = rpcsvc_submit_message(req, &outmsg, 1, NULL, 0, iobref);
506  if (ret == -1) {
508  "Reply submission failed");
509  goto ret;
510  }
511 
512  ret = 0;
513 ret:
514  if (iob)
515  iobuf_unref(iob);
516  if (iobref)
518 
519  return ret;
520 }
521 
522 typedef int (*nlm4_resume_fn_t)(void *cs);
523 
524 int32_t
525 nlm4_file_open_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
526  int32_t op_ret, int32_t op_errno, fd_t *fd, dict_t *xdata)
527 {
528  nfs3_call_state_t *cs = frame->local;
529 
530  if (op_ret == 0)
531  fd_bind(cs->fd);
532  cs->resolve_ret = op_ret;
533  cs->resume_fn(cs);
534 
535  frame->local = NULL;
536  STACK_DESTROY(frame->root);
537  GF_REF_PUT(cs);
538 
539  return 0;
540 }
541 
542 void *
543 nsm_monitor(void *arg)
544 {
545  CLIENT *clnt = NULL;
546  enum clnt_stat ret;
547  struct mon nsm_mon;
548  struct sm_stat_res res;
549  struct timeval tout = {5, 0};
550  char *host = NULL;
551 
552  host = arg;
553  nsm_mon.mon_id.mon_name = gf_strdup(host);
554  nsm_mon.mon_id.my_id.my_name = gf_strdup("localhost");
555  nsm_mon.mon_id.my_id.my_prog = NLMCBK_PROGRAM;
556  nsm_mon.mon_id.my_id.my_vers = NLMCBK_V1;
557  nsm_mon.mon_id.my_id.my_proc = NLMCBK_SM_NOTIFY;
558  /* nothing to put in the private data */
559 #define SM_PROG 100024
560 #define SM_VERS 1
561 #define SM_MON 2
562 
563  /* create a connection to nsm on the localhost */
564  clnt = clnt_create("localhost", SM_PROG, SM_VERS, "tcp");
565  if (!clnt) {
567  clnt_spcreateerror("Clnt_create()"));
568  goto out;
569  }
570 
571  ret = clnt_call(clnt, SM_MON, (xdrproc_t)xdr_mon, (caddr_t)&nsm_mon,
572  (xdrproc_t)xdr_sm_stat_res, (caddr_t)&res, tout);
573  if (ret != RPC_SUCCESS) {
575  "clnt_call(): %s", clnt_sperrno(ret));
576  goto out;
577  }
578  if (res.res_stat != STAT_SUCC) {
580  "clnt_call(): %s", clnt_sperrno(ret));
581  goto out;
582  }
583 
584 out:
585  GF_FREE(nsm_mon.mon_id.mon_name);
586  GF_FREE(nsm_mon.mon_id.my_id.my_name);
587  if (clnt != NULL)
588  clnt_destroy(clnt);
589  return NULL;
590 }
591 
592 nlm_client_t *
593 __nlm_get_uniq(char *caller_name)
594 {
595  nlm_client_t *nlmclnt = NULL;
596 
597  if (!caller_name)
598  return NULL;
599 
600  list_for_each_entry(nlmclnt, &nlm_client_list, nlm_clients)
601  {
602  if (!strcmp(caller_name, nlmclnt->caller_name))
603  return nlmclnt;
604  }
605 
606  return NULL;
607 }
608 
609 nlm_client_t *
610 nlm_get_uniq(char *caller_name)
611 {
612  nlm_client_t *nlmclnt = NULL;
613 
615  nlmclnt = __nlm_get_uniq(caller_name);
617 
618  return nlmclnt;
619 }
620 
621 int
623 {
624  fd_t *fd = NULL;
625  int ret = -1;
626  int flags = 0;
627  nlm_client_t *nlmclnt = NULL;
628  call_frame_t *frame = NULL;
629 
630  if (cs->args.nlm4_lockargs.exclusive == _gf_false)
631  flags = O_RDONLY;
632  else
633  flags = O_WRONLY;
634 
635  nlmclnt = nlm_get_uniq(cs->args.nlm4_lockargs.alock.caller_name);
636  if (nlmclnt == NULL) {
638  "nlm_get_uniq() "
639  "returned NULL");
640  ret = -ENOLCK;
641  goto err;
642  }
643  cs->resume_fn = resume;
644  fd = fd_lookup_uint64(cs->resolvedloc.inode, (uint64_t)(uintptr_t)nlmclnt);
645  if (fd) {
646  cs->fd = fd;
647  cs->resolve_ret = 0;
648  cs->resume_fn(cs);
649  ret = 0;
650  goto err;
651  }
652 
653  fd = fd_create_uint64(cs->resolvedloc.inode, (uint64_t)(uintptr_t)nlmclnt);
654  if (fd == NULL) {
656  "fd_create_uint64() returned NULL");
657  ret = -ENOLCK;
658  goto err;
659  }
660 
661  cs->fd = fd;
662 
663  frame = create_frame(cs->nfsx, cs->nfsx->ctx->pool);
664  if (!frame) {
666  "unable to create frame");
667  ret = -ENOMEM;
668  goto err;
669  }
670 
671  frame->root->pid = NFS_PID;
672  frame->root->uid = rpcsvc_request_uid(cs->req);
673  frame->root->gid = rpcsvc_request_gid(cs->req);
674  frame->local = GF_REF_GET(cs);
675  nfs_fix_groups(cs->nfsx, frame->root);
676 
677  STACK_WIND_COOKIE(frame, nlm4_file_open_cbk, cs->vol, cs->vol,
678  cs->vol->fops->open, &cs->resolvedloc, flags, cs->fd,
679  NULL);
680  ret = 0;
681 err:
682  return ret;
683 }
684 
685 int
686 nlm4_generic_reply(rpcsvc_request_t *req, nlm4_netobj cookie, nlm4_stats stat)
687 {
688  nlm4_res res;
689 
690  memset(&res, 0, sizeof(res));
691  res.cookie = cookie;
692  res.stat.stat = stat;
693 
694  nlm4svc_submit_reply(req, (void *)&res,
696  return 0;
697 }
698 
699 int
701 {
702  struct iovec dummyvec = {
703  0,
704  };
705 
706  if (!req) {
708  "Got NULL request!");
709  return 0;
710  }
711  rpcsvc_submit_generic(req, &dummyvec, 1, NULL, 0, NULL);
712  return 0;
713 }
714 
715 int
716 nlm4_gf_flock_to_holder(nlm4_holder *holder, struct gf_flock *flock)
717 {
718  switch (flock->l_type) {
719  case GF_LK_F_WRLCK:
720  holder->exclusive = 1;
721  break;
722  }
723 
724  holder->svid = flock->l_pid;
725  holder->l_offset = flock->l_start;
726  holder->l_len = flock->l_len;
727  return 0;
728 }
729 
730 int
731 nlm4_lock_to_gf_flock(struct gf_flock *flock, nlm4_lock *lock, int excl)
732 {
733  flock->l_pid = lock->svid;
734  flock->l_start = lock->l_offset;
735  flock->l_len = lock->l_len;
736  if (excl)
737  flock->l_type = F_WRLCK;
738  else
739  flock->l_type = F_RDLCK;
740  flock->l_whence = SEEK_SET;
741  nlm_copy_lkowner(&flock->l_owner, &lock->oh);
742  return 0;
743 }
744 
746  [NLM4_NULL] = {"NULL", NULL},
747  [NLM4_GRANTED] = {"GRANTED", NULL},
748 };
749 
751  [NLM4_NULL] = "NULL",
752  [NLM4_GRANTED] = "GRANTED",
753 };
754 
756  .progname = "NLMv4",
757  .prognum = NLM_PROGRAM,
758  .progver = NLM_V4,
759  .numproc = NLM4_PROC_COUNT,
760  .proctable = nlm4_clnt_actors,
761  .procnames = nlm4_clnt_names,
762 };
763 
764 int
765 nlm4_test_reply(nfs3_call_state_t *cs, nlm4_stats stat, struct gf_flock *flock)
766 {
767  nlm4_testres res;
768 
769  memset(&res, 0, sizeof(res));
770  res.cookie = cs->args.nlm4_testargs.cookie;
771  res.stat.stat = stat;
772  if ((stat == nlm4_denied) && flock)
773  nlm4_gf_flock_to_holder(&res.stat.nlm4_testrply_u.holder, flock);
774 
775  nlm4svc_submit_reply(cs->req, (void *)&res,
777  return 0;
778 }
779 
780 int
781 nlm4svc_test_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
782  int32_t op_ret, int32_t op_errno, struct gf_flock *flock,
783  dict_t *xdata)
784 {
785  nlm4_stats stat = nlm4_denied;
786  nfs3_call_state_t *cs = NULL;
787 
788  cs = frame->local;
789  if (op_ret == -1) {
790  stat = nlm4_errno_to_nlm4stat(op_errno);
791  goto err;
792  } else if (flock->l_type == F_UNLCK)
793  stat = nlm4_granted;
794 
795 err:
796  nlm4_test_reply(cs, stat, flock);
798  return 0;
799 }
800 
801 int
803 {
804  int ret = -EFAULT;
805  nfs_user_t nfu = {
806  0,
807  };
808  nfs3_call_state_t *cs = NULL;
809  struct gf_flock flock = {
810  0,
811  };
812 
813  if (!carg)
814  return ret;
815 
816  cs = GF_REF_GET((nfs3_call_state_t *)carg);
817  nfs_request_user_init(&nfu, cs->req);
818  nlm4_lock_to_gf_flock(&flock, &cs->args.nlm4_testargs.alock,
819  cs->args.nlm4_testargs.exclusive);
820  nlm_copy_lkowner(&nfu.lk_owner, &cs->args.nlm4_testargs.alock.oh);
821  ret = nfs_lk(cs->nfsx, cs->vol, &nfu, cs->fd, F_GETLK, &flock,
822  nlm4svc_test_cbk, cs);
823 
824  GF_REF_PUT(cs);
825 
826  return ret;
827 }
828 
829 int
830 nlm4_test_resume(void *carg)
831 {
832  nlm4_stats stat = nlm4_failed;
833  int ret = -1;
834  nfs3_call_state_t *cs = NULL;
835  fd_t *fd = NULL;
836 
837  if (!carg)
838  return ret;
839 
840  cs = GF_REF_GET((nfs3_call_state_t *)carg);
841  nlm4_check_fh_resolve_status(cs, stat, nlm4err);
842  fd = fd_anonymous(cs->resolvedloc.inode);
843  if (!fd)
844  goto nlm4err;
845  cs->fd = fd;
846  ret = nlm4_test_fd_resume(cs);
847 
848 nlm4err:
849  if (ret < 0) {
851  "unable to open_and_resume");
852  stat = nlm4_errno_to_nlm4stat(-ret);
853  nlm4_test_reply(cs, stat, NULL);
855  }
856 
857  GF_REF_PUT(cs);
858 
859  return ret;
860 }
861 
862 int
864 {
865  xlator_t *vol = NULL;
866  nlm4_stats stat = nlm4_failed;
867  struct nfs_state *nfs = NULL;
868  nfs3_state_t *nfs3 = NULL;
869  nfs3_call_state_t *cs = NULL;
870  int ret = RPCSVC_ACTOR_ERROR;
871  struct nfs3_fh fh = {
872  {0},
873  };
874 
875  if (!req)
876  return ret;
877 
878  nlm4_validate_nfs3_state(req, nfs3, stat, rpcerr, ret);
879  nfs = nfs_state(nfs3->nfsx);
880  nlm4_handle_call_state_init(nfs->nfs3state, cs, req, stat, rpcerr);
881 
883  cs->cookiebytes);
884  if (xdr_to_nlm4_testargs(req->msg[0], &cs->args.nlm4_testargs) <= 0) {
886  "Error decoding args");
887  rpcsvc_request_seterr(req, GARBAGE_ARGS);
888  goto rpcerr;
889  }
890 
891  nlm4_validate_gluster_fh(&fh, stat, nlm4err);
892  nlm4_map_fh_to_volume(cs->nfs3state, fh, req, vol, stat, nlm4err);
893 
894  if (nlm_grace_period) {
896  "NLM in grace period");
897  stat = nlm4_denied_grace_period;
898  nlm4_test_reply(cs, stat, NULL);
900  return 0;
901  }
902 
903  cs->vol = vol;
904  nlm4_volume_started_check(nfs3, vol, ret, rpcerr);
905 
906  ret = nfs3_fh_resolve_and_resume(cs, &fh, NULL, nlm4_test_resume);
907 
908 nlm4err:
909  if (ret < 0) {
911  "unable to resolve and resume");
912  nlm4_test_reply(cs, stat, NULL);
914  return 0;
915  }
916 
917 rpcerr:
918  if (ret < 0)
920 
921  return ret;
922 }
923 
925  GF_REF_DECL; /* refcounting */
926 
927  nfs3_call_state_t *cs; /* call state, w/ lock request details */
928  call_frame_t *frame; /* frame to us for the reply */
929 };
930 
931 static int
932 nlm4svc_send_granted_cbk(struct rpc_req *req, struct iovec *iov, int count,
933  void *myframe)
934 {
935  call_frame_t *frame = myframe;
936  struct nlm4_notify_args *args = frame->local;
937 
938  GF_REF_PUT(args);
939  return 0;
940 }
941 
942 static void
944 {
945  GF_REF_PUT(ncf->cs);
946  STACK_DESTROY(ncf->frame->root);
947  GF_FREE(ncf);
948 }
949 
950 static struct nlm4_notify_args *
952 {
953  struct nlm4_notify_args *ncf = NULL;
954 
955  ncf = GF_CALLOC(1, sizeof(struct nlm4_notify_args), gf_nfs_mt_nlm4_notify);
956  if (!ncf)
957  /* GF_CALLOW will log the ENOMEM error */
958  goto out;
959 
961  ncf->cs = GF_REF_GET(cs);
962 
963 out:
964  return ncf;
965 }
966 
967 static int
969 
970 int
972  void *data)
973 {
974  struct nlm4_notify_args *ncf = mydata;
975 
976  GF_VALIDATE_OR_GOTO("NLM4-notify", ncf, out);
977 
978  switch (fn) {
979  case RPC_CLNT_CONNECT:
981  break;
982 
983  case RPC_CLNT_MSG:
984  break;
985 
986  case RPC_CLNT_DISCONNECT:
988  break;
989 
990  case RPC_CLNT_DESTROY:
991  GF_REF_PUT(ncf);
992  break;
993 
994  default:
995  break;
996  }
997 out:
998  return 0;
999 }
1000 
1001 void *
1003 {
1004  int ret = -1;
1005  union gf_sock_union sock_union;
1006  dict_t *options = NULL;
1007  char peerip[INET6_ADDRSTRLEN + 1] = {0};
1008  char *portstr = NULL;
1009  char myip[INET6_ADDRSTRLEN + 1] = {0};
1010  rpc_clnt_t *rpc_clnt = NULL;
1011  int port = -1;
1012  struct nlm4_notify_args *ncf = NULL;
1013 
1015 
1016  rpc_transport_get_peeraddr(cs->trans, NULL, 0, &sock_union.storage,
1017  sizeof(sock_union.storage));
1018 
1019  switch (sock_union.sa.sa_family) {
1020  case AF_INET6:
1021  /* can not come here as NLM listens on IPv4 */
1022  gf_msg(GF_NLM, GF_LOG_ERROR, EAFNOSUPPORT,
1024  "NLM is not supported on IPv6 in this release");
1025  goto err;
1026  /*
1027  inet_ntop (AF_INET6,
1028  &((struct sockaddr_in6
1029  *)sockaddr)->sin6_addr, peerip, INET6_ADDRSTRLEN+1); break;
1030  */
1031  case AF_INET:
1032  inet_ntop(AF_INET, &sock_union.sin.sin_addr, peerip,
1033  INET6_ADDRSTRLEN + 1);
1034  inet_ntop(AF_INET,
1035  &(((struct sockaddr_in *)&cs->trans->myinfo.sockaddr)
1036  ->sin_addr),
1037  myip, INET6_ADDRSTRLEN + 1);
1038 
1039  break;
1040  default:
1041  break;
1042  /* FIXME: handle the error */
1043  }
1044 
1045  /* looks like libc rpc supports only ipv4 */
1046  port = pmap_getport(&sock_union.sin, NLM_PROGRAM, NLM_V4, IPPROTO_TCP);
1047 
1048  if (port == 0) {
1050  "Unable to get NLM port of the client."
1051  " Is the firewall running on client?"
1052  " OR Are RPC services running (rpcinfo -p)?");
1053  goto err;
1054  }
1055 
1056  options = dict_new();
1057  ret = dict_set_str(options, "transport-type", "socket");
1058  if (ret == -1) {
1060  "dict_set_str error");
1061  goto err;
1062  }
1063 
1064  ret = dict_set_dynstr(options, "remote-host", gf_strdup(peerip));
1065  if (ret == -1) {
1067  "dict_set_str error");
1068  goto err;
1069  }
1070 
1071  ret = gf_asprintf(&portstr, "%d", port);
1072  if (ret == -1)
1073  goto err;
1074 
1075  ret = dict_set_dynstr(options, "remote-port", portstr);
1076  if (ret == -1) {
1078  "dict_set_dynstr error");
1079  goto err;
1080  }
1081 
1082  /* needed in case virtual IP is used */
1083  ret = dict_set_dynstr(options, "transport.socket.source-addr",
1084  gf_strdup(myip));
1085  if (ret == -1)
1086  goto err;
1087 
1088  ret = dict_set_str(options, "auth-null", "on");
1089  if (ret == -1) {
1091  "dict_set_dynstr error");
1092  goto err;
1093  }
1094 
1095  ncf = nlm4_notify_init(cs);
1096  if (!ncf) {
1097  ret = -1;
1098  goto err;
1099  }
1100 
1101  ncf->frame = cbk_frame;
1102  ncf->frame->local = ncf;
1103 
1104  /* TODO: is 32 frames in transit enough ? */
1105  rpc_clnt = rpc_clnt_new(options, cs->nfsx, "NLM-client", 32);
1106  if (rpc_clnt == NULL) {
1108  "rpc_clnt NULL");
1109  goto err;
1110  }
1111 
1113  if (ret == -1) {
1115  "rpc_clnt_register_connect error");
1116  goto err;
1117  }
1118 
1119  /* After this connect succeeds, granted msg is sent in notify */
1120  ret = rpc_transport_connect(rpc_clnt->conn.trans, port);
1121 
1122  if (ret == -1 && EINPROGRESS == errno)
1123  ret = 0;
1124 
1125 err:
1126  if (options)
1128  if (ret == -1) {
1129  if (rpc_clnt)
1131  if (ncf)
1132  GF_REF_PUT(ncf);
1133  }
1134 
1135  return rpc_clnt;
1136 }
1137 
1138 static void
1140 {
1141  int ret = -1;
1142  nfs3_call_state_t *cs = ncf->cs;
1143  rpc_clnt_t *rpc_clnt = NULL;
1144  struct iovec outmsg = {
1145  0,
1146  };
1147  nlm4_testargs testargs;
1148  struct iobuf *iobuf = NULL;
1149  struct iobref *iobref = NULL;
1150  char peerip[INET6_ADDRSTRLEN + 1];
1151  union gf_sock_union sock_union;
1152 
1153  rpc_clnt = nlm_get_rpc_clnt(cs->args.nlm4_lockargs.alock.caller_name);
1154  if (rpc_clnt == NULL) {
1155  nlm4_establish_callback(cs, ncf->frame);
1156  return;
1157  }
1158 
1159  rpc_transport_get_peeraddr(cs->trans, NULL, 0, &sock_union.storage,
1160  sizeof(sock_union.storage));
1161 
1162  switch (sock_union.sa.sa_family) {
1163  case AF_INET6:
1164  inet_ntop(AF_INET6, &sock_union.sin6.sin6_addr, peerip,
1165  INET6_ADDRSTRLEN + 1);
1166  break;
1167  case AF_INET:
1168  inet_ntop(AF_INET, &sock_union.sin.sin_addr, peerip,
1169  INET6_ADDRSTRLEN + 1);
1170  break;
1171  default:
1172  break;
1173  }
1174 
1175  testargs.cookie = cs->args.nlm4_lockargs.cookie;
1176  testargs.exclusive = cs->args.nlm4_lockargs.exclusive;
1177  testargs.alock = cs->args.nlm4_lockargs.alock;
1178 
1179  iobuf = iobuf_get(cs->nfs3state->iobpool);
1180  if (!iobuf) {
1182  "Failed to get iobuf");
1183  goto ret;
1184  }
1185 
1186  iobuf_to_iovec(iobuf, &outmsg);
1187  /* Use the given serializer to translate the give C structure in arg
1188  * to XDR format which will be written into the buffer in outmsg.
1189  */
1190  outmsg.iov_len = xdr_serialize_nlm4_testargs(outmsg, &testargs);
1191 
1192  iobref = iobref_new();
1193  if (iobref == NULL) {
1195  "Failed to get iobref");
1196  goto ret;
1197  }
1198 
1199  ret = iobref_add(iobref, iobuf);
1200  if (ret) {
1202  "Failed to add iob to iobref");
1203  goto ret;
1204  }
1205 
1206  GF_REF_GET(ncf);
1208  nlm4svc_send_granted_cbk, &outmsg, 1, NULL, 0, iobref,
1209  ncf->frame, NULL, 0, NULL, 0, NULL);
1210 
1211  if (ret < 0) {
1213  "rpc_clnt_submit error");
1214  goto ret;
1215  }
1216 ret:
1217  if (iobref)
1219  if (iobuf)
1220  iobuf_unref(iobuf);
1221 
1223  return;
1224 }
1225 
1226 int
1227 nlm_cleanup_fds(char *caller_name)
1228 {
1229  int nlmclnt_found = 0;
1230  nlm_client_t *nlmclnt = NULL;
1231 
1233  list_for_each_entry(nlmclnt, &nlm_client_list, nlm_clients)
1234  {
1235  if (!strcmp(caller_name, nlmclnt->caller_name)) {
1236  nlmclnt_found = 1;
1237  break;
1238  }
1239  }
1240 
1241  if (!nlmclnt_found)
1242  goto ret;
1243 
1244  nlm_client_free(nlmclnt);
1245 ret:
1247  return 0;
1248 }
1249 
1250 void
1251 nlm_search_and_delete(fd_t *fd, nlm4_lock *lk)
1252 {
1253  nlm_fde_t *fde = NULL;
1254  nlm_client_t *nlmclnt = NULL;
1255  int nlmclnt_found = 0;
1256  int fde_found = 0;
1257  int transit_cnt = 0;
1258 
1260  list_for_each_entry(nlmclnt, &nlm_client_list, nlm_clients)
1261  {
1262  if (!strcmp(lk->caller_name, nlmclnt->caller_name)) {
1263  nlmclnt_found = 1;
1264  break;
1265  }
1266  }
1267 
1268  if (!nlmclnt_found)
1269  goto ret;
1270 
1271  list_for_each_entry(fde, &nlmclnt->fdes, fde_list)
1272  {
1273  if (fde->fd == fd) {
1274  fde_found = 1;
1275  break;
1276  }
1277  }
1278 
1279  if (!fde_found)
1280  goto ret;
1281  transit_cnt = fde->transit_cnt;
1282  if (transit_cnt)
1283  goto ret;
1284  list_del(&fde->fde_list);
1285 
1286 ret:
1288 
1289  if (fde_found && !transit_cnt) {
1290  fd_unref(fde->fd);
1291  GF_FREE(fde);
1292  }
1293  return;
1294 }
1295 
1296 int
1297 nlm_dec_transit_count(fd_t *fd, char *caller_name)
1298 {
1299  nlm_fde_t *fde = NULL;
1300  nlm_client_t *nlmclnt = NULL;
1301  int nlmclnt_found = 0;
1302  int fde_found = 0;
1303  int transit_cnt = -1;
1304 
1306  list_for_each_entry(nlmclnt, &nlm_client_list, nlm_clients)
1307  {
1308  if (!strcmp(caller_name, nlmclnt->caller_name)) {
1309  nlmclnt_found = 1;
1310  break;
1311  }
1312  }
1313 
1314  if (!nlmclnt_found) {
1316  "nlmclnt not found");
1317  nlmclnt = NULL;
1318  goto ret;
1319  }
1320 
1321  list_for_each_entry(fde, &nlmclnt->fdes, fde_list)
1322  {
1323  if (fde->fd == fd) {
1324  fde_found = 1;
1325  break;
1326  }
1327  }
1328 
1329  if (fde_found) {
1330  transit_cnt = --fde->transit_cnt;
1331  goto ret;
1332  }
1333 ret:
1334 
1336  return transit_cnt;
1337 }
1338 
1339 nlm_client_t *
1340 nlm_search_and_add(fd_t *fd, char *caller_name)
1341 {
1342  nlm_fde_t *fde = NULL;
1343  nlm_client_t *nlmclnt = NULL;
1344  int nlmclnt_found = 0;
1345  int fde_found = 0;
1346 
1348  list_for_each_entry(nlmclnt, &nlm_client_list, nlm_clients)
1349  {
1350  if (!strcmp(caller_name, nlmclnt->caller_name)) {
1351  nlmclnt_found = 1;
1352  break;
1353  }
1354  }
1355 
1356  if (!nlmclnt_found) {
1358  "nlmclnt not found");
1359  nlmclnt = NULL;
1360  goto ret;
1361  }
1362 
1363  list_for_each_entry(fde, &nlmclnt->fdes, fde_list)
1364  {
1365  if (fde->fd == fd) {
1366  fde_found = 1;
1367  break;
1368  }
1369  }
1370 
1371  if (fde_found)
1372  goto ret;
1373 
1374  fde = GF_CALLOC(1, sizeof(*fde), gf_nfs_mt_nlm4_fde);
1375 
1376  fde->fd = fd_ref(fd);
1377  list_add(&fde->fde_list, &nlmclnt->fdes);
1378 ret:
1379  if (nlmclnt_found && fde)
1380  fde->transit_cnt++;
1382  return nlmclnt;
1383 }
1384 
1385 int
1386 nlm4svc_lock_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
1387  int32_t op_ret, int32_t op_errno, struct gf_flock *flock,
1388  dict_t *xdata)
1389 {
1390  nlm4_stats stat = nlm4_denied;
1391  int transit_cnt = -1;
1392  char *caller_name = NULL;
1393  nfs3_call_state_t *cs = NULL;
1394  pthread_t thr;
1395  struct nlm4_notify_args *ncf = NULL;
1396 
1397  cs = frame->local;
1398  caller_name = cs->args.nlm4_lockargs.alock.caller_name;
1399  transit_cnt = nlm_dec_transit_count(cs->fd, caller_name);
1400 
1401  if (op_ret == -1) {
1402  if (transit_cnt == 0)
1404  stat = nlm4_errno_to_nlm4stat(op_errno);
1405  goto err;
1406  } else {
1407  stat = nlm4_granted;
1408  if (cs->monitor && !nlm_monitor(caller_name)) {
1409  /* FIXME: handle nsm_monitor failure */
1410  (void)gf_thread_create(&thr, NULL, nsm_monitor, (void *)caller_name,
1411  "nlmmon");
1412  }
1413  }
1414 
1415 err:
1416  if (cs->args.nlm4_lockargs.block) {
1417  ncf = nlm4_notify_init(cs);
1418  if (ncf) {
1419  ncf->frame = copy_frame(frame);
1420  ncf->frame->local = ncf;
1421  nlm4svc_send_granted(ncf);
1422  }
1423  } else {
1424  nlm4_generic_reply(cs->req, cs->args.nlm4_lockargs.cookie, stat);
1426  }
1427 
1428  return 0;
1429 }
1430 
1431 int
1433 {
1434  nlm4_stats stat = nlm4_denied;
1435  int ret = -EFAULT;
1436  nfs_user_t nfu = {
1437  0,
1438  };
1439  nfs3_call_state_t *cs = NULL;
1440  struct gf_flock flock = {
1441  0,
1442  };
1443 
1444  if (!carg)
1445  return ret;
1446 
1447  cs = GF_REF_GET((nfs3_call_state_t *)carg);
1448  nlm4_check_fh_resolve_status(cs, stat, nlm4err);
1449  (void)nlm_search_and_add(cs->fd, cs->args.nlm4_lockargs.alock.caller_name);
1450  nfs_request_user_init(&nfu, cs->req);
1451  nlm4_lock_to_gf_flock(&flock, &cs->args.nlm4_lockargs.alock,
1452  cs->args.nlm4_lockargs.exclusive);
1453  nlm_copy_lkowner(&nfu.lk_owner, &cs->args.nlm4_lockargs.alock.oh);
1454  if (cs->args.nlm4_lockargs.block) {
1455  nlm4_generic_reply(cs->req, cs->args.nlm4_lockargs.cookie,
1456  nlm4_blocked);
1457  ret = nfs_lk(cs->nfsx, cs->vol, &nfu, cs->fd, F_SETLKW, &flock,
1458  nlm4svc_lock_cbk, cs);
1459  /* FIXME: handle error from nfs_lk() specially by just
1460  * cleaning up cs and unblock the client lock request.
1461  */
1462  ret = 0;
1463  } else
1464  ret = nfs_lk(cs->nfsx, cs->vol, &nfu, cs->fd, F_SETLK, &flock,
1465  nlm4svc_lock_cbk, cs);
1466 
1467 nlm4err:
1468  if (ret < 0) {
1469  stat = nlm4_errno_to_nlm4stat(-ret);
1471  "unable to call lk()");
1472  nlm4_generic_reply(cs->req, cs->args.nlm4_lockargs.cookie, stat);
1474  }
1475 
1476  GF_REF_PUT(cs);
1477 
1478  return ret;
1479 }
1480 
1481 int
1482 nlm4_lock_resume(void *carg)
1483 {
1484  nlm4_stats stat = nlm4_failed;
1485  int ret = -1;
1486  nfs3_call_state_t *cs = NULL;
1487 
1488  if (!carg)
1489  return ret;
1490 
1491  cs = GF_REF_GET((nfs3_call_state_t *)carg);
1492  nlm4_check_fh_resolve_status(cs, stat, nlm4err);
1494 
1495 nlm4err:
1496  if (ret < 0) {
1498  "unable to open and resume");
1499  stat = nlm4_errno_to_nlm4stat(-ret);
1500  nlm4_generic_reply(cs->req, cs->args.nlm4_lockargs.cookie, stat);
1502  }
1503 
1504  GF_REF_PUT(cs);
1505 
1506  return ret;
1507 }
1508 
1509 int
1511 {
1512  int ret = RPCSVC_ACTOR_ERROR;
1513  nlm4_stats stat = nlm4_failed;
1514  struct nfs3_fh fh = {
1515  {0},
1516  };
1517  xlator_t *vol = NULL;
1518  nfs3_state_t *nfs3 = NULL;
1519  nfs3_call_state_t *cs = NULL;
1520  struct nfs_state *nfs = NULL;
1521 
1522  if (!req)
1523  return ret;
1524 
1525  nlm4_validate_nfs3_state(req, nfs3, stat, rpcerr, ret);
1526  nfs = nfs_state(nfs3->nfsx);
1527  nlm4_handle_call_state_init(nfs->nfs3state, cs, req, stat, rpcerr);
1528 
1530  cs->cookiebytes);
1531  if (xdr_to_nlm4_lockargs(req->msg[0], &cs->args.nlm4_lockargs) <= 0) {
1533  "Error decoding args");
1534  rpcsvc_request_seterr(req, GARBAGE_ARGS);
1535  goto rpcerr;
1536  }
1537 
1538  fh = cs->lockfh;
1539  cs->monitor = mon;
1540  nlm4_validate_gluster_fh(&fh, stat, nlm4err);
1541  nlm4_map_fh_to_volume(cs->nfs3state, fh, req, vol, stat, nlm4err);
1542 
1543  if (nlm_grace_period && !cs->args.nlm4_lockargs.reclaim) {
1545  "NLM in grace period");
1546  stat = nlm4_denied_grace_period;
1547  nlm4_generic_reply(req, cs->args.nlm4_unlockargs.cookie, stat);
1549  return 0;
1550  }
1551 
1552  cs->vol = vol;
1554  nlm4_volume_started_check(nfs3, vol, ret, rpcerr);
1555 
1556  ret = nlm_add_nlmclnt(cs->args.nlm4_lockargs.alock.caller_name);
1557 
1558  ret = nfs3_fh_resolve_and_resume(cs, &fh, NULL, nlm4_lock_resume);
1559 
1560 nlm4err:
1561  if (ret < 0) {
1563  "unable to resolve and resume");
1564  nlm4_generic_reply(cs->req, cs->args.nlm4_lockargs.cookie, stat);
1566  return 0;
1567  }
1568 
1569 rpcerr:
1570  if (ret < 0) {
1572  }
1573 
1574  return ret;
1575 }
1576 
1577 int
1579 {
1580  return nlm4svc_lock_common(req, 1);
1581 }
1582 
1583 int
1585 {
1586  return nlm4svc_lock_common(req, 0);
1587 }
1588 
1589 int
1590 nlm4svc_cancel_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
1591  int32_t op_ret, int32_t op_errno, struct gf_flock *flock,
1592  dict_t *xdata)
1593 {
1594  nlm4_stats stat = nlm4_denied;
1595  nfs3_call_state_t *cs = NULL;
1596 
1597  cs = frame->local;
1598  if (op_ret == -1) {
1599  stat = nlm4_errno_to_nlm4stat(op_errno);
1600  goto err;
1601  } else {
1602  stat = nlm4_granted;
1603  nlm_search_and_delete(cs->fd, &cs->args.nlm4_lockargs.alock);
1604  }
1605 
1606 err:
1607  nlm4_generic_reply(cs->req, cs->args.nlm4_cancargs.cookie, stat);
1609  return 0;
1610 }
1611 
1612 int
1614 {
1615  int ret = -EFAULT;
1616  nfs_user_t nfu = {
1617  0,
1618  };
1619  nfs3_call_state_t *cs = NULL;
1620  struct gf_flock flock = {
1621  0,
1622  };
1623 
1624  if (!carg)
1625  return ret;
1626 
1627  cs = GF_REF_GET((nfs3_call_state_t *)carg);
1628  nfs_request_user_init(&nfu, cs->req);
1629  nlm4_lock_to_gf_flock(&flock, &cs->args.nlm4_cancargs.alock,
1630  cs->args.nlm4_cancargs.exclusive);
1631  nlm_copy_lkowner(&nfu.lk_owner, &cs->args.nlm4_cancargs.alock.oh);
1632  flock.l_type = F_UNLCK;
1633  ret = nfs_lk(cs->nfsx, cs->vol, &nfu, cs->fd, F_SETLK, &flock,
1634  nlm4svc_cancel_cbk, cs);
1635 
1636  GF_REF_PUT(cs);
1637 
1638  return ret;
1639 }
1640 
1641 int
1643 {
1644  nlm4_stats stat = nlm4_failed;
1645  int ret = -EFAULT;
1646  nfs3_call_state_t *cs = NULL;
1647  nlm_client_t *nlmclnt = NULL;
1648 
1649  if (!carg)
1650  return ret;
1651 
1652  cs = GF_REF_GET((nfs3_call_state_t *)carg);
1653  nlm4_check_fh_resolve_status(cs, stat, nlm4err);
1654 
1655  nlmclnt = nlm_get_uniq(cs->args.nlm4_cancargs.alock.caller_name);
1656  if (nlmclnt == NULL) {
1658  "nlm_get_uniq() returned NULL");
1659  goto nlm4err;
1660  }
1662  (uint64_t)(uintptr_t)nlmclnt);
1663  if (cs->fd == NULL) {
1665  "fd_lookup_uint64 retrned NULL");
1666  goto nlm4err;
1667  }
1668  ret = nlm4_cancel_fd_resume(cs);
1669 
1670 nlm4err:
1671  if (ret < 0) {
1673  "unable to unlock_fd_resume()");
1674  stat = nlm4_errno_to_nlm4stat(-ret);
1675  nlm4_generic_reply(cs->req, cs->args.nlm4_cancargs.cookie, stat);
1676 
1678  }
1679 
1680  GF_REF_PUT(cs);
1681 
1682  /* clean up is taken care of */
1683  return 0;
1684 }
1685 
1686 int
1688 {
1689  xlator_t *vol = NULL;
1690  nlm4_stats stat = nlm4_failed;
1691  struct nfs_state *nfs = NULL;
1692  nfs3_state_t *nfs3 = NULL;
1693  nfs3_call_state_t *cs = NULL;
1694  int ret = RPCSVC_ACTOR_ERROR;
1695  struct nfs3_fh fh = {
1696  {0},
1697  };
1698 
1699  if (!req)
1700  return ret;
1701 
1702  nlm4_validate_nfs3_state(req, nfs3, stat, rpcerr, ret);
1703  nfs = nfs_state(nfs3->nfsx);
1704  nlm4_handle_call_state_init(nfs->nfs3state, cs, req, stat, rpcerr);
1705 
1707  cs->cookiebytes);
1708  if (xdr_to_nlm4_cancelargs(req->msg[0], &cs->args.nlm4_cancargs) <= 0) {
1710  "Error decoding args");
1711  rpcsvc_request_seterr(req, GARBAGE_ARGS);
1712  goto rpcerr;
1713  }
1714 
1715  nlm4_validate_gluster_fh(&fh, stat, nlm4err);
1716  nlm4_map_fh_to_volume(cs->nfs3state, fh, req, vol, stat, nlm4err);
1717 
1718  if (nlm_grace_period) {
1720  "NLM in grace period");
1721  stat = nlm4_denied_grace_period;
1722  nlm4_generic_reply(req, cs->args.nlm4_unlockargs.cookie, stat);
1724  return 0;
1725  }
1726 
1727  cs->vol = vol;
1728  nlm4_volume_started_check(nfs3, vol, ret, rpcerr);
1729 
1730  ret = nfs3_fh_resolve_and_resume(cs, &fh, NULL, nlm4_cancel_resume);
1731 
1732 nlm4err:
1733  if (ret < 0) {
1735  "unable to resolve and resume");
1736  nlm4_generic_reply(cs->req, cs->args.nlm4_cancargs.cookie, stat);
1738  return 0;
1739  }
1740 
1741 rpcerr:
1742  if (ret < 0) {
1744  }
1745  return ret;
1746 }
1747 
1748 int
1749 nlm4svc_unlock_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
1750  int32_t op_ret, int32_t op_errno, struct gf_flock *flock,
1751  dict_t *xdata)
1752 {
1753  nlm4_stats stat = nlm4_denied;
1754  nfs3_call_state_t *cs = NULL;
1755 
1756  cs = GF_REF_GET((nfs3_call_state_t *)frame->local);
1757  if (op_ret == -1) {
1758  stat = nlm4_errno_to_nlm4stat(op_errno);
1759  goto err;
1760  } else {
1761  stat = nlm4_granted;
1762  if (flock->l_type == F_UNLCK)
1763  nlm_search_and_delete(cs->fd, &cs->args.nlm4_unlockargs.alock);
1764  }
1765 
1766 err:
1767  nlm4_generic_reply(cs->req, cs->args.nlm4_unlockargs.cookie, stat);
1768  GF_REF_PUT(cs);
1769  return 0;
1770 }
1771 
1772 int
1774 {
1775  int ret = -EFAULT;
1776  nfs_user_t nfu = {
1777  0,
1778  };
1779  nfs3_call_state_t *cs = NULL;
1780  struct gf_flock flock = {
1781  0,
1782  };
1783 
1784  if (!carg)
1785  return ret;
1786  cs = GF_REF_GET((nfs3_call_state_t *)carg);
1787  nfs_request_user_init(&nfu, cs->req);
1788  nlm4_lock_to_gf_flock(&flock, &cs->args.nlm4_unlockargs.alock, 0);
1789  nlm_copy_lkowner(&nfu.lk_owner, &cs->args.nlm4_unlockargs.alock.oh);
1790  flock.l_type = F_UNLCK;
1791  ret = nfs_lk(cs->nfsx, cs->vol, &nfu, cs->fd, F_SETLK, &flock,
1792  nlm4svc_unlock_cbk, cs);
1793 
1794  GF_REF_PUT(cs);
1795 
1796  return ret;
1797 }
1798 
1799 int
1801 {
1802  nlm4_stats stat = nlm4_failed;
1803  int ret = -1;
1804  nfs3_call_state_t *cs = NULL;
1805  nlm_client_t *nlmclnt = NULL;
1806  char *caller_name = NULL;
1807 
1808  if (!carg)
1809  return ret;
1810 
1811  cs = GF_REF_GET((nfs3_call_state_t *)carg);
1812  nlm4_check_fh_resolve_status(cs, stat, nlm4err);
1813  caller_name = cs->args.nlm4_unlockargs.alock.caller_name;
1814 
1815  nlmclnt = nlm_get_uniq(caller_name);
1816  if (nlmclnt == NULL) {
1817  stat = nlm4_granted;
1819  "nlm_get_uniq() returned NULL for %s", caller_name);
1820  goto nlm4err;
1821  }
1823  (uint64_t)(uintptr_t)nlmclnt);
1824  if (cs->fd == NULL) {
1825  stat = nlm4_granted;
1827  "fd_lookup_uint64() returned NULL");
1828  goto nlm4err;
1829  }
1830  ret = nlm4_unlock_fd_resume(cs);
1831 
1832 nlm4err:
1833  if (ret < 0) {
1835  "unable to unlock_fd_resume");
1836  stat = nlm4_errno_to_nlm4stat(-ret);
1837  nlm4_generic_reply(cs->req, cs->args.nlm4_unlockargs.cookie, stat);
1838 
1840  }
1841 
1842  GF_REF_PUT(cs);
1843 
1844  /* we have already taken care of cleanup */
1845  return 0;
1846 }
1847 
1848 int
1850 {
1851  xlator_t *vol = NULL;
1852  nlm4_stats stat = nlm4_failed;
1853  struct nfs_state *nfs = NULL;
1854  nfs3_state_t *nfs3 = NULL;
1855  nfs3_call_state_t *cs = NULL;
1856  int ret = RPCSVC_ACTOR_ERROR;
1857  struct nfs3_fh fh = {
1858  {0},
1859  };
1860 
1861  if (!req)
1862  return ret;
1863 
1864  nlm4_validate_nfs3_state(req, nfs3, stat, rpcerr, ret);
1865  nfs = nfs_state(nfs3->nfsx);
1866  nlm4_handle_call_state_init(nfs->nfs3state, cs, req, stat, rpcerr);
1867 
1869  cs->cookiebytes);
1870  if (xdr_to_nlm4_unlockargs(req->msg[0], &cs->args.nlm4_unlockargs) <= 0) {
1872  "Error decoding args");
1873  rpcsvc_request_seterr(req, GARBAGE_ARGS);
1874  goto rpcerr;
1875  }
1876 
1877  nlm4_validate_gluster_fh(&fh, stat, nlm4err);
1878  nlm4_map_fh_to_volume(cs->nfs3state, fh, req, vol, stat, nlm4err);
1879 
1880  if (nlm_grace_period) {
1882  "NLM in grace period");
1883  stat = nlm4_denied_grace_period;
1884  nlm4_generic_reply(req, cs->args.nlm4_unlockargs.cookie, stat);
1886  return 0;
1887  }
1888 
1889  cs->vol = vol;
1890  /* FIXME: check if trans is being used at all for unlock */
1892  nlm4_volume_started_check(nfs3, vol, ret, rpcerr);
1893 
1894  ret = nfs3_fh_resolve_and_resume(cs, &fh, NULL, nlm4_unlock_resume);
1895 
1896 nlm4err:
1897  if (ret < 0) {
1899  "unable to resolve and resume");
1900  nlm4_generic_reply(req, cs->args.nlm4_unlockargs.cookie, stat);
1902  return 0;
1903  }
1904 
1905 rpcerr:
1906  if (ret < 0) {
1908  }
1909  return ret;
1910 }
1911 
1912 int
1914 {
1915  nlm4_shareres res = {{0}, 0, 0};
1916 
1917  if (!cs)
1918  return -1;
1919 
1920  res.cookie = cs->args.nlm4_shareargs.cookie;
1921  res.stat = stat;
1922  res.sequence = 0;
1923 
1924  nlm4svc_submit_reply(cs->req, (void *)&res,
1926  return 0;
1927 }
1928 
1929 nlm_share_t *
1931 {
1932  nlm_share_t *share = NULL;
1933 
1934  share = GF_CALLOC(1, sizeof(nlm_share_t), gf_nfs_mt_nlm4_share);
1935  if (!share)
1936  goto out;
1937 
1938  INIT_LIST_HEAD(&share->client_list);
1939  INIT_LIST_HEAD(&share->inode_list);
1940 out:
1941  return share;
1942 }
1943 
1944 int
1946 {
1947  int ret = -1;
1948  uint64_t ctx = 0;
1949  struct list_head *head = NULL;
1950  xlator_t *this = NULL;
1951  inode_t *inode = NULL;
1952  struct nfs_inode_ctx *ictx = NULL;
1953  struct nfs_state *priv = NULL;
1954 
1955  this = THIS;
1956  priv = this->private;
1957  inode = share->inode;
1958  ret = inode_ctx_get(inode, this, &ctx);
1959 
1960  if (ret == -1) {
1961  ictx = GF_CALLOC(1, sizeof(struct nfs_inode_ctx), gf_nfs_mt_inode_ctx);
1962  if (!ictx) {
1963  gf_msg(this->name, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY,
1964  "could not allocate nfs inode ctx");
1965  ret = -1;
1966  goto out;
1967  }
1968  ictx->generation = priv->generation;
1969 
1970  head = &ictx->shares;
1971  INIT_LIST_HEAD(head);
1972 
1973  ret = inode_ctx_put(inode, this, (uint64_t)(uintptr_t)ictx);
1974  if (ret) {
1976  "could not store share list");
1977  goto out;
1978  }
1979  } else {
1980  ictx = (struct nfs_inode_ctx *)(uintptr_t)ctx;
1981  head = &ictx->shares;
1982  }
1983 
1984  list_add(&share->inode_list, head);
1985 
1986 out:
1987  if (ret && head)
1988  GF_FREE(head);
1989 
1990  return ret;
1991 }
1992 
1993 int
1995 {
1996  int ret = -1;
1997  uint64_t ctx = 0;
1998  fsh_mode req_mode = 0;
1999  fsh_access req_access = 0;
2000  inode_t *inode = NULL;
2001  nlm_share_t *share = NULL;
2002  struct list_head *head = NULL;
2003  struct nfs_inode_ctx *ictx = NULL;
2004 
2005  if (!cs)
2006  goto out;
2007 
2008  inode = cs->resolvedloc.inode;
2009 
2010  ret = inode_ctx_get(inode, THIS, &ctx);
2011  if (ret) {
2012  ret = 0;
2013  goto out;
2014  }
2015  ictx = (struct nfs_inode_ctx *)(uintptr_t)ctx;
2016 
2017  head = &ictx->shares;
2018  if (!head || list_empty(head))
2019  goto out;
2020 
2021  req_mode = cs->args.nlm4_shareargs.share.mode;
2022  req_access = cs->args.nlm4_shareargs.share.access;
2023 
2024  list_for_each_entry(share, head, inode_list)
2025  {
2026  ret = (((req_mode & share->access) == 0) &&
2027  ((req_access & share->mode) == 0));
2028  if (!ret) {
2029  ret = -1;
2030  goto out;
2031  }
2032  }
2033  ret = 0;
2034 
2035 out:
2036  return ret;
2037 }
2038 
2039 int
2041 {
2042  int ret = -1;
2043  nlm_share_t *share = NULL;
2044  nlm_client_t *client = NULL;
2045  inode_t *inode = NULL;
2046 
2048 
2049  inode = inode_ref(cs->resolvedloc.inode);
2050  if (!inode) {
2052  "inode not found");
2053  goto out;
2054  }
2055 
2056  client = __nlm_get_uniq(cs->args.nlm4_shareargs.share.caller_name);
2057  if (!client) {
2058  /* DO NOT add client. the client is supposed
2059  to be here, since nlm4svc_share adds it */
2061  "client not found");
2062  goto out;
2063  }
2064 
2066  if (ret)
2067  goto out;
2068 
2069  share = nlm4_share_new();
2070  if (!share) {
2071  ret = -1;
2072  goto out;
2073  }
2074 
2075  share->inode = inode;
2076  share->mode = cs->args.nlm4_shareargs.share.mode;
2077  share->access = cs->args.nlm4_shareargs.share.access;
2078  nlm_copy_lkowner(&share->lkowner, &cs->args.nlm4_shareargs.share.oh);
2079 
2080  ret = nlm4_add_share_to_inode(share);
2081  if (ret)
2082  goto out;
2083 
2084  list_add(&share->client_list, &client->shares);
2085 
2086 out:
2087  if (ret && inode) {
2088  inode_unref(inode);
2089  GF_FREE(share);
2090  }
2091 
2093  return ret;
2094 }
2095 
2096 /*
2097  SHARE and UNSHARE calls DO NOT perform STACK_WIND,
2098  the (non-monitored) share reservations are maintained
2099  at *nfs xlator level only*, in memory
2100 */
2101 int
2102 nlm4_share_resume(void *call_state)
2103 {
2104  int ret = -1;
2105  nlm4_stats stat = nlm4_failed;
2106  nfs3_call_state_t *cs = NULL;
2107 
2108  if (!call_state)
2109  return ret;
2110 
2111  cs = (nfs3_call_state_t *)call_state;
2112  nlm4_check_fh_resolve_status(cs, stat, out);
2113 
2115  if (!ret)
2116  stat = nlm4_granted;
2117 
2118 out:
2119  nlm4_share_reply(cs, stat);
2121  return 0;
2122 }
2123 
2124 int
2126 {
2127  nlm4_stats stat = nlm4_failed;
2128  xlator_t *vol = NULL;
2129  nfs3_state_t *nfs3 = NULL;
2130  nfs3_call_state_t *cs = NULL;
2131  struct nfs_state *nfs = NULL;
2132  struct nfs3_fh fh = {
2133  {0},
2134  };
2135  int ret = RPCSVC_ACTOR_ERROR;
2136 
2137  if (!req)
2138  return ret;
2139 
2140  nlm4_validate_nfs3_state(req, nfs3, stat, rpcerr, ret);
2141  nfs = nfs_state(nfs3->nfsx);
2142  nlm4_handle_call_state_init(nfs->nfs3state, cs, req, stat, rpcerr);
2143 
2145  cs->cookiebytes);
2146 
2147  if (xdr_to_nlm4_shareargs(req->msg[0], &cs->args.nlm4_shareargs) <= 0) {
2149  "Error decoding SHARE args");
2150  rpcsvc_request_seterr(req, GARBAGE_ARGS);
2151  goto rpcerr;
2152  }
2153 
2154  fh = cs->lockfh;
2155  nlm4_validate_gluster_fh(&fh, stat, nlm4err);
2156  nlm4_map_fh_to_volume(cs->nfs3state, fh, req, vol, stat, nlm4err);
2157 
2158  if (nlm_grace_period && !cs->args.nlm4_shareargs.reclaim) {
2159  gf_msg_debug(GF_NLM, 0, "NLM in grace period");
2160  stat = nlm4_denied_grace_period;
2161  nlm4_share_reply(cs, stat);
2163  return 0;
2164  }
2165 
2166  cs->vol = vol;
2168  nlm4_volume_started_check(nfs3, vol, ret, rpcerr);
2169 
2170  ret = nlm_add_nlmclnt(cs->args.nlm4_shareargs.share.caller_name);
2171 
2172  ret = nfs3_fh_resolve_and_resume(cs, &fh, NULL, nlm4_share_resume);
2173 
2174 nlm4err:
2175  if (ret < 0) {
2177  "SHARE call failed");
2178  nlm4_share_reply(cs, stat);
2180  return 0;
2181  }
2182 
2183 rpcerr:
2184  if (ret < 0)
2186 
2187  return ret;
2188 }
2189 
2190 int
2192 {
2193  int ret = -1;
2194  uint64_t ctx = 0;
2195  fsh_mode req_mode = 0;
2196  fsh_access req_access = 0;
2197  nlm_share_t *share = NULL;
2198  nlm_share_t *tmp = NULL;
2199  nlm_client_t *client = NULL;
2200  char *caller = NULL;
2201  inode_t *inode = NULL;
2202  xlator_t *this = NULL;
2203  struct list_head *head = NULL;
2204  nlm4_shareargs *args = NULL;
2205  struct nfs_inode_ctx *ictx = NULL;
2206 
2208 
2209  args = &cs->args.nlm4_shareargs;
2210  caller = args->share.caller_name;
2211 
2212  client = __nlm_get_uniq(caller);
2213  if (!client) {
2215  "client not found: %s", caller);
2216  goto out;
2217  }
2218 
2219  inode = cs->resolvedloc.inode;
2220  if (!inode) {
2222  "inode not found: client: %s", caller);
2223  goto out;
2224  }
2225 
2226  this = THIS;
2227  ret = inode_ctx_get(inode, this, &ctx);
2228  if (ret) {
2230  "no shares found for inode:"
2231  "gfid: %s; client: %s",
2232  inode->gfid, caller);
2233  goto out;
2234  }
2235  ictx = (struct nfs_inode_ctx *)(uintptr_t)ctx;
2236 
2237  head = &ictx->shares;
2238  if (list_empty(head)) {
2239  ret = -1;
2240  goto out;
2241  }
2242 
2243  ret = 0;
2244  req_mode = args->share.mode;
2245  req_access = args->share.access;
2246 
2247  list_for_each_entry_safe(share, tmp, head, inode_list)
2248  {
2249  ret = ((req_mode == share->mode) && (req_access == share->access) &&
2250  nlm_is_oh_same_lkowner(&share->lkowner, &args->share.oh));
2251  if (ret) {
2252  list_del(&share->client_list);
2253  list_del(&share->inode_list);
2254  inode_unref(share->inode);
2255  GF_FREE(share);
2256  break;
2257  }
2258  }
2259 
2260  ret = 0;
2261 out:
2263  return ret;
2264 }
2265 
2266 int
2267 nlm4_unshare_resume(void *call_state)
2268 {
2269  int ret = -1;
2270  nlm4_stats stat = nlm4_failed;
2271  nfs3_call_state_t *cs = NULL;
2272 
2273  if (!call_state)
2274  return ret;
2275 
2276  cs = (nfs3_call_state_t *)call_state;
2277 
2278  nlm4_check_fh_resolve_status(cs, stat, out);
2280  if (!ret)
2281  stat = nlm4_granted;
2282 
2283 out:
2284  nlm4_share_reply(cs, stat);
2286  return 0;
2287 }
2288 
2289 int
2291 {
2292  nlm4_stats stat = nlm4_failed;
2293  xlator_t *vol = NULL;
2294  nfs3_state_t *nfs3 = NULL;
2295  nfs3_call_state_t *cs = NULL;
2296  struct nfs_state *nfs = NULL;
2297  struct nfs3_fh fh = {
2298  {0},
2299  };
2300  int ret = RPCSVC_ACTOR_ERROR;
2301 
2302  if (!req)
2303  return ret;
2304 
2305  nlm4_validate_nfs3_state(req, nfs3, stat, rpcerr, ret);
2306  nfs = nfs_state(nfs3->nfsx);
2307  nlm4_handle_call_state_init(nfs->nfs3state, cs, req, stat, rpcerr);
2308 
2310  cs->cookiebytes);
2311 
2312  if (xdr_to_nlm4_shareargs(req->msg[0], &cs->args.nlm4_shareargs) <= 0) {
2314  "Error decoding UNSHARE args");
2315  rpcsvc_request_seterr(req, GARBAGE_ARGS);
2316  goto rpcerr;
2317  }
2318 
2319  fh = cs->lockfh;
2320  nlm4_validate_gluster_fh(&fh, stat, nlm4err);
2321  nlm4_map_fh_to_volume(cs->nfs3state, fh, req, vol, stat, nlm4err);
2322 
2323  if (nlm_grace_period && !cs->args.nlm4_shareargs.reclaim) {
2324  gf_msg_debug(GF_NLM, 0, "NLM in grace period");
2325  stat = nlm4_denied_grace_period;
2326  nlm4_share_reply(cs, stat);
2328  return 0;
2329  }
2330 
2331  cs->vol = vol;
2333  nlm4_volume_started_check(nfs3, vol, ret, rpcerr);
2334 
2335  ret = nfs3_fh_resolve_and_resume(cs, &fh, NULL, nlm4_unshare_resume);
2336 
2337 nlm4err:
2338  if (ret < 0) {
2340  "UNSHARE call failed");
2341  nlm4_share_reply(cs, stat);
2342  ret = 0;
2343  return 0;
2344  }
2345 
2346 rpcerr:
2347  if (ret < 0)
2349 
2350  return ret;
2351 }
2352 
2353 int
2354 nlm4_free_all_shares(char *caller_name)
2355 {
2356  nlm_share_t *share = NULL;
2357  nlm_share_t *tmp = NULL;
2358  nlm_client_t *client = NULL;
2359 
2361 
2362  client = __nlm_get_uniq(caller_name);
2363  if (!client) {
2364  gf_msg_debug(GF_NLM, 0, "client not found: %s", caller_name);
2365  goto out;
2366  }
2367 
2368  list_for_each_entry_safe(share, tmp, &client->shares, client_list)
2369  {
2370  list_del(&share->inode_list);
2371  list_del(&share->client_list);
2372  inode_unref(share->inode);
2373  GF_FREE(share);
2374  }
2375 out:
2377  return 0;
2378 }
2379 
2380 int
2382 {
2383  int ret = RPCSVC_ACTOR_ERROR;
2384  nlm4_stats stat = nlm4_failed;
2385  nfs3_state_t *nfs3 = NULL;
2386  nfs3_call_state_t *cs = NULL;
2387  struct nfs_state *nfs = NULL;
2388 
2389  nlm4_validate_nfs3_state(req, nfs3, stat, err, ret);
2390  nfs = nfs_state(nfs3->nfsx);
2391  nlm4_handle_call_state_init(nfs->nfs3state, cs, req, stat, err);
2392 
2394 
2395  if (xdr_to_nlm4_freeallargs(req->msg[0], &cs->args.nlm4_freeallargs) <= 0) {
2397  "Error decoding FREE_ALL args");
2398  rpcsvc_request_seterr(req, GARBAGE_ARGS);
2399  goto err;
2400  }
2401 
2402  ret = nlm4_free_all_shares(cs->args.nlm4_freeallargs.name);
2403  if (ret)
2404  goto err;
2405 
2406  ret = nlm_cleanup_fds(cs->args.nlm4_freeallargs.name);
2407  if (ret)
2408  goto err;
2409 
2410 err:
2412  if (ret)
2413  gf_msg_debug(GF_NLM, 0, "error in free all; stat: %d", stat);
2414  return ret;
2415 }
2416 
2417 void
2418 nlm4svc_sm_notify(struct nlm_sm_status *status)
2419 {
2421  "sm_notify: "
2422  "%s, state: %d",
2423  status->mon_name, status->state);
2424  nlm_cleanup_fds(status->mon_name);
2425 }
2426 
2427 /* RPC_CLNT_CONNECT gets called on (re)connects and should be able to handle
2428  * different NLM requests. */
2429 static int
2431 {
2432  int ret = -1;
2433  int nlm_proc = NLM4_NULL;
2434  nfs3_call_state_t *cs = NULL;
2435  struct nlm4_lock *alock = NULL;
2436  char *caller_name = NULL;
2437 
2438  cs = GF_REF_GET(ncf->cs);
2439  if (!cs || !cs->req) {
2441  "Spurious notify?!");
2442  goto out;
2443  }
2444 
2445  /* NLM4_* actions from nlm4.h */
2446  if (cs->req->prognum == NLM_PROGRAM) {
2447  nlm_proc = cs->req->procnum;
2448  } else {
2449  /* hmm, cs->req has not been filled completely */
2450  if (cs->resume_fn == nlm4_lock_fd_resume)
2451  nlm_proc = NLM4_LOCK;
2452  else if (cs->resume_fn == nlm4_cancel_fd_resume)
2453  nlm_proc = NLM4_CANCEL;
2454  else if (cs->resume_fn == nlm4_unlock_fd_resume)
2455  nlm_proc = NLM4_UNLOCK;
2456  else {
2458  "(re)connect with an "
2459  "unexpected NLM4 procedure (%d)",
2460  nlm_proc);
2461  goto out;
2462  }
2463  }
2464 
2465  switch (nlm_proc) {
2466  case NLM4_LOCK:
2467  alock = &cs->args.nlm4_lockargs.alock;
2468  caller_name = alock->caller_name;
2469 
2470  ret = nlm_set_rpc_clnt(rpc_clnt, caller_name);
2471  if (ret == -1) {
2473  "Failed to set "
2474  "rpc clnt");
2475  goto out;
2476  }
2477 
2478  /* extra ref taken with nlm_set_rpc_clnt() */
2480 
2481  nlm4svc_send_granted(ncf);
2482  break;
2483 
2484  case NLM4_CANCEL:
2485  /* alock = &cs->args.nlm4_cancargs.alock; */
2486  ret = nlm4svc_cancel(cs->req);
2487  break;
2488 
2489  case NLM4_UNLOCK:
2490  /* alock = &cs->args.nlm4_unlockargs.alock; */
2491  ret = nlm4svc_unlock(cs->req);
2492  break;
2493 
2494  default:
2496  "(re)connect with an unexpected NLM4 procedure "
2497  "(%d)",
2498  nlm_proc);
2499  }
2500 
2501 out:
2502  if (cs)
2503  GF_REF_PUT(cs);
2504 
2505  return ret;
2506 }
2507 
2509  /* 0 */
2510  {"NULL", nlm4svc_null, NULL, NLM4_NULL, DRC_IDEMPOTENT, 0},
2511  {"TEST", nlm4svc_test, NULL, NLM4_TEST, DRC_IDEMPOTENT, 0},
2512  {"LOCK", nlm4svc_lock, NULL, NLM4_LOCK, DRC_IDEMPOTENT, 0},
2513  {"CANCEL", nlm4svc_cancel, NULL, NLM4_CANCEL, DRC_NON_IDEMPOTENT, 0},
2514  {"UNLOCK", nlm4svc_unlock, NULL, NLM4_UNLOCK, DRC_NON_IDEMPOTENT, 0},
2515  /* 5 */
2516  {"GRANTED", NULL, NULL, NLM4_GRANTED, DRC_NA, 0},
2517  {"TEST", NULL, NULL, NLM4_TEST_MSG, DRC_NA, 0},
2518  {"LOCK", NULL, NULL, NLM4_LOCK_MSG, DRC_NA, 0},
2519  {"CANCEL", NULL, NULL, NLM4_CANCEL_MSG, DRC_NA, 0},
2520  {"UNLOCK", NULL, NULL, NLM4_UNLOCK_MSG, DRC_NA, 0},
2521  /* 10 */
2522  {"GRANTED", NULL, NULL, NLM4_GRANTED_MSG, DRC_NA, 0},
2523  {"TEST", NULL, NULL, NLM4_TEST_RES, DRC_NA, 0},
2524  {"LOCK", NULL, NULL, NLM4_LOCK_RES, DRC_NA, 0},
2525  {"CANCEL", NULL, NULL, NLM4_CANCEL_RES, DRC_NA, 0},
2526  {"UNLOCK", NULL, NULL, NLM4_UNLOCK_RES, DRC_NA, 0},
2527  /* 15 ; procedures 17,18,19 are not defined by nlm */
2528  {"GRANTED", NULL, NULL, NLM4_GRANTED_RES, DRC_NA, 0},
2529  {"SM_NOTIFY", NULL, NULL, NLM4_SM_NOTIFY, DRC_NA, 0},
2530  {"SEVENTEEN", NULL, NULL, NLM4_SEVENTEEN, DRC_NA, 0},
2531  {"EIGHTEEN", NULL, NULL, NLM4_EIGHTEEN, DRC_NA, 0},
2532  {"NINETEEN", NULL, NULL, NLM4_NINETEEN, DRC_NA, 0},
2533  /* 20 */
2534  {"SHARE", nlm4svc_share, NULL, NLM4_SHARE, DRC_NON_IDEMPOTENT, 0},
2535  {"UNSHARE", nlm4svc_unshare, NULL, NLM4_UNSHARE, DRC_NON_IDEMPOTENT, 0},
2536  {"NM_LOCK", nlm4svc_nm_lock, NULL, NLM4_NM_LOCK, DRC_NON_IDEMPOTENT, 0},
2537  {"FREE_ALL", nlm4svc_free_all, NULL, NLM4_FREE_ALL, DRC_IDEMPOTENT, 0},
2538 };
2539 
2541  .progname = "NLM4",
2542  .prognum = NLM_PROGRAM,
2543  .progver = NLM_V4,
2544  .progport = GF_NLM4_PORT,
2545  .actors = nlm4svc_actors,
2546  .numactors = NLM4_PROC_COUNT,
2547  .min_auth = AUTH_NULL,
2548 };
2549 
2550 int
2552 {
2553  return 0;
2554 }
2555 
2556 extern void *
2557 nsm_thread(void *argv);
2558 
2559 void
2561 {
2562  nlm_grace_period = 0;
2563 }
2564 
2567 {
2568  struct nfs3_state *ns = NULL;
2569  struct nfs_state *nfs = NULL;
2570  dict_t *options = NULL;
2571  int ret = -1;
2572  char *portstr = NULL;
2573  pthread_t thr;
2574  struct timespec timeout = {
2575  0,
2576  };
2577  FILE *pidfile = NULL;
2578  pid_t pid = -1;
2579 
2580  /* Already inited */
2581  if (nlm4_inited)
2582  return &nlm4prog;
2583 
2584  nfs = (struct nfs_state *)nfsx->private;
2585 
2586  ns = nfs->nfs3state;
2587  if (!ns) {
2589  "NLM4 init failed");
2590  goto err;
2591  }
2592  nlm4prog.private = ns;
2593 
2594  options = dict_new();
2595 
2596  ret = gf_asprintf(&portstr, "%d", GF_NLM4_PORT);
2597  if (ret == -1)
2598  goto err;
2599 
2600  ret = dict_set_dynstr(options, "transport.socket.listen-port", portstr);
2601  if (ret == -1)
2602  goto err;
2603  ret = dict_set_str(options, "transport-type", "socket");
2604  if (ret == -1) {
2606  "dict_set_str error");
2607  goto err;
2608  }
2609 
2610  if (nfs->allow_insecure) {
2611  ret = dict_set_str(options, "rpc-auth-allow-insecure", "on");
2612  if (ret == -1) {
2614  "dict_set_str error");
2615  goto err;
2616  }
2617  ret = dict_set_str(options, "rpc-auth.ports.insecure", "on");
2618  if (ret == -1) {
2620  "dict_set_str error");
2621  goto err;
2622  }
2623  }
2624 
2625  ret = dict_set_str(options, "transport.address-family", "inet");
2626  if (ret == -1) {
2628  "dict_set_str error");
2629  goto err;
2630  }
2631 
2632  ret = rpcsvc_create_listeners(nfs->rpcsvc, options, "NLM");
2633  if (ret == -1) {
2635  "Unable to create listeners");
2637  goto err;
2638  }
2641 
2642  /* unlink sm-notify.pid so that when we restart rpc.statd/sm-notify
2643  * it thinks that the machine has restarted and sends NOTIFY to clients.
2644  */
2645 
2646  /* TODO:
2647  notify/rpc.statd is done differently on OSX
2648 
2649  On OSX rpc.statd is controlled by rpc.lockd and are part for launchd
2650  (unified service management framework)
2651 
2652  A runcmd() should be invoking "launchctl start com.apple.lockd"
2653  instead. This is still a theory but we need to thoroughly test it
2654  out. Until then NLM support is non-existent on OSX.
2655  */
2657  if (ret == -1 && errno != ENOENT) {
2659  "unable to unlink %s: %d", GF_SM_NOTIFY_PIDFILE, errno);
2660  goto err;
2661  }
2662  /* temporary work around to restart statd, not distro/OS independent.
2663  * Need to figure out a more graceful way
2664  * killall will cause problems on solaris.
2665  */
2666 
2667  char *pid_file = GF_RPC_STATD_PIDFILE;
2668  if (nfs->rpc_statd_pid_file)
2669  pid_file = nfs->rpc_statd_pid_file;
2670  pidfile = fopen(pid_file, "r");
2671  if (pidfile) {
2672  ret = fscanf(pidfile, "%d", &pid);
2673  if (ret <= 0) {
2675  "unable to get pid of "
2676  "rpc.statd from %s ",
2678  ret = runcmd(KILLALL_CMD, "-9", "rpc.statd", NULL);
2679  } else
2680  kill(pid, SIGKILL);
2681 
2682  fclose(pidfile);
2683  } else {
2685  "opening %s of rpc.statd failed (%s)", pid_file,
2686  strerror(errno));
2687  /* if ret == -1, do nothing - case either statd was not
2688  * running or was running in valgrind mode
2689  */
2690  ret = runcmd(KILLALL_CMD, "-9", "rpc.statd", NULL);
2691  }
2692 
2694  if (ret == -1 && errno != ENOENT) {
2696  "unable to unlink %s", pid_file);
2697  goto err;
2698  }
2699 
2700  ret = runcmd(nfs->rpc_statd, NULL);
2701  if (ret == -1) {
2703  "unable to start %s", nfs->rpc_statd);
2704  goto err;
2705  }
2706 
2707  (void)gf_thread_create(&thr, NULL, nsm_thread, (void *)NULL, "nfsnsm");
2708 
2709  timeout.tv_sec = nlm_grace_period;
2710  timeout.tv_nsec = 0;
2711 
2712  gf_timer_call_after(nfsx->ctx, timeout, nlm_grace_period_over, NULL);
2714 
2715  if (options)
2717  return &nlm4prog;
2718 err:
2719  if (options)
2721  return NULL;
2722 }
2723 
2724 int32_t
2726 {
2727  int32_t ret = -1;
2728  uint32_t client_count = 0;
2729  uint64_t file_count = 0;
2730  nlm_client_t *client = NULL;
2731  nlm_fde_t *fde = NULL;
2732  char key[GF_DUMP_MAX_BUF_LEN] = {0};
2733  char gfid_str[64] = {0};
2734 
2735  gf_proc_dump_add_section("nfs.nlm");
2736 
2738  goto out;
2739 
2740  list_for_each_entry(client, &nlm_client_list, nlm_clients)
2741  {
2742  gf_proc_dump_build_key(key, "client", "%d.hostname", client_count);
2743  gf_proc_dump_write(key, "%s\n", client->caller_name);
2744 
2745  file_count = 0;
2746  list_for_each_entry(fde, &client->fdes, fde_list)
2747  {
2748  gf_proc_dump_build_key(key, "file", "%" PRIu64 ".gfid", file_count);
2749  memset(gfid_str, 0, 64);
2750  uuid_utoa_r(fde->fd->inode->gfid, gfid_str);
2751  gf_proc_dump_write(key, "%s", gfid_str);
2752  file_count++;
2753  }
2754 
2755  gf_proc_dump_build_key(key, "client", "files-locked");
2756  gf_proc_dump_write(key, "%" PRIu64 "\n", file_count);
2757  client_count++;
2758  }
2759 
2760  gf_proc_dump_build_key(key, "nlm", "client-count");
2761  gf_proc_dump_write(key, "%d", client_count);
2762  ret = 0;
2764 
2765 out:
2766  if (ret) {
2767  gf_proc_dump_build_key(key, "nlm", "statedump_error");
2768  gf_proc_dump_write(key,
2769  "Unable to dump nlm state because "
2770  "nlm is not initialised or nlm_client_list_lk "
2771  "lock couldn't be acquired");
2772  }
2773 
2774  return ret;
2775 }
nlm4_remove_share_reservation
int nlm4_remove_share_reservation(nfs3_call_state_t *cs)
Definition: nlm4.c:2191
syncdaemon.monitor.monitor
def monitor(local, remote)
Definition: monitor.py:352
xlator.h
iobuf_to_iovec
void iobuf_to_iovec(struct iobuf *iob, struct iovec *iov)
Definition: iobuf.c:1093
_gf_false
#define _gf_false
Definition: glusterfs.h:369
gf_lkowner_t
Definition: glusterfs-fops.h:190
xdr_to_nlm4_freeallargs
ssize_t xdr_to_nlm4_freeallargs(struct iovec inmsg, nlm4_freeallargs *args)
Definition: msg-nfs3.c:452
xdr_serialize_nlm4_testres
ssize_t xdr_serialize_nlm4_testres(struct iovec outmsg, nlm4_testres *res)
Definition: msg-nfs3.c:395
iobref
Definition: iobuf.h:154
out
#define out(x...)
Definition: gcrawler.c:35
list_del
static void list_del(struct list_head *old)
Definition: list.h:70
nlm_priv
int32_t nlm_priv(xlator_t *this)
Definition: nlm4.c:2725
nlm_fde::fd
fd_t * fd
Definition: nlm4.h:107
gf_timer_call_after
gf_timer_t * gf_timer_call_after(glusterfs_ctx_t *ctx, struct timespec delta, gf_timer_cbk_t cbk, void *data)
Definition: timer.c:23
DRC_NA
@ DRC_NA
Definition: rpcsvc-common.h:83
nlm4_init_state
int nlm4_init_state(xlator_t *nfsx)
Definition: nlm4.c:2551
lock
static glusterd_lock_t lock
Definition: glusterd-utils.c:220
NLM4_LOCK_MSG
#define NLM4_LOCK_MSG
Definition: nlm4.h:36
nfs3_local::lockfh
struct nfs3_fh lockfh
Definition: nfs3.h:256
nlm_share::inode
inode_t * inode
Definition: nlm4.h:100
xdr_to_nlm4_lockargs
ssize_t xdr_to_nlm4_lockargs(struct iovec inmsg, nlm4_lockargs *args)
Definition: msg-nfs3.c:402
gf_nfs_mt_nlm4_fde
@ gf_nfs_mt_nlm4_fde
Definition: nfs-mem-types.h:37
nlm_client_list_lk
gf_lock_t nlm_client_list_lk
Definition: nlm4.c:55
nfs_state::allow_insecure
int allow_insecure
Definition: nfs.h:80
nsm_monitor
void * nsm_monitor(void *arg)
Definition: nlm4.c:543
GF_RPC_STATD_PIDFILE
#define GF_RPC_STATD_PIDFILE
Definition: nlm4.h:68
nlm4_gf_flock_to_holder
int nlm4_gf_flock_to_holder(nlm4_holder *holder, struct gf_flock *flock)
Definition: nlm4.c:716
nfs3_fh_resolve_and_resume
int nfs3_fh_resolve_and_resume(nfs3_call_state_t *cs, struct nfs3_fh *fh, char *entry, nfs3_resume_fn_t resum_fn)
Definition: nfs3-helpers.c:3889
nlm_dec_transit_count
int nlm_dec_transit_count(fd_t *fd, char *caller_name)
Definition: nlm4.c:1297
nlm4svc_lock_cbk
int nlm4svc_lock_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct gf_flock *flock, dict_t *xdata)
Definition: nlm4.c:1386
nlm4_serializer
ssize_t(* nlm4_serializer)(struct iovec outmsg, void *args)
Definition: nlm4.c:46
nlm4_volume_started_check
#define nlm4_volume_started_check(nfs3state, vlm, rtval, erlbl)
Definition: nlm4.c:125
NFS_MSG_DICT_SET_FAILED
@ NFS_MSG_DICT_SET_FAILED
Definition: nfs-messages.h:100
nlm4svc_cancel_cbk
int nlm4svc_cancel_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct gf_flock *flock, dict_t *xdata)
Definition: nlm4.c:1590
xdr_to_nlm4_shareargs
ssize_t xdr_to_nlm4_shareargs(struct iovec inmsg, nlm4_shareargs *args)
Definition: msg-nfs3.c:426
NLM4_FREE_ALL
#define NLM4_FREE_ALL
Definition: nlm4.h:52
NLM4_CANCEL
#define NLM4_CANCEL
Definition: nlm4.h:32
nlm_get_uniq
nlm_client_t * nlm_get_uniq(char *caller_name)
Definition: nlm4.c:610
nlm_is_oh_same_lkowner
int nlm_is_oh_same_lkowner(gf_lkowner_t *a, nlm4_netobj *b)
Definition: nlm4.c:221
tout
#define tout(x...)
Definition: gcrawler.c:41
nlm4svc_cancel
int nlm4svc_cancel(rpcsvc_request_t *req)
Definition: nlm4.c:1687
nfs3_local::cookiebytes
char cookiebytes[1024]
Definition: nfs3.h:255
_call_stack::uid
uid_t uid
Definition: stack.h:106
rpc_req
Definition: rpc-clnt.h:151
KILLALL_CMD
#define KILLALL_CMD
Definition: nlm4.c:39
nlm4_clnt_names
char * nlm4_clnt_names[24]
Definition: nlm4.c:750
defaults.h
args_::nlm4_unlockargs
nlm4_unlockargs nlm4_unlockargs
Definition: nfs3.h:171
copy_frame
static call_frame_t * copy_frame(call_frame_t *frame)
Definition: stack.h:459
iobuf_unref
void iobuf_unref(struct iobuf *iobuf)
Definition: iobuf.c:720
_xlator::ctx
glusterfs_ctx_t * ctx
Definition: xlator.h:818
mem-pool.h
NFS_MSG_OPEN_FAIL
@ NFS_MSG_OPEN_FAIL
Definition: nfs-messages.h:100
NLM_V4
#define NLM_V4
Definition: nlm4.h:79
nfs_state
#define nfs_state(nfsxl)
Definition: nfs-fops.h:101
nlm4_file_open_cbk
int32_t nlm4_file_open_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, fd_t *fd, dict_t *xdata)
Definition: nlm4.c:525
nlm4_add_share_to_inode
int nlm4_add_share_to_inode(nlm_share_t *share)
Definition: nlm4.c:1945
GF_VALIDATE_OR_GOTO
#define GF_VALIDATE_OR_GOTO(name, arg, label)
Definition: common-utils.h:319
nlm4_unshare_resume
int nlm4_unshare_resume(void *call_state)
Definition: nlm4.c:2267
xlator_fops::open
fop_open_t open
Definition: xlator.h:572
THIS
#define THIS
Definition: globals.h:126
GF_NLM4_PORT
#define GF_NLM4_PORT
Definition: nlm4.h:56
_call_stack::pid
pid_t pid
Definition: stack.h:108
nlm_handle_connect
static int nlm_handle_connect(struct rpc_clnt *rpc_clnt, struct nlm4_notify_args *ncf)
Definition: nlm4.c:2430
nlm4_lock_to_gf_flock
int nlm4_lock_to_gf_flock(struct gf_flock *flock, nlm4_lock *lock, int excl)
Definition: nlm4.c:731
rpcsvc_program
Definition: rpcsvc.h:393
nlm_fde
Definition: nlm4.h:105
NFS_MSG_START_ERROR
@ NFS_MSG_START_ERROR
Definition: nfs-messages.h:100
nfs3_local::resume_fn
nfs3_resume_fn_t resume_fn
Definition: nfs3.h:198
nlm4_map_fh_to_volume
#define nlm4_map_fh_to_volume(nfs3state, handle, req, volume, status, label)
Definition: nlm4.c:99
inode_ref
inode_t * inode_ref(inode_t *inode)
Definition: inode.c:609
nlm_copy_lkowner
void nlm_copy_lkowner(gf_lkowner_t *dst, nlm4_netobj *src)
Definition: nlm4.c:214
NFS_MSG_SHARE_LIST_STORE_FAIL
@ NFS_MSG_SHARE_LIST_STORE_FAIL
Definition: nfs-messages.h:100
rpcsvc_program::private
void * private
Definition: rpcsvc.h:421
rpcsvc_request_seterr
#define rpcsvc_request_seterr(req, err)
Definition: rpcsvc.h:565
GF_FREE
#define GF_FREE(free_ptr)
Definition: mem-pool.h:159
xdr_serialize_nlm4_shareres
ssize_t xdr_serialize_nlm4_shareres(struct iovec outmsg, nlm4_shareres *res)
Definition: msg-nfs3.c:432
args
union args_ args
xdr_to_nlm4_cancelargs
ssize_t xdr_to_nlm4_cancelargs(struct iovec inmsg, nlm4_cancargs *args)
Definition: msg-nfs3.c:414
nlm4svc_submit_reply
int nlm4svc_submit_reply(rpcsvc_request_t *req, void *arg, nlm4_serializer sfunc)
Definition: nlm4.c:447
NFS_MSG_LISTENERS_CREATE_FAIL
@ NFS_MSG_LISTENERS_CREATE_FAIL
Definition: nfs-messages.h:100
nsm_thread
void * nsm_thread(void *argv)
Definition: nlmcbk_svc.c:85
nlm4_resume_fn_t
int(* nlm4_resume_fn_t)(void *cs)
Definition: nlm4.c:522
GF_DUMP_MAX_BUF_LEN
#define GF_DUMP_MAX_BUF_LEN
Definition: statedump.h:18
NFS_MSG_NLM_GRACE_PERIOD
@ NFS_MSG_NLM_GRACE_PERIOD
Definition: nfs-messages.h:100
nlm4clntprog
rpc_clnt_prog_t nlm4clntprog
Definition: nlm4.c:755
nfs_state::rpc_statd_pid_file
char * rpc_statd_pid_file
Definition: nfs.h:101
nfs-generics.h
nlm_add_nlmclnt
int nlm_add_nlmclnt(char *caller_name)
Definition: nlm4.c:411
gf_lock_t
pthread_mutex_t gf_lock_t
Definition: locking.h:74
rpc_clnt::conn
rpc_clnt_connection_t conn
Definition: rpc-clnt.h:171
_xlator::fops
struct xlator_fops * fops
Definition: xlator.h:783
runcmd
int runcmd(const char *arg,...)
Definition: run.c:457
args_::nlm4_freeallargs
nlm4_freeallargs nlm4_freeallargs
Definition: nfs3.h:174
nfs_lk
int nfs_lk(xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, fd_t *fd, int cmd, struct gf_flock *flock, fop_lk_cbk_t cbk, void *local)
Definition: nfs-generics.c:137
nfs_state::generation
uint32_t generation
Definition: nfs.h:98
_call_frame
Definition: stack.h:63
rpc-clnt.h
rpc_clnt_submit
int rpc_clnt_submit(struct rpc_clnt *rpc, rpc_clnt_prog_t *prog, int procnum, fop_cbk_fn_t cbkfn, struct iovec *proghdr, int proghdrcount, struct iovec *progpayload, int progpayloadcount, struct iobref *iobref, void *frame, struct iovec *rsphdr, int rsphdr_count, struct iovec *rsp_payload, int rsp_payload_count, struct iobref *rsp_iobref)
Definition: rpc-clnt.c:1609
rpcsvc.h
nlm_search_and_add
nlm_client_t * nlm_search_and_add(fd_t *fd, char *caller_name)
Definition: nlm4.c:1340
rpc_clnt
Definition: rpc-clnt.h:168
args_::nlm4_shareargs
nlm4_shareargs nlm4_shareargs
Definition: nfs3.h:172
xdr_serialize_nlm4_testargs
ssize_t xdr_serialize_nlm4_testargs(struct iovec outmsg, nlm4_testargs *args)
Definition: msg-nfs3.c:439
rpcsvc_submit_message
int rpcsvc_submit_message(rpcsvc_request_t *req, struct iovec *proghdr, int hdrcount, struct iovec *payload, int payloadcount, struct iobref *iobref)
Definition: rpcsvc.c:1838
nfs3_local::trans
rpc_transport_t * trans
Definition: nfs3.h:258
NFS_MSG_GET_PID_FAIL
@ NFS_MSG_GET_PID_FAIL
Definition: nfs-messages.h:100
nlm_share::access
fsh_access access
Definition: nlm4.h:102
nlm4_notify_free
static void nlm4_notify_free(struct nlm4_notify_args *ncf)
Definition: nlm4.c:943
rpc_clnt_unref
struct rpc_clnt * rpc_clnt_unref(struct rpc_clnt *rpc)
Definition: rpc-clnt.c:1849
nlm_unset_rpc_clnt
int nlm_unset_rpc_clnt(rpc_clnt_t *rpc)
Definition: nlm4.c:393
TRY_LOCK
#define TRY_LOCK(x)
Definition: locking.h:78
NFS_MSG_REP_SUBMIT_FAIL
@ NFS_MSG_REP_SUBMIT_FAIL
Definition: nfs-messages.h:100
gf_lkowner_t::data
char data[1024]
Definition: glusterfs-fops.h:192
gf_sock_union::sin
struct sockaddr_in sin
Definition: common-utils.h:463
rpc_clnt_program::progname
char * progname
Definition: rpc-clnt.h:73
xdr_serialize_nlm4_res
ssize_t xdr_serialize_nlm4_res(struct iovec outmsg, nlm4_res *res)
Definition: msg-nfs3.c:408
NLM4_UNSHARE
#define NLM4_UNSHARE
Definition: nlm4.h:50
nfs3_local::lkowner
nlm4_lkowner_t lkowner
Definition: nfs3.h:254
nlm_rpcclnt_notify
int nlm_rpcclnt_notify(struct rpc_clnt *rpc_clnt, void *mydata, rpc_clnt_event_t fn, void *data)
Definition: nlm4.c:971
syscall.h
run.h
_inode
Definition: inode.h:99
NFS_MSG_UNSUPPORTED_VERSION
@ NFS_MSG_UNSUPPORTED_VERSION
Definition: nfs-messages.h:100
nlm4_unlock_resume
int nlm4_unlock_resume(void *carg)
Definition: nlm4.c:1800
nlm4svc_null
int nlm4svc_null(rpcsvc_request_t *req)
Definition: nlm4.c:700
nlm_client::caller_name
char * caller_name
Definition: nlm4.h:92
NFS_MSG_LOCK_FAIL
@ NFS_MSG_LOCK_FAIL
Definition: nfs-messages.h:100
GF_SM_NOTIFY_PIDFILE
#define GF_SM_NOTIFY_PIDFILE
Definition: nlm4.h:69
nlm4_free_all_shares
int nlm4_free_all_shares(char *caller_name)
Definition: nlm4.c:2354
gf_thread_create
int gf_thread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg, const char *name,...)
Definition: common-utils.c:4084
nfs3-helpers.h
nlm4prog
static rpcsvc_program_t nlm4prog
Definition: nlm4.c:2540
nlm4_clnt_actors
rpc_clnt_procedure_t nlm4_clnt_actors[24]
Definition: nlm4.c:745
gf_sock_union::sin6
struct sockaddr_in6 sin6
Definition: common-utils.h:462
nfs3.h
nlm4_prep_nlm4_testargs
void nlm4_prep_nlm4_testargs(nlm4_testargs *args, struct nfs3_fh *fh, nlm4_lkowner_t *oh, char *cookiebytes)
Definition: nlm4.c:157
gf_flock::l_pid
pid_t l_pid
Definition: glusterfs.h:755
gf_flock::l_start
off_t l_start
Definition: glusterfs.h:753
iobref_new
struct iobref * iobref_new(void)
Definition: iobuf.c:746
gf_asprintf
int gf_asprintf(char **string_ptr, const char *format,...)
Definition: mem-pool.c:237
fd_anonymous
fd_t * fd_anonymous(inode_t *inode)
Definition: fd.c:790
nlm4_test_fd_resume
int nlm4_test_fd_resume(void *carg)
Definition: nlm4.c:802
GF_LOG_WARNING
@ GF_LOG_WARNING
Definition: logging.h:74
NFS_MSG_CLIENT_NOT_FOUND
@ NFS_MSG_CLIENT_NOT_FOUND
Definition: nfs-messages.h:100
nfs3-fh.h
nlm4svc_actors
static rpcsvc_actor_t nlm4svc_actors[24]
Definition: nlm4.c:2508
dict_set_dynstr
int dict_set_dynstr(dict_t *this, char *key, char *str)
Definition: dict.c:2487
create_frame
call_frame_t * create_frame(xlator_t *xl, call_pool_t *pool)
Definition: stack.c:16
iobuf_get
struct iobuf * iobuf_get(struct iobuf_pool *iobuf_pool)
Definition: iobuf.c:608
GF_REF_GET
#define GF_REF_GET(p)
Definition: refcount.h:92
rpcsvc_create_listeners
int32_t rpcsvc_create_listeners(rpcsvc_t *svc, dict_t *options, char *name)
Definition: rpcsvc.c:2018
nlm4_prep_nlm4_unlockargs
void nlm4_prep_nlm4_unlockargs(nlm4_unlockargs *args, struct nfs3_fh *fh, nlm4_lkowner_t *oh, char *cookiebytes)
Definition: nlm4.c:187
NFS_MSG_FD_LOOKUP_NULL
@ NFS_MSG_FD_LOOKUP_NULL
Definition: nfs-messages.h:100
nlm4_validate_gluster_fh
#define nlm4_validate_gluster_fh(handle, status, errlabel)
Definition: nlm4.c:88
nlm4_establish_callback
void * nlm4_establish_callback(nfs3_call_state_t *cs, call_frame_t *cbk_frame)
Definition: nlm4.c:1002
INIT_LIST_HEAD
#define INIT_LIST_HEAD(head)
Definition: list.h:19
nlm4_prep_shareargs
void nlm4_prep_shareargs(nlm4_shareargs *args, struct nfs3_fh *fh, nlm4_lkowner_t *oh, char *cookiebytes)
Definition: nlm4.c:197
SM_PROG
#define SM_PROG
NLM4_TEST_RES
#define NLM4_TEST_RES
Definition: nlm4.h:40
gf_boolean_t
#define gf_boolean_t
Definition: glusterfs.h:368
RPC_CLNT_DESTROY
@ RPC_CLNT_DESTROY
Definition: rpc-clnt.h:25
inode_ctx_get
#define inode_ctx_get(i, x, v)
Definition: inode.h:272
NFS_MSG_RESOLVE_ERROR
@ NFS_MSG_RESOLVE_ERROR
Definition: nfs-messages.h:100
gf_nfs_mt_nlm4_nlmclnt
@ gf_nfs_mt_nlm4_nlmclnt
Definition: nfs-mem-types.h:38
nlm4svc_sm_notify
void nlm4svc_sm_notify(struct nlm_sm_status *status)
Definition: nlm4.c:2418
NLM4_TEST
#define NLM4_TEST
Definition: nlm4.h:30
NFS_MSG_CLNT_CREATE_ERROR
@ NFS_MSG_CLNT_CREATE_ERROR
Definition: nfs-messages.h:100
rpc_transport_connect
int32_t rpc_transport_connect(rpc_transport_t *this, int port)
Definition: rpc-transport.c:406
nlm4_handle_call_state_init
#define nlm4_handle_call_state_init(nfs3state, calls, rq, opstat, errlabel)
Definition: nlm4.c:75
UNLOCK
#define UNLOCK(x)
Definition: locking.h:79
nfs3_local::resolve_ret
int resolve_ret
Definition: nfs3.h:243
gf_flock::l_len
off_t l_len
Definition: glusterfs.h:754
gf_proc_dump_build_key
#define gf_proc_dump_build_key(key, key_prefix, fmt...)
Definition: statedump.h:56
nlm4_generic_reply
int nlm4_generic_reply(rpcsvc_request_t *req, nlm4_netobj cookie, nlm4_stats stat)
Definition: nlm4.c:686
nlm_grace_period_over
void nlm_grace_period_over(void *arg)
Definition: nlm4.c:2560
rpc_clnt_register_notify
int rpc_clnt_register_notify(struct rpc_clnt *rpc, rpc_clnt_notify_t fn, void *mydata)
Definition: rpc-clnt.c:1199
nlm4_share_reply
int nlm4_share_reply(nfs3_call_state_t *cs, nlm4_stats stat)
Definition: nlm4.c:1913
NFS_MSG_NO_MEMORY
@ NFS_MSG_NO_MEMORY
Definition: nfs-messages.h:100
gf_msg
#define gf_msg(dom, level, errnum, msgid, fmt...)
Definition: logging.h:229
_call_frame::local
void * local
Definition: stack.h:67
rpcsvc_request::msg
struct iovec msg[16]
Definition: rpcsvc.h:194
nfs3_local
Definition: nfs3.h:193
rpcsvc_request::procnum
int procnum
Definition: rpcsvc.h:167
NFS_MSG_CALLER_NOT_FOUND
@ NFS_MSG_CALLER_NOT_FOUND
Definition: nfs-messages.h:100
nlm_client
Definition: nlm4.h:85
NLM4_GRANTED_RES
#define NLM4_GRANTED_RES
Definition: nlm4.h:44
args_
Definition: nfs3.h:160
gf_msg_debug
#define gf_msg_debug(dom, errnum, fmt...)
Definition: logging.h:270
gf_sock_union::storage
struct sockaddr_storage storage
Definition: common-utils.h:461
NFS_MSG_MNT_STATE_NOT_FOUND
@ NFS_MSG_MNT_STATE_NOT_FOUND
Definition: nfs-messages.h:100
rpcsvc_request_uid
#define rpcsvc_request_uid(req)
Definition: rpcsvc.h:279
_call_stack::gid
gid_t gid
Definition: stack.h:107
list_head
Definition: list.h:14
NLM4_NULL
#define NLM4_NULL
Definition: nlm4.h:29
dict_new
dict_t * dict_new(void)
Definition: dict.c:107
dict_unref
void dict_unref(dict_t *this)
Definition: dict.c:734
inode_unref
inode_t * inode_unref(inode_t *inode)
Definition: inode.c:588
nlm_grace_period
int nlm_grace_period
Definition: nlm4.c:58
DRC_NON_IDEMPOTENT
@ DRC_NON_IDEMPOTENT
Definition: rpcsvc-common.h:83
nfs_inode_ctx
Definition: nfs.h:106
NLM4_TEST_MSG
#define NLM4_TEST_MSG
Definition: nlm4.h:35
GF_REF_PUT
#define GF_REF_PUT(p)
Definition: refcount.h:99
NFS_MSG_INVALID_ENTRY
@ NFS_MSG_INVALID_ENTRY
Definition: nfs-messages.h:100
list_empty
static int list_empty(struct list_head *head)
Definition: list.h:104
nfs3_state
Definition: nfs3.h:116
nfs_state::rpc_statd
char * rpc_statd
Definition: nfs.h:100
nlm4_lock_fd_resume
int nlm4_lock_fd_resume(void *carg)
Definition: nlm4.c:1432
_glusterfs_ctx::pool
struct call_pool * pool
Definition: glusterfs.h:625
nfs_fix_groups
void nfs_fix_groups(xlator_t *this, call_stack_t *root)
Definition: nfs-fops.c:29
NLM4_LOCK_RES
#define NLM4_LOCK_RES
Definition: nlm4.h:41
RPC_CLNT_DISCONNECT
@ RPC_CLNT_DISCONNECT
Definition: rpc-clnt.h:22
rpcsvc_request_program_private
#define rpcsvc_request_program_private(req)
Definition: rpcsvc.h:271
nlm4svc_free_all
int nlm4svc_free_all(rpcsvc_request_t *req)
Definition: nlm4.c:2381
nlm4_unlock_fd_resume
int nlm4_unlock_fd_resume(void *carg)
Definition: nlm4.c:1773
_xlator::private
void * private
Definition: xlator.h:822
rpcsvc_request
Definition: rpcsvc.h:155
_fd
Definition: fd.h:39
rpc_transport_get_peeraddr
int32_t rpc_transport_get_peeraddr(rpc_transport_t *this, char *peeraddr, int addrlen, struct sockaddr_storage *sa, size_t salen)
Definition: rpc-transport.c:83
gf_nfs_mt_nlm4_share
@ gf_nfs_mt_nlm4_share
Definition: nfs-mem-types.h:39
nlm4svc_unlock_cbk
int nlm4svc_unlock_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct gf_flock *flock, dict_t *xdata)
Definition: nlm4.c:1749
nfs3_local::monitor
int monitor
Definition: nfs3.h:257
_xlator
Definition: xlator.h:770
nfs3_local::req
rpcsvc_request_t * req
Definition: nfs3.h:196
NFS_MSG_INODE_SHARES_NOT_FOUND
@ NFS_MSG_INODE_SHARES_NOT_FOUND
Definition: nfs-messages.h:100
nfs-mem-types.h
rpc_clnt_procedure
Definition: rpc-clnt.h:67
nlm4svc_test_cbk
int nlm4svc_test_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct gf_flock *flock, dict_t *xdata)
Definition: nlm4.c:781
nfs.h
nlm4svc_lock_common
int nlm4svc_lock_common(rpcsvc_request_t *req, int mon)
Definition: nlm4.c:1510
nlm4_share_resume
int nlm4_share_resume(void *call_state)
Definition: nlm4.c:2102
nfs3_call_state_wipe
void nfs3_call_state_wipe(nfs3_call_state_t *cs)
Definition: nfs3.c:571
GF_LK_F_WRLCK
@ GF_LK_F_WRLCK
Definition: glusterfs-fops.h:129
nfs_request_user_init
void nfs_request_user_init(nfs_user_t *nfu, rpcsvc_request_t *req)
Definition: nfs.c:672
rpc_clnt_connection::trans
rpc_transport_t * trans
Definition: rpc-clnt.h:130
fd_ref
fd_t * fd_ref(fd_t *fd)
Definition: fd.c:427
nlm_share::inode_list
struct list_head inode_list
Definition: nlm4.h:98
NFS_MSG_SHARE_CALL_FAIL
@ NFS_MSG_SHARE_CALL_FAIL
Definition: nfs-messages.h:100
nlm4svc_send_granted
static void nlm4svc_send_granted(struct nlm4_notify_args *ncf)
Definition: nlm4.c:1139
NLM4_GRANTED_MSG
#define NLM4_GRANTED_MSG
Definition: nlm4.h:39
rpc_clnt_new
struct rpc_clnt * rpc_clnt_new(dict_t *options, xlator_t *owner, char *name, uint32_t reqpool_size)
Definition: rpc-clnt.c:1088
nfs3_fh_to_xlator
xlator_t * nfs3_fh_to_xlator(struct nfs3_state *nfs3, struct nfs3_fh *fh)
Definition: nfs3.c:152
_loc::inode
inode_t * inode
Definition: xlator.h:69
nfs_state::nfs3state
struct nfs3_state * nfs3state
Definition: nfs.h:66
peer_info::sockaddr
struct sockaddr_storage sockaddr
Definition: rpc-transport.h:68
fd_bind
fd_t * fd_bind(fd_t *fd)
Definition: fd.c:574
rpcsvc_actor_desc
Definition: rpcsvc.h:358
NFS_MSG_UNSHARE_CALL_FAIL
@ NFS_MSG_UNSHARE_CALL_FAIL
Definition: nfs-messages.h:100
nlm_share::mode
fsh_mode mode
Definition: nlm4.h:101
gf_lkowner_t::len
int len
Definition: glusterfs-fops.h:191
nfs_user_info::lk_owner
gf_lkowner_t lk_owner
Definition: nfs.h:132
msg-nfs3.h
iobref_add
int iobref_add(struct iobref *iobref, struct iobuf *iobuf)
Definition: iobuf.c:889
nlm4_prep_freeallargs
void nlm4_prep_freeallargs(nlm4_freeallargs *args, nlm4_lkowner_t *oh)
Definition: nlm4.c:207
nlm_fde::fde_list
struct list_head fde_list
Definition: nlm4.h:106
nlm4_validate_nfs3_state
#define nlm4_validate_nfs3_state(request, state, status, label, retval)
Definition: nlm4.c:62
nfs3_local::vol
xlator_t * vol
Definition: nfs3.h:197
nfs3_fh
Definition: nfs3-fh.h:33
nfs3_call_state_init
nfs3_call_state_t * nfs3_call_state_init(struct nfs3_state *s, rpcsvc_request_t *req, xlator_t *v)
Definition: nfs3.c:542
nlm4svc_nm_lock
int nlm4svc_nm_lock(rpcsvc_request_t *req)
Definition: nlm4.c:1584
RPC_CLNT_CONNECT
@ RPC_CLNT_CONNECT
Definition: rpc-clnt.h:21
name
char * name
Definition: xdr-nfs3.h:948
rpc_clnt_program
Definition: rpc-clnt.h:72
NFS_MSG_SM_NOTIFY
@ NFS_MSG_SM_NOTIFY
Definition: nfs-messages.h:100
NLM4_CANCEL_RES
#define NLM4_CANCEL_RES
Definition: nlm4.h:42
NLM4_NM_LOCK
#define NLM4_NM_LOCK
Definition: nlm4.h:51
nlm4svc_share
int nlm4svc_share(rpcsvc_request_t *req)
Definition: nlm4.c:2125
gf_nfs_mt_inode_ctx
@ gf_nfs_mt_inode_ctx
Definition: nfs-mem-types.h:40
NLM4_NINETEEN
#define NLM4_NINETEEN
Definition: nlm4.h:48
NLM4_UNLOCK_MSG
#define NLM4_UNLOCK_MSG
Definition: nlm4.h:38
nlm4svc_send_granted_cbk
static int nlm4svc_send_granted_cbk(struct rpc_req *req, struct iovec *iov, int count, void *myframe)
Definition: nlm4.c:932
gf_flock::l_owner
gf_lkowner_t l_owner
Definition: glusterfs.h:756
fd_unref
void fd_unref(fd_t *fd)
Definition: fd.c:531
NLM4_CANCEL_MSG
#define NLM4_CANCEL_MSG
Definition: nlm4.h:37
nfs_state
Definition: nfs.h:62
NLM4_UNLOCK_RES
#define NLM4_UNLOCK_RES
Definition: nlm4.h:43
NFS_MSG_GET_PORT_ERROR
@ NFS_MSG_GET_PORT_ERROR
Definition: nfs-messages.h:100
nfs3_state::iobpool
struct iobuf_pool * iobpool
Definition: nfs3.h:125
nlm4_approve_share_reservation
int nlm4_approve_share_reservation(nfs3_call_state_t *cs)
Definition: nlm4.c:1994
GF_REF_DECL
#define GF_REF_DECL
Definition: refcount.h:77
args_::nlm4_lockargs
nlm4_lockargs nlm4_lockargs
Definition: nfs3.h:169
xdr_to_nlm4_unlockargs
ssize_t xdr_to_nlm4_unlockargs(struct iovec inmsg, nlm4_unlockargs *args)
Definition: msg-nfs3.c:420
NFS_MSG_CLNT_CALL_ERROR
@ NFS_MSG_CLNT_CALL_ERROR
Definition: nfs-messages.h:100
gf_flock::l_type
short l_type
Definition: glusterfs.h:751
rpc_clnt_connection_cleanup
int rpc_clnt_connection_cleanup(rpc_clnt_connection_t *conn)
Definition: rpc-clnt.c:495
nlm4_prep_nlm4_lockargs
void nlm4_prep_nlm4_lockargs(nlm4_lockargs *args, struct nfs3_fh *fh, nlm4_lkowner_t *oh, char *cookiebytes)
Definition: nlm4.c:167
fd_lookup_uint64
fd_t * fd_lookup_uint64(inode_t *inode, uint64_t pid)
Definition: fd.c:713
xdr_to_nlm4_testargs
ssize_t xdr_to_nlm4_testargs(struct iovec inmsg, nlm4_testargs *args)
Definition: msg-nfs3.c:389
_call_frame::root
call_stack_t * root
Definition: stack.h:64
nlm4svc_test
int nlm4svc_test(rpcsvc_request_t *req)
Definition: nlm4.c:863
nlm_monitor
int nlm_monitor(char *caller_name)
Definition: nlm4.c:277
nlm4_call_state_init
nfs3_call_state_t * nlm4_call_state_init(struct nfs3_state *s, rpcsvc_request_t *req)
Definition: nlm4.c:260
nlm_fde::transit_cnt
int transit_cnt
Definition: nlm4.h:108
NFS_PID
#define NFS_PID
Definition: stack.h:37
nlm4_cancel_fd_resume
int nlm4_cancel_fd_resume(void *carg)
Definition: nlm4.c:1613
nlm4_inited
static bool nlm4_inited
Definition: nlm4.c:60
NLM4_GRANTED
#define NLM4_GRANTED
Definition: nlm4.h:34
nlm_search_and_delete
void nlm_search_and_delete(fd_t *fd, nlm4_lock *lk)
Definition: nlm4.c:1251
nfs_user_info
Definition: nfs.h:128
sys_unlink
int sys_unlink(const char *pathname)
Definition: syscall.c:208
GF_LOG_ERROR
@ GF_LOG_ERROR
Definition: logging.h:73
_fd::inode
struct _inode * inode
Definition: fd.h:44
nlm4_errno_to_nlm4stat
nlm4_stats nlm4_errno_to_nlm4stat(int errnum)
Definition: nlm4.c:234
list_for_each_entry
#define list_for_each_entry(pos, head, member)
Definition: list.h:235
nlm_client::nsm_monitor
int nsm_monitor
Definition: nlm4.h:93
gf_flock::l_whence
short l_whence
Definition: glusterfs.h:752
gf_sock_union
Definition: common-utils.h:460
RPCSVC_ACTOR_ERROR
#define RPCSVC_ACTOR_ERROR
Definition: rpcsvc.h:323
nfs_inode_ctx::generation
uint32_t generation
Definition: nfs.h:108
nlm4_lock_resume
int nlm4_lock_resume(void *carg)
Definition: nlm4.c:1482
LOCK_INIT
#define LOCK_INIT(x)
Definition: locking.h:76
nlm_client::nlm_clients
struct list_head nlm_clients
Definition: nlm4.h:88
options
static struct argp_option options[]
Definition: glfs-bm.c:322
NLM4_SM_NOTIFY
#define NLM4_SM_NOTIFY
Definition: nlm4.h:45
nlm4_lwowner
Definition: nlm4.h:81
args_::nlm4_testargs
nlm4_testargs nlm4_testargs
Definition: nfs3.h:167
nlm4svc_lock
int nlm4svc_lock(rpcsvc_request_t *req)
Definition: nlm4.c:1578
nlm_client::rpc_clnt
struct rpc_clnt * rpc_clnt
Definition: nlm4.h:91
iobref_unref
void iobref_unref(struct iobref *iobref)
Definition: iobuf.c:804
nlm_client_free
static void nlm_client_free(nlm_client_t *nlmclnt)
Definition: nlm4.c:325
nlm4_test_reply
int nlm4_test_reply(nfs3_call_state_t *cs, nlm4_stats stat, struct gf_flock *flock)
Definition: nlm4.c:765
NLM4_LOCK
#define NLM4_LOCK
Definition: nlm4.h:31
logging.h
gf_flock
Definition: glusterfs.h:750
gf_proc_dump_write
int gf_proc_dump_write(char *key, char *value,...)
Definition: statedump.c:187
dict.h
rpc_clnt_ref
struct rpc_clnt * rpc_clnt_ref(struct rpc_clnt *rpc)
Definition: rpc-clnt.c:1771
nfs3_local::nfs3state
struct nfs3_state * nfs3state
Definition: nfs3.h:200
nlm_client::shares
struct list_head shares
Definition: nlm4.h:90
NLM4_EIGHTEEN
#define NLM4_EIGHTEEN
Definition: nlm4.h:47
nlm4_notify_args::cs
nfs3_call_state_t * cs
Definition: nlm4.c:927
dict_set_str
int dict_set_str(dict_t *this, char *key, char *str)
Definition: dict.c:2410
nfs_inode_ctx::shares
struct list_head shares
Definition: nfs.h:107
SM_MON
#define SM_MON
SM_VERS
#define SM_VERS
NFS_MSG_ARGS_DECODE_ERROR
@ NFS_MSG_ARGS_DECODE_ERROR
Definition: nfs-messages.h:100
nlm_client::fdes
struct list_head fdes
Definition: nlm4.h:89
nfs3_state::nfsx
xlator_t * nfsx
Definition: nfs3.h:120
LOCK
#define LOCK(x)
Definition: locking.h:77
NLM4_UNLOCK
#define NLM4_UNLOCK
Definition: nlm4.h:33
statedump.h
DRC_IDEMPOTENT
@ DRC_IDEMPOTENT
Definition: rpcsvc-common.h:83
nlm4_test_resume
int nlm4_test_resume(void *carg)
Definition: nlm4.c:830
rpc_transport::myinfo
peer_info_t myinfo
Definition: rpc-transport.h:188
args_::nlm4_cancargs
nlm4_cancargs nlm4_cancargs
Definition: nfs3.h:170
nlm4.h
NFS_MSG_NLM_INIT_FAIL
@ NFS_MSG_NLM_INIT_FAIL
Definition: nfs-messages.h:100
_inode::gfid
uuid_t gfid
Definition: inode.h:101
NLM4_SHARE
#define NLM4_SHARE
Definition: nlm4.h:49
nfs3_local::nfsx
xlator_t * nfsx
Definition: nfs3.h:199
list_add
static void list_add(struct list_head *new, struct list_head *head)
Definition: list.h:25
nlm4_cancel_resume
int nlm4_cancel_resume(void *carg)
Definition: nlm4.c:1642
NLM_PROGRAM
#define NLM_PROGRAM
Definition: glusterd-utils.c:89
NFS_MSG_UNLINK_ERROR
@ NFS_MSG_UNLINK_ERROR
Definition: nfs-messages.h:100
nlm4svc_unlock
int nlm4svc_unlock(rpcsvc_request_t *req)
Definition: nlm4.c:1849
nfs3_local::args
args args
Definition: nfs3.h:253
nlm4_check_fh_resolve_status
#define nlm4_check_fh_resolve_status(cst, nfstat, erlabl)
Definition: nlm4.c:135
rpcsvc_request_transport_ref
#define rpcsvc_request_transport_ref(req)
Definition: rpcsvc.h:291
NFS_MSG_NLMCLNT_NOT_FOUND
@ NFS_MSG_NLMCLNT_NOT_FOUND
Definition: nfs-messages.h:100
rpcsvc_request::prognum
int prognum
Definition: rpcsvc.h:163
rpcsvc_submit_generic
int rpcsvc_submit_generic(rpcsvc_request_t *req, struct iovec *proghdr, int hdrcount, struct iovec *payload, int payloadcount, struct iobref *iobref)
Definition: rpcsvc.c:1501
uuid_utoa_r
char * uuid_utoa_r(uuid_t uuid, char *dst)
Definition: common-utils.c:2850
list_for_each_entry_safe
#define list_for_each_entry_safe(pos, n, head, member)
Definition: list.h:240
NLM4_PROC_COUNT
#define NLM4_PROC_COUNT
Definition: nlm4.h:53
nlm4svc_init
rpcsvc_program_t * nlm4svc_init(xlator_t *nfsx)
Definition: nlm4.c:2566
_dict
Definition: dict.h:114
GF_REF_INIT
#define GF_REF_INIT(p, d)
Definition: refcount.h:86
nfs3_local::resolvedloc
loc_t resolvedloc
Definition: nfs3.h:242
rpc_clnt_event_t
rpc_clnt_event_t
Definition: rpc-clnt.h:20
src
Definition: __init__.py:1
nlm4_file_open_and_resume
int nlm4_file_open_and_resume(nfs3_call_state_t *cs, nlm4_resume_fn_t resume)
Definition: nlm4.c:622
GF_CALLOC
#define GF_CALLOC(nmemb, size, type)
Definition: mem-pool.h:153
NFS_MSG_ENCODE_MSG_FAIL
@ NFS_MSG_ENCODE_MSG_FAIL
Definition: nfs-messages.h:100
RPC_CLNT_MSG
@ RPC_CLNT_MSG
Definition: rpc-clnt.h:24
nlm_set_rpc_clnt
int nlm_set_rpc_clnt(rpc_clnt_t *rpc_clnt, char *caller_name)
Definition: nlm4.c:355
nlm_share::lkowner
gf_lkowner_t lkowner
Definition: nlm4.h:99
gf_nfs_mt_nlm4_notify
@ gf_nfs_mt_nlm4_notify
Definition: nfs-mem-types.h:45
nlm4_prep_nlm4_cancargs
void nlm4_prep_nlm4_cancargs(nlm4_cancargs *args, struct nfs3_fh *fh, nlm4_lkowner_t *oh, char *cookiebytes)
Definition: nlm4.c:177
nfs_state::rpcsvc
rpcsvc_t * rpcsvc
Definition: nfs.h:63
STACK_DESTROY
static void STACK_DESTROY(call_stack_t *stack)
Definition: stack.h:177
nlm_share::client_list
struct list_head client_list
Definition: nlm4.h:97
GF_LOG_INFO
@ GF_LOG_INFO
Definition: logging.h:76
__nlm_get_uniq
nlm_client_t * __nlm_get_uniq(char *caller_name)
Definition: nlm4.c:593
NFS_MSG_INODE_NOT_FOUND
@ NFS_MSG_INODE_NOT_FOUND
Definition: nfs-messages.h:100
fd_create_uint64
fd_t * fd_create_uint64(inode_t *inode, uint64_t pid)
Definition: fd.c:646
_gf_true
#define _gf_true
Definition: glusterfs.h:370
nfs-fops.h
nlm4_create_share_reservation
int nlm4_create_share_reservation(nfs3_call_state_t *cs)
Definition: nlm4.c:2040
nlm4_notify_init
static struct nlm4_notify_args * nlm4_notify_init(nfs3_call_state_t *cs)
Definition: nlm4.c:951
nlm_client_list
struct list_head nlm_client_list
Definition: nlm4.c:54
gf_strdup
static char * gf_strdup(const char *src)
Definition: mem-pool.h:182
nlm4svc_unshare
int nlm4svc_unshare(rpcsvc_request_t *req)
Definition: nlm4.c:2290
err
#define err(x...)
Definition: gcrawler.c:34
STACK_WIND_COOKIE
#define STACK_WIND_COOKIE(frame, rfn, cky, obj, fn, params...)
Definition: stack.h:310
rpcsvc_program::progname
char progname[32]
Definition: rpcsvc.h:394
iobuf
Definition: iobuf.h:58
NFS_MSG_RPC_CLNT_ERROR
@ NFS_MSG_RPC_CLNT_ERROR
Definition: nfs-messages.h:100
nlm4_notify_args
Definition: nlm4.c:924
GF_NLM
#define GF_NLM
Definition: nlm4.h:57
nfs-messages.h
nfs3_local::fd
fd_t * fd
Definition: nfs3.h:210
NLM4_SEVENTEEN
#define NLM4_SEVENTEEN
Definition: nlm4.h:46
gf_proc_dump_add_section
int gf_proc_dump_add_section(char *key,...)
Definition: statedump.c:144
rpcsvc_request_gid
#define rpcsvc_request_gid(req)
Definition: rpcsvc.h:280
nlm_get_rpc_clnt
rpc_clnt_t * nlm_get_rpc_clnt(char *caller_name)
Definition: nlm4.c:301
nlm_share
Definition: nlm4.h:96
gf_msg_trace
#define gf_msg_trace(dom, errnum, fmt...)
Definition: logging.h:276
glusterfs_this_set
void glusterfs_this_set(xlator_t *this)
Definition: globals.c:245
inode_ctx_put
static int inode_ctx_put(inode_t *inode, xlator_t *this, uint64_t v)
Definition: inode.h:259
gf_sock_union::sa
struct sockaddr sa
Definition: common-utils.h:464
nlm4_notify_args::frame
call_frame_t * frame
Definition: nlm4.c:928
nlm4_share_new
nlm_share_t * nlm4_share_new()
Definition: nlm4.c:1930
nlm_cleanup_fds
int nlm_cleanup_fds(char *caller_name)
Definition: nlm4.c:1227
mount3.h