Whamcloud - gitweb
LU-8500 ldlm: fix export reference problem 31/22031/3
authorHongchao Zhang <hongchao.zhang@intel.com>
Wed, 24 Aug 2016 23:44:41 +0000 (19:44 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 2 Sep 2016 02:24:35 +0000 (02:24 +0000)
1, in client_import_del_conn, the export returned from
   class_conn2export is not released after using it.

2, in ptlrpc_connect_interpret, the export is not released
   if the connect_flags isn't compatible.

Change-Id: Ie7ef9cb0de2fa1aba71d3981ce47ae87c75e82d8
Signed-off-by: Hongchao Zhang <hongchao.zhang@intel.com>
Reviewed-on: http://review.whamcloud.com/22031
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/ldlm/ldlm_lib.c
lustre/ptlrpc/import.c

index f863f13..e31274b 100644 (file)
@@ -167,14 +167,17 @@ int client_import_del_conn(struct obd_import *imp, struct obd_uuid *uuid)
                         ptlrpc_connection_put(imp->imp_connection);
                         imp->imp_connection = NULL;
 
-                        dlmexp = class_conn2export(&imp->imp_dlm_handle);
-                        if (dlmexp && dlmexp->exp_connection) {
-                                LASSERT(dlmexp->exp_connection ==
-                                        imp_conn->oic_conn);
-                                ptlrpc_connection_put(dlmexp->exp_connection);
-                                dlmexp->exp_connection = NULL;
-                        }
-                }
+                       dlmexp = class_conn2export(&imp->imp_dlm_handle);
+                       if (dlmexp && dlmexp->exp_connection) {
+                               LASSERT(dlmexp->exp_connection ==
+                                       imp_conn->oic_conn);
+                               ptlrpc_connection_put(dlmexp->exp_connection);
+                               dlmexp->exp_connection = NULL;
+                       }
+
+                       if (dlmexp != NULL)
+                               class_export_put(dlmexp);
+               }
 
                list_del(&imp_conn->oic_item);
                 ptlrpc_connection_put(imp_conn->oic_conn);
index 54be719..ef0df00 100644 (file)
@@ -1049,6 +1049,14 @@ static int ptlrpc_connect_interpret(const struct lu_env *env,
 
        spin_unlock(&imp->imp_lock);
 
+       if (!exp) {
+               /* This could happen if export is cleaned during the
+                  connect attempt */
+               CERROR("%s: missing export after connect\n",
+                      imp->imp_obd->obd_name);
+               GOTO(out, rc = -ENODEV);
+       }
+
        /* check that server granted subset of flags we asked for. */
        if ((ocd->ocd_connect_flags & imp->imp_connect_flags_orig) !=
            ocd->ocd_connect_flags) {
@@ -1094,13 +1102,6 @@ static int ptlrpc_connect_interpret(const struct lu_env *env,
                }
        }
 
-       if (!exp) {
-               /* This could happen if export is cleaned during the
-                  connect attempt */
-               CERROR("%s: missing export after connect\n",
-                      imp->imp_obd->obd_name);
-               GOTO(out, rc = -ENODEV);
-       }
        old_connect_flags = exp_connect_flags(exp);
        exp->exp_connect_data = *ocd;
        imp->imp_obd->obd_self_export->exp_connect_data = *ocd;