Skip to contentSkip to conversation

dlm: Avoid that dlm_release_lockspace() incorrectly returns -EBUSY

PATCH New Bart Van Assche 2 participants 2 messages Oct 16, 2013 Distributed lock manager (DLM)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dlm: Avoid that dlm_release_lockspace() incorrectly returns -EBUSY

When dlm_release_lockspace(ls, 1) is invoked on a busy system immediately after the last dlm_unlock() AST has finished it can occur that lkb_idr_is_local() is invoked for the unlocked LKB since removal from ls_lkbidr only occurs after the AST has returned. If that happens dlm_release_lockspace(ls, 1) will return -EBUSY instead of releasing the lockspace. Fix this race condition by changing lkb_idr_is_local() such that it only returns true for LKB's that have not yet been unlocked.

---
 fs/dlm/lockspace.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
fs/dlm/lockspace.c +1 -3
index 88556dc..d5abafd 100644
@@ -706,9 +706,7 @@ static int lkb_idr_is_local(int id, void *p, void *data)
 {
 	struct dlm_lkb *lkb = p;
 
-	if (!lkb->lkb_nodeid)
-		return 1;
-	return 0;
+	return lkb->lkb_nodeid == 0 && lkb->lkb_grmode != DLM_LOCK_IV;
 }
 
 static int lkb_idr_is_any(int id, void *p, void *data)
Signature · 1 line
1.8.1.4
maintainer
#1 lore raw

PATCH 1/1 dlm: Avoid that dlm_release_lockspace() incorrectly returns -EBUSY

Quoted 1 line · Bart Van Assche

When dlm_release_lockspace(ls, 1) is invoked on a busy system

I've pushed this to the next branch.
Thanks, Dave