From 16ce96c299c93e09b1c1ddceaa75399a7211a7d0 Mon Sep 17 00:00:00 2001 From: Rajesh Amaravathi Date: Fri, 1 Mar 2013 14:49:57 +0530 Subject: 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 Reviewed-on: http://review.gluster.org/4603 Reviewed-by: Kaleb KEITHLEY Tested-by: Gluster Build System Reviewed-by: Anand Avati --- xlators/nfs/server/src/nlm4.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'xlators/nfs') diff --git a/xlators/nfs/server/src/nlm4.c b/xlators/nfs/server/src/nlm4.c index aee14e9c8..595738b2c 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: -- cgit