Whamcloud - gitweb
LU-327 cleanup the client import of mgc
authorhongchao.zhang <hongchao.zhang@whamcloud.com>
Thu, 28 Jul 2011 07:46:47 +0000 (15:46 +0800)
committerOleg Drokin <green@whamcloud.com>
Tue, 2 Aug 2011 20:24:45 +0000 (16:24 -0400)
the client import will not have been cleaned if it is setup but never
connected, adding such cleanup code in mgc_precleanup.

define a new inline function "obd_cleanup_client_import" in "obd_class.h"
to be used by mgc, mdc and osc.

Change-Id: If033de3fe81b9a565a7af40a7b93e395fb0bd659
Signed-off-by: Hongchao Zhang <hongchao.zhang@whamcloud.com>
Reviewed-on: http://review.whamcloud.com/917
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Fan Yong <yong.fan@whamcloud.com>
Reviewed-by: Mikhail Pershin <tappro@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/obd_class.h
lustre/mdc/mdc_request.c
lustre/mgc/libmgc.c
lustre/mgc/mgc_request.c
lustre/osc/osc_request.c

index d4cd526..3865358 100644 (file)
@@ -619,6 +619,31 @@ static inline int obd_cleanup(struct obd_device *obd)
         RETURN(rc);
 }
 
+static inline void obd_cleanup_client_import(struct obd_device *obd)
+{
+        ENTRY;
+
+        /* If we set up but never connected, the
+           client import will not have been cleaned. */
+        cfs_down_write(&obd->u.cli.cl_sem);
+        if (obd->u.cli.cl_import) {
+                struct obd_import *imp;
+                imp = obd->u.cli.cl_import;
+                CDEBUG(D_CONFIG, "%s: client import never connected\n",
+                       obd->obd_name);
+                ptlrpc_invalidate_import(imp);
+                if (imp->imp_rq_pool) {
+                        ptlrpc_free_rq_pool(imp->imp_rq_pool);
+                        imp->imp_rq_pool = NULL;
+                }
+                class_destroy_import(imp);
+                obd->u.cli.cl_import = NULL;
+        }
+        cfs_up_write(&obd->u.cli.cl_sem);
+
+        EXIT;
+}
+
 static inline int
 obd_process_config(struct obd_device *obd, int datalen, void *data)
 {
index a0bb726..3abdd77 100644 (file)
@@ -2060,18 +2060,8 @@ static int mdc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
                 if (obd->obd_type->typ_refcnt <= 1)
                         libcfs_kkuc_group_rem(0, KUC_GRP_HSM);
 
-                /* If we set up but never connected, the
-                   client import will not have been cleaned. */
-                if (obd->u.cli.cl_import) {
-                        struct obd_import *imp;
-                        cfs_down_write(&obd->u.cli.cl_sem);
-                        imp = obd->u.cli.cl_import;
-                        CERROR("client import never connected\n");
-                        ptlrpc_invalidate_import(imp);
-                        class_destroy_import(imp);
-                        cfs_up_write(&obd->u.cli.cl_sem);
-                        obd->u.cli.cl_import = NULL;
-                }
+                obd_cleanup_client_import(obd);
+
                 rc = obd_llog_finish(obd, 0);
                 if (rc != 0)
                         CERROR("failed to cleanup llogging subsystems\n");
index 966f0ec..981b79b 100644 (file)
@@ -93,6 +93,7 @@ static int mgc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
         switch (stage) {
         case OBD_CLEANUP_EARLY:
         case OBD_CLEANUP_EXPORTS:
+                obd_cleanup_client_import(obd);
                 rc = obd_llog_finish(obd, 0);
                 if (rc != 0)
                         CERROR("failed to cleanup llogging subsystems\n");
index b4795bd..cfc2797 100644 (file)
@@ -633,6 +633,7 @@ static int mgc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
                         cfs_spin_unlock(&config_list_lock);
                         cfs_waitq_signal(&rq_waitq);
                 }
+                obd_cleanup_client_import(obd);
                 rc = obd_llog_finish(obd, 0);
                 if (rc != 0)
                         CERROR("failed to cleanup llogging subsystems\n");
index 33a0c2c..4b5f2c3 100644 (file)
@@ -4514,23 +4514,7 @@ static int osc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
                  *   client_disconnect_export()
                  */
                 obd_zombie_barrier();
-                /* If we set up but never connected, the
-                   client import will not have been cleaned. */
-                if (obd->u.cli.cl_import) {
-                        struct obd_import *imp;
-                        cfs_down_write(&obd->u.cli.cl_sem);
-                        imp = obd->u.cli.cl_import;
-                        CDEBUG(D_CONFIG, "%s: client import never connected\n",
-                               obd->obd_name);
-                        ptlrpc_invalidate_import(imp);
-                        if (imp->imp_rq_pool) {
-                                ptlrpc_free_rq_pool(imp->imp_rq_pool);
-                                imp->imp_rq_pool = NULL;
-                        }
-                        class_destroy_import(imp);
-                        cfs_up_write(&obd->u.cli.cl_sem);
-                        obd->u.cli.cl_import = NULL;
-                }
+                obd_cleanup_client_import(obd);
                 rc = obd_llog_finish(obd, 0);
                 if (rc != 0)
                         CERROR("failed to cleanup llogging subsystems\n");