summaryrefslogtreecommitdiffstats
path: root/xlators/nfs
diff options
context:
space:
mode:
authorRajesh Amaravathi <rajesh@redhat.com>2013-03-01 14:49:57 +0530
committerAnand Avati <avati@redhat.com>2013-03-05 16:38:30 -0800
commit16ce96c299c93e09b1c1ddceaa75399a7211a7d0 (patch)
tree536ecf35e0c5cf70fd68fa8b68360eca0eb9fd41 /xlators/nfs
parent2398e1e0da61f4ec5f209c704e037b54b5c249e1 (diff)
nlm: use appropriate open flags while locking
In case of a shared/read lock, open the file in O_RDONLY mode, and in the case of an exclusive lock, open the file in O_WRONLY mode to emulate the behaviour posix fcntl implementation as given in the man pages. Change-Id: Ib9eab6570c3bc65f8bd48a14a9d801616213b295 BUG: 916930 Signed-off-by: Rajesh Amaravathi <rajesh@redhat.com> Reviewed-on: http://review.gluster.org/4603 Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators/nfs')
-rw-r--r--xlators/nfs/server/src/nlm4.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/xlators/nfs/server/src/nlm4.c b/xlators/nfs/server/src/nlm4.c
index aee14e9c8cd..595738b2c17 100644
--- a/xlators/nfs/server/src/nlm4.c
+++ b/xlators/nfs/server/src/nlm4.c
@@ -594,9 +594,15 @@ nlm4_file_open_and_resume(nfs3_call_state_t *cs, nlm4_resume_fn_t resume)
{
fd_t *fd = NULL;
int ret = -1;
+ int flags = 0;
nlm_client_t *nlmclnt = NULL;
call_frame_t *frame = NULL;
+ if (cs->args.nlm4_lockargs.exclusive == _gf_false)
+ flags = O_RDONLY;
+ else
+ flags = O_WRONLY;
+
nlmclnt = nlm_get_uniq (cs->args.nlm4_lockargs.alock.caller_name);
if (nlmclnt == NULL) {
gf_log (GF_NLM, GF_LOG_ERROR, "nlm_get_uniq() returned NULL");
@@ -636,7 +642,7 @@ nlm4_file_open_and_resume(nfs3_call_state_t *cs, nlm4_resume_fn_t resume)
nfs_fix_groups (cs->nfsx, frame->root);
STACK_WIND_COOKIE (frame, nlm4_file_open_cbk, cs->vol, cs->vol,
- cs->vol->fops->open, &cs->resolvedloc, O_RDWR,
+ cs->vol->fops->open, &cs->resolvedloc, flags,
cs->fd, NULL);
ret = 0;
err: