Whamcloud - gitweb
LU-3810 obd: Cleanup client import if client_obd_setup fails 61/7561/4
authorSwapnil Pimpale <spimpale@ddn.com>
Thu, 5 Sep 2013 12:27:00 +0000 (17:57 +0530)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 14 Nov 2013 23:20:00 +0000 (23:20 +0000)
client_obd_setup() allocates an obd_import which should be cleaned up
if there is any failure afterwards in callers of client_obd_setup().
This patch fixes the bug in osc_setup(), mgc_setup(), mdc_setup() and
lwp_setup(). The fix is to call obd_cleanup_client_import() before
calling client_obd_cleanup() in case of an error.

Signed-off-by: Swapnil Pimpale <spimpale@ddn.com>
Change-Id: Ib8c2194d80fd14538d4ca42fb8084c93dd575199
Reviewed-on: http://review.whamcloud.com/7561
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lustre/ldlm/ldlm_lib.c
lustre/mgc/libmgc.c
lustre/mgc/mgc_request.c
lustre/osp/lwp_dev.c
lustre/osp/osp_dev.c

index facc975..6b18781 100644 (file)
@@ -473,15 +473,16 @@ EXPORT_SYMBOL(client_obd_setup);
 
 int client_obd_cleanup(struct obd_device *obddev)
 {
 
 int client_obd_cleanup(struct obd_device *obddev)
 {
-        ENTRY;
+       ENTRY;
 
 
-        ldlm_namespace_free_post(obddev->obd_namespace);
-        obddev->obd_namespace = NULL;
+       ldlm_namespace_free_post(obddev->obd_namespace);
+       obddev->obd_namespace = NULL;
 
 
-        LASSERT(obddev->u.cli.cl_import == NULL);
+       obd_cleanup_client_import(obddev);
+       LASSERT(obddev->u.cli.cl_import == NULL);
 
 
-        ldlm_put_ref();
-        RETURN(0);
+       ldlm_put_ref();
+       RETURN(0);
 }
 EXPORT_SYMBOL(client_obd_cleanup);
 
 }
 EXPORT_SYMBOL(client_obd_cleanup);
 
index c639da8..bcc3617 100644 (file)
 
 static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
 {
 
 static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
 {
-        int rc;
-        ENTRY;
+       int rc;
+       ENTRY;
 
        rc = ptlrpcd_addref();
        if (rc < 0)
                RETURN(rc);
 
 
        rc = ptlrpcd_addref();
        if (rc < 0)
                RETURN(rc);
 
-        rc = client_obd_setup(obd, lcfg);
-        if (rc)
-                GOTO(err_decref, rc);
+       rc = client_obd_setup(obd, lcfg);
+       if (rc)
+               GOTO(err_decref, rc);
 
 
-        /* liblustre only support null flavor to MGS */
-        obd->u.cli.cl_flvr_mgc.sf_rpc = SPTLRPC_FLVR_NULL;
+       /* liblustre only support null flavor to MGS */
+       obd->u.cli.cl_flvr_mgc.sf_rpc = SPTLRPC_FLVR_NULL;
 
 
-        rc = obd_llog_init(obd, &obd->obd_olg, obd, NULL);
-        if (rc) {
-                CERROR("failed to setup llogging subsystems\n");
-                GOTO(err_cleanup, rc);
-        }
+       rc = obd_llog_init(obd, &obd->obd_olg, obd, NULL);
+       if (rc) {
+               CERROR("failed to setup llogging subsystems\n");
+               GOTO(err_cleanup, rc);
+       }
 
 
-        RETURN(rc);
+       RETURN(rc);
 
 err_cleanup:
 
 err_cleanup:
-        client_obd_cleanup(obd);
+       client_obd_cleanup(obd);
 err_decref:
 err_decref:
-        ptlrpcd_decref();
-        RETURN(rc);
+       ptlrpcd_decref();
+       RETURN(rc);
 }
 
 static int mgc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
 }
 
 static int mgc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
