Whamcloud - gitweb
LU-5518 lfsck: recover orphans from backend lost+found
[fs/lustre-release.git] / lustre / lfsck / lfsck_internal.h
index ab25ede..1ce764e 100644 (file)
@@ -111,6 +111,8 @@ struct lfsck_bookmark {
 enum lfsck_namespace_trace_flags {
        LNTF_CHECK_LINKEA       = 0x01,
        LNTF_CHECK_PARENT       = 0x02,
+       LNTF_SKIP_NLINK         = 0x04,
+       LNTF_CHECK_ORPHAN       = 0x08,
        LNTF_ALL                = 0xff
 };
 
@@ -119,6 +121,9 @@ enum lfsck_namespace_inconsistency_type {
        LNIT_BAD_LINKEA         = 1,
        LNIT_UNMATCHED_PAIRS    = 2,
        LNIT_DANGLING           = 3,
+       LNIT_MUL_REF            = 4,
+       LNIT_BAD_TYPE           = 5,
+       LNIT_BAD_DIRENT         = 6,
 };
 
 struct lfsck_namespace {
@@ -182,9 +187,6 @@ struct lfsck_namespace {
        /* How many objects with nlink fixed. */
        __u64   ln_objs_nlink_repaired;
 
-       /* How many objects were lost before, but found back now. */
-       __u64   ln_objs_lost_found;
-
        /* The latest object has been processed (failed) during double scan. */
        struct lu_fid   ln_fid_latest_scanned_phase2;
 
@@ -209,8 +211,36 @@ struct lfsck_namespace {
        /* How many dangling name entries have been found/repaired. */
        __u64   ln_dangling_repaired;
 
+       /* How many multiple referenced name entries have been
+        * found/repaired. */
+       __u64   ln_mul_ref_repaired;
+
+       /* How many name entries with bad file type have been repaired. */
+       __u64   ln_bad_type_repaired;
+
+       /* How many lost name entries have been re-inserted. */
+       __u64   ln_lost_dirent_repaired;
+
+       /* How many objects under /lost+found have been scanned. */
+       __u64   ln_local_lpf_scanned;
+
+       /* How many objects under /lost+found have been moved to
+        * namespace visible directory. */
+       __u64   ln_local_lpf_moved;
+
+       /* How many objects under /lost+found have been skipped. */
+       __u64   ln_local_lpf_skipped;
+
+       /* How many objects under /lost+found failed to be processed. */
+       __u64   ln_local_lpf_failed;
+
+       /* The size of MDT targets bitmap with nbits. Such bitmap records
+        * the MDTs that contain non-verified MDT-objects. */
+       __u32   ln_bitmap_size;
+
+       __u32   ln_reserved_1;
        /* For further using. 256-bytes aligned now. */
-       __u64   ln_reserved[28];
+       __u64   ln_reserved[25];
 };
 
 enum lfsck_layout_inconsistency_type {
@@ -344,7 +374,8 @@ struct lfsck_operations {
 
        int (*lfsck_in_notify)(const struct lu_env *env,
                               struct lfsck_component *com,
-                              struct lfsck_request *lr);
+                              struct lfsck_request *lr,
+                              struct thandle *th);
 
        int (*lfsck_query)(const struct lu_env *env,
                           struct lfsck_component *com);
@@ -372,7 +403,8 @@ struct lfsck_tgt_desc {
        __u32              ltd_namespace_gen;
        unsigned int       ltd_dead:1,
                           ltd_layout_done:1,
-                          ltd_namespace_done:1;
+                          ltd_namespace_done:1,
+                          ltd_namespace_failed:1;
 };
 
 struct lfsck_tgt_desc_idx {
@@ -642,6 +674,7 @@ struct lfsck_assistant_data {
 struct lfsck_thread_info {
        struct lu_name          lti_name_const;
        struct lu_name          lti_name;
+       struct lu_name          lti_name2;
        struct lu_buf           lti_buf;
        struct lu_buf           lti_linkea_buf;
        struct lu_buf           lti_linkea_buf2;
@@ -650,6 +683,7 @@ struct lfsck_thread_info {
        struct lu_fid           lti_fid2;
        struct lu_fid           lti_fid3;
        struct lu_fid           lti_fid4;
+       struct lu_fid           lti_fid5;
        struct lu_attr          lti_la;
        struct lu_attr          lti_la2;
        struct lu_attr          lti_la3;
@@ -737,6 +771,7 @@ void lfsck_quit_generic(const struct lu_env *env,
                        struct lfsck_component *com);
 
 /* lfsck_engine.c */
+int lfsck_unpack_ent(struct lu_dirent *ent, __u64 *cookie, __u16 *type);
 int lfsck_master_engine(void *args);
 int lfsck_assistant_engine(void *args);
 
@@ -765,6 +800,12 @@ int lfsck_namespace_repair_dangling(const struct lu_env *env,
                                    struct lfsck_component *com,
                                    struct dt_object *child,
                                    struct lfsck_namespace_req *lnr);
+int lfsck_namespace_repair_dirent(const struct lu_env *env,
+                                 struct lfsck_component *com,
+                                 struct dt_object *parent,
+                                 struct dt_object *child,
+                                 const char *name, const char *name2,
+                                 __u16 type, bool update, bool dec);
 int lfsck_verify_linkea(const struct lu_env *env, struct dt_device *dev,
                        struct dt_object *obj, const struct lu_name *cname,
                        const struct lu_fid *pfid);
@@ -1080,11 +1121,15 @@ static inline void lfsck_lad_set_bitmap(const struct lu_env *env,
 
        LASSERT(com->lc_lfsck->li_master);
        LASSERT(bitmap != NULL);
-       LASSERTF(bitmap->size > index, "invalid index: nbits %d, index %u\n",
-                bitmap->size, index);
 
-       cfs_bitmap_set(bitmap, index);
-       lad->lad_incomplete = 1;
+       if (likely(bitmap->size > index)) {
+               cfs_bitmap_set(bitmap, index);
+               lad->lad_incomplete = 1;
+       } else if (com->lc_type == LFSCK_TYPE_NAMESPACE) {
+               struct lfsck_namespace *ns = com->lc_file_ram;
+
+               ns->ln_flags |= LF_INCOMPLETE;
+       }
 }
 
 static inline int lfsck_links_read(const struct lu_env *env,