Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6d95e048 authored by Andreas Dilger's avatar Andreas Dilger Committed by Greg Kroah-Hartman
Browse files

staging/lustre/ldlm: fix resource/fid check, use DLDLMRES

In ll_md_blocking_ast() the FID/resource comparison is incorrectly
checking for fid_ver() stored in res_id.name[2] instead of name[1]
changed since http://review.whamcloud.com/2271 (commit 4f91d5161d00)
landed.  This does not impact current clients, since name[2] and
fid_ver() are always zero, but it could cause problems in the future.

In ldlm_cli_enqueue_fini() use ldlm_res_eq() instead of comparing
each of the resource fields separately.

Use DLDLMRES/PLDLMRES when printing resource names everywhere.

Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2901
Lustre-change: http://review.whamcloud.com/6592


Signed-off-by: default avatarLai Siyao <lai.siyao@intel.com>
Reviewed-by: default avatarJohann Lombardi <johann.lombardi@intel.com>
Signed-off-by: default avatarPeng Tao <bergwolf@gmail.com>
Signed-off-by: default avatarAndreas Dilger <andreas.dilger@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 5ea17d6c
Loading
Loading
Loading
Loading
+11 −21
Original line number Original line Diff line number Diff line
@@ -610,18 +610,12 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req,
			lock->l_req_mode = newmode;
			lock->l_req_mode = newmode;
		}
		}


		if (memcmp(reply->lock_desc.l_resource.lr_name.name,
		if (!ldlm_res_eq(&reply->lock_desc.l_resource.lr_name,
			  lock->l_resource->lr_name.name,
				 &lock->l_resource->lr_name)) {
			  sizeof(struct ldlm_res_id))) {
			CDEBUG(D_INFO, "remote intent success, locking "DLDLMRES
			CDEBUG(D_INFO, "remote intent success, locking "
				       " instead of "DLDLMRES"\n",
					"(%ld,%ld,%ld) instead of "
			       PLDLMRES(&reply->lock_desc.l_resource),
					"(%ld,%ld,%ld)\n",
			       PLDLMRES(lock->l_resource));
			      (long)reply->lock_desc.l_resource.lr_name.name[0],
			      (long)reply->lock_desc.l_resource.lr_name.name[1],
			      (long)reply->lock_desc.l_resource.lr_name.name[2],
			      (long)lock->l_resource->lr_name.name[0],
			      (long)lock->l_resource->lr_name.name[1],
			      (long)lock->l_resource->lr_name.name[2]);


			rc = ldlm_lock_change_resource(ns, lock,
			rc = ldlm_lock_change_resource(ns, lock,
					&reply->lock_desc.l_resource.lr_name);
					&reply->lock_desc.l_resource.lr_name);
@@ -1912,7 +1906,8 @@ int ldlm_cli_cancel_unused_resource(struct ldlm_namespace *ns,
					   0, flags | LCF_BL_AST, opaque);
					   0, flags | LCF_BL_AST, opaque);
	rc = ldlm_cli_cancel_list(&cancels, count, NULL, flags);
	rc = ldlm_cli_cancel_list(&cancels, count, NULL, flags);
	if (rc != ELDLM_OK)
	if (rc != ELDLM_OK)
		CERROR("ldlm_cli_cancel_unused_resource: %d\n", rc);
		CERROR("canceling unused lock "DLDLMRES": rc = %d\n",
		       PLDLMRES(res), rc);


	LDLM_RESOURCE_DELREF(res);
	LDLM_RESOURCE_DELREF(res);
	ldlm_resource_putref(res);
	ldlm_resource_putref(res);
@@ -1930,15 +1925,10 @@ static int ldlm_cli_hash_cancel_unused(struct cfs_hash *hs, struct cfs_hash_bd *
{
{
	struct ldlm_resource	   *res = cfs_hash_object(hs, hnode);
	struct ldlm_resource	   *res = cfs_hash_object(hs, hnode);
	struct ldlm_cli_cancel_arg     *lc = arg;
	struct ldlm_cli_cancel_arg     *lc = arg;
	int			     rc;


	rc = ldlm_cli_cancel_unused_resource(ldlm_res_to_ns(res), &res->lr_name,
	ldlm_cli_cancel_unused_resource(ldlm_res_to_ns(res), &res->lr_name,
					NULL, LCK_MINMODE,
					NULL, LCK_MINMODE,
					lc->lc_flags, lc->lc_opaque);
					lc->lc_flags, lc->lc_opaque);
	if (rc != 0) {
		CERROR("ldlm_cli_cancel_unused ("LPU64"): %d\n",
		       res->lr_name.name[0], rc);
	}
	/* must return 0 for hash iteration */
	/* must return 0 for hash iteration */
	return 0;
	return 0;
}
}
+5 −14
Original line number Original line Diff line number Diff line
@@ -762,16 +762,9 @@ static int ldlm_resource_complain(struct cfs_hash *hs, struct cfs_hash_bd *bd,
	struct ldlm_resource  *res = cfs_hash_object(hs, hnode);
	struct ldlm_resource  *res = cfs_hash_object(hs, hnode);


	lock_res(res);
	lock_res(res);
	CERROR("Namespace %s resource refcount nonzero "
	CERROR("%s: namespace resource "DLDLMRES
	       "(%d) after lock cleanup; forcing "
	       " (%p) refcount nonzero (%d) after lock cleanup; forcing cleanup.\n",
	       "cleanup.\n",
	       ldlm_ns_name(ldlm_res_to_ns(res)), PLDLMRES(res), res,
	       ldlm_ns_name(ldlm_res_to_ns(res)),
	       atomic_read(&res->lr_refcount) - 1);

	CERROR("Resource: %p ("LPU64"/"LPU64"/"LPU64"/"
	       LPU64") (rc: %d)\n", res,
	       res->lr_name.name[0], res->lr_name.name[1],
	       res->lr_name.name[2], res->lr_name.name[3],
	       atomic_read(&res->lr_refcount) - 1);
	       atomic_read(&res->lr_refcount) - 1);


	ldlm_resource_dump(D_ERROR, res);
	ldlm_resource_dump(D_ERROR, res);
@@ -1403,10 +1396,8 @@ void ldlm_resource_dump(int level, struct ldlm_resource *res)
	if (!((libcfs_debug | D_ERROR) & level))
	if (!((libcfs_debug | D_ERROR) & level))
		return;
		return;


	CDEBUG(level, "--- Resource: %p ("LPU64"/"LPU64"/"LPU64"/"LPU64
	CDEBUG(level, "--- Resource: "DLDLMRES" (%p) refcount = %d\n",
	       ") (rc: %d)\n", res, res->lr_name.name[0], res->lr_name.name[1],
	       PLDLMRES(res), res, atomic_read(&res->lr_refcount));
	       res->lr_name.name[2], res->lr_name.name[3],
	       atomic_read(&res->lr_refcount));


	if (!list_empty(&res->lr_granted)) {
	if (!list_empty(&res->lr_granted)) {
		CDEBUG(level, "Granted locks (in reverse order):\n");
		CDEBUG(level, "Granted locks (in reverse order):\n");
+1 −4
Original line number Original line Diff line number Diff line
@@ -233,12 +233,9 @@ int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
			ll_have_md_lock(inode, &bits, mode);
			ll_have_md_lock(inode, &bits, mode);


		fid = ll_inode2fid(inode);
		fid = ll_inode2fid(inode);
		if (lock->l_resource->lr_name.name[0] != fid_seq(fid) ||
		if (!fid_res_name_eq(fid, &lock->l_resource->lr_name))
		    lock->l_resource->lr_name.name[1] != fid_oid(fid) ||
		    lock->l_resource->lr_name.name[2] != fid_ver(fid)) {
			LDLM_ERROR(lock, "data mismatch with object "
			LDLM_ERROR(lock, "data mismatch with object "
				   DFID" (%p)", PFID(fid), inode);
				   DFID" (%p)", PFID(fid), inode);
		}


		if (bits & MDS_INODELOCK_OPEN) {
		if (bits & MDS_INODELOCK_OPEN) {
			int flags = 0;
			int flags = 0;
+2 −7
Original line number Original line Diff line number Diff line
@@ -971,13 +971,8 @@ static int mdc_finish_intent_lock(struct obd_export *exp,


		LASSERTF(fid_res_name_eq(&mdt_body->fid1,
		LASSERTF(fid_res_name_eq(&mdt_body->fid1,
					 &lock->l_resource->lr_name),
					 &lock->l_resource->lr_name),
			 "Lock res_id: %lu/%lu/%lu, fid: %lu/%lu/%lu.\n",
			 "Lock res_id: "DLDLMRES", fid: "DFID"\n",
			 (unsigned long)lock->l_resource->lr_name.name[0],
			 PLDLMRES(lock->l_resource), PFID(&mdt_body->fid1));
			 (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);
		LDLM_LOCK_PUT(lock);


		memcpy(&old_lock, lockh, sizeof(*lockh));
		memcpy(&old_lock, lockh, sizeof(*lockh));
+2 −2
Original line number Original line Diff line number Diff line
@@ -788,8 +788,8 @@ static int mgc_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
		/* We've given up the lock, prepare ourselves to update. */
		/* We've given up the lock, prepare ourselves to update. */
		LDLM_DEBUG(lock, "MGC cancel CB");
		LDLM_DEBUG(lock, "MGC cancel CB");


		CDEBUG(D_MGC, "Lock res "LPX64" (%.8s)\n",
		CDEBUG(D_MGC, "Lock res "DLDLMRES" (%.8s)\n",
		       lock->l_resource->lr_name.name[0],
		       PLDLMRES(lock->l_resource),
		       (char *)&lock->l_resource->lr_name.name[0]);
		       (char *)&lock->l_resource->lr_name.name[0]);


		if (!cld) {
		if (!cld) {