Unverified Commit 1e6631f5 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!15316 ocfs2: dlmfs: fix error handling of user_dlm_destroy_lock

parents cd53aeb4 d92a3dd8
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -449,6 +449,11 @@ int user_dlm_cluster_lock(struct user_lock_res *lockres,
	}

	spin_lock(&lockres->l_lock);
	if (lockres->l_flags & USER_LOCK_IN_TEARDOWN) {
		spin_unlock(&lockres->l_lock);
		status = -EAGAIN;
		goto bail;
	}

	/* We only compare against the currently granted level
	 * here. If the lock is blocked waiting on a downconvert,
@@ -615,7 +620,7 @@ int user_dlm_destroy_lock(struct user_lock_res *lockres)
	spin_lock(&lockres->l_lock);
	if (lockres->l_flags & USER_LOCK_IN_TEARDOWN) {
		spin_unlock(&lockres->l_lock);
		return 0;
		goto bail;
	}

	lockres->l_flags |= USER_LOCK_IN_TEARDOWN;
@@ -629,12 +634,17 @@ int user_dlm_destroy_lock(struct user_lock_res *lockres)
	}

	if (lockres->l_ro_holders || lockres->l_ex_holders) {
		lockres->l_flags &= ~USER_LOCK_IN_TEARDOWN;
		spin_unlock(&lockres->l_lock);
		goto bail;
	}

	status = 0;
	if (!(lockres->l_flags & USER_LOCK_ATTACHED)) {
		/*
		 * lock is never requested, leave USER_LOCK_IN_TEARDOWN set
		 * to avoid new lock request coming in.
		 */
		spin_unlock(&lockres->l_lock);
		goto bail;
	}
@@ -645,6 +655,10 @@ int user_dlm_destroy_lock(struct user_lock_res *lockres)

	status = ocfs2_dlm_unlock(conn, &lockres->l_lksb, DLM_LKF_VALBLK);
	if (status) {
		spin_lock(&lockres->l_lock);
		lockres->l_flags &= ~USER_LOCK_IN_TEARDOWN;
		lockres->l_flags &= ~USER_LOCK_BUSY;
		spin_unlock(&lockres->l_lock);
		user_log_dlm_error("ocfs2_dlm_unlock", status, lockres);
		goto bail;
	}