Whamcloud - gitweb
LU-3810 obd: Cleanup client import if client_obd_setup fails
[fs/lustre-release.git] / lustre / ldlm / ldlm_lib.c
index 3364504..6b18781 100644 (file)
@@ -343,8 +343,8 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg)
         cli->cl_avail_grant = 0;
        /* FIXME: Should limit this for the sum of all cl_dirty_max. */
        cli->cl_dirty_max = OSC_MAX_DIRTY_DEFAULT * 1024 * 1024;
-       if (cli->cl_dirty_max >> PAGE_CACHE_SHIFT > num_physpages / 8)
-               cli->cl_dirty_max = num_physpages << (PAGE_CACHE_SHIFT - 3);
+       if (cli->cl_dirty_max >> PAGE_CACHE_SHIFT > totalram_pages / 8)
+               cli->cl_dirty_max = totalram_pages << (PAGE_CACHE_SHIFT - 3);
         CFS_INIT_LIST_HEAD(&cli->cl_cache_waiters);
         CFS_INIT_LIST_HEAD(&cli->cl_loi_ready_list);
         CFS_INIT_LIST_HEAD(&cli->cl_loi_hp_ready_list);
@@ -370,6 +370,7 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg)
        cfs_atomic_set(&cli->cl_lru_in_list, 0);
        CFS_INIT_LIST_HEAD(&cli->cl_lru_list);
        client_obd_list_lock_init(&cli->cl_lru_list_lock);
+       cfs_atomic_set(&cli->cl_unstable_count, 0);
 
        init_waitqueue_head(&cli->cl_destroy_waitq);
        cfs_atomic_set(&cli->cl_destroy_in_flight, 0);
@@ -394,11 +395,11 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg)
 
        if (!strcmp(name, LUSTRE_MDC_NAME)) {
                cli->cl_max_rpcs_in_flight = MDC_MAX_RIF_DEFAULT;
-       } else if (num_physpages >> (20 - PAGE_CACHE_SHIFT) <= 128 /* MB */) {
+       } else if (totalram_pages >> (20 - PAGE_CACHE_SHIFT) <= 128 /* MB */) {
                cli->cl_max_rpcs_in_flight = 2;
-       } else if (num_physpages >> (20 - PAGE_CACHE_SHIFT) <= 256 /* MB */) {
+       } else if (totalram_pages >> (20 - PAGE_CACHE_SHIFT) <= 256 /* MB */) {
                cli->cl_max_rpcs_in_flight = 3;
-       } else if (num_physpages >> (20 - PAGE_CACHE_SHIFT) <= 512 /* MB */) {
+       } else if (totalram_pages >> (20 - PAGE_CACHE_SHIFT) <= 512 /* MB */) {
                cli->cl_max_rpcs_in_flight = 4;
        } else {
                if (osc_on_mdt(obddev->obd_name))
@@ -472,15 +473,16 @@ EXPORT_SYMBOL(client_obd_setup);
 
 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);
 
@@ -826,7 +828,7 @@ int target_handle_connect(struct ptlrpc_request *req)
        /* Make sure the target isn't cleaned up while we're here. Yes,
         * there's still a race between the above check and our incref here.
         * Really, class_uuid2obd should take the ref. */
-        targref = class_incref(target, __FUNCTION__, cfs_current());
+       targref = class_incref(target, __FUNCTION__, current);
 
        target->obd_conn_inprogress++;
        spin_unlock(&target->obd_dev_lock);
@@ -1271,7 +1273,7 @@ out:
                target->obd_conn_inprogress--;
                spin_unlock(&target->obd_dev_lock);
 
-               class_decref(targref, __func__, cfs_current());
+               class_decref(targref, __func__, current);
        }
        if (rc)
                req->rq_status = rc;
@@ -1912,7 +1914,7 @@ static int handle_recovery_req(struct ptlrpc_thread *thread,
         if (req->rq_export->exp_disconnected)
                 GOTO(reqcopy_put, rc = 0);
 
-        rc = lu_context_init(&req->rq_recov_session, LCT_SESSION);
+        rc = lu_context_init(&req->rq_recov_session, LCT_SERVER_SESSION);
         if (rc) {
                 CERROR("Failure to initialize session: %d\n", rc);
                 GOTO(reqcopy_put, rc);
@@ -1995,8 +1997,8 @@ static int target_recovery_thread(void *arg)
         thread->t_env = env;
         thread->t_id = -1; /* force filter_iobuf_get/put to use local buffers */
         env->le_ctx.lc_thread = thread;
-        thread->t_data = NULL;
-        thread->t_watchdog = NULL;
+       tgt_io_thread_init(thread); /* init thread_big_cache for IO requests */
+       thread->t_watchdog = NULL;
 
        CDEBUG(D_HA, "%s: started recovery thread pid %d\n", obd->obd_name,
               current_pid());
@@ -2091,9 +2093,10 @@ static int target_recovery_thread(void *arg)
         trd->trd_processing_task = 0;
        complete(&trd->trd_finishing);
 
-        OBD_FREE_PTR(thread);
-        OBD_FREE_PTR(env);
-        RETURN(rc);
+       tgt_io_thread_done(thread);
+       OBD_FREE_PTR(thread);
+       OBD_FREE_PTR(env);
+       RETURN(rc);
 }
 
 static int target_start_recovery_thread(struct lu_target *lut,