index 94b8d8d..64ab255 100644 (file)
@@ -893,27 +893,27 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
 {
        struct lprocfs_static_vars      lvars;
        int                             rc;
 {
        struct lprocfs_static_vars      lvars;
        int                             rc;
-        ENTRY;
+       ENTRY;
 
        rc = ptlrpcd_addref();
        if (rc < 0)
                RETURN(rc);
 
 
        rc = ptlrpcd_addref();
        if (rc < 0)
                RETURN(rc);
 
-        rc = client_obd_setup(obd, lcfg);
-        if (rc)
-                GOTO(err_decref, rc);
+       rc = client_obd_setup(obd, lcfg);
+       if (rc)
+               GOTO(err_decref, rc);
 
        rc = mgc_llog_init(NULL, obd);
 
        rc = mgc_llog_init(NULL, obd);
-        if (rc) {
-                CERROR("failed to setup llogging subsystems\n");
-                GOTO(err_cleanup, rc);
-        }
+       if (rc) {
+               CERROR("failed to setup llogging subsystems\n");
+               GOTO(err_cleanup, rc);
+       }
 
 
-        lprocfs_mgc_init_vars(&lvars);
-        lprocfs_obd_setup(obd, lvars.obd_vars);
-        sptlrpc_lprocfs_cliobd_attach(obd);
+       lprocfs_mgc_init_vars(&lvars);
+       lprocfs_obd_setup(obd, lvars.obd_vars);
+       sptlrpc_lprocfs_cliobd_attach(obd);
 
 
-        if (cfs_atomic_inc_return(&mgc_count) == 1) {
+       if (cfs_atomic_inc_return(&mgc_count) == 1) {
                rq_state = 0;
                init_waitqueue_head(&rq_waitq);
 
                rq_state = 0;
                init_waitqueue_head(&rq_waitq);
 
@@ -928,15 +928,15 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
                }
                /* rc is the task_struct pointer of mgc_requeue_thread. */
                rc = 0;
                }
                /* rc is the task_struct pointer of mgc_requeue_thread. */
                rc = 0;
-        }
+       }
 
 
-        RETURN(rc);
+       RETURN(rc);
 
 err_cleanup:
 
 err_cleanup:
-        client_obd_cleanup(obd);
+       client_obd_cleanup(obd);
 err_decref:
 err_decref:
-        ptlrpcd_decref();
-        RETURN(rc);
+       ptlrpcd_decref();
+       RETURN(rc);
 }
 
 /* based on ll_mdc_blocking_ast */
 }
 
 /* based on ll_mdc_blocking_ast */
index 8b1653e..fce82a2 100644 (file)
@@ -145,6 +145,7 @@ out:
                lustre_cfg_free(lcfg);
        if (rc)
                client_obd_cleanup(lwp->lpd_obd);
                lustre_cfg_free(lcfg);
        if (rc)
                client_obd_cleanup(lwp->lpd_obd);
+
        RETURN(rc);
 }
 
        RETURN(rc);
 }
 
@@ -321,8 +322,6 @@ static struct lu_device *lwp_device_fini(const struct lu_env *env,
                imp->imp_rq_pool = NULL;
        }
 
                imp->imp_rq_pool = NULL;
        }
 
-       obd_cleanup_client_import(m->lpd_obd);
-
        LASSERT(m->lpd_obd);
        ptlrpc_lprocfs_unregister_obd(m->lpd_obd);
        lprocfs_obd_cleanup(m->lpd_obd);
        LASSERT(m->lpd_obd);
        ptlrpc_lprocfs_unregister_obd(m->lpd_obd);
        lprocfs_obd_cleanup(m->lpd_obd);
index 8e71157..1094a65 100644 (file)
@@ -745,7 +745,6 @@ out_last_used:
 out_proc:
        ptlrpc_lprocfs_unregister_obd(obd);
        lprocfs_obd_cleanup(obd);
 out_proc:
        ptlrpc_lprocfs_unregister_obd(obd);
        lprocfs_obd_cleanup(obd);
-       obd_cleanup_client_import(obd);
        if (m->opd_symlink)
                lprocfs_remove(&m->opd_symlink);
        client_obd_cleanup(obd);
        if (m->opd_symlink)
                lprocfs_remove(&m->opd_symlink);
        client_obd_cleanup(obd);
@@ -825,8 +824,6 @@ static struct lu_device *osp_device_fini(const struct lu_env *env,
                imp->imp_rq_pool = NULL;
        }
 
                imp->imp_rq_pool = NULL;
        }
 
-       obd_cleanup_client_import(m->opd_obd);
-
        if (m->opd_symlink)
                lprocfs_remove(&m->opd_symlink);
 
        if (m->opd_symlink)
                lprocfs_remove(&m->opd_symlink);