Linux RAID subsystem development
 help / color / mirror / Atom feed
From: Guoqing Jiang <gqjiang@suse.com>
To: linux-raid@vger.kernel.org
Cc: shli@fb.com, Guoqing Jiang <gqjiang@suse.com>
Subject: [PATCH V2 02/10] md-cluster: use FORCEUNLOCK in lockres_free
Date: Fri, 12 Aug 2016 13:42:35 +0800	[thread overview]
Message-ID: <1470980563-26062-3-git-send-email-gqjiang@suse.com> (raw)
In-Reply-To: <1470980563-26062-1-git-send-email-gqjiang@suse.com>

For dlm_unlock, we need to pass flag to dlm_unlock as the
third parameter instead of set res->flags.

Also, DLM_LKF_FORCEUNLOCK is more suitable for dlm_unlock
since it works even the lock is on waiting or convert queue.

Acked-by: NeilBrown <neilb@suse.com>
Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
---
 drivers/md/md-cluster.c | 23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
index 41573f1..0a0605f 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -194,25 +194,18 @@ out_err:
 
 static void lockres_free(struct dlm_lock_resource *res)
 {
-	int ret;
+	int ret = 0;
 
 	if (!res)
 		return;
 
-	/* cancel a lock request or a conversion request that is blocked */
-	res->flags |= DLM_LKF_CANCEL;
-retry:
-	ret = dlm_unlock(res->ls, res->lksb.sb_lkid, 0, &res->lksb, res);
-	if (unlikely(ret != 0)) {
-		pr_info("%s: failed to unlock %s return %d\n", __func__, res->name, ret);
-
-		/* if a lock conversion is cancelled, then the lock is put
-		 * back to grant queue, need to ensure it is unlocked */
-		if (ret == -DLM_ECANCEL)
-			goto retry;
-	}
-	res->flags &= ~DLM_LKF_CANCEL;
-	wait_for_completion(&res->completion);
+	/* use FORCEUNLOCK flag, so we can unlock even the lock is on the
+	 * waiting or convert queue */
+	ret = dlm_unlock(res->ls, res->lksb.sb_lkid, DLM_LKF_FORCEUNLOCK, &res->lksb, res);
+	if (unlikely(ret != 0))
+		pr_err("failed to unlock %s return %d\n", res->name, ret);
+	else
+		wait_for_completion(&res->completion);
 
 	kfree(res->name);
 	kfree(res->lksb.sb_lvbptr);
-- 
2.6.2


  parent reply	other threads:[~2016-08-12  5:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-12  5:42 [PATCH V2 00/10] The latest changes for md-cluster Guoqing Jiang
2016-08-12  5:42 ` [PATCH V2 01/10] md-cluster: call md_kick_rdev_from_array once ack failed Guoqing Jiang
2016-08-12  5:42 ` Guoqing Jiang [this message]
2016-08-12  5:42 ` [PATCH V2 03/10] md-cluster: remove some unnecessary dlm_unlock_sync Guoqing Jiang
2016-08-12  5:42 ` [PATCH V2 04/10] md: changes for MD_STILL_CLOSED flag Guoqing Jiang
2016-08-12  5:42 ` [PATCH V2 05/10] md-cluster: clean related infos of cluster Guoqing Jiang
2016-08-12  5:42 ` [PATCH V2 06/10] md-cluster: protect md_find_rdev_nr_rcu with rcu lock Guoqing Jiang
2016-08-12  5:42 ` [PATCH V2 07/10] md: remove obsolete ret in md_start_sync Guoqing Jiang
2016-08-12  5:42 ` [PATCH V2 08/10] md-cluster: convert the completion to wait queue Guoqing Jiang
2016-08-12  5:42 ` [PATCH V2 09/10] md-cluster: introduce dlm_lock_sync_interruptible to fix tasks hang Guoqing Jiang
2016-08-12  5:42 ` [PATCH V2 10/10] md-cluster: make resync lock also could be interruptted Guoqing Jiang
2016-08-17  1:49 ` [PATCH V2 00/10] The latest changes for md-cluster Shaohua Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1470980563-26062-3-git-send-email-gqjiang@suse.com \
    --to=gqjiang@suse.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=shli@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox