Skip to content

Commit 400cb45

Browse files
GuoqingJiangshligit
authored andcommitted
md-cluster: use FORCEUNLOCK in lockres_free
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> Signed-off-by: Shaohua Li <shli@fb.com>
1 parent e566aef commit 400cb45

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

drivers/md/md-cluster.c

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -194,25 +194,21 @@ static struct dlm_lock_resource *lockres_init(struct mddev *mddev,
194194

195195
static void lockres_free(struct dlm_lock_resource *res)
196196
{
197-
int ret;
197+
int ret = 0;
198198

199199
if (!res)
200200
return;
201201

202-
/* cancel a lock request or a conversion request that is blocked */
203-
res->flags |= DLM_LKF_CANCEL;
204-
retry:
205-
ret = dlm_unlock(res->ls, res->lksb.sb_lkid, 0, &res->lksb, res);
206-
if (unlikely(ret != 0)) {
207-
pr_info("%s: failed to unlock %s return %d\n", __func__, res->name, ret);
208-
209-
/* if a lock conversion is cancelled, then the lock is put
210-
* back to grant queue, need to ensure it is unlocked */
211-
if (ret == -DLM_ECANCEL)
212-
goto retry;
213-
}
214-
res->flags &= ~DLM_LKF_CANCEL;
215-
wait_for_completion(&res->completion);
202+
/*
203+
* use FORCEUNLOCK flag, so we can unlock even the lock is on the
204+
* waiting or convert queue
205+
*/
206+
ret = dlm_unlock(res->ls, res->lksb.sb_lkid, DLM_LKF_FORCEUNLOCK,
207+
&res->lksb, res);
208+
if (unlikely(ret != 0))
209+
pr_err("failed to unlock %s return %d\n", res->name, ret);
210+
else
211+
wait_for_completion(&res->completion);
216212

217213
kfree(res->name);
218214
kfree(res->lksb.sb_lvbptr);

0 commit comments

Comments
 (0)