summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiels de Vos <ndevos@redhat.com>2017-01-13 13:02:23 +0100
committerRaghavendra Talur <rtalur@redhat.com>2017-05-14 17:19:22 +0000
commit9662e858da7a3dcab64361a049a86d06e092b28a (patch)
treee3a9beb0907b7ad5e1b2d0d5d0f42e2bdb246d36
parent4e118f1846caeb1024c2bc3eaff01d9f0cd11374 (diff)
nfs/nlm: remove lock request from the list after cancel
Once an NLM client cancels a lock request, it should be removed from the list. The list can also be cleaned of unneeded entries once the client does not have any outstanding lock/share requests/granted. Cherry picked from commit 71cb7f3eb4fb706aab7f83906592942a2ff2e924: > Change-Id: I2f2b666b627dcb52cddc6d5b95856e420b2b2e26 > BUG: 1381970 > Signed-off-by: Niels de Vos <ndevos@redhat.com> > Reviewed-on: https://review.gluster.org/17188 > Smoke: Gluster Build System <jenkins@build.gluster.org> > NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> > Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com> > CentOS-regression: Gluster Build System <jenkins@build.gluster.org> > Reviewed-by: jiffin tony Thottan <jthottan@redhat.com> Change-Id: I2f2b666b627dcb52cddc6d5b95856e420b2b2e26 BUG: 1450378 Signed-off-by: Niels de Vos <ndevos@redhat.com> Reviewed-on: https://review.gluster.org/17273 Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Raghavendra Talur <rtalur@redhat.com>
-rw-r--r--xlators/nfs/server/src/nlm4.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/xlators/nfs/server/src/nlm4.c b/xlators/nfs/server/src/nlm4.c
index cff9a3f5044..8580448b762 100644
--- a/xlators/nfs/server/src/nlm4.c
+++ b/xlators/nfs/server/src/nlm4.c
@@ -1213,7 +1213,7 @@ ret:
}
void
-nlm_search_and_delete (fd_t *fd, char *caller_name)
+nlm_search_and_delete (fd_t *fd, nlm4_lock *lk)
{
nlm_fde_t *fde = NULL;
nlm_client_t *nlmclnt = NULL;
@@ -1224,7 +1224,7 @@ nlm_search_and_delete (fd_t *fd, char *caller_name)
LOCK (&nlm_client_list_lk);
list_for_each_entry (nlmclnt,
&nlm_client_list, nlm_clients) {
- if (!strcmp(caller_name, nlmclnt->caller_name)) {
+ if (!strcmp (lk->caller_name, nlmclnt->caller_name)) {
nlmclnt_found = 1;
break;
}
@@ -1247,6 +1247,9 @@ nlm_search_and_delete (fd_t *fd, char *caller_name)
goto ret;
list_del (&fde->fde_list);
+ if (list_empty (&nlmclnt->fdes) && list_empty (&nlmclnt->shares))
+ nlm_client_free (nlmclnt);
+
ret:
UNLOCK (&nlm_client_list_lk);
@@ -1362,7 +1365,8 @@ nlm4svc_lock_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (op_ret == -1) {
if (transit_cnt == 0)
- nlm_search_and_delete (cs->fd, caller_name);
+ nlm_search_and_delete (cs->fd,
+ &cs->args.nlm4_lockargs.alock);
stat = nlm4_errno_to_nlm4stat (op_errno);
goto err;
} else {
@@ -1553,8 +1557,10 @@ nlm4svc_cancel_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (op_ret == -1) {
stat = nlm4_errno_to_nlm4stat (op_errno);
goto err;
- } else
+ } else {
stat = nlm4_granted;
+ nlm_search_and_delete (cs->fd, &cs->args.nlm4_lockargs.alock);
+ }
err:
nlm4_generic_reply (cs->req, cs->args.nlm4_cancargs.cookie,
@@ -1707,7 +1713,7 @@ nlm4svc_unlock_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
stat = nlm4_granted;
if (flock->l_type == F_UNLCK)
nlm_search_and_delete (cs->fd,
- cs->args.nlm4_unlockargs.alock.caller_name);
+ &cs->args.nlm4_unlockargs.alock);
}
err: