__u8 ll_ost_bitmap[0];
};
+struct lfsck_assistant_object {
+ struct lu_fid lso_fid;
+ __u64 lso_oit_cookie;
+ struct lu_attr lso_attr;
+ atomic_t lso_ref;
+ unsigned int lso_dead:1,
+ lso_is_dir:1;
+};
+
struct lfsck_component;
struct lfsck_tgt_descs;
struct lfsck_tgt_desc;
int (*lfsck_exec_dir)(const struct lu_env *env,
struct lfsck_component *com,
+ struct lfsck_assistant_object *lso,
struct lu_dirent *ent,
__u16 type);
__u32 ltd_tgtnr;
};
-#define LTD_TGT(ltd, index) \
- ((ltd)->ltd_tgts_idx[(index) / TGT_PTRS_PER_BLOCK]->\
- ldi_tgts[(index) % TGT_PTRS_PER_BLOCK])
+static inline struct lfsck_tgt_desc *
+lfsck_ltd2tgt(struct lfsck_tgt_descs *ltd, __u32 index)
+{
+ __u32 idx1 = index / TGT_PTRS_PER_BLOCK;
+ __u32 idx2 = index % TGT_PTRS_PER_BLOCK;
+ struct lfsck_tgt_desc *__tgt = NULL;
+
+ if (unlikely(idx1 >= TGT_PTRS))
+ CDEBUG(D_LFSCK, "The target idx %u is invalid.\n", index);
+ else if (likely(ltd->ltd_tgts_idx[idx1] != NULL))
+ __tgt = ltd->ltd_tgts_idx[idx1]->ldi_tgts[idx2];
+
+ return __tgt;
+}
-#define OST_TGT(lfsck, index) LTD_TGT(&lfsck->li_ost_descs, index)
-#define MDT_TGT(lfsck, index) LTD_TGT(&lfsck->li_mdt_descs, index)
+static inline void lfsck_assign_tgt(struct lfsck_tgt_descs *ltd,
+ struct lfsck_tgt_desc *tgt, __u32 index)
+{
+ __u32 idx1 = index / TGT_PTRS_PER_BLOCK;
+ __u32 idx2 = index % TGT_PTRS_PER_BLOCK;
+
+ if (likely(idx1 < TGT_PTRS && ltd->ltd_tgts_idx[idx1] != NULL))
+ ltd->ltd_tgts_idx[idx1]->ldi_tgts[idx2] = tgt;
+}
#define LFSCK_STF_BITS 4
/* If want to adjust the LFSCK_STF_COUNT, please change LFSCK_STF_BITS. */
};
struct lfsck_assistant_req {
- struct list_head lar_list;
- struct lu_fid lar_fid;
+ struct list_head lar_list;
+ struct lfsck_assistant_object *lar_parent;
};
struct lfsck_namespace_req {
struct lfsck_assistant_req lnr_lar;
struct lfsck_lmv *lnr_lmv;
struct lu_fid lnr_fid;
- __u64 lnr_oit_cookie;
__u64 lnr_dir_cookie;
__u32 lnr_attr;
__u32 lnr_size;
char lnr_name[0];
};
+struct lfsck_layout_req {
+ struct lfsck_assistant_req llr_lar;
+ struct dt_object *llr_child;
+ __u32 llr_ost_idx;
+ __u32 llr_lov_idx; /* offset in LOV EA */
+};
+
struct lfsck_assistant_operations {
int (*la_handler_p1)(const struct lu_env *env,
struct lfsck_component *com,
lad_in_double_scan:1,
lad_exit:1,
lad_incomplete:1;
+ bool lad_advance_lock;
};
#define LFSCK_TMPBUF_LEN 64
struct lu_fid lti_fid3;
struct lu_attr lti_la;
struct lu_attr lti_la2;
- struct lu_attr lti_la3;
struct ost_id lti_oi;
union {
struct lustre_mdt_attrs lti_lma;
struct lfsck_assistant_data *
lfsck_assistant_data_init(struct lfsck_assistant_operations *lao,
const char *name);
+struct lfsck_assistant_object *
+lfsck_assistant_object_init(const struct lu_env *env, const struct lu_fid *fid,
+ const struct lu_attr *attr, __u64 cookie,
+ bool is_dir);
+struct dt_object *
+lfsck_assistant_object_load(const struct lu_env *env,
+ struct lfsck_instance *lfsck,
+ struct lfsck_assistant_object *lso);
int lfsck_async_interpret_common(const struct lu_env *env,
struct ptlrpc_request *req,
void *args, int rc);
const char *name);
int lfsck_namespace_striped_dir_rescan(const struct lu_env *env,
struct lfsck_component *com,
- struct dt_object *dir,
struct lfsck_namespace_req *lnr);
int lfsck_namespace_handle_striped_master(const struct lu_env *env,
struct lfsck_component *com,
- struct dt_object *dir,
struct lfsck_namespace_req *lnr);
/* lfsck_layout.c */
} else {
struct lfsck_tgt_desc *ltd;
- ltd = LTD_TGT(&lfsck->li_mdt_descs, idx);
+ ltd = lfsck_ltd2tgt(&lfsck->li_mdt_descs, idx);
if (unlikely(ltd == NULL))
return ERR_PTR(-ENODEV);
{
struct lfsck_tgt_desc *ltd;
- ltd = LTD_TGT(ltds, index);
+ ltd = lfsck_ltd2tgt(ltds, index);
if (ltd != NULL)
atomic_inc(<d->ltd_ref);
dst->lmv_hash_type = cpu_to_le32(src->lmv_hash_type);
dst->lmv_layout_version = cpu_to_le32(src->lmv_layout_version);
}
+
+static inline struct lfsck_assistant_object *
+lfsck_assistant_object_get(struct lfsck_assistant_object *lso)
+{
+ atomic_inc(&lso->lso_ref);
+
+ return lso;
+}
+
+static inline void
+lfsck_assistant_object_put(const struct lu_env *env,
+ struct lfsck_assistant_object *lso)
+{
+ if (atomic_dec_and_test(&lso->lso_ref))
+ OBD_FREE_PTR(lso);
+}
#endif /* _LFSCK_INTERNAL_H */