From 72ef44b6b3c3d61bf35ccf2a440cbba121796397 Mon Sep 17 00:00:00 2001 From: yury Date: Mon, 23 Oct 2006 12:08:59 +0000 Subject: [PATCH] - small fixes, cleanups, comments in pdirops code in mdt. --- lustre/include/lustre_fid.h | 16 +++++++++++----- lustre/mdd/mdd_dir.c | 5 +++-- lustre/mdd/mdd_orphans.c | 2 +- lustre/mdt/mdt_handler.c | 20 +++++++++++++++++--- lustre/osd/osd_handler.c | 1 + 5 files changed, 33 insertions(+), 11 deletions(-) diff --git a/lustre/include/lustre_fid.h b/lustre/include/lustre_fid.h index ec666f8..75873e7 100644 --- a/lustre/include/lustre_fid.h +++ b/lustre/include/lustre_fid.h @@ -200,6 +200,13 @@ void fid_be_to_cpu(struct lu_fid *dst, const struct lu_fid *src); struct ldlm_namespace; +enum { + LUSTRE_RES_ID_SEQ_OFF = 0, + LUSTRE_RES_ID_OID_OFF = 1, + LUSTRE_RES_ID_VER_OFF = 2, + LUSTRE_RES_ID_HSH_OFF = 3 +}; + /* * Build (DLM) resource name from fid. */ @@ -208,10 +215,9 @@ fid_build_reg_res_name(const struct lu_fid *f, struct ldlm_res_id *name) { memset(name, 0, sizeof *name); - name->name[0] = fid_seq(f); - name->name[1] = fid_oid(f); - name->name[2] = fid_ver(f); - name->name[3] = 0ull; + name->name[LUSTRE_RES_ID_SEQ_OFF] = fid_seq(f); + name->name[LUSTRE_RES_ID_OID_OFF] = fid_oid(f); + name->name[LUSTRE_RES_ID_VER_OFF] = fid_ver(f); return name; } @@ -221,7 +227,7 @@ fid_build_pdo_res_name(const struct lu_fid *f, struct ldlm_res_id *name) { fid_build_reg_res_name(f, name); - name->name[3] = hash; + name->name[LUSTRE_RES_ID_HSH_OFF] = hash; return name; } diff --git a/lustre/mdd/mdd_dir.c b/lustre/mdd/mdd_dir.c index b7efa71..97a46f3 100644 --- a/lustre/mdd/mdd_dir.c +++ b/lustre/mdd/mdd_dir.c @@ -107,7 +107,7 @@ static int mdd_is_parent(const struct lu_env *env, LASSERT(!lu_fid_eq(mdo2fid(p1), lf)); pfid = &mdd_env_info(env)->mti_fid; - /* Do not lookup ".." in root, they do not exist there. */ + /* Check for root first. */ if (lu_fid_eq(mdo2fid(p1), &mdd->mdd_root_fid)) RETURN(0); @@ -1232,7 +1232,8 @@ enum rename_order { MDD_RN_TGTSRC }; -static int mdd_rename_order(const struct lu_env *env, struct mdd_device *mdd, +static int mdd_rename_order(const struct lu_env *env, + struct mdd_device *mdd, struct mdd_object *src_pobj, struct mdd_object *tgt_pobj) { diff --git a/lustre/mdd/mdd_orphans.c b/lustre/mdd/mdd_orphans.c index 9e2d798..5cb4999 100644 --- a/lustre/mdd/mdd_orphans.c +++ b/lustre/mdd/mdd_orphans.c @@ -35,7 +35,7 @@ #include #include #include - +#include #include "mdd_internal.h" const char orph_index_name[] = "orphans"; diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 32ee805..ad0c326 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -212,7 +212,7 @@ void mdt_lock_pdo_init(struct mdt_lock_handle *lh, ldlm_mode_t lm, lh->mlh_reg_mode = lm; lh->mlh_type = MDT_PDO_LOCK; lh->mlh_pdo_hash = (name != NULL && namelen > 0 ? - full_name_hash(name, namelen) : 0); + full_name_hash(name, namelen - 1) : 0); } #ifdef CONFIG_PDIROPS @@ -1583,6 +1583,11 @@ int mdt_object_lock(struct mdt_thread_info *info, struct mdt_object *o, if (lh->mlh_type == MDT_PDO_LOCK && lh->mlh_pdo_hash != 0) { lh->mlh_pdo_mode = mdt_lock_pdo_mode(info, o, lh->mlh_reg_mode); if (lh->mlh_pdo_mode != LCK_MINMODE) { + /* + * Do not use LDLM_FL_LOCAL_ONLY for paralell lock, it + * is never going to be sent to client and we do not + * want it slowed down due to possible cancels. + */ policy->l_inodebits.bits = MDS_INODELOCK_UPDATE; rc = mdt_fid_lock(ns, &lh->mlh_pdo_lh, lh->mlh_pdo_mode, policy, res_id, LDLM_FL_ATOMIC_CB); @@ -1590,12 +1595,21 @@ int mdt_object_lock(struct mdt_thread_info *info, struct mdt_object *o, RETURN(rc); } - fid_build_pdo_res_name(mdt_object_fid(o), lh->mlh_pdo_hash, - res_id); + /* + * Finish rs_id initializing by name hash marking patr of + * directory which is taking modification. + */ + res_id->name[LUSTRE_RES_ID_HSH_OFF] = lh->mlh_pdo_hash; } #endif policy->l_inodebits.bits = ibits; + + /* + * Use LDLM_FL_LOCAL_ONLY for this lock. We do not know yet if it is + * going to be sent to client. If it is - mdt_intent_policy() path will + * fix it up and turns FL_LOCAL flag off. + */ rc = mdt_fid_lock(ns, &lh->mlh_reg_lh, lh->mlh_reg_mode, policy, res_id, LDLM_FL_LOCAL_ONLY | LDLM_FL_ATOMIC_CB); #ifdef CONFIG_PDIROPS diff --git a/lustre/osd/osd_handler.c b/lustre/osd/osd_handler.c index 28f899f..0dd3312 100644 --- a/lustre/osd/osd_handler.c +++ b/lustre/osd/osd_handler.c @@ -1322,6 +1322,7 @@ static int osd_dir_page_build(const struct lu_env *env, int first, *end = hash; CDEBUG(D_INFO, "%p %p %d "DFID": %#8.8x (%d) \"%*.*s\"\n", name, ent, nob, PFID(fid), hash, len, len, len, name); + if (nob >= recsize) { fid_be_to_cpu(&ent->lde_fid, fid); fid_cpu_to_le(&ent->lde_fid, &ent->lde_fid); -- 1.8.3.1