Commit 0a11aa1f authored by Pavel Emelyanov's avatar Pavel Emelyanov

locks: When checking for lock being ours handle mand-locks

Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 18000564
......@@ -127,6 +127,9 @@ static int lock_check_fd(int lfd, struct file_lock *fl)
{
int ret;
if (fl->fl_ltype & LOCK_MAND)
ret = flock(lfd, LOCK_MAND | LOCK_RW);
else
ret = flock(lfd, LOCK_EX | LOCK_NB);
pr_debug(" `- %d/%d\n", ret, errno);
if (ret != 0) {
......@@ -145,7 +148,9 @@ static int lock_check_fd(int lfd, struct file_lock *fl)
* on file pointed by fd.
*/
pr_debug(" `- downgrading lock back\n");
if (fl->fl_ltype == F_RDLCK)
if (fl->fl_ltype & LOCK_MAND)
flock(lfd, fl->fl_ltype);
else if (fl->fl_ltype == F_RDLCK)
flock(lfd, LOCK_SH);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment