21ab4e
From 2ba31393b8f38838b03e82da58ca22443e1b15cb Mon Sep 17 00:00:00 2001
21ab4e
From: Niels de Vos <ndevos@redhat.com>
21ab4e
Date: Fri, 30 Jun 2017 17:54:34 +0200
21ab4e
Subject: [PATCH 547/557] nfs/nlm: unref fds in nlm_client_free()
21ab4e
21ab4e
When a nlm_clnt is getting free'd, the FDs associated with this client
21ab4e
should be unref'd as well.
21ab4e
21ab4e
Cherry picked from commit e9a482f94e748ea12e73ddd2e275bad9aa314b4c:
21ab4e
> Change-Id: Ifa4ea4b7ed45a454413cfc0c820f2516c534a9aa
21ab4e
> BUG: 1467313
21ab4e
> Signed-off-by: Niels de Vos <ndevos@redhat.com>
21ab4e
> Reviewed-on: https://review.gluster.org/17697
21ab4e
> Smoke: Gluster Build System <jenkins@build.gluster.org>
21ab4e
> Reviewed-by: Amar Tumballi <amarts@redhat.com>
21ab4e
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
21ab4e
> Reviewed-by: jiffin tony Thottan <jthottan@redhat.com>
21ab4e
> Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
21ab4e
21ab4e
Change-Id: Ifa4ea4b7ed45a454413cfc0c820f2516c534a9aa
21ab4e
BUG: 1411344
21ab4e
Signed-off-by: Niels de Vos <ndevos@redhat.com>
21ab4e
Reviewed-on: https://code.engineering.redhat.com/gerrit/111766
21ab4e
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
21ab4e
---
21ab4e
 xlators/nfs/server/src/nlm4.c | 25 ++++++++++++-------------
21ab4e
 1 file changed, 12 insertions(+), 13 deletions(-)
21ab4e
21ab4e
diff --git a/xlators/nfs/server/src/nlm4.c b/xlators/nfs/server/src/nlm4.c
21ab4e
index dc7d23d..f57df4e 100644
21ab4e
--- a/xlators/nfs/server/src/nlm4.c
21ab4e
+++ b/xlators/nfs/server/src/nlm4.c
21ab4e
@@ -329,6 +329,17 @@ ret:
21ab4e
 static void
21ab4e
 nlm_client_free (nlm_client_t *nlmclnt)
21ab4e
 {
21ab4e
+        nlm_fde_t *fde = NULL, *tmp = NULL;
21ab4e
+
21ab4e
+        gf_msg_trace (GF_NLM, 0, "removing nlm-client %s from the list",
21ab4e
+                      nlmclnt->caller_name);
21ab4e
+
21ab4e
+        list_for_each_entry_safe (fde, tmp, &nlmclnt->fdes, fde_list) {
21ab4e
+                fd_unref (fde->fd);
21ab4e
+                list_del (&fde->fde_list);
21ab4e
+                GF_FREE (fde);
21ab4e
+        }
21ab4e
+
21ab4e
         list_del (&nlmclnt->fdes);
21ab4e
         list_del (&nlmclnt->nlm_clients);
21ab4e
         list_del (&nlmclnt->shares);
21ab4e
@@ -1176,7 +1187,6 @@ int
21ab4e
 nlm_cleanup_fds (char *caller_name)
21ab4e
 {
21ab4e
         int nlmclnt_found = 0;
21ab4e
-        nlm_fde_t *fde = NULL, *tmp = NULL;
21ab4e
         nlm_client_t *nlmclnt = NULL;
21ab4e
 
21ab4e
         LOCK (&nlm_client_list_lk);
21ab4e
@@ -1191,15 +1201,7 @@ nlm_cleanup_fds (char *caller_name)
21ab4e
         if (!nlmclnt_found)
21ab4e
                 goto ret;
21ab4e
 
21ab4e
-        if (list_empty (&nlmclnt->fdes))
21ab4e
-                goto ret;
21ab4e
-
21ab4e
-        list_for_each_entry_safe (fde, tmp, &nlmclnt->fdes, fde_list) {
21ab4e
-                fd_unref (fde->fd);
21ab4e
-                list_del (&fde->fde_list);
21ab4e
-                GF_FREE (fde);
21ab4e
-        }
21ab4e
-
21ab4e
+        nlm_client_free (nlmclnt);
21ab4e
 ret:
21ab4e
         UNLOCK (&nlm_client_list_lk);
21ab4e
         return 0;
21ab4e
@@ -1240,9 +1242,6 @@ nlm_search_and_delete (fd_t *fd, nlm4_lock *lk)
21ab4e
                 goto ret;
21ab4e
         list_del (&fde->fde_list);
21ab4e
 
21ab4e
-        if (list_empty (&nlmclnt->fdes) && list_empty (&nlmclnt->shares))
21ab4e
-                nlm_client_free (nlmclnt);
21ab4e
-
21ab4e
 ret:
21ab4e
         UNLOCK (&nlm_client_list_lk);
21ab4e
 
21ab4e
-- 
21ab4e
1.8.3.1
21ab4e