Whamcloud - gitweb
LU-3634 llapi: Fix returned value of llapi_hsm_copy_start/end.
[fs/lustre-release.git] / lustre / lfsck / lfsck_lib.c
index 83e9c54..4fefa7d 100644 (file)
  * Author: Fan, Yong <fan.yong@intel.com>
  */
 
-#ifndef EXPORT_SYMTAB
-# define EXPORT_SYMTAB
-#endif
 #define DEBUG_SUBSYSTEM S_LFSCK
 
 #include <libcfs/list.h>
 #include <lu_object.h>
 #include <dt_object.h>
+#include <md_object.h>
+#include <lustre_fld.h>
 #include <lustre_lib.h>
 #include <lustre_net.h>
 #include <lustre_lfsck.h>
@@ -340,9 +339,7 @@ void lfsck_pos_fill(const struct lu_env *env, struct lfsck_instance *lfsck,
 {
        const struct dt_it_ops *iops = &lfsck->li_obj_oit->do_index_ops->dio_it;
 
-       spin_lock(&lfsck->li_lock);
        if (unlikely(lfsck->li_di_oit == NULL)) {
-               spin_unlock(&lfsck->li_lock);
                memset(pos, 0, sizeof(*pos));
                return;
        }
@@ -369,7 +366,6 @@ void lfsck_pos_fill(const struct lu_env *env, struct lfsck_instance *lfsck,
                fid_zero(&pos->lp_dir_parent);
                pos->lp_dir_cookie = 0;
        }
-       spin_unlock(&lfsck->li_lock);
 }
 
 static void __lfsck_set_speed(struct lfsck_instance *lfsck, __u32 limit)
@@ -633,6 +629,7 @@ int lfsck_prep(const struct lu_env *env, struct lfsck_instance *lfsck)
        }
 
        lfsck->li_obj_dir = lfsck_object_get(obj);
+       lfsck->li_cookie_dir = iops->store(env, di);
        spin_lock(&lfsck->li_lock);
        lfsck->li_di_dir = di;
        spin_unlock(&lfsck->li_lock);
@@ -707,6 +704,7 @@ int lfsck_exec_oit(const struct lu_env *env, struct lfsck_instance *lfsck,
        }
 
        lfsck->li_obj_dir = lfsck_object_get(obj);
+       lfsck->li_cookie_dir = iops->store(env, di);
        spin_lock(&lfsck->li_lock);
        lfsck->li_di_dir = di;
        spin_unlock(&lfsck->li_lock);
@@ -871,7 +869,7 @@ int lfsck_start(const struct lu_env *env, struct dt_device *key,
        struct lfsck_component *com;
        struct l_wait_info      lwi    = { 0 };
        bool                    dirty  = false;
-       int                     rc     = 0;
+       long                    rc     = 0;
        __u16                   valid  = 0;
        __u16                   flags  = 0;
        ENTRY;
@@ -1015,18 +1013,19 @@ trigger:
 
        lfsck->li_args_oit = (flags << DT_OTABLE_IT_FLAGS_SHIFT) | valid;
        thread_set_flags(thread, 0);
-       if (lfsck->li_master)
-               rc = cfs_create_thread(lfsck_master_engine, lfsck, 0);
-       if (rc < 0)
-               CERROR("%s: cannot start LFSCK thread, rc = %d\n",
+       rc = PTR_ERR(kthread_run(lfsck_master_engine, lfsck, "lfsck"));
+       if (IS_ERR_VALUE(rc)) {
+               CERROR("%s: cannot start LFSCK thread, rc = %ld\n",
                       lfsck_lfsck2name(lfsck), rc);
-       else
+       } else {
+               rc = 0;
                l_wait_event(thread->t_ctl_waitq,
                             thread_is_running(thread) ||
                             thread_is_stopped(thread),
                             &lwi);
+       }
 
-       GOTO(out, rc = 0);
+       GOTO(out, rc);
 
 out:
        mutex_unlock(&lfsck->li_mutex);
@@ -1060,11 +1059,6 @@ int lfsck_stop(const struct lu_env *env, struct dt_device *key, bool pause)
        if (pause)
                lfsck->li_paused = 1;
        thread_set_flags(thread, SVC_STOPPING);
-       /* The LFSCK thread may be sleeping on low layer wait queue,
-        * wake it up. */
-       if (likely(lfsck->li_di_oit != NULL))
-               lfsck->li_obj_oit->do_index_ops->dio_it.put(env,
-                                                           lfsck->li_di_oit);
        spin_unlock(&lfsck->li_lock);
 
        cfs_waitq_broadcast(&thread->t_ctl_waitq);