X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Flfsck%2Flfsck_striped_dir.c;h=ba3112865c8d83e60446c4ea285f917c49f24cf2;hb=a4bcfa9c49abae8035b05d94a09352aae01bd77d;hp=d0bbd4e978899fd60baf84e689723b12dd415284;hpb=b5ff160e58b070c03290598914554a9ffecbea2e;p=fs%2Flustre-release.git diff --git a/lustre/lfsck/lfsck_striped_dir.c b/lustre/lfsck/lfsck_striped_dir.c index d0bbd4e..ba31128 100644 --- a/lustre/lfsck/lfsck_striped_dir.c +++ b/lustre/lfsck/lfsck_striped_dir.c @@ -206,7 +206,7 @@ static int lfsck_disable_master_lmv(const struct lu_env *env, struct lfsck_thread_info *info = lfsck_env_info(env); struct lu_attr *la = &info->lti_la; struct lfsck_instance *lfsck = com->lc_lfsck; - struct dt_device *dev = lfsck_obj2dt_dev(obj); + struct dt_device *dev = lfsck_obj2dev(obj); struct thandle *th = NULL; int rc = 0; ENTRY; @@ -238,16 +238,16 @@ static int lfsck_disable_master_lmv(const struct lu_env *env, GOTO(unlock, rc = 0); if (del_lmv) { - rc = dt_xattr_del(env, obj, XATTR_NAME_LMV, th, BYPASS_CAPA); + rc = dt_xattr_del(env, obj, XATTR_NAME_LMV, th); if (rc != 0) GOTO(unlock, rc); } - rc = dt_attr_get(env, obj, la, BYPASS_CAPA); + rc = dt_attr_get(env, obj, la); if (rc == 0 && !(la->la_flags & LUSTRE_IMMUTABLE_FL)) { la->la_valid = LA_FLAGS; la->la_flags |= LUSTRE_IMMUTABLE_FL; - rc = dt_attr_set(env, obj, la, th, BYPASS_CAPA); + rc = dt_attr_set(env, obj, la, th); } GOTO(unlock, rc); @@ -290,6 +290,7 @@ static inline bool lfsck_is_valid_slave_lmv(struct lmv_mds_md_v1 *lmv) * * \param[in] env pointer to the thread context * \param[in] com pointer to the lfsck component + * \param[in] obj pointer to the striped directory to be handled * \param[in] lnr pointer to the namespace request that contains the * striped directory to be handled and other information * @@ -299,9 +300,9 @@ static inline bool lfsck_is_valid_slave_lmv(struct lmv_mds_md_v1 *lmv) */ static int lfsck_remove_lmv(const struct lu_env *env, struct lfsck_component *com, + struct dt_object *obj, struct lfsck_namespace_req *lnr) { - struct dt_object *obj = lnr->lnr_obj; struct lustre_handle lh = { 0 }; int rc; @@ -341,7 +342,7 @@ static int lfsck_remove_dirent(const struct lu_env *env, snprintf(info->lti_tmpbuf2, sizeof(info->lti_tmpbuf2), DFID":%u", PFID(fid), index); - obj = lfsck_object_find_by_dev(env, com->lc_lfsck->li_bottom, fid); + obj = lfsck_object_find_bottom(env, com->lc_lfsck, fid); if (IS_ERR(obj)) return PTR_ERR(obj); @@ -367,6 +368,7 @@ static int lfsck_remove_dirent(const struct lu_env *env, * * \param[in] env pointer to the thread context * \param[in] com pointer to the lfsck component + * \param[in] dir pointer to the striped directory to be handled * \param[in] lslr pointer to lfsck_disable_master_lmv slot which content * will be replaced by the given information * \param[in] lnr contain the shard's FID to be used to fill the @@ -382,40 +384,33 @@ static int lfsck_remove_dirent(const struct lu_env *env, */ static int lfsck_replace_lmv(const struct lu_env *env, struct lfsck_component *com, + struct dt_object *dir, struct lfsck_slave_lmv_rec *lslr, struct lfsck_namespace_req *lnr, struct lmv_mds_md_v1 *lmv, __u32 index, __u32 flags) { - int rc; + struct lfsck_lmv *llmv = lnr->lnr_lmv; + int rc; - rc = lfsck_remove_dirent(env, com, lnr->lnr_obj, + rc = lfsck_remove_dirent(env, com, dir, &lslr->lslr_fid, index); if (rc < 0) return rc; lslr->lslr_fid = lnr->lnr_fid; lslr->lslr_flags = flags; - if (lmv != NULL) { - struct lfsck_lmv *llmv = lnr->lnr_lmv; - - lslr->lslr_stripe_count = lmv->lmv_stripe_count; - lslr->lslr_index = lmv->lmv_master_mdt_index; - lslr->lslr_hash_type = lmv->lmv_hash_type; - - if (flags == LSLF_NONE && - llmv->ll_hash_type == LMV_HASH_TYPE_UNKNOWN && + lslr->lslr_stripe_count = lmv->lmv_stripe_count; + lslr->lslr_index = lmv->lmv_master_mdt_index; + lslr->lslr_hash_type = lmv->lmv_hash_type; + if (flags == LSLF_NONE) { + if (llmv->ll_hash_type == LMV_HASH_TYPE_UNKNOWN && lmv_is_known_hash_type(lmv->lmv_hash_type)) llmv->ll_hash_type = lmv->lmv_hash_type; - if (flags == LSLF_NONE && - lslr->lslr_stripe_count <= LFSCK_LMV_MAX_STRIPES && + if (lslr->lslr_stripe_count <= LFSCK_LMV_MAX_STRIPES && llmv->ll_max_stripe_count < lslr->lslr_stripe_count) llmv->ll_max_stripe_count = lslr->lslr_stripe_count; - } else { - lslr->lslr_stripe_count = 0; - lslr->lslr_index = 0; - lslr->lslr_hash_type = 0; } return 0; @@ -462,6 +457,7 @@ static int lfsck_replace_lmv(const struct lu_env *env, * * \param[in] env pointer to the thread context * \param[in] com pointer to the lfsck component + * \param[in] dir pointer to the striped directory to be handled * \param[in] lnr contain the shard's FID to fill the @lslr slot, * it also records the known max filled index and * the known max stripe count @@ -488,13 +484,13 @@ static int lfsck_replace_lmv(const struct lu_env *env, */ static int lfsck_record_lmv(const struct lu_env *env, struct lfsck_component *com, + struct dt_object *dir, struct lfsck_namespace_req *lnr, struct lmv_mds_md_v1 *lmv, __u32 shard_idx, __u32 flags, __u32 flags2, __u32 *depth) { struct lfsck_instance *lfsck = com->lc_lfsck; struct lfsck_lmv *llmv = lnr->lnr_lmv; - struct dt_object *dir = lnr->lnr_obj; const struct lu_fid *fid = &lnr->lnr_fid; struct lfsck_slave_lmv_rec *lslr; struct lfsck_rec_lmv_save *lrls; @@ -535,26 +531,22 @@ static int lfsck_record_lmv(const struct lu_env *env, if (fid_is_zero(&lslr->lslr_fid)) { lslr->lslr_fid = *fid; - if (lmv != NULL) { - lslr->lslr_stripe_count = lmv->lmv_stripe_count; - lslr->lslr_index = lmv->lmv_master_mdt_index; - lslr->lslr_hash_type = lmv->lmv_hash_type; - - if (flags == LSLF_NONE && - llmv->ll_hash_type == LMV_HASH_TYPE_UNKNOWN && + lslr->lslr_stripe_count = lmv->lmv_stripe_count; + lslr->lslr_index = lmv->lmv_master_mdt_index; + lslr->lslr_hash_type = lmv->lmv_hash_type; + lslr->lslr_flags = flags; + llmv->ll_stripes_filled++; + if (flags == LSLF_NONE) { + if (llmv->ll_hash_type == LMV_HASH_TYPE_UNKNOWN && lmv_is_known_hash_type(lmv->lmv_hash_type)) llmv->ll_hash_type = lmv->lmv_hash_type; - if (flags == LSLF_NONE && - lslr->lslr_stripe_count <= LFSCK_LMV_MAX_STRIPES && + if (lslr->lslr_stripe_count <= LFSCK_LMV_MAX_STRIPES && llmv->ll_max_stripe_count < lslr->lslr_stripe_count) llmv->ll_max_stripe_count = lslr->lslr_stripe_count; } - lslr->lslr_flags = flags; - llmv->ll_stripes_filled++; - if (llmv->ll_max_filled_off < index) llmv->ll_max_filled_off = index; @@ -579,7 +571,7 @@ static int lfsck_record_lmv(const struct lu_env *env, * mark the master MDT-object as read-only. The * administrator can handle the conflict with * more human knowledge. */ - rc = lfsck_remove_lmv(env, com, lnr); + rc = lfsck_remove_lmv(env, com, dir, lnr); break; case LSLF_BAD_INDEX2: GOTO(out, rc = -EEXIST); @@ -598,7 +590,7 @@ no_lmvea: * as read-only. The administrator can * handle the conflict with more human * knowledge. */ - rc = lfsck_remove_lmv(env, com, lnr); + rc = lfsck_remove_lmv(env, com, dir, lnr); } else { /* Otherwise, remove the current name entry, * and add its FID in the LFSCK tracing file @@ -621,7 +613,7 @@ no_lmvea: /* The name entry claims an index that is conflict * with a valid existing name entry, then try the * index in the lmv recursively. */ - rc = lfsck_record_lmv(env, com, lnr, lmv, index, + rc = lfsck_record_lmv(env, com, dir, lnr, lmv, index, LSLF_BAD_INDEX2, lslr->lslr_flags, depth); lmv->lmv_master_mdt_index = index; if (rc == -ERANGE || rc == -EEXIST) @@ -630,7 +622,7 @@ no_lmvea: * not know how to resolve the conflict. * We will handle it as handle the case * of 'LSLF_NONE' vs 'LSLF_NONE'. */ - rc = lfsck_remove_lmv(env, com, lnr); + rc = lfsck_remove_lmv(env, com, dir, lnr); break; default: @@ -656,7 +648,7 @@ none: * as read-only. The administrator can * handle the conflict with more human * knowledge. */ - rc = lfsck_remove_lmv(env, com, lnr); + rc = lfsck_remove_lmv(env, com, dir, lnr); } else { lrls = &lfsck->li_rec_lmv_save[*depth - 1]; lrls->lrls_fid = lslr->lslr_fid; @@ -668,8 +660,8 @@ none: com, &lrls->lrls_fid, LNTF_CHECK_PARENT, true); if (rc == 0) - rc = lfsck_replace_lmv(env, com, lslr, - lnr, lmv, index, flags); + rc = lfsck_replace_lmv(env, com, dir, + lslr, lnr, lmv, index, flags); } break; @@ -690,7 +682,7 @@ none: /* The name entry claims an index that is conflict * with a valid existing name entry, then try the * index in the lmv recursively. */ - rc = lfsck_record_lmv(env, com, lnr, lmv, index, + rc = lfsck_record_lmv(env, com, dir, lnr, lmv, index, LSLF_BAD_INDEX2, lslr->lslr_flags, depth); lmv->lmv_master_mdt_index = index; if (rc == -ERANGE || rc == -EEXIST) { @@ -712,7 +704,7 @@ none: case LSLF_NO_LMVEA: /* Remove the existing dangling name entry. * Refill the lslr slot with the given LMV. */ - rc = lfsck_replace_lmv(env, com, lslr, lnr, + rc = lfsck_replace_lmv(env, com, dir, lslr, lnr, lmv, index, flags); break; case LSLF_DANGLING: @@ -726,7 +718,7 @@ none: /* The name entry claims an index that is conflict * with a valid existing name entry, then try the * index in the lmv recursively. */ - rc = lfsck_record_lmv(env, com, lnr, lmv, index, + rc = lfsck_record_lmv(env, com, dir, lnr, lmv, index, LSLF_BAD_INDEX2, lslr->lslr_flags, depth); lmv->lmv_master_mdt_index = index; if (rc == -ERANGE || rc == -EEXIST) @@ -734,7 +726,7 @@ none: * also conflict with other, then remove * the existing dangling name entry. * Refill the lslr slot with the given LMV. */ - rc = lfsck_replace_lmv(env, com, lslr, lnr, + rc = lfsck_replace_lmv(env, com, dir, lslr, lnr, lmv, shard_idx, flags); break; @@ -759,7 +751,7 @@ none: /* The existing one has another possible slot, * try it recursively. */ - rc = lfsck_record_lmv(env, com, lnr, lmv, index, + rc = lfsck_record_lmv(env, com, dir, lnr, lmv, index, LSLF_BAD_INDEX2, flags, depth); *lmv = lrls->lrls_lmv; lnr->lnr_fid = lrls->lrls_fid; @@ -773,25 +765,18 @@ none: lslr->lslr_fid = *fid; lslr->lslr_flags = flags; - if (lmv != NULL) { - lslr->lslr_stripe_count = lmv->lmv_stripe_count; - lslr->lslr_index = lmv->lmv_master_mdt_index; - lslr->lslr_hash_type = lmv->lmv_hash_type; - - if (flags == LSLF_NONE && - llmv->ll_hash_type == LMV_HASH_TYPE_UNKNOWN && + lslr->lslr_stripe_count = lmv->lmv_stripe_count; + lslr->lslr_index = lmv->lmv_master_mdt_index; + lslr->lslr_hash_type = lmv->lmv_hash_type; + if (flags == LSLF_NONE) { + if (llmv->ll_hash_type == LMV_HASH_TYPE_UNKNOWN && lmv_is_known_hash_type(lmv->lmv_hash_type)) llmv->ll_hash_type = lmv->lmv_hash_type; - if (flags == LSLF_NONE && - lslr->lslr_stripe_count <= LFSCK_LMV_MAX_STRIPES && + if (lslr->lslr_stripe_count <= LFSCK_LMV_MAX_STRIPES && llmv->ll_max_stripe_count < lslr->lslr_stripe_count) llmv->ll_max_stripe_count = lslr->lslr_stripe_count; - } else { - lslr->lslr_stripe_count = 0; - lslr->lslr_index = 0; - lslr->lslr_hash_type = 0; } break; @@ -806,7 +791,7 @@ conflict: * mark the master MDT-object as read-only. The * administrator can handle the conflict with * more human knowledge. */ - rc = lfsck_remove_lmv(env, com, lnr); + rc = lfsck_remove_lmv(env, com, dir, lnr); break; case LSLF_BAD_INDEX2: GOTO(out, rc = -EEXIST); @@ -822,7 +807,7 @@ conflict: /* The name entry claims an index that is conflict * with a valid existing name entry, then try the * index in the lmv recursively. */ - rc = lfsck_record_lmv(env, com, lnr, lmv, index, + rc = lfsck_record_lmv(env, com, dir, lnr, lmv, index, LSLF_BAD_INDEX2, lslr->lslr_flags, depth); lmv->lmv_master_mdt_index = index; if (rc == -ERANGE || rc == -EEXIST) @@ -831,7 +816,7 @@ conflict: * not know how to resolve the conflict. * We will handle it as handle the case * of 'LSLF_NONE' vs 'LSLF_NONE'. */ - rc = lfsck_remove_lmv(env, com, lnr); + rc = lfsck_remove_lmv(env, com, dir, lnr); break; } @@ -856,22 +841,12 @@ out: int lfsck_read_stripe_lmv(const struct lu_env *env, struct dt_object *obj, struct lmv_mds_md_v1 *lmv) { - struct dt_object *bottom; - int rc; + int rc; - /* Currently, we only store the LMV header on disk. It is the LOD's - * duty to iterate the master MDT-object's directory to compose the - * integrated LMV EA. But here, we only want to load the LMV header, - * so we need to bypass LOD to avoid unnecessary iteration in LOD. */ - bottom = lu2dt(container_of0(obj->do_lu.lo_header->loh_layers.prev, - struct lu_object, lo_linkage)); - if (unlikely(bottom == NULL)) - return -ENOENT; - - dt_read_lock(env, bottom, 0); - rc = dt_xattr_get(env, bottom, lfsck_buf_get(env, lmv, sizeof(*lmv)), - XATTR_NAME_LMV, BYPASS_CAPA); - dt_read_unlock(env, bottom); + dt_read_lock(env, obj, 0); + rc = dt_xattr_get(env, obj, lfsck_buf_get(env, lmv, sizeof(*lmv)), + XATTR_NAME_LMV); + dt_read_unlock(env, obj); if (rc != sizeof(*lmv)) return rc > 0 ? -EINVAL : rc; @@ -1024,7 +999,7 @@ int lfsck_namespace_update_lmv(const struct lu_env *env, struct lmv_mds_md_v1 *lmv4 = &info->lti_lmv4; struct lu_buf *buf = &info->lti_buf; struct lfsck_instance *lfsck = com->lc_lfsck; - struct dt_device *dev = lfsck_obj2dt_dev(obj); + struct dt_device *dev = lfsck_obj2dev(obj); struct thandle *th = NULL; struct lustre_handle lh = { 0 }; int rc = 0; @@ -1068,7 +1043,7 @@ int lfsck_namespace_update_lmv(const struct lu_env *env, if (lfsck->li_bookmark_ram.lb_param & LPF_DRYRUN) GOTO(unlock, rc = 0); - rc = dt_xattr_set(env, obj, buf, XATTR_NAME_LMV, 0, th, BYPASS_CAPA); + rc = dt_xattr_set(env, obj, buf, XATTR_NAME_LMV, 0, th); GOTO(unlock, rc); @@ -1137,7 +1112,7 @@ static int lfsck_allow_regenerate_master_lmv(const struct lu_env *env, snprintf(info->lti_tmpbuf, sizeof(info->lti_tmpbuf), DFID":%u", PFID(cfid), cidx); rc = dt_lookup(env, obj, (struct dt_rec *)tfid, - (const struct dt_key *)info->lti_tmpbuf, BYPASS_CAPA); + (const struct dt_key *)info->lti_tmpbuf); if (rc != 0) RETURN(rc); @@ -1146,7 +1121,7 @@ static int lfsck_allow_regenerate_master_lmv(const struct lu_env *env, args = lfsck->li_args_dir & ~(LUDA_VERIFY | LUDA_VERIFY_DRYRUN); iops = &obj->do_index_ops->dio_it; - di = iops->init(env, obj, args, BYPASS_CAPA); + di = iops->init(env, obj, args); if (IS_ERR(di)) RETURN(PTR_ERR(di)); @@ -1252,7 +1227,7 @@ static int lfsck_namespace_notify_lmv_remote(const struct lu_env *env, lr = req_capsule_client_get(&req->rq_pill, &RMF_LFSCK_REQUEST); memset(lr, 0, sizeof(*lr)); lr->lr_event = event; - lr->lr_index = lfsck_dev_idx(lfsck->li_bottom); + lr->lr_index = lfsck_dev_idx(lfsck); lr->lr_active = LFSCK_TYPE_NAMESPACE; lr->lr_fid = *fid; lr->lr_flags = flags; @@ -1371,7 +1346,7 @@ int lfsck_namespace_notify_lmv_master_local(const struct lu_env *env, * * \param[in] env pointer to the thread context * \param[in] com pointer to the lfsck component - * \param[in] dir pointer to the object on which the LMV EA will be set + * \param[in] obj pointer to the object on which the LMV EA will be set * \param[in] lmv pointer to the buffer holding the new LMV EA * \param[in] cfid the shard's FID used for verification * \param[in] cidx the shard's index used for verification @@ -1383,7 +1358,7 @@ int lfsck_namespace_notify_lmv_master_local(const struct lu_env *env, */ static int lfsck_namespace_set_lmv_master(const struct lu_env *env, struct lfsck_component *com, - struct dt_object *dir, + struct dt_object *obj, struct lmv_mds_md_v1 *lmv, const struct lu_fid *cfid, __u32 cidx, __u32 flags) @@ -1392,20 +1367,12 @@ static int lfsck_namespace_set_lmv_master(const struct lu_env *env, struct lmv_mds_md_v1 *lmv3 = &info->lti_lmv3; struct lu_seq_range *range = &info->lti_range; struct lfsck_instance *lfsck = com->lc_lfsck; - struct seq_server_site *ss = - lu_site2seq(lfsck->li_bottom->dd_lu_dev.ld_site); - struct dt_object *obj; + struct seq_server_site *ss = lfsck_dev_site(lfsck); struct lustre_handle lh = { 0 }; int pidx = -1; int rc = 0; ENTRY; - /* Find the bottom object to bypass LOD when set LMV EA. */ - obj = lu2dt(container_of0(dir->do_lu.lo_header->loh_layers.prev, - struct lu_object, lo_linkage)); - if (unlikely(obj == NULL)) - RETURN(-ENOENT); - fld_range_set_mdt(range); rc = fld_server_lookup(env, ss->ss_server_fld, fid_seq(lfsck_dto2fid(obj)), range); @@ -1518,7 +1485,7 @@ int lfsck_namespace_repair_bad_name_hash(const struct lu_env *env, ENTRY; rc = dt_lookup(env, shard, (struct dt_rec *)pfid, - (const struct dt_key *)dotdot, BYPASS_CAPA); + (const struct dt_key *)dotdot); if (rc != 0 || !fid_is_sane(pfid)) GOTO(log, rc); @@ -1539,7 +1506,7 @@ log: CDEBUG(D_LFSCK, "%s: namespace LFSCK assistant found bad name hash " "on the MDT %x, parent "DFID", name %s, shard_%x "DFID ": rc = %d\n", - lfsck_lfsck2name(lfsck), lfsck_dev_idx(lfsck->li_bottom), + lfsck_lfsck2name(lfsck), lfsck_dev_idx(lfsck), PFID(pfid), name, llmv->ll_lmv.lmv_master_mdt_index, PFID(lfsck_dto2fid(shard)), rc); @@ -1611,7 +1578,7 @@ int lfsck_namespace_scan_shard(const struct lu_env *env, args = lfsck->li_args_dir & ~(LUDA_VERIFY | LUDA_VERIFY_DRYRUN); iops = &child->do_index_ops->dio_it; - di = iops->init(env, child, args, BYPASS_CAPA); + di = iops->init(env, child, args); if (IS_ERR(di)) GOTO(out, rc = PTR_ERR(di)); @@ -1622,19 +1589,9 @@ int lfsck_namespace_scan_shard(const struct lu_env *env, rc = 0; while (rc == 0) { - if (OBD_FAIL_CHECK(OBD_FAIL_LFSCK_DELAY3) && - cfs_fail_val > 0) { - struct l_wait_info lwi; - - lwi = LWI_TIMEOUT(cfs_time_seconds(cfs_fail_val), - NULL, NULL); - l_wait_event(thread->t_ctl_waitq, - !thread_is_running(thread), - &lwi); - - if (unlikely(!thread_is_running(thread))) - GOTO(out, rc = 0); - } + if (CFS_FAIL_TIMEOUT(OBD_FAIL_LFSCK_DELAY3, cfs_fail_val) && + unlikely(!thread_is_running(thread))) + GOTO(out, rc = 0); rc = iops->rec(env, di, (struct dt_rec *)ent, args); if (rc == 0) @@ -1714,8 +1671,8 @@ int lfsck_namespace_verify_stripe_slave(const struct lu_env *env, char *name = info->lti_key; char *name2; struct lu_fid *pfid = &info->lti_fid3; - struct lu_fid *tfid = &info->lti_fid4; const struct lu_fid *cfid = lfsck_dto2fid(obj); + struct lu_fid tfid; struct lfsck_instance *lfsck = com->lc_lfsck; struct lmv_mds_md_v1 *clmv = &llmv->ll_lmv; struct lmv_mds_md_v1 *plmv = &info->lti_lmv; @@ -1731,7 +1688,7 @@ int lfsck_namespace_verify_stripe_slave(const struct lu_env *env, } rc = dt_lookup(env, obj, (struct dt_rec *)pfid, - (const struct dt_key *)dotdot, BYPASS_CAPA); + (const struct dt_key *)dotdot); if (rc != 0 || !fid_is_sane(pfid)) { rc = lfsck_namespace_trace_update(env, com, cfid, LNTF_UNCERTAIN_LMV, true); @@ -1739,7 +1696,7 @@ int lfsck_namespace_verify_stripe_slave(const struct lu_env *env, GOTO(out, rc); } - parent = lfsck_object_find(env, lfsck, pfid); + parent = lfsck_object_find_bottom(env, lfsck, pfid); if (IS_ERR(parent)) { rc = lfsck_namespace_trace_update(env, com, cfid, LNTF_UNCERTAIN_LMV, true); @@ -1747,6 +1704,9 @@ int lfsck_namespace_verify_stripe_slave(const struct lu_env *env, GOTO(out, rc); } + if (unlikely(!dt_try_as_dir(env, parent))) + GOTO(out, rc = -ENOTDIR); + rc = lfsck_read_stripe_lmv(env, parent, plmv); if (rc != 0) { int rc1; @@ -1796,16 +1756,16 @@ int lfsck_namespace_verify_stripe_slave(const struct lu_env *env, PFID(cfid), clmv->lmv_master_mdt_index); name2 = info->lti_tmpbuf2; - rc = lfsck_links_get_first(env, obj, name, tfid); - if (rc == 0 && strcmp(name, name2) == 0 && lu_fid_eq(pfid, tfid)) { + rc = lfsck_links_get_first(env, obj, name, &tfid); + if (rc == 0 && strcmp(name, name2) == 0 && lu_fid_eq(pfid, &tfid)) { llmv->ll_lmv_verified = 1; GOTO(out, rc); } - rc = dt_lookup(env, parent, (struct dt_rec *)tfid, - (const struct dt_key *)name2, BYPASS_CAPA); - if (rc != 0 || !lu_fid_eq(cfid, tfid)) + rc = dt_lookup(env, parent, (struct dt_rec *)&tfid, + (const struct dt_key *)name2); + if (rc != 0 || !lu_fid_eq(cfid, &tfid)) rc = lfsck_namespace_trace_update(env, com, cfid, LNTF_UNCERTAIN_LMV, true); else @@ -1838,6 +1798,8 @@ out: * * \param[in] env pointer to the thread context * \param[in] com pointer to the lfsck component + * \paran[in] dir pointer to the striped directory or its shard to be + * rescanned * \param[in] lnr pointer to the namespace request that contains the * striped directory or the shard * @@ -1846,6 +1808,7 @@ out: */ int lfsck_namespace_striped_dir_rescan(const struct lu_env *env, struct lfsck_component *com, + struct dt_object *dir, struct lfsck_namespace_req *lnr) { struct lfsck_thread_info *info = lfsck_env_info(env); @@ -1854,11 +1817,9 @@ int lfsck_namespace_striped_dir_rescan(const struct lu_env *env, struct lfsck_lmv *llmv = lnr->lnr_lmv; struct lmv_mds_md_v1 *lmv = &llmv->ll_lmv; struct lmv_mds_md_v1 *lmv2 = &info->lti_lmv2; - struct dt_object *dir = lnr->lnr_obj; const struct lu_fid *pfid = lfsck_dto2fid(dir); struct lu_seq_range *range = &info->lti_range; - struct seq_server_site *ss = - lu_site2seq(lfsck->li_bottom->dd_lu_dev.ld_site); + struct seq_server_site *ss = lfsck_dev_site(lfsck); __u32 stripe_count; __u32 hash_type; int rc = 0; @@ -1933,7 +1894,7 @@ int lfsck_namespace_striped_dir_rescan(const struct lu_env *env, struct lfsck_slave_lmv_rec *lslr = llmv->ll_lslr + i; const struct lu_fid *cfid = &lslr->lslr_fid; const struct lu_name *cname; - struct linkea_data ldata = { 0 }; + struct linkea_data ldata = { NULL }; int len; int rc1 = 0; bool repair_linkea = false; @@ -1954,8 +1915,11 @@ int lfsck_namespace_striped_dir_rescan(const struct lu_env *env, cname = lfsck_name_get_const(env, info->lti_tmpbuf, len); memcpy(lnr->lnr_name, info->lti_tmpbuf, len); - obj = lfsck_object_find_bottom(env, lfsck, cfid); + obj = lfsck_object_find_bottom_nowait(env, lfsck, cfid); if (IS_ERR(obj)) { + if (lfsck_is_dead_obj(dir)) + RETURN(0); + rc1 = PTR_ERR(obj); goto next; } @@ -2018,7 +1982,7 @@ int lfsck_namespace_striped_dir_rescan(const struct lu_env *env, repair: if (create) { - rc1 = lfsck_namespace_repair_dangling(env, com, + rc1 = lfsck_namespace_repair_dangling(env, com, dir, obj, lnr); if (rc1 >= 0) { create_repaired = true; @@ -2114,12 +2078,12 @@ repair: rc1 = lfsck_ibits_lock(env, lfsck, obj, &lh, MDS_INODELOCK_UPDATE | MDS_INODELOCK_XATTR, LCK_EX); - lfsck_ibits_unlock(&lh, LCK_EX); if (rc1 != 0) goto next; rc1 = lfsck_namespace_rebuild_linkea(env, com, obj, &ldata); + lfsck_ibits_unlock(&lh, LCK_EX); if (rc1 >= 0) { linkea_repaired = true; if (rc1 > 0) @@ -2195,6 +2159,8 @@ next: * * \param[in] env pointer to the thread context * \param[in] com pointer to the lfsck component + * \param[in] dir pointer to the master MDT-object of the + * striped directory * \param[in] lnr pointer to the namespace request that contains the * shard's name, parent object, parent's LMV, and ect. * @@ -2203,6 +2169,7 @@ next: */ int lfsck_namespace_handle_striped_master(const struct lu_env *env, struct lfsck_component *com, + struct dt_object *dir, struct lfsck_namespace_req *lnr) { struct lfsck_thread_info *info = lfsck_env_info(env); @@ -2210,7 +2177,6 @@ int lfsck_namespace_handle_striped_master(const struct lu_env *env, struct lfsck_instance *lfsck = com->lc_lfsck; struct lfsck_namespace *ns = com->lc_file_ram; struct lfsck_lmv *llmv = lnr->lnr_lmv; - struct dt_object *dir = lnr->lnr_obj; const struct lu_fid *pfid = lfsck_dto2fid(dir); struct dt_object *obj = NULL; struct dt_device *dev = NULL; @@ -2229,11 +2195,11 @@ int lfsck_namespace_handle_striped_master(const struct lu_env *env, if (shard_idx < 0) GOTO(fail_lmv, rc = shard_idx); - if (shard_idx == lfsck_dev_idx(lfsck->li_bottom)) { + if (shard_idx == lfsck_dev_idx(lfsck)) { if (unlikely(strcmp(lnr->lnr_name, dotdot) == 0)) GOTO(out, rc = 0); - dev = lfsck->li_next; + dev = lfsck->li_bottom; } else { struct lfsck_tgt_desc *ltd; @@ -2260,9 +2226,13 @@ int lfsck_namespace_handle_striped_master(const struct lu_env *env, dev = ltd->ltd_tgt; } - obj = lfsck_object_find_by_dev(env, dev, &lnr->lnr_fid); - if (IS_ERR(obj)) + obj = lfsck_object_find_by_dev_nowait(env, dev, &lnr->lnr_fid); + if (IS_ERR(obj)) { + if (lfsck_is_dead_obj(dir)) + RETURN(0); + GOTO(fail_lmv, rc = PTR_ERR(obj)); + } if (!dt_object_exists(obj)) { stripe = lfsck_shard_name_to_index(env, lnr->lnr_name, @@ -2275,9 +2245,12 @@ int lfsck_namespace_handle_striped_master(const struct lu_env *env, dangling: rc = lfsck_namespace_check_exist(env, dir, obj, lnr->lnr_name); - if (rc == 0) - rc = lfsck_record_lmv(env, com, lnr, NULL, stripe, + if (rc == 0) { + memset(lmv, 0, sizeof(*lmv)); + lmv->lmv_magic = LMV_MAGIC; + rc = lfsck_record_lmv(env, com, dir, lnr, lmv, stripe, LSLF_DANGLING, LSLF_NONE, &depth); + } GOTO(out, rc); } @@ -2298,10 +2271,10 @@ dangling: goto dangling; if (rc == -ENODATA) - rc = lfsck_record_lmv(env, com, lnr, lmv, stripe, + rc = lfsck_record_lmv(env, com, dir, lnr, lmv, stripe, LSLF_NO_LMVEA, LSLF_NONE, &depth); else if (rc == 0) - rc = lfsck_record_lmv(env, com, lnr, lmv, stripe, + rc = lfsck_record_lmv(env, com, dir, lnr, lmv, stripe, lmv->lmv_master_mdt_index != stripe ? LSLF_BAD_INDEX1 : LSLF_NONE, LSLF_NONE, &depth); @@ -2338,13 +2311,13 @@ out: CDEBUG(D_LFSCK, "%s: namespace LFSCK assistant fail to handle " "the shard: "DFID", parent "DFID", name %.*s: rc = %d\n", lfsck_lfsck2name(lfsck), PFID(&lnr->lnr_fid), - PFID(lfsck_dto2fid(lnr->lnr_obj)), + PFID(lfsck_dto2fid(dir)), lnr->lnr_namelen, lnr->lnr_name, rc); if ((rc == -ENOTCONN || rc == -ESHUTDOWN || rc == -EREMCHG || rc == -ETIMEDOUT || rc == -EHOSTDOWN || rc == -EHOSTUNREACH || rc == -EINPROGRESS) && - dev != NULL && dev != lfsck->li_next) + dev != NULL && dev != lfsck->li_bottom) lfsck_lad_set_bitmap(env, com, shard_idx); if (!(lfsck->li_bookmark_ram.lb_param & LPF_FAILOUT))