From: huanghua Date: Tue, 25 Jul 2006 15:22:57 +0000 (+0000) Subject: finally get rid of the defect which caused by a wrong comparism in ldlm_cli_enqueue(): X-Git-Tag: v1_8_0_110~486^2~1337 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=dba9e4389d9a345b8c5244abff5b05c2f9b7c312;p=fs%2Flustre-release.git finally get rid of the defect which caused by a wrong comparism in ldlm_cli_enqueue(): compare with res_id completely. --- diff --git a/lustre/include/lustre/lustre_idl.h b/lustre/include/lustre/lustre_idl.h index ea00dfe..eaf8e4d 100644 --- a/lustre/include/lustre/lustre_idl.h +++ b/lustre/include/lustre/lustre_idl.h @@ -262,6 +262,7 @@ static inline void fid_le_to_cpu(struct lu_fid *fid) fid->f_ver = le32_to_cpu(fid_ver(fid)); } + #define MEA_MAGIC_LAST_CHAR 0xb2221ca1 #define MEA_MAGIC_ALL_CHARS 0xb222a11c @@ -1679,5 +1680,16 @@ typedef enum { QUOTA_DQREL = 602, } quota_cmd_t; +/* + * Return true if resource is for object identified by fid. + */ +static inline int fid_res_name_eq(const struct lu_fid *f, + const struct ldlm_res_id *name) +{ + return name->name[0] == fid_seq(f) && + name->name[1] == fid_oid(f) && + name->name[2] == fid_ver(f); +} + #define JOIN_FILE_ALIGN 4096 #endif diff --git a/lustre/ldlm/ldlm_request.c b/lustre/ldlm/ldlm_request.c index bf2f655..128fe76 100644 --- a/lustre/ldlm/ldlm_request.c +++ b/lustre/ldlm/ldlm_request.c @@ -471,8 +471,8 @@ int ldlm_cli_enqueue(struct obd_export *exp, lock->l_req_mode = newmode; } - if (reply->lock_desc.l_resource.lr_name.name[0] != - lock->l_resource->lr_name.name[0]) { + if (memcmp(reply->lock_desc.l_resource.lr_name.name, + lock->l_resource->lr_name.name, sizeof(struct ldlm_res_id))) { CDEBUG(D_INFO, "remote intent success, locking %ld " "instead of %ld\n", (long)reply->lock_desc.l_resource.lr_name.name[0], diff --git a/lustre/mdc/mdc_locks.c b/lustre/mdc/mdc_locks.c index d1d967e..5b5590c 100644 --- a/lustre/mdc/mdc_locks.c +++ b/lustre/mdc/mdc_locks.c @@ -126,37 +126,14 @@ int mdc_set_lock_data(struct obd_export *exp, __u64 *lockh, void *data) if (lock->l_ast_data && lock->l_ast_data != data) { struct inode *new_inode = data; struct inode *old_inode = lock->l_ast_data; -/* FIXME: This is commented out by huanghua@clusterfs.com, - * if anything wrong, please restore that */ -#if 0 LASSERTF(old_inode->i_state & I_FREEING, "Found existing inode %p/%lu/%u state %lu in lock: " "setting data to %p/%lu/%u\n", old_inode, old_inode->i_ino, old_inode->i_generation, old_inode->i_state, new_inode, new_inode->i_ino, new_inode->i_generation); -#else - if (!(old_inode->i_state & I_FREEING)) { - CERROR("Found existing inode %p/%lu/%u state %lu in " - "lock: "LPX64", and setting its data to %p/%lu/%u\n", - old_inode, old_inode->i_ino, - old_inode->i_generation, old_inode->i_state, - ((struct lustre_handle *)lockh)->cookie, - new_inode, new_inode->i_ino, new_inode->i_generation); - } -#endif } #endif - -#ifdef __KERNEL__ - { - /* This is debug code by huanghua. Please remove this when ready */ - struct inode *new_inode = data; - CERROR("XXX: I am going to set lockh : "LPX64" to %p/%lu/%u\n", - ((struct lustre_handle *)lockh)->cookie, - new_inode, new_inode->i_ino, new_inode->i_generation); - } -#endif lock->l_ast_data = data; l_unlock(&lock->l_resource->lr_namespace->ns_lock); LDLM_LOCK_PUT(lock); @@ -602,9 +579,10 @@ int mdc_intent_lock(struct obd_export *exp, struct md_op_data *op_data, ENTRY; LASSERT(it); - CDEBUG(D_DLMTRACE,"name: %.*s in obj "DFID3", intent: %s flags %#o\n", - op_data->namelen, op_data->name, PFID3(&op_data->fid1), - ldlm_it2str(it->it_op), it->it_flags); + CDEBUG(D_DLMTRACE, "(name: %.*s,"DFID3") in obj "DFID3 + ", intent: %s flags %#o\n", + op_data->namelen, op_data->name, PFID3(&op_data->fid2), + PFID3(&op_data->fid1), ldlm_it2str(it->it_op), it->it_flags); if (fid_is_sane(&op_data->fid2) && (it->it_op & (IT_LOOKUP | IT_GETATTR))) { @@ -739,7 +717,18 @@ int mdc_intent_lock(struct obd_export *exp, struct md_op_data *op_data, if (lock) { ldlm_policy_data_t policy = lock->l_policy_data; LDLM_DEBUG(lock, "matching against this"); + + LASSERTF(fid_res_name_eq(&mdt_body->fid1, + &lock->l_resource->lr_name), + "Lock res_id: %lu/%lu/%lu, fid: %lu/%lu/%lu.\n", + (unsigned long)lock->l_resource->lr_name.name[0], + (unsigned long)lock->l_resource->lr_name.name[1], + (unsigned long)lock->l_resource->lr_name.name[2], + (unsigned long)fid_seq(&mdt_body->fid1), + (unsigned long)fid_oid(&mdt_body->fid1), + (unsigned long)fid_ver(&mdt_body->fid1)); LDLM_LOCK_PUT(lock); + memcpy(&old_lock, &lockh, sizeof(lockh)); if (ldlm_lock_match(NULL, LDLM_FL_BLOCK_GRANTED, NULL, LDLM_IBITS, &policy, LCK_NL, &old_lock)) { diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 13badfb..46650a1 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -620,6 +620,7 @@ int mdc_close(struct obd_export *exp, struct md_op_data *op_data, a reasonable return. bug 6155 */ CERROR("LBUG POISONED open %p!\n", mod->mod_open_req); ptlrpc_req_finished(req); + req = NULL; GOTO(out, rc = -EIO); } DEBUG_REQ(D_HA, mod->mod_open_req, "matched open"); diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index d5cc81e..76d64c9 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -397,6 +397,8 @@ static int mdt_getattr_name_lock(struct mdt_thread_info *info, ENTRY; LASSERT(info->mti_object != NULL); + CDEBUG(D_INFO, "getattr with lock for "DFID3"/%s, ldlm_rep = %p\n", + PFID3(mdt_object_fid(parent)), name, ldlm_rep); name = req_capsule_client_get(&info->mti_pill, &RMF_NAME); if (name == NULL) @@ -424,8 +426,6 @@ static int mdt_getattr_name_lock(struct mdt_thread_info *info, GOTO(out, result); } - CDEBUG(D_INFO, DFID3"/%s, ldlm_rep = %p\n", - PFID3(mdt_object_fid(parent)), name, ldlm_rep); /*step 1: lock parent */ lhp = &info->mti_lh[MDT_LH_PARENT]; lhp->mlh_mode = LCK_CR; @@ -455,6 +455,24 @@ static int mdt_getattr_name_lock(struct mdt_thread_info *info, result = mdt_getattr_internal(info, child, ldlm_rep ? 0 : 1); if (result != 0) mdt_object_unlock(info, child, lhc, 1); + else { + struct ldlm_lock *lock; + struct ldlm_res_id *res_id; + lock = ldlm_handle2lock(&lhc->mlh_lh); + if (lock) { + res_id = &lock->l_resource->lr_name; + LDLM_DEBUG(lock, "we will return this lock client\n"); + LASSERTF(fid_res_name_eq(mdt_object_fid(child), + &lock->l_resource->lr_name), + "Lock res_id: %lu/%lu/%lu, Fid: "DFID3".\n", + (unsigned long)res_id->name[0], + (unsigned long)res_id->name[1], + (unsigned long)res_id->name[2], + PFID3(mdt_object_fid(child))); + LDLM_LOCK_PUT(lock); + } + + } mdt_object_put(info->mti_ctxt, child); EXIT; @@ -581,7 +599,6 @@ static int mdt_readpage(struct mdt_thread_info *info) int rc; int i; ENTRY; - RETURN(-EOPNOTSUPP); if (MDT_FAIL_CHECK(OBD_FAIL_MDS_READPAGE_PACK)) RETURN(-ENOMEM); @@ -853,16 +870,6 @@ struct ldlm_res_id *fid_build_res_name(const struct lu_fid *f, return name; } -/* - * Return true if resource is for object identified by fid. - */ -int fid_res_name_eq(const struct lu_fid *f, const struct ldlm_res_id *name) -{ - return name->name[0] == fid_seq(f) && - name->name[1] == fid_oid(f) && - name->name[2] == fid_ver(f); -} - /* issues dlm lock on passed @ns, @f stores it lock handle into @lh. */ int fid_lock(struct ldlm_namespace *ns, const struct lu_fid *f, struct lustre_handle *lh, ldlm_mode_t mode, @@ -1632,8 +1639,8 @@ static int mdt_intent_getattr(enum mdt_it_code opcode, new_lock->l_flags &= ~LDLM_FL_LOCAL; - LDLM_LOCK_PUT(new_lock); l_unlock(&new_lock->l_resource->lr_namespace->ns_lock); + LDLM_LOCK_PUT(new_lock); RETURN(ELDLM_LOCK_REPLACED); }