From 72da7808cb0497b4ac6df55c58c9bf34daeee7ac Mon Sep 17 00:00:00 2001 From: Krishnan Parthasarathi Date: Thu, 10 May 2012 15:48:22 +0530 Subject: locks: Set flock.l_type on successful F_UNLCK to signal last unlock on fd. NLM expects a successful F_UNLCK on an fd to set flock.l_type to F_UNLCK if it were the last unlock else F_RDLCK. Change-Id: Ib304ac6102664abbb13d1fda649b3da63f1ee97e BUG: 800300 Signed-off-by: Krishnan Parthasarathi Reviewed-on: http://review.gluster.com/3306 Tested-by: Gluster Build System Reviewed-by: Krishna Srinivas Reviewed-by: Anand Avati --- xlators/features/locks/src/posix.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'xlators/features/locks/src') diff --git a/xlators/features/locks/src/posix.c b/xlators/features/locks/src/posix.c index 0bf022a943e..32d37f6abea 100644 --- a/xlators/features/locks/src/posix.c +++ b/xlators/features/locks/src/posix.c @@ -1244,6 +1244,13 @@ pl_lk (call_frame_t *frame, xlator_t *this, op_ret = -1; op_errno = EAGAIN; __destroy_lock (reqlock); + + } else if ((0 == ret) && (F_UNLCK == flock->l_type)) { + /* For NLM's last "unlock on fd" detection */ + if (pl_locks_by_fd (pl_inode, fd)) + flock->l_type = F_RDLCK; + else + flock->l_type = F_UNLCK; } } @@ -1251,10 +1258,6 @@ unwind: pl_trace_out (this, frame, fd, NULL, cmd, flock, op_ret, op_errno, NULL); pl_update_refkeeper (this, fd->inode); - if (pl_locks_by_fd(pl_inode, fd)) - flock->l_type = F_RDLCK; - else - flock->l_type = F_UNLCK; STACK_UNWIND_STRICT (lk, frame, op_ret, op_errno, flock, xdata); out: -- cgit