Whamcloud - gitweb
LU-3935 scrub: support dryrun mode OI scrub
[fs/lustre-release.git] / lustre / lfsck / lfsck_namespace.c
index a3a3948..5eb8cee 100644 (file)
@@ -28,9 +28,6 @@
  * Author: Fan, Yong <fan.yong@intel.com>
  */
 
-#ifndef EXPORT_SYMTAB
-# define EXPORT_SYMTAB
-#endif
 #define DEBUG_SUBSYSTEM S_LFSCK
 
 #include <lustre/lustre_idl.h>
@@ -655,10 +652,17 @@ static int lfsck_namespace_reset(const struct lu_env *env,
        struct lfsck_instance   *lfsck = com->lc_lfsck;
        struct lfsck_namespace  *ns    =
                                (struct lfsck_namespace *)com->lc_file_ram;
+       struct dt_object        *root;
        struct dt_object        *dto;
        int                      rc;
        ENTRY;
 
+       root = dt_locate(env, lfsck->li_bottom, &lfsck->li_local_root_fid);
+       if (IS_ERR(root))
+               RETURN(PTR_ERR(root));
+
+       dt_try_as_dir(env, root);
+
        down_write(&com->lc_sem);
        if (init) {
                memset(ns, 0, sizeof(*ns));
@@ -673,12 +677,14 @@ static int lfsck_namespace_reset(const struct lu_env *env,
        ns->ln_magic = LFSCK_NAMESPACE_MAGIC;
        ns->ln_status = LS_INIT;
 
-       rc = local_object_unlink(env, lfsck->li_bottom, lfsck->li_local_root,
+       rc = local_object_unlink(env, lfsck->li_bottom, root,
                                 lfsck_namespace_name);
        if (rc != 0)
                GOTO(out, rc);
 
-       dto = local_index_find_or_create(env, lfsck->li_los, lfsck->li_local_root,
+       lfsck_object_put(env, com->lc_obj);
+       com->lc_obj = NULL;
+       dto = local_index_find_or_create(env, lfsck->li_los, root,
                                         lfsck_namespace_name,
                                         S_IFREG | S_IRUGO | S_IWUSR,
                                         &dt_lfsck_features);
@@ -696,6 +702,7 @@ static int lfsck_namespace_reset(const struct lu_env *env,
 
 out:
        up_write(&com->lc_sem);
+       lu_object_put(env, &root->do_lu);
        return rc;
 }
 
@@ -1015,10 +1022,16 @@ out:
                if (!(bk->lb_param & LPF_FAILOUT))
                        rc = 0;
        } else {
-               if (repaired)
+               if (repaired) {
                        ns->ln_items_repaired++;
-               else
+                       if (bk->lb_param & LPF_DRYRUN &&
+                           lfsck_pos_is_zero(&ns->ln_pos_first_inconsistent))
+                               lfsck_pos_fill(env, lfsck,
+                                              &ns->ln_pos_first_inconsistent,
+                                              false);
+               } else {
                        com->lc_journal = 0;
+               }
                rc = 0;
        }
        up_write(&com->lc_sem);
@@ -1150,7 +1163,7 @@ lfsck_namespace_dump(const struct lu_env *env, struct lfsck_component *com,
                                          lfsck->li_time_last_checkpoint;
                __u64 checked = ns->ln_items_checked + com->lc_new_checked;
                __u64 speed = checked;
-               __u64 new_checked = com->lc_new_checked * CFS_HZ;
+               __u64 new_checked = com->lc_new_checked * HZ;
                __u32 rtime = ns->ln_run_time_phase1 +
                              cfs_duration_sec(duration + HALF_SEC);
 
@@ -1234,7 +1247,7 @@ lfsck_namespace_dump(const struct lu_env *env, struct lfsck_component *com,
                                com->lc_new_checked;
                __u64 speed1 = ns->ln_items_checked;
                __u64 speed2 = checked;
-               __u64 new_checked = com->lc_new_checked * CFS_HZ;
+               __u64 new_checked = com->lc_new_checked * HZ;
                __u32 rtime = ns->ln_run_time_phase2 +
                              cfs_duration_sec(duration + HALF_SEC);
 
@@ -1525,6 +1538,7 @@ int lfsck_namespace_setup(const struct lu_env *env,
 {
        struct lfsck_component  *com;
        struct lfsck_namespace  *ns;
+       struct dt_object        *root = NULL;
        struct dt_object        *obj;
        int                      rc;
        ENTRY;
@@ -1551,8 +1565,12 @@ int lfsck_namespace_setup(const struct lu_env *env,
        if (com->lc_file_disk == NULL)
                GOTO(out, rc = -ENOMEM);
 
-       obj = local_index_find_or_create(env, lfsck->li_los,
-                                        lfsck->li_local_root,
+       root = dt_locate(env, lfsck->li_bottom, &lfsck->li_local_root_fid);
+       if (IS_ERR(root))
+               GOTO(out, rc = PTR_ERR(root));
+
+       dt_try_as_dir(env, root);
+       obj = local_index_find_or_create(env, lfsck->li_los, root,
                                         lfsck_namespace_name,
                                         S_IFREG | S_IRUGO | S_IWUSR,
                                         &dt_lfsck_features);
@@ -1601,6 +1619,8 @@ int lfsck_namespace_setup(const struct lu_env *env,
        GOTO(out, rc = 0);
 
 out:
+       if (root != NULL && !IS_ERR(root))
+               lu_object_put(env, &root->do_lu);
        if (rc != 0)
                lfsck_component_cleanup(env, com);
        return rc;