Whamcloud - gitweb
LU-1267 lfsck: framework (3) for MDT-OST consistency
[fs/lustre-release.git] / lustre / lfsck / lfsck_internal.h
index 1c16e06..038c350 100644 (file)
@@ -95,8 +95,11 @@ struct lfsck_bookmark {
        /* How many items can be scanned at most per second. */
        __u32   lb_speed_limit;
 
+       /* The windows size for async requests pipeline. */
+       __u16   lb_async_windows;
+
        /* For 64-bits aligned. */
-       __u32   lb_padding;
+       __u16   lb_padding;
 
        /* For future using. */
        __u64   lb_reserved[6];
@@ -290,14 +293,62 @@ struct lfsck_operations {
 
        void (*lfsck_data_release)(const struct lu_env *env,
                                   struct lfsck_component *com);
+
+       void (*lfsck_quit)(const struct lu_env *env,
+                          struct lfsck_component *com);
+};
+
+#define TGT_PTRS               256     /* number of pointers at 1st level */
+#define TGT_PTRS_PER_BLOCK     256     /* number of pointers at 2nd level */
+
+struct lfsck_tgt_desc {
+       struct list_head   ltd_orphan_list;
+       struct dt_device  *ltd_tgt;
+       struct dt_device  *ltd_key;
+       struct obd_export *ltd_exp;
+       struct list_head   ltd_layout_list;
+       atomic_t           ltd_ref;
+       __u32              ltd_index;
+};
+
+struct lfsck_tgt_desc_idx {
+       struct lfsck_tgt_desc *ldi_tgts[TGT_PTRS_PER_BLOCK];
+};
+
+struct lfsck_tgt_descs {
+       /* list of known TGTs */
+       struct lfsck_tgt_desc_idx       *ltd_tgts_idx[TGT_PTRS];
+
+       /* bitmap of TGTs available */
+       cfs_bitmap_t                    *ltd_tgts_bitmap;
+
+       /* for lfsck_tgt_desc::ltd_xxx_list */
+       spinlock_t                       ltd_lock;
+
+       /* for tgts table accessing and changes */
+       struct rw_semaphore              ltd_rw_sem;
+
+       /* Temporary list for orphan targets. */
+       struct list_head                 ltd_orphan;
+
+       /* number of registered TGTs */
+       int                              ltd_tgtnr;
 };
 
+#define LTD_TGT(ltd, index)    \
+       ((ltd)->ltd_tgts_idx[(index) / TGT_PTRS_PER_BLOCK]->\
+        ldi_tgts[(index) % TGT_PTRS_PER_BLOCK])
+
+#define OST_TGT(lfsck, index)   LTD_TGT(&lfsck->li_ost_descs, index)
+#define MDT_TGT(lfsck, index)   LTD_TGT(&lfsck->li_mdt_descs, index)
+
 struct lfsck_component {
        /* into lfsck_instance::li_list_(scan,double_scan,idle} */
        cfs_list_t               lc_link;
 
        /* into lfsck_instance::li_list_dir */
        cfs_list_t               lc_link_dir;
+
        struct rw_semaphore      lc_sem;
        atomic_t                 lc_ref;
 
@@ -349,6 +400,7 @@ struct lfsck_instance {
        cfs_list_t                li_list_idle;
 
        atomic_t                  li_ref;
+       atomic_t                  li_double_scan_count;
        struct ptlrpc_thread      li_thread;
 
        /* The time for last checkpoint, jiffies */
@@ -382,6 +434,12 @@ struct lfsck_instance {
        /* It for directory traversal */
        struct dt_it             *li_di_dir;
 
+       /* Description of OST */
+       struct lfsck_tgt_descs    li_ost_descs;
+
+       /* Description of MDT */
+       struct lfsck_tgt_descs    li_mdt_descs;
+
        /* namespace-based directory traversal position. */
        __u64                     li_cookie_dir;
 
@@ -439,6 +497,7 @@ struct lfsck_thread_info {
         * then lti_ent::lde_name will be lti_key. */
        struct lu_dirent        lti_ent;
        char                    lti_key[NAME_MAX + 16];
+       struct lfsck_request    lti_lr;
 };
 
 /* lfsck_lib.c */
@@ -472,6 +531,7 @@ int lfsck_exec_dir(const struct lu_env *env, struct lfsck_instance *lfsck,
 int lfsck_post(const struct lu_env *env, struct lfsck_instance *lfsck,
               int result);
 int lfsck_double_scan(const struct lu_env *env, struct lfsck_instance *lfsck);
+void lfsck_quit(const struct lu_env *env, struct lfsck_instance *lfsck);
 
 /* lfsck_engine.c */
 int lfsck_master_engine(void *args);
@@ -636,6 +696,24 @@ static inline void lfsck_object_put(const struct lu_env *env,
        lu_object_put(env, &obj->do_lu);
 }
 
+static inline struct lfsck_tgt_desc *lfsck_tgt_get(struct lfsck_tgt_descs *ltds,
+                                                  __u32 index)
+{
+       struct lfsck_tgt_desc *ltd;
+
+       ltd = LTD_TGT(ltds, index);
+       if (ltd != NULL)
+               atomic_inc(&ltd->ltd_ref);
+
+       return ltd;
+}
+
+static inline void lfsck_tgt_put(struct lfsck_tgt_desc *ltd)
+{
+       if (atomic_dec_and_test(&ltd->ltd_ref))
+               OBD_FREE_PTR(ltd);
+}
+
 static inline struct lfsck_component *
 lfsck_component_get(struct lfsck_component *com)
 {