diff options
author | Krishna Srinivas <ksriniva@redhat.com> | 2012-02-20 14:34:39 +0530 |
---|---|---|
committer | Vijay Bellur <vijay@gluster.com> | 2012-02-20 07:26:51 -0800 |
commit | ed2036979499cb272336187c06955aa5e484023d (patch) | |
tree | a2173280ad5753aa4d674e86e6ed66bcdcd6f973 /xlators/features/locks | |
parent | db20a0f8a99f715a77366e518720612f043d5c9e (diff) |
NLM - Network Lock Manger V4
Change-Id: Ic31b8bb10a28408da2a623f4ecc0c60af01c64af
BUG: 795421
Signed-off-by: Krishna Srinivas <ksriniva@redhat.com>
Reviewed-on: http://review.gluster.com/2711
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Diffstat (limited to 'xlators/features/locks')
-rw-r--r-- | xlators/features/locks/src/posix.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/xlators/features/locks/src/posix.c b/xlators/features/locks/src/posix.c index bd30ca4937d..17bc802a000 100644 --- a/xlators/features/locks/src/posix.c +++ b/xlators/features/locks/src/posix.c @@ -284,6 +284,27 @@ unwind: return 0; } +int +pl_locks_by_fd (pl_inode_t *pl_inode, fd_t *fd) +{ + posix_lock_t *l = NULL; + int found = 0; + + pthread_mutex_lock (&pl_inode->mutex); + { + + list_for_each_entry (l, &pl_inode->ext_list, list) { + if ((l->fd_num == fd_to_fdnum(fd))) { + found = 1; + break; + } + } + + } + pthread_mutex_unlock (&pl_inode->mutex); + return found; +} + static void delete_locks_of_fd (xlator_t *this, pl_inode_t *pl_inode, fd_t *fd) { @@ -1219,6 +1240,12 @@ pl_lk (call_frame_t *frame, xlator_t *this, 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); out: return 0; |