Whamcloud - gitweb
LU-11699 lfsck: Umount while running LFSCK
[fs/lustre-release.git] / lustre / lfsck / lfsck_engine.c
index a202a92..626c2bb 100644 (file)
@@ -1016,6 +1016,10 @@ int lfsck_master_engine(void *args)
        int                       rc;
        ENTRY;
 
+       spin_lock(&lfsck->li_lock);
+       lfsck->li_task = current;
+       spin_unlock(&lfsck->li_lock);
+
        /* There will be some objects verification during the LFSCK start,
         * such as the subsequent lfsck_verify_lpf(). Trigger low layer OI
         * OI scrub before that to handle the potential inconsistence. */
@@ -1059,6 +1063,11 @@ int lfsck_master_engine(void *args)
               current_pid());
 
        spin_lock(&lfsck->li_lock);
+       if (unlikely(!thread_is_starting(thread))) {
+               spin_unlock(&lfsck->li_lock);
+               GOTO(fini_oit, rc = 0);
+       }
+
        thread_set_flags(thread, SVC_RUNNING);
        spin_unlock(&lfsck->li_lock);
        wake_up_all(&thread->t_ctl_waitq);
@@ -1107,6 +1116,7 @@ fini_oit:
 fini_args:
        spin_lock(&lfsck->li_lock);
        thread_set_flags(thread, SVC_STOPPED);
+       lfsck->li_task = NULL;
        spin_unlock(&lfsck->li_lock);
        wake_up_all(&thread->t_ctl_waitq);
        lfsck_thread_args_fini(lta);
@@ -1225,7 +1235,7 @@ again:
        }
        spin_unlock(&ltds->ltd_lock);
 
-       rc = ptlrpc_set_wait(set);
+       rc = ptlrpc_set_wait(env, set);
        if (rc < 0) {
                ptlrpc_set_destroy(set);
                RETURN(rc);
@@ -1320,7 +1330,7 @@ static int lfsck_assistant_notify_others(const struct lu_env *env,
                up_read(&ltds->ltd_rw_sem);
 
                /* Sync up */
-               rc = ptlrpc_set_wait(set);
+               rc = ptlrpc_set_wait(env, set);
                if (rc < 0) {
                        ptlrpc_set_destroy(set);
                        RETURN(rc);
@@ -1452,7 +1462,7 @@ again:
                }
                spin_unlock(&ltds->ltd_lock);
 
-               rc = ptlrpc_set_wait(set);
+               rc = ptlrpc_set_wait(env, set);
                if (rc < 0) {
                        ptlrpc_set_destroy(set);
                        RETURN(rc);
@@ -1526,7 +1536,7 @@ again:
                break;
        }
 
-       rc1 = ptlrpc_set_wait(set);
+       rc1 = ptlrpc_set_wait(env, set);
        ptlrpc_set_destroy(set);
 
        RETURN(rc != 0 ? rc : rc1);
@@ -1827,7 +1837,6 @@ fini:
        spin_lock(&lad->lad_lock);
        lad->lad_assistant_status = (rc1 != 0 ? rc1 : rc);
        thread_set_flags(athread, SVC_STOPPED);
-       wake_up_all(&mthread->t_ctl_waitq);
        lad->lad_task = NULL;
        spin_unlock(&lad->lad_lock);
 
@@ -1836,6 +1845,7 @@ fini:
               lad->lad_assistant_status);
 
        lfsck_thread_args_fini(lta);
+       wake_up_all(&mthread->t_ctl_waitq);
 
        return rc;
 }