Whamcloud - gitweb
LU-4972 lfsck: skip .lustre and children for namespace check
[fs/lustre-release.git] / lustre / lfsck / lfsck_namespace.c
index c80fb48..586694f 100644 (file)
 
 static const char lfsck_namespace_name[] = "lfsck_namespace";
 
-static void lfsck_namespace_le_to_cpu(struct lfsck_namespace *des,
+static void lfsck_namespace_le_to_cpu(struct lfsck_namespace *dst,
                                      struct lfsck_namespace *src)
 {
-       des->ln_magic = le32_to_cpu(src->ln_magic);
-       des->ln_status = le32_to_cpu(src->ln_status);
-       des->ln_flags = le32_to_cpu(src->ln_flags);
-       des->ln_success_count = le32_to_cpu(src->ln_success_count);
-       des->ln_run_time_phase1 = le32_to_cpu(src->ln_run_time_phase1);
-       des->ln_run_time_phase2 = le32_to_cpu(src->ln_run_time_phase2);
-       des->ln_time_last_complete = le64_to_cpu(src->ln_time_last_complete);
-       des->ln_time_latest_start = le64_to_cpu(src->ln_time_latest_start);
-       des->ln_time_last_checkpoint =
+       dst->ln_magic = le32_to_cpu(src->ln_magic);
+       dst->ln_status = le32_to_cpu(src->ln_status);
+       dst->ln_flags = le32_to_cpu(src->ln_flags);
+       dst->ln_success_count = le32_to_cpu(src->ln_success_count);
+       dst->ln_run_time_phase1 = le32_to_cpu(src->ln_run_time_phase1);
+       dst->ln_run_time_phase2 = le32_to_cpu(src->ln_run_time_phase2);
+       dst->ln_time_last_complete = le64_to_cpu(src->ln_time_last_complete);
+       dst->ln_time_latest_start = le64_to_cpu(src->ln_time_latest_start);
+       dst->ln_time_last_checkpoint =
                                le64_to_cpu(src->ln_time_last_checkpoint);
-       lfsck_position_le_to_cpu(&des->ln_pos_latest_start,
+       lfsck_position_le_to_cpu(&dst->ln_pos_latest_start,
                                 &src->ln_pos_latest_start);
-       lfsck_position_le_to_cpu(&des->ln_pos_last_checkpoint,
+       lfsck_position_le_to_cpu(&dst->ln_pos_last_checkpoint,
                                 &src->ln_pos_last_checkpoint);
-       lfsck_position_le_to_cpu(&des->ln_pos_first_inconsistent,
+       lfsck_position_le_to_cpu(&dst->ln_pos_first_inconsistent,
                                 &src->ln_pos_first_inconsistent);
-       des->ln_items_checked = le64_to_cpu(src->ln_items_checked);
-       des->ln_items_repaired = le64_to_cpu(src->ln_items_repaired);
-       des->ln_items_failed = le64_to_cpu(src->ln_items_failed);
-       des->ln_dirs_checked = le64_to_cpu(src->ln_dirs_checked);
-       des->ln_mlinked_checked = le64_to_cpu(src->ln_mlinked_checked);
-       des->ln_objs_checked_phase2 = le64_to_cpu(src->ln_objs_checked_phase2);
-       des->ln_objs_repaired_phase2 =
+       dst->ln_items_checked = le64_to_cpu(src->ln_items_checked);
+       dst->ln_items_repaired = le64_to_cpu(src->ln_items_repaired);
+       dst->ln_items_failed = le64_to_cpu(src->ln_items_failed);
+       dst->ln_dirs_checked = le64_to_cpu(src->ln_dirs_checked);
+       dst->ln_mlinked_checked = le64_to_cpu(src->ln_mlinked_checked);
+       dst->ln_objs_checked_phase2 = le64_to_cpu(src->ln_objs_checked_phase2);
+       dst->ln_objs_repaired_phase2 =
                                le64_to_cpu(src->ln_objs_repaired_phase2);
-       des->ln_objs_failed_phase2 = le64_to_cpu(src->ln_objs_failed_phase2);
-       des->ln_objs_nlink_repaired = le64_to_cpu(src->ln_objs_nlink_repaired);
-       des->ln_objs_lost_found = le64_to_cpu(src->ln_objs_lost_found);
-       fid_le_to_cpu(&des->ln_fid_latest_scanned_phase2,
+       dst->ln_objs_failed_phase2 = le64_to_cpu(src->ln_objs_failed_phase2);
+       dst->ln_objs_nlink_repaired = le64_to_cpu(src->ln_objs_nlink_repaired);
+       dst->ln_objs_lost_found = le64_to_cpu(src->ln_objs_lost_found);
+       fid_le_to_cpu(&dst->ln_fid_latest_scanned_phase2,
                      &src->ln_fid_latest_scanned_phase2);
+       dst->ln_dirent_repaired = le64_to_cpu(src->ln_dirent_repaired);
+       dst->ln_linkea_repaired = le64_to_cpu(src->ln_linkea_repaired);
 }
 
-static void lfsck_namespace_cpu_to_le(struct lfsck_namespace *des,
+static void lfsck_namespace_cpu_to_le(struct lfsck_namespace *dst,
                                      struct lfsck_namespace *src)
 {
-       des->ln_magic = cpu_to_le32(src->ln_magic);
-       des->ln_status = cpu_to_le32(src->ln_status);
-       des->ln_flags = cpu_to_le32(src->ln_flags);
-       des->ln_success_count = cpu_to_le32(src->ln_success_count);
-       des->ln_run_time_phase1 = cpu_to_le32(src->ln_run_time_phase1);
-       des->ln_run_time_phase2 = cpu_to_le32(src->ln_run_time_phase2);
-       des->ln_time_last_complete = cpu_to_le64(src->ln_time_last_complete);
-       des->ln_time_latest_start = cpu_to_le64(src->ln_time_latest_start);
-       des->ln_time_last_checkpoint =
+       dst->ln_magic = cpu_to_le32(src->ln_magic);
+       dst->ln_status = cpu_to_le32(src->ln_status);
+       dst->ln_flags = cpu_to_le32(src->ln_flags);
+       dst->ln_success_count = cpu_to_le32(src->ln_success_count);
+       dst->ln_run_time_phase1 = cpu_to_le32(src->ln_run_time_phase1);
+       dst->ln_run_time_phase2 = cpu_to_le32(src->ln_run_time_phase2);
+       dst->ln_time_last_complete = cpu_to_le64(src->ln_time_last_complete);
+       dst->ln_time_latest_start = cpu_to_le64(src->ln_time_latest_start);
+       dst->ln_time_last_checkpoint =
                                cpu_to_le64(src->ln_time_last_checkpoint);
-       lfsck_position_cpu_to_le(&des->ln_pos_latest_start,
+       lfsck_position_cpu_to_le(&dst->ln_pos_latest_start,
                                 &src->ln_pos_latest_start);
-       lfsck_position_cpu_to_le(&des->ln_pos_last_checkpoint,
+       lfsck_position_cpu_to_le(&dst->ln_pos_last_checkpoint,
                                 &src->ln_pos_last_checkpoint);
-       lfsck_position_cpu_to_le(&des->ln_pos_first_inconsistent,
+       lfsck_position_cpu_to_le(&dst->ln_pos_first_inconsistent,
                                 &src->ln_pos_first_inconsistent);
-       des->ln_items_checked = cpu_to_le64(src->ln_items_checked);
-       des->ln_items_repaired = cpu_to_le64(src->ln_items_repaired);
-       des->ln_items_failed = cpu_to_le64(src->ln_items_failed);
-       des->ln_dirs_checked = cpu_to_le64(src->ln_dirs_checked);
-       des->ln_mlinked_checked = cpu_to_le64(src->ln_mlinked_checked);
-       des->ln_objs_checked_phase2 = cpu_to_le64(src->ln_objs_checked_phase2);
-       des->ln_objs_repaired_phase2 =
+       dst->ln_items_checked = cpu_to_le64(src->ln_items_checked);
+       dst->ln_items_repaired = cpu_to_le64(src->ln_items_repaired);
+       dst->ln_items_failed = cpu_to_le64(src->ln_items_failed);
+       dst->ln_dirs_checked = cpu_to_le64(src->ln_dirs_checked);
+       dst->ln_mlinked_checked = cpu_to_le64(src->ln_mlinked_checked);
+       dst->ln_objs_checked_phase2 = cpu_to_le64(src->ln_objs_checked_phase2);
+       dst->ln_objs_repaired_phase2 =
                                cpu_to_le64(src->ln_objs_repaired_phase2);
-       des->ln_objs_failed_phase2 = cpu_to_le64(src->ln_objs_failed_phase2);
-       des->ln_objs_nlink_repaired = cpu_to_le64(src->ln_objs_nlink_repaired);
-       des->ln_objs_lost_found = cpu_to_le64(src->ln_objs_lost_found);
-       fid_cpu_to_le(&des->ln_fid_latest_scanned_phase2,
+       dst->ln_objs_failed_phase2 = cpu_to_le64(src->ln_objs_failed_phase2);
+       dst->ln_objs_nlink_repaired = cpu_to_le64(src->ln_objs_nlink_repaired);
+       dst->ln_objs_lost_found = cpu_to_le64(src->ln_objs_lost_found);
+       fid_cpu_to_le(&dst->ln_fid_latest_scanned_phase2,
                      &src->ln_fid_latest_scanned_phase2);
+       dst->ln_dirent_repaired = cpu_to_le64(src->ln_dirent_repaired);
+       dst->ln_linkea_repaired = cpu_to_le64(src->ln_linkea_repaired);
 }
 
 /**
@@ -763,6 +767,9 @@ static int lfsck_namespace_prep(const struct lu_env *env,
                int rc;
 
                rc = lfsck_namespace_reset(env, com, false);
+               if (rc == 0)
+                       rc = lfsck_set_param(env, lfsck, lsp->lsp_start, true);
+
                if (rc != 0)
                        return rc;
        }
@@ -862,16 +869,18 @@ static int lfsck_namespace_exec_dir(const struct lu_env *env,
 
        if (ent->lde_attrs & LUDA_UPGRADE) {
                ns->ln_flags |= LF_UPGRADE;
+               ns->ln_dirent_repaired++;
                repaired = true;
        } else if (ent->lde_attrs & LUDA_REPAIR) {
                ns->ln_flags |= LF_INCONSISTENT;
+               ns->ln_dirent_repaired++;
                repaired = true;
        }
 
        if (ent->lde_name[0] == '.' &&
            (ent->lde_namelen == 1 ||
             (ent->lde_namelen == 2 && ent->lde_name[1] == '.') ||
-            fid_is_dot_lustre(&ent->lde_fid)))
+            fid_seq_is_dot_lustre(fid_seq(&ent->lde_fid))))
                GOTO(out, rc = 0);
 
        if (!(bk->lb_param & LPF_DRYRUN) &&
@@ -937,6 +946,7 @@ again:
 
 nodata:
                if (bk->lb_param & LPF_DRYRUN) {
+                       ns->ln_linkea_repaired++;
                        repaired = true;
                        goto record;
                }
@@ -969,6 +979,7 @@ nodata:
                        GOTO(stop, rc);
 
                count = ldata.ld_leh->leh_reccount;
+               ns->ln_linkea_repaired++;
                repaired = true;
        } else {
                GOTO(stop, rc);
@@ -1175,6 +1186,8 @@ lfsck_namespace_dump(const struct lu_env *env, struct lfsck_component *com,
                              "failed_phase2: "LPU64"\n"
                              "dirs: "LPU64"\n"
                              "M-linked: "LPU64"\n"
+                             "dirent_repaired: "LPU64"\n"
+                             "linkea_repaired: "LPU64"\n"
                              "nlinks_repaired: "LPU64"\n"
                              "lost_found: "LPU64"\n"
                              "success_count: %u\n"
@@ -1192,6 +1205,8 @@ lfsck_namespace_dump(const struct lu_env *env, struct lfsck_component *com,
                              ns->ln_objs_failed_phase2,
                              ns->ln_dirs_checked,
                              ns->ln_mlinked_checked,
+                             ns->ln_dirent_repaired,
+                             ns->ln_linkea_repaired,
                              ns->ln_objs_nlink_repaired,
                              ns->ln_objs_lost_found,
                              ns->ln_success_count,
@@ -1261,6 +1276,8 @@ lfsck_namespace_dump(const struct lu_env *env, struct lfsck_component *com,
                              "failed_phase2: "LPU64"\n"
                              "dirs: "LPU64"\n"
                              "M-linked: "LPU64"\n"
+                             "dirent_repaired: "LPU64"\n"
+                             "linkea_repaired: "LPU64"\n"
                              "nlinks_repaired: "LPU64"\n"
                              "lost_found: "LPU64"\n"
                              "success_count: %u\n"
@@ -1279,6 +1296,8 @@ lfsck_namespace_dump(const struct lu_env *env, struct lfsck_component *com,
                              ns->ln_objs_failed_phase2,
                              ns->ln_dirs_checked,
                              ns->ln_mlinked_checked,
+                             ns->ln_dirent_repaired,
+                             ns->ln_linkea_repaired,
                              ns->ln_objs_nlink_repaired,
                              ns->ln_objs_lost_found,
                              ns->ln_success_count,
@@ -1310,6 +1329,8 @@ lfsck_namespace_dump(const struct lu_env *env, struct lfsck_component *com,
                              "failed_phase2: "LPU64"\n"
                              "dirs: "LPU64"\n"
                              "M-linked: "LPU64"\n"
+                             "dirent_repaired: "LPU64"\n"
+                             "linkea_repaired: "LPU64"\n"
                              "nlinks_repaired: "LPU64"\n"
                              "lost_found: "LPU64"\n"
                              "success_count: %u\n"
@@ -1328,6 +1349,8 @@ lfsck_namespace_dump(const struct lu_env *env, struct lfsck_component *com,
                              ns->ln_objs_failed_phase2,
                              ns->ln_dirs_checked,
                              ns->ln_mlinked_checked,
+                             ns->ln_dirent_repaired,
+                             ns->ln_linkea_repaired,
                              ns->ln_objs_nlink_repaired,
                              ns->ln_objs_lost_found,
                              ns->ln_success_count,