struct lfsck_assistant_req *lar)
{
struct lfsck_namespace_req *lnr =
- container_of0(lar, struct lfsck_namespace_req, lnr_lar);
+ container_of(lar, struct lfsck_namespace_req, lnr_lar);
if (lnr->lnr_lmv != NULL)
lfsck_lmv_put(env, lnr->lnr_lmv);
if (unlikely(lfsck_is_dead_obj(obj)))
RETURN(LFSCK_NAMEENTRY_DEAD);
- rc = dt_lookup(env, dir, (struct dt_rec *)fid,
- (const struct dt_key *)name);
+ rc = dt_lookup_dir(env, dir, name, fid);
if (rc == -ENOENT)
RETURN(LFSCK_NAMEENTRY_REMOVED);
do {
namelen = snprintf(info->lti_key, NAME_MAX, DFID"%s-%s-%d",
PFID(cfid), infix, type, idx++);
- rc = dt_lookup(env, parent, (struct dt_rec *)&tfid,
- (const struct dt_key *)info->lti_key);
+ rc = dt_lookup_dir(env, parent, info->lti_key, &tfid);
if (rc != 0 && rc != -ENOENT)
GOTO(log, rc);
/* Re-check whether the name conflict with othrs after taken
* the ldlm lock. */
- rc = dt_lookup(env, parent, (struct dt_rec *)&tfid,
- (const struct dt_key *)info->lti_key);
+ rc = dt_lookup_dir(env, parent, info->lti_key, &tfid);
if (rc == 0) {
if (!lu_fid_eq(cfid, &tfid)) {
exist = false;
if (IS_ERR(th))
RETURN(PTR_ERR(th));
- rc = dt_declare_xattr_set(env, obj, &buf, XATTR_NAME_LMV".set", 0, th);
+ rc = dt_declare_xattr_set(env, obj, &buf, XATTR_NAME_LMV, 0, th);
if (rc)
GOTO(stop, rc);
if (rc != 0)
GOTO(stop, rc);
- rc = dt_xattr_set(env, obj, &buf, XATTR_NAME_LMV".set", 0, th);
+ rc = dt_xattr_set(env, obj, &buf, XATTR_NAME_LMV, 0, th);
if (rc)
GOTO(stop, rc);
}
if (parent_lmv_lost) {
- rc = dt_declare_xattr_set(env, parent, &buf,
- XATTR_NAME_LMV".set", 0, th);
+ rc = dt_declare_xattr_set(env, parent, &buf, XATTR_NAME_LMV,
+ 0, th);
if (rc)
GOTO(stop, rc);
}
}
if (parent_lmv_lost) {
- rc = dt_xattr_set(env, parent, &buf, XATTR_NAME_LMV".set", 0,
- th);
+ rc = dt_xattr_set(env, parent, &buf, XATTR_NAME_LMV, 0, th);
if (rc)
GOTO(stop, rc);
}
GOTO(log, rc = idx);
snprintf(name, 8, "MDT%04x", idx);
- rc = dt_lookup(env, lfsck->li_lpf_root_obj,
- (struct dt_rec *)&tfid,
- (const struct dt_key *)name);
+ rc = dt_lookup_dir(env, lfsck->li_lpf_root_obj, name, &tfid);
if (rc != 0)
GOTO(log, rc = (rc == -ENOENT ? -ENXIO : rc));
do {
namelen = snprintf(name, 31, DFID"-P-%d",
PFID(cfid), idx++);
- rc = dt_lookup(env, parent, (struct dt_rec *)&tfid,
- (const struct dt_key *)name);
+ rc = dt_lookup_dir(env, parent, name, &tfid);
if (rc != 0 && rc != -ENOENT)
GOTO(log, rc);
} while (rc == 0);
/* Re-check whether the name conflict with othrs after taken
* the ldlm lock. */
- rc = dt_lookup(env, parent, (struct dt_rec *)&tfid,
- (const struct dt_key *)name);
+ rc = dt_lookup_dir(env, parent, name, &tfid);
if (unlikely(rc == 0)) {
lfsck_unlock(llh);
goto again;
lmv->lmv_master_mdt_index = lfsck_dev_idx(lfsck);
lfsck_lmv_header_cpu_to_le(lmv2, lmv);
lfsck_buf_init(&lmv_buf, lmv2, sizeof(*lmv2));
- rc = dt_declare_xattr_set(env, orphan, &lmv_buf,
- XATTR_NAME_LMV, 0, th);
+ rc = dt_declare_xattr_set(env, orphan, &lmv_buf, XATTR_NAME_LMV,
+ 0, th);
if (rc != 0)
GOTO(stop, rc);
}
goto replace;
}
- rc = dt_lookup(env, parent, (struct dt_rec *)&tfid,
- (const struct dt_key *)name);
+ rc = dt_lookup_dir(env, parent, name, &tfid);
if (rc == -ENOENT) {
exist = false;
goto replace;
dt_write_lock(env, parent, 0);
- rc = dt_lookup(env, parent, (struct dt_rec *)&tfid,
- (const struct dt_key *)name);
+ rc = dt_lookup_dir(env, dt_object_child(parent), name, &tfid);
/* Someone has removed the bad name entry by race. */
if (rc == -ENOENT)
GOTO(unlock2, rc = 0);
GOTO(out, rc);
}
- rc = dt_lookup(env, parent, (struct dt_rec *)&tfid,
- (const struct dt_key *)cname->ln_name);
+ rc = dt_lookup_dir(env, parent, cname->ln_name, &tfid);
if (rc == -ENOENT) {
/* If the LFSCK is marked as LF_INCOMPLETE, then means some MDT
* has ever tried to verify some remote MDT-object that resides
continue;
}
- rc = dt_lookup(env, parent, (struct dt_rec *)&tfid,
- (const struct dt_key *)cname->ln_name);
+ rc = dt_lookup_dir(env, parent, cname->ln_name, &tfid);
*pfid2 = *lfsck_dto2fid(parent);
if (rc == -ENOENT) {
lfsck_object_put(env, parent);
if (flags & (LNTF_CHECK_LINKEA | LNTF_CHECK_PARENT) &&
!(lfsck->li_bookmark_ram.lb_param & LPF_ALL_TGT)) {
- CDEBUG(D_LFSCK, "%s: some MDT(s) maybe NOT take part in the"
- "the namespace LFSCK, then the LFSCK cannot guarantee"
- "all the name entries have been verified in first-stage"
- "scanning. So have to skip orphan related handling for"
- "the directory object "DFID" with remote name entry\n",
+ CDEBUG(D_LFSCK,
+ "%s: some MDT(s) maybe NOT take part in the the namespace LFSCK, then the LFSCK cannot guarantee all the name entries have been verified in first-stage scanning. So have to skip orphan related handling for the directory object "DFID" with remote name entry\n",
lfsck_lfsck2name(lfsck), PFID(cfid));
RETURN(0);
GOTO(out, rc = 0);
}
- rc = dt_lookup(env, child, (struct dt_rec *)pfid,
- (const struct dt_key *)dotdot);
+ rc = dt_lookup_dir(env, child, dotdot, pfid);
if (rc != 0) {
if (rc != -ENOENT && rc != -ENODATA && rc != -EINVAL) {
dt_read_unlock(env, child);
continue;
}
- rc = dt_lookup(env, parent, (struct dt_rec *)cfid,
- (const struct dt_key *)cname->ln_name);
+ rc = dt_lookup_dir(env, parent, cname->ln_name, cfid);
if (rc != 0 && rc != -ENOENT) {
lfsck_object_put(env, parent);
struct lfsck_component *com,
struct dt_object *obj)
{
- struct lfsck_thread_info *info = lfsck_env_info(env);
- struct lfsck_namespace *ns = com->lc_file_ram;
- struct lfsck_instance *lfsck = com->lc_lfsck;
- const struct lu_fid *fid = lfsck_dto2fid(obj);
- struct lu_fid *pfid = &info->lti_fid2;
- struct lu_name *cname = &info->lti_name;
- struct lu_seq_range *range = &info->lti_range;
- struct seq_server_site *ss = lfsck_dev_site(lfsck);
- struct linkea_data ldata = { NULL };
- __u32 idx = lfsck_dev_idx(lfsck);
- int rc;
+ struct lfsck_thread_info *info = lfsck_env_info(env);
+ struct lfsck_namespace *ns = com->lc_file_ram;
+ struct lfsck_instance *lfsck = com->lc_lfsck;
+ const struct lu_fid *fid = lfsck_dto2fid(obj);
+ struct lu_fid *pfid = &info->lti_fid2;
+ struct lu_name *cname = &info->lti_name;
+ struct lu_seq_range *range = &info->lti_range;
+ struct seq_server_site *ss = lfsck_dev_site(lfsck);
+ struct linkea_data ldata = { NULL };
+ __u32 idx = lfsck_dev_idx(lfsck);
+ struct lu_attr la = { .la_valid = 0 };
bool remote = false;
+ int rc;
ENTRY;
+ rc = dt_attr_get(env, obj, &la);
+ if (unlikely(rc || (la.la_valid & LA_FLAGS &&
+ la.la_flags & LUSTRE_ORPHAN_FL))) {
+ CDEBUG(D_INFO,
+ "%s: skip orphan "DFID", %llx/%x: rc = %d\n",
+ lfsck_lfsck2name(lfsck), PFID(fid),
+ la.la_valid, la.la_flags, rc);
+
+ return rc;
+ }
+
rc = lfsck_links_read(env, obj, &ldata);
if (rc == -ENOENT)
GOTO(out, rc = 0);
struct lfsck_bookmark *bk = &lfsck->li_bookmark_ram;
struct ptlrpc_thread *mthread = &lfsck->li_thread;
struct ptlrpc_thread *athread = &lad->lad_thread;
- struct l_wait_info lwi = { 0 };
bool wakeup = false;
- l_wait_event(mthread->t_ctl_waitq,
- lad->lad_prefetched < bk->lb_async_windows ||
- !thread_is_running(mthread) ||
- !thread_is_running(athread),
- &lwi);
+ wait_event_idle(mthread->t_ctl_waitq,
+ lad->lad_prefetched < bk->lb_async_windows ||
+ !thread_is_running(mthread) ||
+ !thread_is_running(athread));
if (unlikely(!thread_is_running(mthread) ||
!thread_is_running(athread)))
return rc;
}
-static struct lfsck_operations lfsck_namespace_ops = {
+static const struct lfsck_operations lfsck_namespace_ops = {
.lfsck_reset = lfsck_namespace_reset,
.lfsck_fail = lfsck_namespace_fail,
.lfsck_close_dir = lfsck_namespace_close_dir,
*/
if (S_ISREG(type))
child->do_ops->do_ah_init(env, hint, parent, child, type);
+ else if (S_ISDIR(type))
+ child->do_ops->do_ah_init(env, hint, NULL, child, type);
memset(dof, 0, sizeof(*dof));
dof->dof_type = dt_mode_to_dft(type);
lfsck_lmv_header_cpu_to_le(lmv2, lmv2);
lfsck_buf_init(&lmv_buf, lmv2, sizeof(*lmv2));
rc = dt_declare_xattr_set(env, child, &lmv_buf,
- XATTR_NAME_LMV".set", 0, th);
+ XATTR_NAME_LMV, 0, th);
if (rc != 0)
GOTO(stop, rc);
}
/* 5b. generate slave LMV EA. */
if (lnr->lnr_lmv != NULL && lnr->lnr_lmv->ll_lmv_master) {
- rc = dt_xattr_set(env, child, &lmv_buf,
- XATTR_NAME_LMV".set", 0, th);
+ rc = dt_xattr_set(env, child, &lmv_buf, XATTR_NAME_LMV,
+ 0, th);
if (rc != 0)
GOTO(unlock, rc);
}
const struct lu_name *cname;
struct thandle *handle = NULL;
struct lfsck_namespace_req *lnr =
- container_of0(lar, struct lfsck_namespace_req, lnr_lar);
+ container_of(lar, struct lfsck_namespace_req, lnr_lar);
struct dt_object *dir = NULL;
struct dt_object *obj = NULL;
struct lfsck_assistant_object *lso = lar->lar_parent;
repaired = true;
}
- if (unlikely(fid_is_zero(&lnr->lnr_fid))) {
- if (strcmp(lnr->lnr_name, dotdot) != 0)
- LBUG();
- else
- rc = lfsck_namespace_trace_update(env, com, pfid,
+ if (unlikely(fid_is_zero(&lnr->lnr_fid) &&
+ strcmp(lnr->lnr_name, dotdot) == 0)) {
+ rc = lfsck_namespace_trace_update(env, com, pfid,
LNTF_CHECK_PARENT, true);
GOTO(out, rc);
EXIT;
}
-struct lfsck_assistant_operations lfsck_namespace_assistant_ops = {
+const struct lfsck_assistant_operations lfsck_namespace_assistant_ops = {
.la_handler_p1 = lfsck_namespace_assistant_handler_p1,
.la_handler_p2 = lfsck_namespace_assistant_handler_p2,
.la_fill_pos = lfsck_namespace_assistant_fill_pos,