Skip to contentSkip to conversation

libdlm: Don't pass LKF_WAIT to the kernel

Cluster-devel Joel Becker 1 participant 1 message Mar 19, 2008

lore
Share & tools
lore
#0 lore raw

libdlm is passing LKF_WAIT to the kernel. In the kernel, the unlock path strictly audits flags, and errors on this unknown (to the kernel) flag. The correct answer is to keep the flag in userspace.

dlm/lib/libdlm.c +4 -4
@@ -754,7 +754,7 @@ static int ls_lock_v5(dlm_lshandle_t ls,
 
 	req->cmd = DLM_USER_LOCK;
 	req->i.lock.mode = mode;
-	req->i.lock.flags = flags;
+	req->i.lock.flags = (flags & ~LKF_WAIT);
 	req->i.lock.lkid = lksb->sb_lkid;
 	req->i.lock.parent = parent;
 	req->i.lock.lksb = lksb;
@@ -822,7 +822,7 @@ static int ls_lock_v6(dlm_lshandle_t ls,
 
 	req->cmd = DLM_USER_LOCK;
 	req->i.lock.mode = mode;
-	req->i.lock.flags = flags;
+	req->i.lock.flags = (flags & ~LKF_WAIT);
 	req->i.lock.lkid = lksb->sb_lkid;
 	req->i.lock.parent = parent;
 	req->i.lock.lksb = lksb;
@@ -1014,7 +1014,7 @@ static int ls_unlock_v5(struct dlm_ls_in
 	set_version_v5(&req);
 	req.cmd = DLM_USER_UNLOCK;
 	req.i.lock.lkid = lkid;
-	req.i.lock.flags = flags;
+	req.i.lock.flags = (flags & ~LKF_WAIT);
 	req.i.lock.lksb  = lksb;
 	req.i.lock.castparam = astarg;
 	/* DLM_USER_UNLOCK will default to existing completion AST */
@@ -1035,7 +1035,7 @@ static int ls_unlock_v6(struct dlm_ls_in
 	set_version_v6(&req);
 	req.cmd = DLM_USER_UNLOCK;
 	req.i.lock.lkid = lkid;
-	req.i.lock.flags = flags;
+	req.i.lock.flags = (flags & ~LKF_WAIT);
 	req.i.lock.lksb  = lksb;
 	req.i.lock.namelen = 0;
 	req.i.lock.castparam = astarg;
Signature · 9 lines
Life's Little Instruction Book #24

	"Drink champagne for no reason at all."

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127