* GPL HEADER END
*/
/*
- * Copyright (c) 2012, 2013, Intel Corporation.
+ * Copyright (c) 2013, 2014, Intel Corporation.
*/
/*
* lustre/lfsck/lfsck_lib.c
#include "lfsck_internal.h"
+#define LFSCK_CHECKPOINT_SKIP 1
+
/* define lfsck thread key */
LU_KEY_INIT(lfsck, struct lfsck_thread_info);
struct lfsck_thread_info *info = data;
lu_buf_free(&info->lti_linkea_buf);
+ lu_buf_free(&info->lti_linkea_buf2);
lu_buf_free(&info->lti_big_buf);
OBD_FREE_PTR(info);
}
"broadcast",
"orphan",
"create_ostobj",
+ "create_mdtobj",
NULL
};
+enum lfsck_verify_lpf_types {
+ LVLT_BY_BOOKMARK = 0,
+ LVLT_BY_NAMEENTRY = 1,
+};
+
const char *lfsck_status2names(enum lfsck_status status)
{
if (unlikely(status < 0 || status >= LS_MAX))
if (likely(ltd != NULL)) {
LASSERT(list_empty(<d->ltd_layout_list));
LASSERT(list_empty(<d->ltd_layout_phase_list));
+ LASSERT(list_empty(<d->ltd_namespace_list));
+ LASSERT(list_empty(<d->ltd_namespace_phase_list));
ltds->ltd_tgtnr--;
cfs_bitmap_clear(ltds->ltd_tgts_bitmap, idx);
RETURN(rc);
}
-static const char dot[] = ".";
-static const char dotdot[] = "..";
+/**
+ * Request the specified ibits lock for the given object.
+ *
+ * Before the LFSCK modifying on the namespace visible object,
+ * it needs to acquire related ibits ldlm lock.
+ *
+ * \param[in] env pointer to the thread context
+ * \param[in] lfsck pointer to the lfsck instance
+ * \param[in] obj pointer to the dt_object to be locked
+ * \param[out] lh pointer to the lock handle
+ * \param[in] ibits the bits for the ldlm lock to be acquired
+ * \param[in] mode the mode for the ldlm lock to be acquired
+ *
+ * \retval 0 for success
+ * \retval negative error number on failure
+ */
+int lfsck_ibits_lock(const struct lu_env *env, struct lfsck_instance *lfsck,
+ struct dt_object *obj, struct lustre_handle *lh,
+ __u64 bits, ldlm_mode_t mode)
+{
+ struct lfsck_thread_info *info = lfsck_env_info(env);
+ ldlm_policy_data_t *policy = &info->lti_policy;
+ struct ldlm_res_id *resid = &info->lti_resid;
+ __u64 flags = LDLM_FL_ATOMIC_CB;
+ int rc;
+
+ LASSERT(lfsck->li_namespace != NULL);
+
+ memset(policy, 0, sizeof(*policy));
+ policy->l_inodebits.bits = bits;
+ fid_build_reg_res_name(lfsck_dto2fid(obj), resid);
+ if (dt_object_remote(obj)) {
+ struct ldlm_enqueue_info *einfo = &info->lti_einfo;
+
+ memset(einfo, 0, sizeof(*einfo));
+ einfo->ei_type = LDLM_IBITS;
+ einfo->ei_mode = mode;
+ einfo->ei_cb_bl = ldlm_blocking_ast;
+ einfo->ei_cb_cp = ldlm_completion_ast;
+ einfo->ei_res_id = resid;
+
+ rc = dt_object_lock(env, obj, lh, einfo, policy);
+ } else {
+ rc = ldlm_cli_enqueue_local(lfsck->li_namespace, resid,
+ LDLM_IBITS, policy, mode,
+ &flags, ldlm_blocking_ast,
+ ldlm_completion_ast, NULL, NULL,
+ 0, LVB_T_NONE, NULL, lh);
+ }
+
+ if (rc == ELDLM_OK) {
+ rc = 0;
+ } else {
+ memset(lh, 0, sizeof(*lh));
+ rc = -EIO;
+ }
+
+ return rc;
+}
+
+/**
+ * Release the the specified ibits lock.
+ *
+ * If the lock has been acquired before, release it
+ * and cleanup the handle. Otherwise, do nothing.
+ *
+ * \param[in] lh pointer to the lock handle
+ * \param[in] mode the mode for the ldlm lock to be released
+ */
+void lfsck_ibits_unlock(struct lustre_handle *lh, ldlm_mode_t mode)
+{
+ if (lustre_handle_is_used(lh)) {
+ ldlm_lock_decref(lh, mode);
+ memset(lh, 0, sizeof(*lh));
+ }
+}
+
+int lfsck_find_mdt_idx_by_fid(const struct lu_env *env,
+ struct lfsck_instance *lfsck,
+ const struct lu_fid *fid)
+{
+ struct seq_server_site *ss =
+ lu_site2seq(lfsck->li_bottom->dd_lu_dev.ld_site);
+ struct lu_seq_range *range = &lfsck_env_info(env)->lti_range;
+ int rc;
+
+ fld_range_set_mdt(range);
+ rc = fld_server_lookup(env, ss->ss_server_fld, fid_seq(fid), range);
+ if (rc == 0)
+ rc = range->lsr_index;
+
+ return rc;
+}
+
+const char dot[] = ".";
+const char dotdot[] = "..";
static const char dotlustre[] = ".lustre";
static const char lostfound[] = "lost+found";
+/**
+ * Remove the name entry from the .lustre/lost+found directory.
+ *
+ * No need to care about the object referenced by the name entry,
+ * either the name entry is invalid or redundant, or the referenced
+ * object has been processed or will be handled by others.
+ *
+ * \param[in] env pointer to the thread context
+ * \param[in] lfsck pointer to the lfsck instance
+ * \param[in] name the name for the name entry to be removed
+ *
+ * \retval 0 for success
+ * \retval negative error number on failure
+ */
+static int lfsck_lpf_remove_name_entry(const struct lu_env *env,
+ struct lfsck_instance *lfsck,
+ const char *name)
+{
+ struct dt_object *parent = lfsck->li_lpf_root_obj;
+ struct dt_device *dev = lfsck->li_next;
+ struct thandle *th;
+ struct lustre_handle lh = { 0 };
+ int rc;
+ ENTRY;
+
+ rc = lfsck_ibits_lock(env, lfsck, parent, &lh,
+ MDS_INODELOCK_UPDATE, LCK_EX);
+ if (rc != 0)
+ RETURN(rc);
+
+ th = dt_trans_create(env, dev);
+ if (IS_ERR(th))
+ GOTO(unlock, rc = PTR_ERR(th));
+
+ rc = dt_declare_delete(env, parent, (const struct dt_key *)name, th);
+ if (rc != 0)
+ GOTO(stop, rc);
+
+ rc = dt_declare_ref_del(env, parent, th);
+ if (rc != 0)
+ GOTO(stop, rc);
+
+ rc = dt_trans_start(env, dev, th);
+ if (rc != 0)
+ GOTO(stop, rc);
+
+ rc = dt_delete(env, parent, (const struct dt_key *)name, th,
+ BYPASS_CAPA);
+ if (rc != 0)
+ GOTO(stop, rc);
+
+ dt_write_lock(env, parent, 0);
+ rc = dt_ref_del(env, parent, th);
+ dt_write_unlock(env, parent);
+
+ GOTO(stop, rc);
+
+stop:
+ dt_trans_stop(env, dev, th);
+
+unlock:
+ lfsck_ibits_unlock(&lh, LCK_EX);
+
+ CDEBUG(D_LFSCK, "%s: remove name entry "DFID"/%s: rc = %d\n",
+ lfsck_lfsck2name(lfsck), PFID(lfsck_dto2fid(parent)), name, rc);
+
+ return rc;
+}
+
static int lfsck_create_lpf_local(const struct lu_env *env,
struct lfsck_instance *lfsck,
- struct dt_object *parent,
struct dt_object *child,
struct lu_attr *la,
struct dt_object_format *dof,
const char *name)
{
struct dt_insert_rec *rec = &lfsck_env_info(env)->lti_dt_rec;
+ struct dt_object *parent = lfsck->li_lpf_root_obj;
struct dt_device *dev = lfsck->li_bottom;
struct lfsck_bookmark *bk = &lfsck->li_bookmark_ram;
struct dt_object *bk_obj = lfsck->li_bookmark_obj;
const struct lu_fid *cfid = lfsck_dto2fid(child);
struct thandle *th = NULL;
- struct linkea_data ldata = { 0 };
+ struct linkea_data ldata = { NULL };
struct lu_buf linkea_buf;
const struct lu_name *cname;
loff_t pos = 0;
ENTRY;
rc = linkea_data_new(&ldata,
- &lfsck_env_info(env)->lti_linkea_buf);
+ &lfsck_env_info(env)->lti_linkea_buf2);
if (rc != 0)
RETURN(rc);
GOTO(stop, rc);
/* 3a. insert linkEA for child */
- linkea_buf.lb_buf = ldata.ld_buf->lb_buf;
- linkea_buf.lb_len = ldata.ld_leh->leh_len;
+ lfsck_buf_init(&linkea_buf, ldata.ld_buf->lb_buf,
+ ldata.ld_leh->leh_len);
rc = dt_declare_xattr_set(env, child, &linkea_buf,
XATTR_NAME_LINK, 0, th);
if (rc != 0)
static int lfsck_create_lpf_remote(const struct lu_env *env,
struct lfsck_instance *lfsck,
- struct dt_object *parent,
struct dt_object *child,
struct lu_attr *la,
struct dt_object_format *dof,
const char *name)
{
struct dt_insert_rec *rec = &lfsck_env_info(env)->lti_dt_rec;
+ struct dt_object *parent = lfsck->li_lpf_root_obj;
struct lfsck_bookmark *bk = &lfsck->li_bookmark_ram;
struct dt_object *bk_obj = lfsck->li_bookmark_obj;
const struct lu_fid *cfid = lfsck_dto2fid(child);
struct thandle *th = NULL;
- struct linkea_data ldata = { 0 };
+ struct linkea_data ldata = { NULL };
struct lu_buf linkea_buf;
const struct lu_name *cname;
struct dt_device *dev;
ENTRY;
rc = linkea_data_new(&ldata,
- &lfsck_env_info(env)->lti_linkea_buf);
+ &lfsck_env_info(env)->lti_linkea_buf2);
if (rc != 0)
RETURN(rc);
GOTO(stop, rc);
/* 3a. insert linkEA for child */
- linkea_buf.lb_buf = ldata.ld_buf->lb_buf;
- linkea_buf.lb_len = ldata.ld_leh->leh_len;
+ lfsck_buf_init(&linkea_buf, ldata.ld_buf->lb_buf,
+ ldata.ld_leh->leh_len);
rc = dt_declare_xattr_set(env, child, &linkea_buf,
XATTR_NAME_LINK, 0, th);
if (rc != 0)
return rc;
}
-/* Do NOT create .lustre/lost+found/MDTxxxx when register the lfsck instance,
- * because the MDT0 maybe not reaady for sequence allocation yet. We do that
- * only when it is required, such as orphan OST-objects repairing. */
-int lfsck_create_lpf(const struct lu_env *env, struct lfsck_instance *lfsck)
+/**
+ * Create the MDTxxxx directory under /ROOT/.lustre/lost+found/
+ *
+ * The /ROOT/.lustre/lost+found/MDTxxxx/ directory is used for holding
+ * orphans and other uncertain inconsistent objects found during the
+ * LFSCK. Such directory will be created by the LFSCK engine on the
+ * local MDT before the LFSCK scanning.
+ *
+ * \param[in] env pointer to the thread context
+ * \param[in] lfsck pointer to the lfsck instance
+ *
+ * \retval 0 for success
+ * \retval negative error number on failure
+ */
+static int lfsck_create_lpf(const struct lu_env *env,
+ struct lfsck_instance *lfsck)
{
struct lfsck_bookmark *bk = &lfsck->li_bookmark_ram;
struct lfsck_thread_info *info = lfsck_env_info(env);
struct lu_fid *cfid = &info->lti_fid2;
struct lu_attr *la = &info->lti_la;
struct dt_object_format *dof = &info->lti_dof;
- struct dt_object *parent = NULL;
+ struct dt_object *parent = lfsck->li_lpf_root_obj;
struct dt_object *child = NULL;
+ struct lustre_handle lh = { 0 };
char name[8];
int node = lfsck_dev_idx(lfsck->li_bottom);
int rc = 0;
ENTRY;
LASSERT(lfsck->li_master);
+ LASSERT(parent != NULL);
+ LASSERT(lfsck->li_lpf_obj == NULL);
- sprintf(name, "MDT%04x", node);
- if (node == 0) {
- parent = lfsck_object_find_by_dev(env, lfsck->li_bottom,
- &LU_LPF_FID);
- } else {
- struct lfsck_tgt_desc *ltd;
-
- ltd = lfsck_tgt_get(&lfsck->li_mdt_descs, 0);
- if (unlikely(ltd == NULL))
- RETURN(-ENXIO);
-
- parent = lfsck_object_find_by_dev(env, ltd->ltd_tgt,
- &LU_LPF_FID);
- lfsck_tgt_put(ltd);
- }
- if (IS_ERR(parent))
- RETURN(PTR_ERR(parent));
-
- if (unlikely(!dt_try_as_dir(env, parent)))
- GOTO(out, rc = -ENOTDIR);
-
- mutex_lock(&lfsck->li_mutex);
- if (lfsck->li_lpf_obj != NULL)
- GOTO(unlock, rc = 0);
+ rc = lfsck_ibits_lock(env, lfsck, parent, &lh,
+ MDS_INODELOCK_UPDATE, LCK_EX);
+ if (rc != 0)
+ RETURN(rc);
+ snprintf(name, 8, "MDT%04x", node);
if (fid_is_zero(&bk->lb_lpf_fid)) {
/* There is corner case that: in former LFSCK scanning we have
* created the .lustre/lost+found/MDTxxxx but failed to update
dof->dof_type = dt_mode_to_dft(S_IFDIR);
if (node == 0)
- rc = lfsck_create_lpf_local(env, lfsck, parent, child, la,
- dof, name);
+ rc = lfsck_create_lpf_local(env, lfsck, child, la, dof, name);
else
- rc = lfsck_create_lpf_remote(env, lfsck, parent, child, la,
- dof, name);
+ rc = lfsck_create_lpf_remote(env, lfsck, child, la, dof, name);
if (rc == 0)
lfsck->li_lpf_obj = child;
GOTO(unlock, rc);
unlock:
- mutex_unlock(&lfsck->li_mutex);
+ lfsck_ibits_unlock(&lh, LCK_EX);
if (rc != 0 && child != NULL && !IS_ERR(child))
lu_object_put(env, &child->do_lu);
-out:
- if (parent != NULL && !IS_ERR(parent))
+
+ return rc;
+}
+
+/**
+ * Scan .lustre/lost+found for bad name entries and remove them.
+ *
+ * The valid name entry should be "MDTxxxx", the "xxxx" is the MDT device
+ * index in the system. Any other formatted name is invalid and should be
+ * removed.
+ *
+ * \param[in] env pointer to the thread context
+ * \param[in] lfsck pointer to the lfsck instance
+ *
+ * \retval 0 for success
+ * \retval negative error number on failure
+ */
+static int lfsck_scan_lpf_bad_entries(const struct lu_env *env,
+ struct lfsck_instance *lfsck)
+{
+ struct dt_object *parent = lfsck->li_lpf_root_obj;
+ struct lu_dirent *ent =
+ (struct lu_dirent *)lfsck_env_info(env)->lti_key;
+ const struct dt_it_ops *iops = &parent->do_index_ops->dio_it;
+ struct dt_it *it;
+ int rc;
+ ENTRY;
+
+ it = iops->init(env, parent, LUDA_64BITHASH, BYPASS_CAPA);
+ if (IS_ERR(it))
+ RETURN(PTR_ERR(it));
+
+ rc = iops->load(env, it, 0);
+ if (rc == 0)
+ rc = iops->next(env, it);
+ else if (rc > 0)
+ rc = 0;
+
+ while (rc == 0) {
+ int off = 3;
+
+ rc = iops->rec(env, it, (struct dt_rec *)ent, LUDA_64BITHASH);
+ if (rc != 0)
+ break;
+
+ ent->lde_namelen = le16_to_cpu(ent->lde_namelen);
+ if (name_is_dot_or_dotdot(ent->lde_name, ent->lde_namelen))
+ goto next;
+
+ /* name length must be strlen("MDTxxxx") */
+ if (ent->lde_namelen != 7)
+ goto remove;
+
+ if (memcmp(ent->lde_name, "MDT", off) != 0)
+ goto remove;
+
+ while (off < 7 && isxdigit(ent->lde_name[off]))
+ off++;
+
+ if (off != 7) {
+
+remove:
+ rc = lfsck_lpf_remove_name_entry(env, lfsck,
+ ent->lde_name);
+ if (rc != 0)
+ break;
+ }
+
+next:
+ rc = iops->next(env, it);
+ }
+
+ iops->put(env, it);
+ iops->fini(env, it);
+
+ RETURN(rc > 0 ? 0 : rc);
+}
+
+static int lfsck_update_lpf_entry(const struct lu_env *env,
+ struct lfsck_instance *lfsck,
+ struct dt_object *parent,
+ struct dt_object *child,
+ const char *name,
+ enum lfsck_verify_lpf_types type)
+{
+ int rc;
+
+ if (type == LVLT_BY_BOOKMARK) {
+ rc = lfsck_update_name_entry(env, lfsck, parent, name,
+ lfsck_dto2fid(child), S_IFDIR);
+ } else /* if (type == LVLT_BY_NAMEENTRY) */ {
+ lfsck->li_bookmark_ram.lb_lpf_fid = *lfsck_dto2fid(child);
+ rc = lfsck_bookmark_store(env, lfsck);
+
+ CDEBUG(D_LFSCK, "%s: update LPF fid "DFID
+ " in the bookmark file: rc = %d\n",
+ lfsck_lfsck2name(lfsck),
+ PFID(lfsck_dto2fid(child)), rc);
+ }
+
+ return rc;
+}
+
+/**
+ * Check whether the @child back references the @parent.
+ *
+ * Two cases:
+ * 1) The child's FID is stored in the bookmark file. If the child back
+ * references the parent (LU_LPF_FID object) via its ".." entry, then
+ * insert the name (MDTxxxx) to the .lustre/lost+found; otherwise, if
+ * the child back references another parent2, then:
+ * 1.1) If the parent2 recognizes the child, then update the bookmark file;
+ * 1.2) Otherwise, the LFSCK cannot know whether there will be parent3 that
+ * references the child. So keep them there. As the LFSCK processing,
+ * the parent3 may be found, then when the LFSCK run next time, the
+ * inconsistency can be repaired.
+ *
+ * 2) The child's FID is stored in the .lustre/lost+found/ sub-directory name
+ * entry (MDTxxxx). If the child back references the parent (LU_LPF_FID obj)
+ * via its ".." entry, then update the bookmark file, otherwise, if the child
+ * back references another parent2, then:
+ * 2.1) If the parent2 recognizes the child, then remove the sub-directory
+ * from .lustre/lost+found/;
+ * 2.2) Otherwise, if the parent2 does not recognizes the child, trust the
+ * sub-directory name entry and update the child;
+ * 2.3) Otherwise, if we do not know whether the parent2 recognizes the child
+ * or not, then keep them there.
+ *
+ * \param[in] env pointer to the thread context
+ * \param[in] lfsck pointer to the lfsck instance
+ * \param[in] child pointer to the lost+found sub-directory object
+ * \param[in] name the name for lost+found sub-directory object
+ * \param[out] fid pointer to the buffer to hold the FID of the object
+ * (called it as parent2) that is referenced via the
+ * child's dotdot entry; it also can be the FID that
+ * is referenced by the name entry under the parent2.
+ * \param[in] type to indicate where the child's FID is stored in
+ *
+ * \retval positive number for uncertain inconsistency
+ * \retval 0 for success
+ * \retval negative error number on failure
+ */
+static int lfsck_verify_lpf_pairs(const struct lu_env *env,
+ struct lfsck_instance *lfsck,
+ struct dt_object *child, const char *name,
+ struct lu_fid *fid,
+ enum lfsck_verify_lpf_types type)
+{
+ struct dt_object *parent = lfsck->li_lpf_root_obj;
+ struct lfsck_thread_info *info = lfsck_env_info(env);
+ char *name2 = info->lti_key;
+ struct lu_fid *fid2 = &info->lti_fid3;
+ struct dt_object *parent2 = NULL;
+ struct lustre_handle lh = { 0 };
+ int rc;
+ ENTRY;
+
+ fid_zero(fid);
+ rc = dt_lookup(env, child, (struct dt_rec *)fid,
+ (const struct dt_key *)dotdot, BYPASS_CAPA);
+ if (rc != 0)
+ GOTO(linkea, rc);
+
+ if (!fid_is_sane(fid))
+ GOTO(linkea, rc = -EINVAL);
+
+ if (lu_fid_eq(fid, &LU_LPF_FID)) {
+ const struct lu_name *cname;
+
+ if (lfsck->li_lpf_obj == NULL) {
+ lu_object_get(&child->do_lu);
+ lfsck->li_lpf_obj = child;
+ }
+
+ cname = lfsck_name_get_const(env, name, strlen(name));
+ rc = lfsck_verify_linkea(env, lfsck->li_bottom, child, cname,
+ &LU_LPF_FID);
+ if (rc == 0)
+ rc = lfsck_update_lpf_entry(env, lfsck, parent, child,
+ name, type);
+
+ GOTO(out_done, rc);
+ }
+
+ parent2 = lfsck_object_find_by_dev(env, lfsck->li_next, fid);
+ if (IS_ERR(parent2))
+ GOTO(linkea, parent2);
+
+ if (!dt_object_exists(parent2)) {
+ lu_object_put(env, &parent2->do_lu);
+
+ GOTO(linkea, parent2 = ERR_PTR(-ENOENT));
+ }
+
+ if (!dt_try_as_dir(env, parent2)) {
+ lu_object_put(env, &parent2->do_lu);
+
+ GOTO(linkea, parent2 = ERR_PTR(-ENOTDIR));
+ }
+
+linkea:
+ /* To prevent rename/unlink race */
+ rc = lfsck_ibits_lock(env, lfsck, child, &lh,
+ MDS_INODELOCK_UPDATE, LCK_PR);
+ if (rc != 0)
+ GOTO(out_put, rc);
+
+ dt_read_lock(env, child, 0);
+ rc = lfsck_links_get_first(env, child, name2, fid2);
+ if (rc != 0) {
+ dt_read_unlock(env, child);
+ lfsck_ibits_unlock(&lh, LCK_PR);
+
+ GOTO(out_put, rc = 1);
+ }
+
+ /* It is almost impossible that the bookmark file (or the name entry)
+ * and the linkEA hit the same data corruption. Trust the linkEA. */
+ if (lu_fid_eq(fid2, &LU_LPF_FID) && strcmp(name, name2) == 0) {
+ dt_read_unlock(env, child);
+ lfsck_ibits_unlock(&lh, LCK_PR);
+
+ *fid = *fid2;
+ if (lfsck->li_lpf_obj == NULL) {
+ lu_object_get(&child->do_lu);
+ lfsck->li_lpf_obj = child;
+ }
+
+ /* Update the child's dotdot entry */
+ rc = lfsck_update_name_entry(env, lfsck, child, dotdot,
+ &LU_LPF_FID, S_IFDIR);
+ if (rc == 0)
+ rc = lfsck_update_lpf_entry(env, lfsck, parent, child,
+ name, type);
+
+ GOTO(out_put, rc);
+ }
+
+ if (parent2 == NULL || IS_ERR(parent2)) {
+ dt_read_unlock(env, child);
+ lfsck_ibits_unlock(&lh, LCK_PR);
+
+ GOTO(out_done, rc = 1);
+ }
+
+ rc = dt_lookup(env, parent2, (struct dt_rec *)fid,
+ (const struct dt_key *)name2, BYPASS_CAPA);
+ dt_read_unlock(env, child);
+ lfsck_ibits_unlock(&lh, LCK_PR);
+ if (rc != 0 && rc != -ENOENT)
+ GOTO(out_put, rc);
+
+ if (rc == -ENOENT || !lu_fid_eq(fid, lfsck_dto2fid(child))) {
+ if (type == LVLT_BY_BOOKMARK)
+ GOTO(out_put, rc = 1);
+
+ /* Trust the name entry, update the child's dotdot entry. */
+ rc = lfsck_update_name_entry(env, lfsck, child, dotdot,
+ &LU_LPF_FID, S_IFDIR);
+
+ GOTO(out_put, rc);
+ }
+
+ if (type == LVLT_BY_BOOKMARK) {
+ /* Invalid FID record in the bookmark file, reset it. */
+ fid_zero(&lfsck->li_bookmark_ram.lb_lpf_fid);
+ rc = lfsck_bookmark_store(env, lfsck);
+
+ CDEBUG(D_LFSCK, "%s: reset invalid LPF fid "DFID
+ " in the bookmark file: rc = %d\n",
+ lfsck_lfsck2name(lfsck), PFID(lfsck_dto2fid(child)), rc);
+ } else /* if (type == LVLT_BY_NAMEENTRY) */ {
+ /* The name entry is wrong, remove it. */
+ rc = lfsck_lpf_remove_name_entry(env, lfsck, name);
+ }
+
+ GOTO(out_put, rc);
+
+out_put:
+ if (parent2 != NULL && !IS_ERR(parent2))
+ lu_object_put(env, &parent2->do_lu);
+
+out_done:
+ return rc;
+}
+
+/**
+ * Verify the /ROOT/.lustre/lost+found/ directory.
+ *
+ * /ROOT/.lustre/lost+found/ is a special directory to hold the objects that
+ * the LFSCK does not exactly know how to handle, such as orphans. So before
+ * the LFSCK scanning the system, the consistency of such directory needs to
+ * be verified firstly to allow the users to use it during the LFSCK.
+ *
+ * \param[in] env pointer to the thread context
+ * \param[in] lfsck pointer to the lfsck instance
+ *
+ * \retval positive number for uncertain inconsistency
+ * \retval 0 for success
+ * \retval negative error number on failure
+ */
+int lfsck_verify_lpf(const struct lu_env *env, struct lfsck_instance *lfsck)
+{
+ struct lfsck_thread_info *info = lfsck_env_info(env);
+ struct lu_fid *pfid = &info->lti_fid;
+ struct lu_fid *cfid = &info->lti_fid2;
+ struct lfsck_bookmark *bk = &lfsck->li_bookmark_ram;
+ struct dt_object *parent;
+ /* child1's FID is in the bookmark file. */
+ struct dt_object *child1 = NULL;
+ /* child2's FID is in the name entry MDTxxxx. */
+ struct dt_object *child2 = NULL;
+ struct dt_device *dev = lfsck->li_bottom;
+ const struct lu_name *cname;
+ char name[8];
+ int node = lfsck_dev_idx(dev);
+ int rc = 0;
+ ENTRY;
+
+ LASSERT(lfsck->li_master);
+
+ if (lfsck->li_lpf_root_obj != NULL)
+ RETURN(0);
+
+ if (node == 0) {
+ parent = lfsck_object_find_by_dev(env, dev, &LU_LPF_FID);
+ } else {
+ struct lfsck_tgt_desc *ltd;
+
+ ltd = lfsck_tgt_get(&lfsck->li_mdt_descs, 0);
+ if (unlikely(ltd == NULL))
+ RETURN(-ENXIO);
+
+ parent = lfsck_object_find_by_dev(env, ltd->ltd_tgt,
+ &LU_LPF_FID);
+ lfsck_tgt_put(ltd);
+ }
+
+ if (IS_ERR(parent))
+ RETURN(PTR_ERR(parent));
+
+ LASSERT(dt_object_exists(parent));
+
+ if (unlikely(!dt_try_as_dir(env, parent))) {
lu_object_put(env, &parent->do_lu);
+ GOTO(put, rc = -ENOTDIR);
+ }
+
+ lfsck->li_lpf_root_obj = parent;
+ if (node == 0) {
+ rc = lfsck_scan_lpf_bad_entries(env, lfsck);
+ if (rc != 0)
+ CDEBUG(D_LFSCK, "%s: scan .lustre/lost+found/ "
+ "for bad sub-directories: rc = %d\n",
+ lfsck_lfsck2name(lfsck), rc);
+ }
+
+ if (!fid_is_zero(&bk->lb_lpf_fid)) {
+ if (unlikely(!fid_is_norm(&bk->lb_lpf_fid))) {
+ struct lu_fid tfid = bk->lb_lpf_fid;
+
+ /* Invalid FID record in the bookmark file, reset it. */
+ fid_zero(&bk->lb_lpf_fid);
+ rc = lfsck_bookmark_store(env, lfsck);
+
+ CDEBUG(D_LFSCK, "%s: reset invalid LPF fid "DFID
+ " in the bookmark file: rc = %d\n",
+ lfsck_lfsck2name(lfsck), PFID(&tfid), rc);
+
+ if (rc != 0)
+ GOTO(put, rc);
+ } else {
+ child1 = lfsck_object_find_by_dev(env, dev,
+ &bk->lb_lpf_fid);
+ if (IS_ERR(child1)) {
+ child1 = NULL;
+ goto find_child2;
+ }
+
+ if (unlikely(!dt_object_exists(child1) ||
+ dt_object_remote(child1)) ||
+ !S_ISDIR(lfsck_object_type(child1))) {
+ /* Invalid FID record in the bookmark file,
+ * reset it. */
+ fid_zero(&bk->lb_lpf_fid);
+ rc = lfsck_bookmark_store(env, lfsck);
+
+ CDEBUG(D_LFSCK, "%s: reset invalid LPF fid "DFID
+ " in the bookmark file: rc = %d\n",
+ lfsck_lfsck2name(lfsck),
+ PFID(lfsck_dto2fid(child1)), rc);
+
+ if (rc != 0)
+ GOTO(put, rc);
+
+ lu_object_put(env, &child1->do_lu);
+ child1 = NULL;
+ } else if (unlikely(!dt_try_as_dir(env, child1))) {
+ GOTO(put, rc = -ENOTDIR);
+ }
+ }
+ }
+
+find_child2:
+ snprintf(name, 8, "MDT%04x", node);
+ rc = dt_lookup(env, parent, (struct dt_rec *)cfid,
+ (const struct dt_key *)name, BYPASS_CAPA);
+ if (rc == -ENOENT) {
+ if (!fid_is_zero(&bk->lb_lpf_fid))
+ goto check_child1;
+
+ GOTO(put, rc = 0);
+ }
+
+ if (rc != 0)
+ GOTO(put, rc);
+
+ /* Invalid FID in the name entry, remove the name entry. */
+ if (!fid_is_norm(cfid)) {
+ rc = lfsck_lpf_remove_name_entry(env, lfsck, name);
+ if (rc != 0)
+ GOTO(put, rc);
+
+ goto check_child1;
+ }
+
+ child2 = lfsck_object_find_by_dev(env, dev, cfid);
+ if (IS_ERR(child2))
+ GOTO(put, rc = PTR_ERR(child2));
+
+ if (unlikely(!dt_object_exists(child2) ||
+ dt_object_remote(child2)) ||
+ !S_ISDIR(lfsck_object_type(child2))) {
+ rc = lfsck_lpf_remove_name_entry(env, lfsck, name);
+ if (rc != 0)
+ GOTO(put, rc);
+
+ goto check_child1;
+ }
+
+ if (unlikely(!dt_try_as_dir(env, child2)))
+ GOTO(put, rc = -ENOTDIR);
+
+ if (child1 == NULL) {
+ rc = lfsck_verify_lpf_pairs(env, lfsck, child2, name,
+ pfid, LVLT_BY_NAMEENTRY);
+ } else if (!lu_fid_eq(cfid, &bk->lb_lpf_fid)) {
+ rc = lfsck_verify_lpf_pairs(env, lfsck, child1, name,
+ pfid, LVLT_BY_BOOKMARK);
+ if (!lu_fid_eq(pfid, &LU_LPF_FID))
+ rc = lfsck_verify_lpf_pairs(env, lfsck, child2,
+ name, pfid,
+ LVLT_BY_NAMEENTRY);
+ } else {
+ if (lfsck->li_lpf_obj == NULL) {
+ lu_object_get(&child2->do_lu);
+ lfsck->li_lpf_obj = child2;
+ }
+
+ cname = lfsck_name_get_const(env, name, strlen(name));
+ rc = lfsck_verify_linkea(env, dev, child2, cname, &LU_LPF_FID);
+ }
+
+ GOTO(put, rc);
+
+check_child1:
+ if (child1 != NULL)
+ rc = lfsck_verify_lpf_pairs(env, lfsck, child1, name,
+ pfid, LVLT_BY_BOOKMARK);
+
+ GOTO(put, rc);
+
+put:
+ if (lfsck->li_lpf_obj != NULL) {
+ if (unlikely(!dt_try_as_dir(env, lfsck->li_lpf_obj))) {
+ lu_object_put(env, &lfsck->li_lpf_obj->do_lu);
+ lfsck->li_lpf_obj = NULL;
+ rc = -ENOTDIR;
+ }
+ } else if (rc == 0) {
+ rc = lfsck_create_lpf(env, lfsck);
+ }
+
+ if (child2 != NULL && !IS_ERR(child2))
+ lu_object_put(env, &child2->do_lu);
+ if (child1 != NULL && !IS_ERR(child1))
+ lu_object_put(env, &child1->do_lu);
+
return rc;
}
struct ptlrpc_thread *thread = &lfsck->li_thread;
struct lfsck_component *com;
struct lfsck_component *next;
+ struct lfsck_lmv_unit *llu;
+ struct lfsck_lmv_unit *llu_next;
+ struct lfsck_lmv *llmv;
ENTRY;
LASSERT(list_empty(&lfsck->li_link));
}
LASSERT(lfsck->li_obj_dir == NULL);
+ LASSERT(lfsck->li_lmv == NULL);
+
+ list_for_each_entry_safe(llu, llu_next, &lfsck->li_list_lmv, llu_link) {
+ llmv = &llu->llu_lmv;
+
+ LASSERTF(atomic_read(&llmv->ll_ref) == 1,
+ "still in using: %u\n",
+ atomic_read(&llmv->ll_ref));
+
+ lfsck_lmv_put(env, llmv);
+ }
list_for_each_entry_safe(com, next, &lfsck->li_list_scan, lc_link) {
lfsck_component_cleanup(env, com);
lfsck->li_lpf_obj = NULL;
}
+ if (lfsck->li_lpf_root_obj != NULL) {
+ lu_object_put(env, &lfsck->li_lpf_root_obj->do_lu);
+ lfsck->li_lpf_root_obj = NULL;
+ }
+
if (lfsck->li_los != NULL) {
local_oid_storage_fini(env, lfsck->li_los);
lfsck->li_los = NULL;
bool dirty = false;
if (limit != LFSCK_SPEED_NO_LIMIT) {
- if (limit > HZ) {
- lfsck->li_sleep_rate = limit / HZ;
+ if (limit > msecs_to_jiffies(MSEC_PER_SEC)) {
+ lfsck->li_sleep_rate = limit /
+ msecs_to_jiffies(MSEC_PER_SEC);
lfsck->li_sleep_jif = 1;
} else {
lfsck->li_sleep_rate = 1;
- lfsck->li_sleep_jif = HZ / limit;
+ lfsck->li_sleep_jif = msecs_to_jiffies(MSEC_PER_SEC) /
+ limit;
}
} else {
lfsck->li_sleep_jif = 0;
if (lfsck->li_sleep_jif > 0 &&
lfsck->li_new_scanned >= lfsck->li_sleep_rate) {
lwi = LWI_TIMEOUT_INTR(lfsck->li_sleep_jif, NULL,
- LWI_ON_SIGNAL_NOOP, NULL);
-
- l_wait_event(thread->t_ctl_waitq,
- !thread_is_running(thread),
- &lwi);
- lfsck->li_new_scanned = 0;
- }
-}
-
-void lfsck_control_speed_by_self(struct lfsck_component *com)
-{
- struct lfsck_instance *lfsck = com->lc_lfsck;
- struct ptlrpc_thread *thread = &lfsck->li_thread;
- struct l_wait_info lwi;
-
- if (lfsck->li_sleep_jif > 0 &&
- com->lc_new_scanned >= lfsck->li_sleep_rate) {
- lwi = LWI_TIMEOUT_INTR(lfsck->li_sleep_jif, NULL,
- LWI_ON_SIGNAL_NOOP, NULL);
-
- l_wait_event(thread->t_ctl_waitq,
- !thread_is_running(thread),
- &lwi);
- com->lc_new_scanned = 0;
- }
-}
-
-static int lfsck_parent_fid(const struct lu_env *env, struct dt_object *obj,
- struct lu_fid *fid)
-{
- if (unlikely(!S_ISDIR(lfsck_object_type(obj)) ||
- !dt_try_as_dir(env, obj)))
- return -ENOTDIR;
-
- return dt_lookup(env, obj, (struct dt_rec *)fid,
- (const struct dt_key *)"..", BYPASS_CAPA);
-}
-
-static int lfsck_needs_scan_dir(const struct lu_env *env,
- struct lfsck_instance *lfsck,
- struct dt_object *obj)
-{
- struct lu_fid *fid = &lfsck_env_info(env)->lti_fid;
- int depth = 0;
- int rc;
-
- if (!lfsck->li_master || !S_ISDIR(lfsck_object_type(obj)) ||
- list_empty(&lfsck->li_list_dir))
- RETURN(0);
-
- while (1) {
- /* XXX: Currently, we do not scan the "/REMOTE_PARENT_DIR",
- * which is the agent directory to manage the objects
- * which name entries reside on remote MDTs. Related
- * consistency verification will be processed in LFSCK
- * phase III. */
- if (lu_fid_eq(lfsck_dto2fid(obj), &lfsck->li_global_root_fid)) {
- if (depth > 0)
- lfsck_object_put(env, obj);
- return 1;
- }
-
- /* No need to check .lustre and its children. */
- if (fid_seq_is_dot_lustre(fid_seq(lfsck_dto2fid(obj)))) {
- if (depth > 0)
- lfsck_object_put(env, obj);
- return 0;
- }
-
- dt_read_lock(env, obj, MOR_TGT_CHILD);
- if (unlikely(lfsck_is_dead_obj(obj))) {
- dt_read_unlock(env, obj);
- if (depth > 0)
- lfsck_object_put(env, obj);
- return 0;
- }
-
- rc = dt_xattr_get(env, obj,
- lfsck_buf_get(env, NULL, 0), XATTR_NAME_LINK,
- BYPASS_CAPA);
- dt_read_unlock(env, obj);
- if (rc >= 0) {
- if (depth > 0)
- lfsck_object_put(env, obj);
- return 1;
- }
-
- if (rc < 0 && rc != -ENODATA) {
- if (depth > 0)
- lfsck_object_put(env, obj);
- return rc;
- }
-
- rc = lfsck_parent_fid(env, obj, fid);
- if (depth > 0)
- lfsck_object_put(env, obj);
- if (rc != 0)
- return rc;
-
- if (unlikely(lu_fid_eq(fid, &lfsck->li_local_root_fid)))
- return 0;
-
- obj = lfsck_object_find(env, lfsck, fid);
- if (obj == NULL)
- return 0;
- else if (IS_ERR(obj))
- return PTR_ERR(obj);
-
- if (!dt_object_exists(obj)) {
- lfsck_object_put(env, obj);
- return 0;
- }
-
- if (dt_object_remote(obj)) {
- /* .lustre/lost+found/MDTxxx can be remote directory. */
- if (fid_seq_is_dot_lustre(fid_seq(lfsck_dto2fid(obj))))
- rc = 0;
- else
- /* Other remote directory should be client
- * visible and need to be checked. */
- rc = 1;
- lfsck_object_put(env, obj);
- return rc;
- }
-
- depth++;
- }
- return 0;
-}
-
-struct lfsck_thread_args *lfsck_thread_args_init(struct lfsck_instance *lfsck,
- struct lfsck_component *com,
- struct lfsck_start_param *lsp)
-{
- struct lfsck_thread_args *lta;
- int rc;
-
- OBD_ALLOC_PTR(lta);
- if (lta == NULL)
- return ERR_PTR(-ENOMEM);
-
- rc = lu_env_init(<a->lta_env, LCT_MD_THREAD | LCT_DT_THREAD);
- if (rc != 0) {
- OBD_FREE_PTR(lta);
- return ERR_PTR(rc);
- }
-
- lta->lta_lfsck = lfsck_instance_get(lfsck);
- if (com != NULL)
- lta->lta_com = lfsck_component_get(com);
-
- lta->lta_lsp = lsp;
-
- return lta;
-}
-
-void lfsck_thread_args_fini(struct lfsck_thread_args *lta)
-{
- if (lta->lta_com != NULL)
- lfsck_component_put(<a->lta_env, lta->lta_com);
- lfsck_instance_put(<a->lta_env, lta->lta_lfsck);
- lu_env_fini(<a->lta_env);
- OBD_FREE_PTR(lta);
-}
-
-/* LFSCK wrap functions */
-
-void lfsck_fail(const struct lu_env *env, struct lfsck_instance *lfsck,
- bool new_checked)
-{
- struct lfsck_component *com;
-
- list_for_each_entry(com, &lfsck->li_list_scan, lc_link) {
- com->lc_ops->lfsck_fail(env, com, new_checked);
- }
-}
-
-int lfsck_checkpoint(const struct lu_env *env, struct lfsck_instance *lfsck)
-{
- struct lfsck_component *com;
- int rc = 0;
- int rc1 = 0;
-
- if (likely(cfs_time_beforeq(cfs_time_current(),
- lfsck->li_time_next_checkpoint)))
- return 0;
-
- lfsck_pos_fill(env, lfsck, &lfsck->li_pos_current, false);
- list_for_each_entry(com, &lfsck->li_list_scan, lc_link) {
- rc = com->lc_ops->lfsck_checkpoint(env, com, false);
- if (rc != 0)
- rc1 = rc;
- }
-
- lfsck->li_time_last_checkpoint = cfs_time_current();
- lfsck->li_time_next_checkpoint = lfsck->li_time_last_checkpoint +
- cfs_time_seconds(LFSCK_CHECKPOINT_INTERVAL);
- return rc1 != 0 ? rc1 : rc;
-}
-
-int lfsck_prep(const struct lu_env *env, struct lfsck_instance *lfsck,
- struct lfsck_start_param *lsp)
-{
- struct dt_object *obj = NULL;
- struct lfsck_component *com;
- struct lfsck_component *next;
- struct lfsck_position *pos = NULL;
- const struct dt_it_ops *iops =
- &lfsck->li_obj_oit->do_index_ops->dio_it;
- struct dt_it *di;
- int rc;
- ENTRY;
-
- LASSERT(lfsck->li_obj_dir == NULL);
- LASSERT(lfsck->li_di_dir == NULL);
-
- lfsck->li_current_oit_processed = 0;
- list_for_each_entry_safe(com, next, &lfsck->li_list_scan, lc_link) {
- com->lc_new_checked = 0;
- if (lfsck->li_bookmark_ram.lb_param & LPF_DRYRUN)
- com->lc_journal = 0;
-
- rc = com->lc_ops->lfsck_prep(env, com, lsp);
- if (rc != 0)
- GOTO(out, rc);
-
- if ((pos == NULL) ||
- (!lfsck_pos_is_zero(&com->lc_pos_start) &&
- lfsck_pos_is_eq(pos, &com->lc_pos_start) > 0))
- pos = &com->lc_pos_start;
- }
-
- /* Init otable-based iterator. */
- if (pos == NULL) {
- rc = iops->load(env, lfsck->li_di_oit, 0);
- if (rc > 0) {
- lfsck->li_oit_over = 1;
- rc = 0;
- }
-
- GOTO(out, rc);
- }
-
- rc = iops->load(env, lfsck->li_di_oit, pos->lp_oit_cookie);
- if (rc < 0)
- GOTO(out, rc);
- else if (rc > 0)
- lfsck->li_oit_over = 1;
-
- if (!lfsck->li_master || fid_is_zero(&pos->lp_dir_parent))
- GOTO(out, rc = 0);
+ LWI_ON_SIGNAL_NOOP, NULL);
- /* Find the directory for namespace-based traverse. */
- obj = lfsck_object_find(env, lfsck, &pos->lp_dir_parent);
- if (obj == NULL)
- GOTO(out, rc = 0);
- else if (IS_ERR(obj))
- RETURN(PTR_ERR(obj));
+ l_wait_event(thread->t_ctl_waitq,
+ !thread_is_running(thread),
+ &lwi);
+ lfsck->li_new_scanned = 0;
+ }
+}
- /* XXX: Currently, skip remote object, the consistency for
- * remote object will be processed in LFSCK phase III. */
- if (!dt_object_exists(obj) || dt_object_remote(obj) ||
- unlikely(!S_ISDIR(lfsck_object_type(obj))))
- GOTO(out, rc = 0);
+void lfsck_control_speed_by_self(struct lfsck_component *com)
+{
+ struct lfsck_instance *lfsck = com->lc_lfsck;
+ struct ptlrpc_thread *thread = &lfsck->li_thread;
+ struct l_wait_info lwi;
- if (unlikely(!dt_try_as_dir(env, obj)))
- GOTO(out, rc = -ENOTDIR);
+ if (lfsck->li_sleep_jif > 0 &&
+ com->lc_new_scanned >= lfsck->li_sleep_rate) {
+ lwi = LWI_TIMEOUT_INTR(lfsck->li_sleep_jif, NULL,
+ LWI_ON_SIGNAL_NOOP, NULL);
- /* Init the namespace-based directory traverse. */
- iops = &obj->do_index_ops->dio_it;
- di = iops->init(env, obj, lfsck->li_args_dir, BYPASS_CAPA);
- if (IS_ERR(di))
- GOTO(out, rc = PTR_ERR(di));
+ l_wait_event(thread->t_ctl_waitq,
+ !thread_is_running(thread),
+ &lwi);
+ com->lc_new_scanned = 0;
+ }
+}
- LASSERT(pos->lp_dir_cookie < MDS_DIR_END_OFF);
+static struct lfsck_thread_args *
+lfsck_thread_args_init(struct lfsck_instance *lfsck,
+ struct lfsck_component *com,
+ struct lfsck_start_param *lsp)
+{
+ struct lfsck_thread_args *lta;
+ int rc;
- rc = iops->load(env, di, pos->lp_dir_cookie);
- if ((rc == 0) || (rc > 0 && pos->lp_dir_cookie > 0))
- rc = iops->next(env, di);
- else if (rc > 0)
- rc = 0;
+ OBD_ALLOC_PTR(lta);
+ if (lta == NULL)
+ return ERR_PTR(-ENOMEM);
+ rc = lu_env_init(<a->lta_env, LCT_MD_THREAD | LCT_DT_THREAD);
if (rc != 0) {
- iops->put(env, di);
- iops->fini(env, di);
- GOTO(out, rc);
+ OBD_FREE_PTR(lta);
+ return ERR_PTR(rc);
}
- lfsck->li_obj_dir = lfsck_object_get(obj);
- lfsck->li_cookie_dir = iops->store(env, di);
- spin_lock(&lfsck->li_lock);
- lfsck->li_di_dir = di;
- spin_unlock(&lfsck->li_lock);
+ lta->lta_lfsck = lfsck_instance_get(lfsck);
+ if (com != NULL)
+ lta->lta_com = lfsck_component_get(com);
- GOTO(out, rc = 0);
+ lta->lta_lsp = lsp;
-out:
- if (obj != NULL)
- lfsck_object_put(env, obj);
+ return lta;
+}
- if (rc < 0) {
- list_for_each_entry_safe(com, next, &lfsck->li_list_scan,
- lc_link)
- com->lc_ops->lfsck_post(env, com, rc, true);
+void lfsck_thread_args_fini(struct lfsck_thread_args *lta)
+{
+ if (lta->lta_com != NULL)
+ lfsck_component_put(<a->lta_env, lta->lta_com);
+ lfsck_instance_put(<a->lta_env, lta->lta_lfsck);
+ lu_env_fini(<a->lta_env);
+ OBD_FREE_PTR(lta);
+}
- return rc;
- }
+struct lfsck_assistant_data *
+lfsck_assistant_data_init(struct lfsck_assistant_operations *lao,
+ const char *name)
+{
+ struct lfsck_assistant_data *lad;
+
+ OBD_ALLOC_PTR(lad);
+ if (lad != NULL) {
+ lad->lad_bitmap = CFS_ALLOCATE_BITMAP(BITS_PER_LONG);
+ if (lad->lad_bitmap == NULL) {
+ OBD_FREE_PTR(lad);
+ return NULL;
+ }
- rc = 0;
- lfsck_pos_fill(env, lfsck, &lfsck->li_pos_current, true);
- list_for_each_entry(com, &lfsck->li_list_scan, lc_link) {
- rc = com->lc_ops->lfsck_checkpoint(env, com, true);
- if (rc != 0)
- break;
+ INIT_LIST_HEAD(&lad->lad_req_list);
+ spin_lock_init(&lad->lad_lock);
+ INIT_LIST_HEAD(&lad->lad_ost_list);
+ INIT_LIST_HEAD(&lad->lad_ost_phase1_list);
+ INIT_LIST_HEAD(&lad->lad_ost_phase2_list);
+ INIT_LIST_HEAD(&lad->lad_mdt_list);
+ INIT_LIST_HEAD(&lad->lad_mdt_phase1_list);
+ INIT_LIST_HEAD(&lad->lad_mdt_phase2_list);
+ init_waitqueue_head(&lad->lad_thread.t_ctl_waitq);
+ lad->lad_ops = lao;
+ lad->lad_name = name;
}
- lfsck->li_time_last_checkpoint = cfs_time_current();
- lfsck->li_time_next_checkpoint = lfsck->li_time_last_checkpoint +
- cfs_time_seconds(LFSCK_CHECKPOINT_INTERVAL);
- return rc;
+ return lad;
}
-int lfsck_exec_oit(const struct lu_env *env, struct lfsck_instance *lfsck,
- struct dt_object *obj)
+/**
+ * Generic LFSCK asynchronous communication interpretor function.
+ * The LFSCK RPC reply for both the event notification and status
+ * querying will be handled here.
+ *
+ * \param[in] env pointer to the thread context
+ * \param[in] req pointer to the LFSCK request
+ * \param[in] args pointer to the lfsck_async_interpret_args
+ * \param[in] rc the result for handling the LFSCK request
+ *
+ * \retval 0 for success
+ * \retval negative error number on failure
+ */
+int lfsck_async_interpret_common(const struct lu_env *env,
+ struct ptlrpc_request *req,
+ void *args, int rc)
{
- struct lfsck_component *com;
- const struct dt_it_ops *iops;
- struct dt_it *di;
- int rc;
- ENTRY;
-
- LASSERT(lfsck->li_obj_dir == NULL);
+ struct lfsck_async_interpret_args *laia = args;
+ struct lfsck_component *com = laia->laia_com;
+ struct lfsck_assistant_data *lad = com->lc_data;
+ struct lfsck_tgt_descs *ltds = laia->laia_ltds;
+ struct lfsck_tgt_desc *ltd = laia->laia_ltd;
+ struct lfsck_request *lr = laia->laia_lr;
- list_for_each_entry(com, &lfsck->li_list_scan, lc_link) {
- rc = com->lc_ops->lfsck_exec_oit(env, com, obj);
- if (rc != 0)
- RETURN(rc);
- }
+ LASSERT(com->lc_lfsck->li_master);
- rc = lfsck_needs_scan_dir(env, lfsck, obj);
- if (rc <= 0)
- GOTO(out, rc);
+ switch (lr->lr_event) {
+ case LE_START:
+ if (rc != 0) {
+ CDEBUG(D_LFSCK, "%s: fail to notify %s %x for %s "
+ "start: rc = %d\n",
+ lfsck_lfsck2name(com->lc_lfsck),
+ (lr->lr_flags & LEF_TO_OST) ? "OST" : "MDT",
+ ltd->ltd_index, lad->lad_name, rc);
+
+ if (com->lc_type == LFSCK_TYPE_LAYOUT) {
+ struct lfsck_layout *lo = com->lc_file_ram;
+
+ if (lr->lr_flags & LEF_TO_OST)
+ lfsck_lad_set_bitmap(env, com,
+ ltd->ltd_index);
+ else
+ lo->ll_flags |= LF_INCOMPLETE;
+ } else {
+ struct lfsck_namespace *ns = com->lc_file_ram;
+
+ /* If some MDT does not join the namespace
+ * LFSCK, then we cannot know whether there
+ * is some name entry on such MDT that with
+ * the referenced MDT-object on this MDT or
+ * not. So the namespace LFSCK on this MDT
+ * cannot handle orphan MDT-objects properly.
+ * So we mark the LFSCK as LF_INCOMPLETE and
+ * skip orphan MDT-objects handling. */
+ ns->ln_flags |= LF_INCOMPLETE;
+ }
+ break;
+ }
- if (unlikely(!dt_try_as_dir(env, obj)))
- GOTO(out, rc = -ENOTDIR);
+ spin_lock(<ds->ltd_lock);
+ if (ltd->ltd_dead) {
+ spin_unlock(<ds->ltd_lock);
+ break;
+ }
- iops = &obj->do_index_ops->dio_it;
- di = iops->init(env, obj, lfsck->li_args_dir, BYPASS_CAPA);
- if (IS_ERR(di))
- GOTO(out, rc = PTR_ERR(di));
+ if (com->lc_type == LFSCK_TYPE_LAYOUT) {
+ struct list_head *list;
+ struct list_head *phase_list;
- rc = iops->load(env, di, 0);
- if (rc == 0)
- rc = iops->next(env, di);
- else if (rc > 0)
- rc = 0;
+ if (ltd->ltd_layout_done) {
+ spin_unlock(<ds->ltd_lock);
+ break;
+ }
- if (rc != 0) {
- iops->put(env, di);
- iops->fini(env, di);
- GOTO(out, rc);
- }
+ if (lr->lr_flags & LEF_TO_OST) {
+ list = &lad->lad_ost_list;
+ phase_list = &lad->lad_ost_phase1_list;
+ } else {
+ list = &lad->lad_mdt_list;
+ phase_list = &lad->lad_mdt_phase1_list;
+ }
- lfsck->li_obj_dir = lfsck_object_get(obj);
- lfsck->li_cookie_dir = iops->store(env, di);
- spin_lock(&lfsck->li_lock);
- lfsck->li_di_dir = di;
- spin_unlock(&lfsck->li_lock);
+ if (list_empty(<d->ltd_layout_list))
+ list_add_tail(<d->ltd_layout_list, list);
+ if (list_empty(<d->ltd_layout_phase_list))
+ list_add_tail(<d->ltd_layout_phase_list,
+ phase_list);
+ } else {
+ if (ltd->ltd_namespace_done) {
+ spin_unlock(<ds->ltd_lock);
+ break;
+ }
- GOTO(out, rc = 0);
+ if (list_empty(<d->ltd_namespace_list))
+ list_add_tail(<d->ltd_namespace_list,
+ &lad->lad_mdt_list);
+ if (list_empty(<d->ltd_namespace_phase_list))
+ list_add_tail(<d->ltd_namespace_phase_list,
+ &lad->lad_mdt_phase1_list);
+ }
+ spin_unlock(<ds->ltd_lock);
+ break;
+ case LE_STOP:
+ case LE_PHASE1_DONE:
+ case LE_PHASE2_DONE:
+ case LE_PEER_EXIT:
+ if (rc != 0 && rc != -EALREADY)
+ CDEBUG(D_LFSCK, "%s: fail to notify %s %x for %s: "
+ "event = %d, rc = %d\n",
+ lfsck_lfsck2name(com->lc_lfsck),
+ (lr->lr_flags & LEF_TO_OST) ? "OST" : "MDT",
+ ltd->ltd_index, lad->lad_name, lr->lr_event, rc);
+ break;
+ case LE_QUERY: {
+ struct lfsck_reply *reply;
+ struct list_head *list;
+ struct list_head *phase_list;
+
+ if (com->lc_type == LFSCK_TYPE_LAYOUT) {
+ list = <d->ltd_layout_list;
+ phase_list = <d->ltd_layout_phase_list;
+ } else {
+ list = <d->ltd_namespace_list;
+ phase_list = <d->ltd_namespace_phase_list;
+ }
-out:
- if (rc < 0)
- lfsck_fail(env, lfsck, false);
- return (rc > 0 ? 0 : rc);
-}
+ if (rc != 0) {
+ spin_lock(<ds->ltd_lock);
+ list_del_init(phase_list);
+ list_del_init(list);
+ spin_unlock(<ds->ltd_lock);
+ break;
+ }
-int lfsck_exec_dir(const struct lu_env *env, struct lfsck_instance *lfsck,
- struct dt_object *obj, struct lu_dirent *ent)
-{
- struct lfsck_component *com;
- int rc;
+ reply = req_capsule_server_get(&req->rq_pill,
+ &RMF_LFSCK_REPLY);
+ if (reply == NULL) {
+ rc = -EPROTO;
+ CDEBUG(D_LFSCK, "%s: invalid query reply for %s: "
+ "rc = %d\n", lfsck_lfsck2name(com->lc_lfsck),
+ lad->lad_name, rc);
+ spin_lock(<ds->ltd_lock);
+ list_del_init(phase_list);
+ list_del_init(list);
+ spin_unlock(<ds->ltd_lock);
+ break;
+ }
- list_for_each_entry(com, &lfsck->li_list_scan, lc_link) {
- rc = com->lc_ops->lfsck_exec_dir(env, com, obj, ent);
- if (rc != 0)
- return rc;
- }
- return 0;
-}
+ switch (reply->lr_status) {
+ case LS_SCANNING_PHASE1:
+ break;
+ case LS_SCANNING_PHASE2:
+ spin_lock(<ds->ltd_lock);
+ list_del_init(phase_list);
+ if (ltd->ltd_dead) {
+ spin_unlock(<ds->ltd_lock);
+ break;
+ }
-int lfsck_post(const struct lu_env *env, struct lfsck_instance *lfsck,
- int result)
-{
- struct lfsck_component *com;
- struct lfsck_component *next;
- int rc = 0;
- int rc1 = 0;
+ if (com->lc_type == LFSCK_TYPE_LAYOUT) {
+ if (ltd->ltd_layout_done) {
+ spin_unlock(<ds->ltd_lock);
+ break;
+ }
+
+ if (lr->lr_flags & LEF_TO_OST)
+ list_add_tail(phase_list,
+ &lad->lad_ost_phase2_list);
+ else
+ list_add_tail(phase_list,
+ &lad->lad_mdt_phase2_list);
+ } else {
+ if (ltd->ltd_namespace_done) {
+ spin_unlock(<ds->ltd_lock);
+ break;
+ }
- lfsck_pos_fill(env, lfsck, &lfsck->li_pos_current, false);
- list_for_each_entry_safe(com, next, &lfsck->li_list_scan, lc_link) {
- rc = com->lc_ops->lfsck_post(env, com, result, false);
- if (rc != 0)
- rc1 = rc;
+ list_add_tail(phase_list,
+ &lad->lad_mdt_phase2_list);
+ }
+ spin_unlock(<ds->ltd_lock);
+ break;
+ default:
+ spin_lock(<ds->ltd_lock);
+ list_del_init(phase_list);
+ list_del_init(list);
+ spin_unlock(<ds->ltd_lock);
+ break;
+ }
+ break;
+ }
+ default:
+ CDEBUG(D_LFSCK, "%s: unexpected event: rc = %d\n",
+ lfsck_lfsck2name(com->lc_lfsck), lr->lr_event);
+ break;
}
- lfsck->li_time_last_checkpoint = cfs_time_current();
- lfsck->li_time_next_checkpoint = lfsck->li_time_last_checkpoint +
- cfs_time_seconds(LFSCK_CHECKPOINT_INTERVAL);
+ if (!laia->laia_shared) {
+ lfsck_tgt_put(ltd);
+ lfsck_component_put(env, com);
+ }
- /* Ignore some component post failure to make other can go ahead. */
- return result;
+ return 0;
}
static void lfsck_interpret(const struct lu_env *env,
spin_lock(&lfsck->li_lock);
list_for_each_entry(com, &lfsck->li_list_scan, lc_link) {
- if (com->lc_ops->lfsck_interpret != NULL) {
- laia->laia_com = com;
- com->lc_ops->lfsck_interpret(env, req, laia, result);
- }
+ laia->laia_com = com;
+ lfsck_async_interpret_common(env, req, laia, result);
}
list_for_each_entry(com, &lfsck->li_list_double_scan, lc_link) {
- if (com->lc_ops->lfsck_interpret != NULL) {
- laia->laia_com = com;
- com->lc_ops->lfsck_interpret(env, req, laia, result);
- }
+ laia->laia_com = com;
+ lfsck_async_interpret_common(env, req, laia, result);
}
spin_unlock(&lfsck->li_lock);
}
-int lfsck_double_scan(const struct lu_env *env, struct lfsck_instance *lfsck)
-{
- struct lfsck_component *com;
- struct lfsck_component *next;
- struct l_wait_info lwi = { 0 };
- int rc = 0;
- int rc1 = 0;
-
- list_for_each_entry(com, &lfsck->li_list_double_scan, lc_link) {
- if (lfsck->li_bookmark_ram.lb_param & LPF_DRYRUN)
- com->lc_journal = 0;
-
- rc = com->lc_ops->lfsck_double_scan(env, com);
- if (rc != 0)
- rc1 = rc;
- }
-
- l_wait_event(lfsck->li_thread.t_ctl_waitq,
- atomic_read(&lfsck->li_double_scan_count) == 0,
- &lwi);
-
- if (lfsck->li_status != LS_PAUSED &&
- lfsck->li_status != LS_CO_PAUSED) {
- list_for_each_entry_safe(com, next, &lfsck->li_list_double_scan,
- lc_link) {
- spin_lock(&lfsck->li_lock);
- list_move_tail(&com->lc_link, &lfsck->li_list_idle);
- spin_unlock(&lfsck->li_lock);
- }
- }
-
- return rc1 != 0 ? rc1 : rc;
-}
-
static int lfsck_stop_notify(const struct lu_env *env,
struct lfsck_instance *lfsck,
struct lfsck_tgt_descs *ltds,
struct lfsck_tgt_desc *ltd, __u16 type)
{
- struct ptlrpc_request_set *set;
- struct lfsck_component *com;
- int rc = 0;
+ struct lfsck_component *com;
+ int rc = 0;
ENTRY;
+ LASSERT(lfsck->li_master);
+
spin_lock(&lfsck->li_lock);
com = __lfsck_component_find(lfsck, type, &lfsck->li_list_scan);
if (com == NULL)
spin_unlock(&lfsck->li_lock);
if (com != NULL) {
- if (com->lc_ops->lfsck_stop_notify != NULL) {
- set = ptlrpc_prep_set();
- if (set == NULL) {
- lfsck_component_put(env, com);
+ struct lfsck_thread_info *info = lfsck_env_info(env);
+ struct lfsck_async_interpret_args *laia = &info->lti_laia;
+ struct lfsck_request *lr = &info->lti_lr;
+ struct lfsck_assistant_data *lad = com->lc_data;
+ struct list_head *list;
+ struct list_head *phase_list;
+ struct ptlrpc_request_set *set;
+
+ set = ptlrpc_prep_set();
+ if (set == NULL) {
+ lfsck_component_put(env, com);
- RETURN(-ENOMEM);
- }
+ RETURN(-ENOMEM);
+ }
- rc = com->lc_ops->lfsck_stop_notify(env, com, ltds,
- ltd, set);
- if (rc == 0)
- rc = ptlrpc_set_wait(set);
+ if (type == LFSCK_TYPE_LAYOUT) {
+ list = <d->ltd_layout_list;
+ phase_list = <d->ltd_layout_phase_list;
+ } else {
+ list = <d->ltd_namespace_list;
+ phase_list = <d->ltd_namespace_phase_list;
+ }
+ spin_lock(<ds->ltd_lock);
+ if (list_empty(list)) {
+ LASSERT(list_empty(phase_list));
+ spin_unlock(<ds->ltd_lock);
ptlrpc_set_destroy(set);
- }
- lfsck_component_put(env, com);
- }
+ RETURN(0);
+ }
- RETURN(rc);
-}
+ list_del_init(phase_list);
+ list_del_init(list);
+ spin_unlock(<ds->ltd_lock);
-void lfsck_quit(const struct lu_env *env, struct lfsck_instance *lfsck)
-{
- struct lfsck_component *com;
- struct lfsck_component *next;
+ memset(lr, 0, sizeof(*lr));
+ lr->lr_index = lfsck_dev_idx(lfsck->li_bottom);
+ lr->lr_event = LE_PEER_EXIT;
+ lr->lr_active = type;
+ lr->lr_status = LS_CO_PAUSED;
+ if (ltds == &lfsck->li_ost_descs)
+ lr->lr_flags = LEF_TO_OST;
+
+ laia->laia_com = com;
+ laia->laia_ltds = ltds;
+ atomic_inc(<d->ltd_ref);
+ laia->laia_ltd = ltd;
+ laia->laia_lr = lr;
+ laia->laia_shared = 0;
- list_for_each_entry_safe(com, next, &lfsck->li_list_scan,
- lc_link) {
- if (com->lc_ops->lfsck_quit != NULL)
- com->lc_ops->lfsck_quit(env, com);
+ rc = lfsck_async_request(env, ltd->ltd_exp, lr, set,
+ lfsck_async_interpret_common,
+ laia, LFSCK_NOTIFY);
+ if (rc != 0) {
+ CDEBUG(D_LFSCK, "%s: fail to notify %s %x for "
+ "co-stop for %s: rc = %d\n",
+ lfsck_lfsck2name(lfsck),
+ (lr->lr_flags & LEF_TO_OST) ? "OST" : "MDT",
+ ltd->ltd_index, lad->lad_name, rc);
+ lfsck_tgt_put(ltd);
+ } else {
+ rc = ptlrpc_set_wait(set);
+ }
- spin_lock(&lfsck->li_lock);
- list_del_init(&com->lc_link_dir);
- list_move_tail(&com->lc_link, &lfsck->li_list_idle);
- spin_unlock(&lfsck->li_lock);
+ ptlrpc_set_destroy(set);
+ lfsck_component_put(env, com);
}
- list_for_each_entry_safe(com, next, &lfsck->li_list_double_scan,
- lc_link) {
- if (com->lc_ops->lfsck_quit != NULL)
- com->lc_ops->lfsck_quit(env, com);
-
- spin_lock(&lfsck->li_lock);
- list_move_tail(&com->lc_link, &lfsck->li_list_idle);
- spin_unlock(&lfsck->li_lock);
- }
+ RETURN(rc);
}
static int lfsck_async_interpret(const struct lu_env *env,
return 0;
}
+int lfsck_start_assistant(const struct lu_env *env, struct lfsck_component *com,
+ struct lfsck_start_param *lsp)
+{
+ struct lfsck_instance *lfsck = com->lc_lfsck;
+ struct lfsck_assistant_data *lad = com->lc_data;
+ struct ptlrpc_thread *mthread = &lfsck->li_thread;
+ struct ptlrpc_thread *athread = &lad->lad_thread;
+ struct lfsck_thread_args *lta;
+ struct task_struct *task;
+ int rc;
+ ENTRY;
+
+ lad->lad_assistant_status = 0;
+ lad->lad_post_result = 0;
+ lad->lad_to_post = 0;
+ lad->lad_to_double_scan = 0;
+ lad->lad_in_double_scan = 0;
+ lad->lad_exit = 0;
+ thread_set_flags(athread, 0);
+
+ lta = lfsck_thread_args_init(lfsck, com, lsp);
+ if (IS_ERR(lta))
+ RETURN(PTR_ERR(lta));
+
+ task = kthread_run(lfsck_assistant_engine, lta, lad->lad_name);
+ if (IS_ERR(task)) {
+ rc = PTR_ERR(task);
+ CERROR("%s: cannot start LFSCK assistant thread for %s: "
+ "rc = %d\n", lfsck_lfsck2name(lfsck), lad->lad_name, rc);
+ lfsck_thread_args_fini(lta);
+ } else {
+ struct l_wait_info lwi = { 0 };
+
+ l_wait_event(mthread->t_ctl_waitq,
+ thread_is_running(athread) ||
+ thread_is_stopped(athread),
+ &lwi);
+ if (unlikely(!thread_is_running(athread)))
+ rc = lad->lad_assistant_status;
+ else
+ rc = 0;
+ }
+
+ RETURN(rc);
+}
+
+int lfsck_checkpoint_generic(const struct lu_env *env,
+ struct lfsck_component *com)
+{
+ struct lfsck_assistant_data *lad = com->lc_data;
+ struct ptlrpc_thread *mthread = &com->lc_lfsck->li_thread;
+ struct ptlrpc_thread *athread = &lad->lad_thread;
+ struct l_wait_info lwi = { 0 };
+
+ if (com->lc_new_checked == 0)
+ return LFSCK_CHECKPOINT_SKIP;
+
+ l_wait_event(mthread->t_ctl_waitq,
+ list_empty(&lad->lad_req_list) ||
+ !thread_is_running(mthread) ||
+ thread_is_stopped(athread),
+ &lwi);
+
+ if (!thread_is_running(mthread) || thread_is_stopped(athread))
+ return LFSCK_CHECKPOINT_SKIP;
+
+ return 0;
+}
+
+void lfsck_post_generic(const struct lu_env *env,
+ struct lfsck_component *com, int *result)
+{
+ struct lfsck_assistant_data *lad = com->lc_data;
+ struct ptlrpc_thread *athread = &lad->lad_thread;
+ struct ptlrpc_thread *mthread = &com->lc_lfsck->li_thread;
+ struct l_wait_info lwi = { 0 };
+
+ lad->lad_post_result = *result;
+ if (*result <= 0)
+ lad->lad_exit = 1;
+ lad->lad_to_post = 1;
+
+ wake_up_all(&athread->t_ctl_waitq);
+ l_wait_event(mthread->t_ctl_waitq,
+ (*result > 0 && list_empty(&lad->lad_req_list)) ||
+ thread_is_stopped(athread),
+ &lwi);
+
+ if (lad->lad_assistant_status < 0)
+ *result = lad->lad_assistant_status;
+}
+
+int lfsck_double_scan_generic(const struct lu_env *env,
+ struct lfsck_component *com, int status)
+{
+ struct lfsck_assistant_data *lad = com->lc_data;
+ struct ptlrpc_thread *mthread = &com->lc_lfsck->li_thread;
+ struct ptlrpc_thread *athread = &lad->lad_thread;
+ struct l_wait_info lwi = { 0 };
+
+ if (status != LS_SCANNING_PHASE2)
+ lad->lad_exit = 1;
+ else
+ lad->lad_to_double_scan = 1;
+
+ wake_up_all(&athread->t_ctl_waitq);
+ l_wait_event(mthread->t_ctl_waitq,
+ lad->lad_in_double_scan ||
+ thread_is_stopped(athread),
+ &lwi);
+
+ if (lad->lad_assistant_status < 0)
+ return lad->lad_assistant_status;
+
+ return 0;
+}
+
+void lfsck_quit_generic(const struct lu_env *env,
+ struct lfsck_component *com)
+{
+ struct lfsck_assistant_data *lad = com->lc_data;
+ struct ptlrpc_thread *mthread = &com->lc_lfsck->li_thread;
+ struct ptlrpc_thread *athread = &lad->lad_thread;
+ struct l_wait_info lwi = { 0 };
+
+ lad->lad_exit = 1;
+ wake_up_all(&athread->t_ctl_waitq);
+ l_wait_event(mthread->t_ctl_waitq,
+ thread_is_init(athread) ||
+ thread_is_stopped(athread),
+ &lwi);
+}
+
/* external interfaces */
int lfsck_get_speed(struct seq_file *m, struct dt_device *key)
lr->lr_param = start->ls_flags;
lr->lr_async_windows = bk->lb_async_windows;
lr->lr_valid = LSV_SPEED_LIMIT | LSV_ERROR_HANDLE | LSV_DRYRUN |
- LSV_ASYNC_WINDOWS;
+ LSV_ASYNC_WINDOWS | LSV_CREATE_OSTOBJ |
+ LSV_CREATE_MDTOBJ;
laia->laia_com = NULL;
laia->laia_ltds = ltds;
laia->laia_ltd = ltd;
ltd->ltd_layout_done = 0;
+ ltd->ltd_namespace_done = 0;
rc = lfsck_async_request(env, ltd->ltd_exp, lr, set,
lfsck_async_interpret, laia,
LFSCK_NOTIFY);
}
trigger:
- lfsck->li_args_dir = LUDA_64BITHASH | LUDA_VERIFY;
+ lfsck->li_args_dir = LUDA_64BITHASH | LUDA_VERIFY | LUDA_TYPE;
if (bk->lb_param & LPF_DRYRUN)
lfsck->li_args_dir |= LUDA_VERIFY_DRYRUN;
EXPORT_SYMBOL(lfsck_stop);
int lfsck_in_notify(const struct lu_env *env, struct dt_device *key,
- struct lfsck_request *lr)
+ struct lfsck_request *lr, struct thandle *th)
{
int rc = -EOPNOTSUPP;
ENTRY;
case LE_FID_ACCESSED:
case LE_PEER_EXIT:
case LE_CONDITIONAL_DESTROY:
+ case LE_SKIP_NLINK_DECLARE:
+ case LE_SKIP_NLINK:
+ case LE_SET_LMV_MASTER:
+ case LE_SET_LMV_SLAVE:
case LE_PAIRS_VERIFY: {
struct lfsck_instance *lfsck;
struct lfsck_component *com;
com = lfsck_component_find(lfsck, lr->lr_active);
if (likely(com != NULL)) {
- rc = com->lc_ops->lfsck_in_notify(env, com, lr);
+ rc = com->lc_ops->lfsck_in_notify(env, com, lr, th);
lfsck_component_put(env, com);
}
INIT_LIST_HEAD(&lfsck->li_list_dir);
INIT_LIST_HEAD(&lfsck->li_list_double_scan);
INIT_LIST_HEAD(&lfsck->li_list_idle);
+ INIT_LIST_HEAD(&lfsck->li_list_lmv);
atomic_set(&lfsck->li_ref, 1);
atomic_set(&lfsck->li_double_scan_count, 0);
init_waitqueue_head(&lfsck->li_thread.t_ctl_waitq);
if (IS_ERR(obj))
GOTO(out, rc = PTR_ERR(obj));
+ if (unlikely(!dt_try_as_dir(env, obj)))
+ GOTO(out, rc = -ENOTDIR);
+
rc = dt_lookup(env, obj, (struct dt_rec *)fid,
(const struct dt_key *)dotlustre, BYPASS_CAPA);
if (rc != 0)
if (rc != 0)
GOTO(out, rc);
+ if (unlikely(!dt_try_as_dir(env, obj)))
+ GOTO(out, rc = -ENOTDIR);
+
*pfid = *fid;
rc = dt_lookup(env, obj, (struct dt_rec *)fid,
(const struct dt_key *)lostfound,
INIT_LIST_HEAD(<d->ltd_orphan_list);
INIT_LIST_HEAD(<d->ltd_layout_list);
INIT_LIST_HEAD(<d->ltd_layout_phase_list);
+ INIT_LIST_HEAD(<d->ltd_namespace_list);
+ INIT_LIST_HEAD(<d->ltd_namespace_phase_list);
atomic_set(<d->ltd_ref, 1);
ltd->ltd_index = index;
spin_lock(<ds->ltd_lock);
ltd->ltd_dead = 1;
spin_unlock(<ds->ltd_lock);
+ lfsck_stop_notify(env, lfsck, ltds, ltd, LFSCK_TYPE_NAMESPACE);
lfsck_stop_notify(env, lfsck, ltds, ltd, LFSCK_TYPE_LAYOUT);
lfsck_tgt_put(ltd);
}