From: yury Date: Sun, 29 Oct 2006 19:03:49 +0000 (+0000) Subject: - fixes in split. Tom! Your changes in cmm_remove_entries() were wrong; X-Git-Tag: v1_8_0_110~486^2~309 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=32a15af5a97bc8d71fc3cd2d5367fcfc42b8b141;p=fs%2Flustre-release.git - fixes in split. Tom! Your changes in cmm_remove_entries() were wrong; --- diff --git a/lustre/cmm/cmm_internal.h b/lustre/cmm/cmm_internal.h index 99b9f5e..c5b48fe 100644 --- a/lustre/cmm/cmm_internal.h +++ b/lustre/cmm/cmm_internal.h @@ -151,6 +151,9 @@ int cmm_split_lock_mode(const struct lu_env *env, struct md_object *mo, mdl_mode_t lm); #endif +int cmm_fld_lookup(struct cmm_device *cm, const struct lu_fid *fid, + mdsno_t *mds, const struct lu_env *env); + #endif /* __KERNEL__ */ #endif /* _CMM_INTERNAL_H */ diff --git a/lustre/cmm/cmm_object.c b/lustre/cmm/cmm_object.c index c73f836..eefdcda 100644 --- a/lustre/cmm/cmm_object.c +++ b/lustre/cmm/cmm_object.c @@ -36,9 +36,8 @@ #include "cmm_internal.h" #include "mdc_internal.h" -static int cmm_fld_lookup(struct cmm_device *cm, - const struct lu_fid *fid, mdsno_t *mds, - const struct lu_env *env) +int cmm_fld_lookup(struct cmm_device *cm, const struct lu_fid *fid, + mdsno_t *mds, const struct lu_env *env) { int rc = 0; ENTRY; diff --git a/lustre/cmm/cmm_split.c b/lustre/cmm/cmm_split.c index 3ba61b0..97f3e82 100644 --- a/lustre/cmm/cmm_split.c +++ b/lustre/cmm/cmm_split.c @@ -141,6 +141,8 @@ static int cmm_slave_object_create(const struct lu_env *env, RETURN(PTR_ERR(obj)); OBD_ALLOC_PTR(spec); + if (spec == NULL) + RETURN(-ENOMEM); spec->u.sp_ea.fid = fid; spec->u.sp_ea.eadata = lmv; @@ -185,14 +187,14 @@ static int cmm_slaves_create(const struct lu_env *env, { struct cmm_device *cmm = cmm_obj2dev(md2cmm_obj(mo)); struct lu_fid *lf = cmm2fid(md2cmm_obj(mo)); - struct lmv_stripe_md *lmv; struct lmv_stripe_md *slave_lmv = NULL; struct mdc_device *mc, *tmp; + struct lmv_stripe_md *lmv; int i = 1, rc = 0; ENTRY; - lmv = ma->ma_lmv; /* Init the split MEA */ + lmv = ma->ma_lmv; lmv->mea_master = cmm->cmm_local_num; lmv->mea_magic = MEA_MAGIC_HASH_SEGMENT; lmv->mea_count = cmm->cmm_tgt_count + 1; @@ -313,27 +315,24 @@ static int cmm_remove_entries(const struct lu_env *env, kmap(rdpg->rp_pages[0]); dp = page_address(rdpg->rp_pages[0]); - *len = 0; - - for (ent = lu_dirent_start(dp); - ent != NULL && ent->lde_hash < hash_end; + for (ent = lu_dirent_start(dp); ent != NULL; ent = lu_dirent_next(ent)) { - rc = cmm_remove_split_ent(env, mo, ent); - if (rc) { - /* - * XXX Error handler to insert remove name back, - * currently we assumed it will success anyway - * in verfication test. - * - */ - CERROR("Can not del %*.*s rc %d\n", ent->lde_namelen, - ent->lde_namelen, ent->lde_name, rc); + if (ent->lde_hash < hash_end) { + rc = cmm_remove_split_ent(env, mo, ent); + if (rc) { + CERROR("Can not del %s rc %d\n", + ent->lde_name, rc); + GOTO(unmap, rc); + } + } else { + if (ent != lu_dirent_start(dp)) + *len = (int)((__u32)ent - (__u32)dp); + else + *len = 0; GOTO(unmap, rc); } - *len += le16_to_cpu(ent->lde_reclen); } - if (ent != lu_dirent_start(dp)) - *len += sizeof(struct lu_dirpage); + *len = CFS_PAGE_SIZE; EXIT; unmap: kunmap(rdpg->rp_pages[0]); @@ -349,6 +348,7 @@ static int cmm_split_entries(const struct lu_env *env, ENTRY; LASSERT(rdpg->rp_npages == 1); + /* Read split page and send them to the slave master. */ do { struct lu_dirpage *ldp; @@ -382,9 +382,9 @@ static int cmm_split_entries(const struct lu_env *env, kmap(rdpg->rp_pages[0]); ldp = page_address(rdpg->rp_pages[0]); - if (ldp->ldp_hash_end >= end) { + if (ldp->ldp_hash_end >= end) done = 1; - } + rdpg->rp_hash = ldp->ldp_hash_end; kunmap(rdpg->rp_pages[0]); } while (!done); @@ -431,9 +431,9 @@ static int cmm_scan_and_split(const struct lu_env *env, hash_end = rdpg->rp_hash + hash_segement; rc = cmm_split_entries(env, mo, rdpg, lf, hash_end); if (rc) { - CERROR("Error (rc=%d) while splitting for %d: fid=" - DFID", %08x:%08x\n", rc, i, PFID(lf), - rdpg->rp_hash, hash_end); + CERROR("Error (rc = %d) while splitting for %d: fid=" + DFID", %08x:%08x\n", rc, i, PFID(lf), + rdpg->rp_hash, hash_end); GOTO(cleanup, rc); } } @@ -492,7 +492,7 @@ int cmm_try_to_split(const struct lu_env *env, struct md_object *mo) rc = cmm_upcall(env, &cmm->cmm_md_dev, MD_NO_TRANS); if (rc) { CERROR("Can't disable trans for split, rc %d\n", rc); - GOTO(cleanup, rc); + RETURN(rc); } /* Step2: Prepare the md memory */ @@ -551,9 +551,10 @@ int cmm_mdsnum_check(const struct lu_env *env, struct md_object *mp, rc = mo_attr_get(env, mp, ma); if (rc) RETURN(rc); + /* No LMV just return */ if (!(ma->ma_valid & MA_LMV)) - RETURN(rc); + RETURN(0); LASSERT(ma->ma_lmv_size > 0); OBD_ALLOC(ma->ma_lmv, ma->ma_lmv_size); @@ -569,20 +570,22 @@ int cmm_mdsnum_check(const struct lu_env *env, struct md_object *mp, /* Skip checking the slave dirs (mea_count is 0) */ if (ma->ma_lmv->mea_count != 0) { - int stripe; + int idx; + /* - * Get stripe by name to check the name belongs to - * master dir, otherwise return the -ERESTART + * Get stripe by name to check the name belongs to master dir, + * otherwise return the -ERESTART */ - stripe = mea_name2idx(ma->ma_lmv, name, strlen(name)); - - /* Master stripe is always 0 */ - if (stripe != 0) + idx = mea_name2idx(ma->ma_lmv, name, strlen(name)); + + /* Check if name came to correct MDT server. */ + if (idx != 0) rc = -ERESTART; } + EXIT; cleanup: OBD_FREE(ma->ma_lmv, ma->ma_lmv_size); - RETURN(rc); + return rc; } int cmm_split_lock_mode(const struct lu_env *env, struct md_object *mo, @@ -593,9 +596,10 @@ int cmm_split_lock_mode(const struct lu_env *env, struct md_object *mo, ENTRY; memset(ma, 0, sizeof(*ma)); + /* - * Check only if we need protection from split. - * If not - mdt handles other cases. + * Check only if we need protection from split. If not - mdt handles + * other cases. */ rc = cmm_expect_splitting(env, mo, ma, &split); if (rc) { @@ -604,8 +608,8 @@ int cmm_split_lock_mode(const struct lu_env *env, struct md_object *mo, } /* - * Do not take PDO lock on non-splittable objects if - * this is not PW, this should speed things up a bit. + * Do not take PDO lock on non-splittable objects if this is not PW, + * this should speed things up a bit. */ if (split == CMM_NOT_SPLITTABLE && lm != MDL_PW) RETURN(MDL_NL); @@ -615,8 +619,7 @@ int cmm_split_lock_mode(const struct lu_env *env, struct md_object *mo, RETURN(MDL_EX); /* - * XXX Have no idea about lock mode, let it be - * what higher layer wants. + * Have no idea about lock mode, let it be what higher layer wants. */ RETURN(MDL_MINMODE); } diff --git a/lustre/obdclass/mea.c b/lustre/obdclass/mea.c index 57839c2..2dd4131 100644 --- a/lustre/obdclass/mea.c +++ b/lustre/obdclass/mea.c @@ -127,16 +127,16 @@ int raw_name2idx(int hashtype, int count, const char *name, int namelen) switch (hashtype) { case MEA_MAGIC_LAST_CHAR: - c = mea_last_char_hash(count, (char *) name, namelen); + c = mea_last_char_hash(count, (char *)name, namelen); break; case MEA_MAGIC_ALL_CHARS: - c = mea_all_chars_hash(count, (char *) name, namelen); + c = mea_all_chars_hash(count, (char *)name, namelen); break; case MEA_MAGIC_HASH_SEGMENT: - c = mea_hash_segment(count, (char *) name, namelen); + c = mea_hash_segment(count, (char *)name, namelen); break; default: - CERROR("unknown hash type 0x%x\n", hashtype); + CERROR("Unknown hash type 0x%x\n", hashtype); } return c; @@ -149,7 +149,7 @@ int mea_name2idx(struct lmv_stripe_md *mea, const char *name, int namelen) LASSERT(mea && mea->mea_count); c = raw_name2idx(mea->mea_magic, mea->mea_count, name, namelen); - + LASSERT(c < mea->mea_count); return c; } diff --git a/lustre/tests/sanity-lmv.sh b/lustre/tests/sanity-lmv.sh index debf9e3..dcc9814 100644 --- a/lustre/tests/sanity-lmv.sh +++ b/lustre/tests/sanity-lmv.sh @@ -228,6 +228,15 @@ echo # add a newline after mke2fs. umask 077 +test_0a() { + mkdir $DIR/0a0 || error + for ((i=0;i<5000;i++)); do + mkdir $DIR/0a0/`uuidgen -t` || error + done + rm -rf $DIR/0a0 || error +} +run_test 0a " create random names =============================" + test_1a() { mkdir $DIR/1a0 || error createmany -o $DIR/1a0/f 4000 || error