X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fmdd%2Fmdd_lfsck.c;h=dd8979e6c8749c17bd8d7a472680957f46c756d7;hb=ec0c7b569d5a2f25c8ea80f515d2bdc853abc7df;hp=152a2d4d62699e5b516f3d4aa39593b3888f52cd;hpb=1ccdab699584306383dc21ff2c0f48bce70f6660;p=fs%2Flustre-release.git diff --git a/lustre/mdd/mdd_lfsck.c b/lustre/mdd/mdd_lfsck.c index 152a2d4..dd8979e 100644 --- a/lustre/mdd/mdd_lfsck.c +++ b/lustre/mdd/mdd_lfsck.c @@ -261,13 +261,12 @@ static void mdd_lfsck_pos_fill(const struct lu_env *env, struct md_lfsck *lfsck, LASSERT(pos->lp_dir_cookie != MDS_DIR_DUMMY_START); - if (pos->lp_dir_cookie == MDS_DIR_END_OFF) - LASSERT(dir_processed); - - /* For the dir which just to be processed, - * lp_dir_cookie will become MDS_DIR_DUMMY_START, - * which can be correctly handled by mdd_lfsck_prep. */ - if (!dir_processed) + if (pos->lp_dir_cookie >= MDS_DIR_END_OFF) + pos->lp_dir_cookie = MDS_DIR_END_OFF; + else if (!dir_processed) + /* For the dir which just to be processed, + * lp_dir_cookie will become MDS_DIR_DUMMY_START, + * which can be correctly handled by mdd_lfsck_prep. */ pos->lp_dir_cookie--; } else { fid_zero(&pos->lp_dir_parent); @@ -484,7 +483,7 @@ static int mdd_lfsck_bookmark_init(const struct lu_env *env, struct lfsck_bookmark *mb = &lfsck->ml_bookmark_ram; int rc; - memset(mb, 0, sizeof(mb)); + memset(mb, 0, sizeof(*mb)); mb->lb_magic = LFSCK_BOOKMARK_MAGIC; mb->lb_version = LFSCK_VERSION_V2; mutex_lock(&lfsck->ml_mutex); @@ -912,7 +911,7 @@ static int mdd_lfsck_namespace_double_scan_one(const struct lu_env *env, struct lfsck_bookmark *bk = &lfsck->ml_bookmark_ram; struct lfsck_namespace *ns = (struct lfsck_namespace *)com->lc_file_ram; - struct mdd_link_data ldata = { 0 }; + struct linkea_data ldata = { 0 }; struct thandle *handle = NULL; bool locked = false; bool update = false; @@ -930,7 +929,7 @@ again: if (IS_ERR(handle)) RETURN(rc = PTR_ERR(handle)); - rc = mdd_declare_links_add(env, child, handle);; + rc = mdd_declare_links_add(env, child, handle, NULL); if (rc != 0) GOTO(stop, rc); @@ -958,13 +957,14 @@ again: if (rc != 0) GOTO(stop, rc); - ldata.ml_lee = (struct link_ea_entry *)(ldata.ml_leh + 1); - count = ldata.ml_leh->leh_reccount; + ldata.ld_lee = LINKEA_FIRST_ENTRY(ldata); + count = ldata.ld_leh->leh_reccount; while (count-- > 0) { struct mdd_object *parent = NULL; struct dt_object *dir; - mdd_lee_unpack(ldata.ml_lee, &ldata.ml_reclen, cname, pfid); + linkea_entry_unpack(ldata.ld_lee, &ldata.ld_reclen, cname, + pfid); if (!fid_is_sane(pfid)) goto shrink; @@ -980,8 +980,7 @@ again: /* XXX: need more processing for remote object in the future. */ if (mdd_object_remote(parent)) { mdd_object_put(env, parent); - ldata.ml_lee = (struct link_ea_entry *) - ((char *)ldata.ml_lee + ldata.ml_reclen); + ldata.ld_lee = LINKEA_NEXT_ENTRY(ldata); continue; } @@ -1004,15 +1003,14 @@ again: if (rc == 0) { if (lu_fid_eq(cfid, mdo2fid(child))) { mdd_object_put(env, parent); - ldata.ml_lee = (struct link_ea_entry *) - ((char *)ldata.ml_lee + ldata.ml_reclen); + ldata.ld_lee = LINKEA_NEXT_ENTRY(ldata); continue; } goto shrink; } - if (ldata.ml_leh->leh_reccount > la->la_nlink) + if (ldata.ld_leh->leh_reccount > la->la_nlink) goto shrink; /* XXX: For the case of there is linkea entry, but without name @@ -1023,8 +1021,7 @@ again: * It is out of LFSCK 1.5 scope, will implement it in the * future. Keep the linkEA entry. */ mdd_object_put(env, parent); - ldata.ml_lee = (struct link_ea_entry *) - ((char *)ldata.ml_lee + ldata.ml_reclen); + ldata.ld_lee = LINKEA_NEXT_ENTRY(ldata); continue; shrink: @@ -1036,7 +1033,7 @@ shrink: CDEBUG(D_LFSCK, "Remove linkEA: "DFID"[%.*s], "DFID"\n", PFID(mdo2fid(child)), cname->ln_namelen, cname->ln_name, PFID(pfid)); - mdd_links_del_buf(env, &ldata, cname); + linkea_del_buf(&ldata, cname); update = true; } @@ -1272,7 +1269,7 @@ static int mdd_declare_lfsck_namespace_exec_dir(const struct lu_env *env, return rc; /* For insert new linkEA entry. */ - rc = mdd_declare_links_add(env, obj, handle); + rc = mdd_declare_links_add(env, obj, handle, NULL); return rc; } @@ -1315,7 +1312,7 @@ static int mdd_lfsck_namespace_exec_dir(const struct lu_env *env, struct lfsck_namespace *ns = (struct lfsck_namespace *)com->lc_file_ram; struct mdd_device *mdd = mdd_lfsck2mdd(lfsck); - struct mdd_link_data ldata = { 0 }; + struct linkea_data ldata = { 0 }; const struct lu_fid *pfid = lu_object_fid(&lfsck->ml_obj_dir->do_lu); const struct lu_fid *cfid = mdo2fid(obj); @@ -1373,8 +1370,8 @@ again: rc = mdd_links_read(env, obj, &ldata); if (rc == 0) { - count = ldata.ml_leh->leh_reccount; - rc = mdd_links_find(env, obj, &ldata, cname, pfid); + count = ldata.ld_leh->leh_reccount; + rc = linkea_links_find(&ldata, cname, pfid); if (rc == 0) { /* For dir, if there are more than one linkea entries, * then remove all the other redundant linkea entries.*/ @@ -1435,7 +1432,7 @@ unmatch: } nodata: - rc = mdd_links_new(env, &ldata); + rc = linkea_data_new(&ldata, &mdd_env_info(env)->mti_link_buf); if (rc != 0) GOTO(stop, rc); @@ -1443,7 +1440,7 @@ add: if (!com->lc_journal) goto again; - rc = mdd_links_add_buf(env, &ldata, cname, pfid); + rc = linkea_add_buf(&ldata, cname, pfid); if (rc != 0) GOTO(stop, rc); @@ -1451,7 +1448,7 @@ add: if (rc != 0) GOTO(stop, rc); - count = ldata.ml_leh->leh_reccount; + count = ldata.ld_leh->leh_reccount; repaired = true; } else { GOTO(stop, rc); @@ -2120,12 +2117,17 @@ static int object_is_client_visible(const struct lu_env *env, else if (IS_ERR(obj)) return PTR_ERR(obj); - /* XXX: need more processing for remote object in the future. */ - if (!mdd_object_exists(obj) || mdd_object_remote(obj)) { + if (!mdd_object_exists(obj)) { mdd_object_put(env, obj); return 0; } + /* Currently, only client visible directory can be remote. */ + if (mdd_object_remote(obj)) { + mdd_object_put(env, obj); + return 1; + } + depth++; } return 0; @@ -2215,12 +2217,19 @@ static int mdd_lfsck_prep(struct lu_env *env, struct md_lfsck *lfsck) /* Init otable-based iterator. */ if (pos == NULL) { rc = iops->load(env, lfsck->ml_di_oit, 0); - GOTO(out, rc = (rc >= 0 ? 0 : rc)); + if (rc > 0) { + lfsck->ml_oit_over = 1; + rc = 0; + } + + GOTO(out, rc); } rc = iops->load(env, lfsck->ml_di_oit, pos->lp_oit_cookie); if (rc < 0) GOTO(out, rc); + else if (rc > 0) + lfsck->ml_oit_over = 1; if (fid_is_zero(&pos->lp_dir_parent)) GOTO(out, rc = 0);