X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Flfsck%2Flfsck_namespace.c;h=ff660c4f1a57f7aebf209e965cdeb8c4b0be1af1;hb=d525ad4bd0d5d851405e4249859a1c77378f0ee3;hp=14ed2a540f715e4e20e8b04fcf47f3e23a839256;hpb=38e6ee6fb779c34c7ef3eb4a010332385b3b84c1;p=fs%2Flustre-release.git diff --git a/lustre/lfsck/lfsck_namespace.c b/lustre/lfsck/lfsck_namespace.c index 14ed2a5..ff660c4 100644 --- a/lustre/lfsck/lfsck_namespace.c +++ b/lustre/lfsck/lfsck_namespace.c @@ -87,7 +87,7 @@ static void lfsck_namespace_assistant_req_fini(const struct lu_env *env, 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); @@ -596,8 +596,7 @@ int lfsck_namespace_check_exist(const struct lu_env *env, 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); @@ -946,8 +945,7 @@ again: 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); @@ -962,8 +960,7 @@ again: /* 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; @@ -1129,7 +1126,7 @@ static int lfsck_lmv_set(const struct lu_env *env, 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); @@ -1137,7 +1134,7 @@ static int lfsck_lmv_set(const struct lu_env *env, 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); @@ -1341,8 +1338,8 @@ static int lfsck_namespace_insert_normal(const struct lu_env *env, } 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); } @@ -1375,8 +1372,7 @@ static int lfsck_namespace_insert_normal(const struct lu_env *env, } 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); } @@ -1475,9 +1471,7 @@ static int lfsck_namespace_create_orphan_dir(const struct lu_env *env, 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)); @@ -1504,8 +1498,7 @@ again: 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); @@ -1517,8 +1510,7 @@ again: /* 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; @@ -1584,8 +1576,8 @@ 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); } @@ -1990,8 +1982,7 @@ static int lfsck_namespace_replace_cond(const struct lu_env *env, 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; @@ -2277,8 +2268,7 @@ int lfsck_namespace_repair_dirent(const struct lu_env *env, 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); @@ -2676,8 +2666,7 @@ lost_parent: 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 @@ -2917,8 +2906,7 @@ again: 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); @@ -3277,8 +3265,7 @@ lock: 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); @@ -3868,8 +3855,7 @@ lost_parent: 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); @@ -5228,7 +5214,7 @@ static int lfsck_namespace_query(const struct lu_env *env, 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, @@ -5371,6 +5357,8 @@ int lfsck_namespace_repair_dangling(const struct lu_env *env, */ 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); @@ -5430,7 +5418,7 @@ int lfsck_namespace_repair_dangling(const struct lu_env *env, 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); } @@ -5492,8 +5480,8 @@ int lfsck_namespace_repair_dangling(const struct lu_env *env, /* 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); } @@ -5565,7 +5553,7 @@ static int lfsck_namespace_assistant_handler_p1(const struct lu_env *env, 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; @@ -5599,11 +5587,9 @@ static int lfsck_namespace_assistant_handler_p1(const struct lu_env *env, 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); @@ -6829,7 +6815,7 @@ out: 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,