* GPL HEADER END
*/
/*
- * Copyright (c) 2013, Intel Corporation.
+ * Copyright (c) 2013, 2014, Intel Corporation.
*/
/*
* lustre/lfsck/lfsck_internal.h
#include <md_object.h>
#include <lustre_linkea.h>
-#define HALF_SEC (HZ >> 1)
+#define HALF_SEC msecs_to_jiffies(MSEC_PER_SEC >> 1)
#define LFSCK_CHECKPOINT_INTERVAL 60
enum lfsck_flags {
LNTF_CHECK_PARENT = 0x02,
LNTF_SKIP_NLINK = 0x04,
LNTF_CHECK_ORPHAN = 0x08,
+ LNTF_UNCERTAIN_LMV = 0x10,
+ LNTF_RECHECK_NAME_HASH = 0x20,
LNTF_ALL = 0xff
};
#define LFSCK_LMV_MAX_STRIPES LMV_MAX_STRIPE_COUNT
#define LFSCK_LMV_DEF_STRIPES 4
+/* Warning: NOT change the lfsck_slave_lmv_flags members order,
+ * otherwise the lfsck_record_lmv() may be wrong. */
+enum lfsck_slave_lmv_flags {
+ LSLF_NONE = 0,
+ LSLF_BAD_INDEX2 = 1,
+ LSLF_NO_LMVEA = 2,
+ LSLF_DANGLING = 3,
+ LSLF_BAD_INDEX1 = 4,
+};
+
+/* When the namespace LFSCK scans a striped directory, it will record all
+ * the known shards' information in the structure "lfsck_slave_lmv_rec",
+ * including the shard's FID, index, slave LMV EA, and so on. Each shard
+ * will take one lfsck_slave_lmv_rec slot. After the 1st cycle scanning
+ * the striped directory, the LFSCK will get all the information about
+ * whether there are some inconsistency, and then it can repair them in
+ * the 2nd cycle scanning. */
struct lfsck_slave_lmv_rec {
struct lu_fid lslr_fid;
__u32 lslr_stripe_count;
struct lfsck_slave_lmv_rec *ll_lslr;
};
+/* If the namespace LFSCK finds that the master MDT-object of a striped
+ * directory lost its master LMV EA, it will re-generate the master LMV
+ * EA and notify the LFSCK instance on the MDT on which the striped dir
+ * master MDT-object resides to rescan the striped directory. To do that,
+ * the notify handler will insert a "lfsck_lmv_unit" structure into the
+ * lfsck::li_list_lmv. The LFSCK instance will scan such list from time
+ * to time to check whether needs to rescan some stirped directories. */
+struct lfsck_lmv_unit {
+ struct list_head llu_link;
+ struct lfsck_lmv llu_lmv;
+ struct dt_object *llu_obj;
+ struct lfsck_instance *llu_lfsck;
+};
+
+struct lfsck_rec_lmv_save {
+ struct lu_fid lrls_fid;
+ struct lmv_mds_md_v1 lrls_lmv;
+};
+
+/* Allow lfsck_record_lmv() to be called recursively at most three times. */
+#define LFSCK_REC_LMV_MAX_DEPTH 3
+
struct lfsck_instance {
struct mutex li_mutex;
spinlock_t li_lock;
/* For the components those are not scanning now. */
struct list_head li_list_idle;
+ /* For the lfsck_lmv_unit to be handled. */
+ struct list_head li_list_lmv;
+
atomic_t li_ref;
atomic_t li_double_scan_count;
struct ptlrpc_thread li_thread;
li_master:1, /* Master instance or not. */
li_current_oit_processed:1,
li_start_unplug:1;
+ struct lfsck_rec_lmv_save li_rec_lmv_save[LFSCK_REC_LMV_MAX_DEPTH];
};
struct lfsck_async_interpret_args {
struct lfsck_start lti_start;
struct lfsck_stop lti_stop;
ldlm_policy_data_t lti_policy;
+ struct ldlm_enqueue_info lti_einfo;
struct ldlm_res_id lti_resid;
union {
struct filter_fid_old lti_old_pfid;
/* lfsck_engine.c */
int lfsck_unpack_ent(struct lu_dirent *ent, __u64 *cookie, __u16 *type);
+void lfsck_close_dir(const struct lu_env *env,
+ struct lfsck_instance *lfsck, int result);
+int lfsck_open_dir(const struct lu_env *env,
+ struct lfsck_instance *lfsck, __u64 cookie);
int lfsck_master_engine(void *args);
int lfsck_assistant_engine(void *args);
struct lfsck_component *com,
const struct lu_fid *fid,
const __u8 flags, bool add);
+int lfsck_namespace_check_exist(const struct lu_env *env,
+ struct dt_object *dir,
+ struct dt_object *obj, const char *name);
int __lfsck_links_read(const struct lu_env *env, struct dt_object *obj,
struct linkea_data *ldata);
int lfsck_namespace_rebuild_linkea(const struct lu_env *env,
struct dt_object *parent,
struct dt_object *child,
const struct lu_name *cname);
+int lfsck_namespace_update_lmv(const struct lu_env *env,
+ struct lfsck_component *com,
+ struct dt_object *obj,
+ struct lmv_mds_md_v1 *lmv, bool locked);
int lfsck_namespace_verify_stripe_slave(const struct lu_env *env,
struct lfsck_component *com,
struct dt_object *obj,
struct lfsck_lmv *llmv);
+int lfsck_namespace_scan_shard(const struct lu_env *env,
+ struct lfsck_component *com,
+ struct dt_object *child);
+int lfsck_namespace_notify_lmv_master_local(const struct lu_env *env,
+ struct lfsck_component *com,
+ struct dt_object *obj);
+int lfsck_namespace_repair_bad_name_hash(const struct lu_env *env,
+ struct lfsck_component *com,
+ struct dt_object *shard,
+ struct lfsck_lmv *llmv,
+ const char *name);
+int lfsck_namespace_striped_dir_rescan(const struct lu_env *env,
+ struct lfsck_component *com,
+ struct lfsck_namespace_req *lnr);
+int lfsck_namespace_handle_striped_master(const struct lu_env *env,
+ struct lfsck_component *com,
+ struct lfsck_namespace_req *lnr);
/* lfsck_layout.c */
int lfsck_layout_setup(const struct lu_env *env, struct lfsck_instance *lfsck);
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,
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;
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)
{