Whamcloud - gitweb
LU-6120 lfsck: notify ever failed server to exit LFSCK
[fs/lustre-release.git] / lustre / lfsck / lfsck_internal.h
index 0e2312d..287ae97 100644 (file)
@@ -20,7 +20,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright (c) 2013, Intel Corporation.
+ * Copyright (c) 2013, 2014, Intel Corporation.
  */
 /*
  * lustre/lfsck/lfsck_internal.h
@@ -446,7 +446,7 @@ struct lfsck_tgt_desc {
        unsigned int       ltd_dead:1,
                           ltd_layout_done:1,
                           ltd_namespace_done:1,
-                          ltd_namespace_failed:1;
+                          ltd_synced_failures:1;
 };
 
 struct lfsck_tgt_desc_idx {
@@ -480,6 +480,15 @@ struct lfsck_tgt_descs {
 #define OST_TGT(lfsck, index)   LTD_TGT(&lfsck->li_ost_descs, index)
 #define MDT_TGT(lfsck, index)   LTD_TGT(&lfsck->li_mdt_descs, index)
 
+#define LFSCK_STF_BITS 4
+/* If want to adjust the LFSCK_STF_COUNT, please change LFSCK_STF_BITS. */
+#define LFSCK_STF_COUNT        (1 << LFSCK_STF_BITS)
+
+struct lfsck_sub_trace_obj {
+       struct dt_object        *lsto_obj;
+       struct mutex             lsto_mutex;
+};
+
 struct lfsck_component {
        /* into lfsck_instance::li_list_(scan,double_scan,idle} */
        struct list_head         lc_link;
@@ -493,6 +502,7 @@ struct lfsck_component {
        struct lfsck_position    lc_pos_start;
        struct lfsck_instance   *lc_lfsck;
        struct dt_object        *lc_obj;
+       struct lfsck_sub_trace_obj lc_sub_trace_objs[LFSCK_STF_COUNT];
        struct lfsck_operations *lc_ops;
        void                    *lc_file_ram;
        void                    *lc_file_disk;
@@ -628,8 +638,10 @@ struct lfsck_instance {
        struct local_oid_storage *li_los;
        struct lu_fid             li_local_root_fid;  /* backend root "/" */
        struct lu_fid             li_global_root_fid; /* /ROOT */
+       struct dt_object         *li_lfsck_dir;
        struct dt_object         *li_bookmark_obj;
        struct dt_object         *li_lpf_obj;
+       struct dt_object         *li_lpf_root_obj;
        struct lu_client_seq     *li_seq;
        struct lfsck_bookmark     li_bookmark_ram;
        struct lfsck_bookmark     li_bookmark_disk;
@@ -800,8 +812,6 @@ struct lfsck_thread_info {
        struct lu_fid           lti_fid;
        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;
@@ -850,7 +860,6 @@ void lfsck_ibits_unlock(struct lustre_handle *lh, ldlm_mode_t mode);
 int lfsck_find_mdt_idx_by_fid(const struct lu_env *env,
                              struct lfsck_instance *lfsck,
                              const struct lu_fid *fid);
-int lfsck_create_lpf(const struct lu_env *env, struct lfsck_instance *lfsck);
 int lfsck_verify_lpf(const struct lu_env *env, struct lfsck_instance *lfsck);
 struct lfsck_instance *lfsck_instance_find(struct dt_device *key, bool ref,
                                           bool unlink);
@@ -942,10 +951,6 @@ int lfsck_verify_linkea(const struct lu_env *env, struct dt_device *dev,
                        const struct lu_fid *pfid);
 int lfsck_links_get_first(const struct lu_env *env, struct dt_object *obj,
                          char *name, struct lu_fid *pfid);
-int lfsck_remove_name_entry(const struct lu_env *env,
-                           struct lfsck_instance *lfsck,
-                           struct dt_object *parent,
-                           const char *name, __u32 type);
 int lfsck_update_name_entry(const struct lu_env *env,
                            struct lfsck_instance *lfsck,
                            struct dt_object *parent, const char *name,
@@ -1165,27 +1170,16 @@ lfsck_object_find_by_dev_nowait(const struct lu_env *env, struct dt_device *dev,
                                const struct lu_fid *fid)
 {
        struct lu_object_conf   *conf = &lfsck_env_info(env)->lti_conf;
-       struct dt_object        *obj;
 
        conf->loc_flags = LOC_F_NOWAIT;
-       obj = lu2dt(lu_object_find_slice(env, dt2lu_dev(dev), fid, conf));
-       if (unlikely(obj == NULL))
-               return ERR_PTR(-ENOENT);
-
-       return obj;
+       return lu2dt(lu_object_find_slice(env, dt2lu_dev(dev), fid, conf));
 }
 
 static inline struct dt_object *
 lfsck_object_find_by_dev(const struct lu_env *env, struct dt_device *dev,
                         const struct lu_fid *fid)
 {
-       struct dt_object *obj;
-
-       obj = lu2dt(lu_object_find_slice(env, dt2lu_dev(dev), fid, NULL));
-       if (unlikely(obj == NULL))
-               return ERR_PTR(-ENOENT);
-
-       return obj;
+       return lu2dt(lu_object_find_slice(env, dt2lu_dev(dev), fid, NULL));
 }
 
 static inline struct dt_object *lfsck_object_find(const struct lu_env *env,
@@ -1195,9 +1189,9 @@ static inline struct dt_object *lfsck_object_find(const struct lu_env *env,
        return lfsck_object_find_by_dev(env, lfsck->li_next, fid);
 }
 
-static inline struct dt_object *
-lfsck_object_find_bottom(const struct lu_env *env, struct lfsck_instance *lfsck,
-                        const struct lu_fid *fid)
+static inline struct dt_device *
+lfsck_find_dev_by_fid(const struct lu_env *env, struct lfsck_instance *lfsck,
+                     const struct lu_fid *fid)
 {
        struct dt_device *dev;
        int               idx;
@@ -1218,9 +1212,36 @@ lfsck_object_find_bottom(const struct lu_env *env, struct lfsck_instance *lfsck,
                dev = ltd->ltd_tgt;
        }
 
+       return dev;
+}
+
+static inline struct dt_object *
+lfsck_object_find_bottom(const struct lu_env *env, struct lfsck_instance *lfsck,
+                        const struct lu_fid *fid)
+{
+       struct dt_device *dev;
+
+       dev = lfsck_find_dev_by_fid(env, lfsck, fid);
+       if (IS_ERR(dev))
+               return (struct dt_object *)dev;
+
        return lfsck_object_find_by_dev(env, dev, fid);
 }
 
+static inline struct dt_object *
+lfsck_object_find_bottom_nowait(const struct lu_env *env,
+                               struct lfsck_instance *lfsck,
+                               const struct lu_fid *fid)
+{
+       struct dt_device *dev;
+
+       dev = lfsck_find_dev_by_fid(env, lfsck, fid);
+       if (IS_ERR(dev))
+               return (struct dt_object *)dev;
+
+       return lfsck_object_find_by_dev_nowait(env, dev, fid);
+}
+
 static inline struct lfsck_tgt_desc *lfsck_tgt_get(struct lfsck_tgt_descs *ltds,
                                                   __u32 index)
 {
@@ -1251,6 +1272,15 @@ static inline void lfsck_component_put(const struct lu_env *env,
                                       struct lfsck_component *com)
 {
        if (atomic_dec_and_test(&com->lc_ref)) {
+               struct lfsck_sub_trace_obj *lsto;
+               int                         i;
+
+               for (i = 0, lsto = &com->lc_sub_trace_objs[0];
+                    i < LFSCK_STF_COUNT; i++, lsto++) {
+                       if (lsto->lsto_obj != NULL)
+                               lu_object_put(env, &lsto->lsto_obj->do_lu);
+               }
+
                if (com->lc_obj != NULL)
                        lu_object_put_nocache(env, &com->lc_obj->do_lu);
                if (com->lc_file_ram != NULL)
@@ -1339,6 +1369,11 @@ static inline struct lfsck_lmv *lfsck_lmv_get(struct lfsck_lmv *llmv)
        return llmv;
 }
 
+static inline int lfsck_sub_trace_file_fid2idx(const struct lu_fid *fid)
+{
+       return fid->f_oid & (LFSCK_STF_COUNT - 1);
+}
+
 static inline void lfsck_lmv_header_le_to_cpu(struct lmv_mds_md_v1 *dst,
                                              const struct lmv_mds_md_v1 *src)
 {