From d9f0536b7f3cbe6b9b4d0dc5b4e4acd3337d41b5 Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Fri, 6 Oct 2017 14:23:23 -0400 Subject: [PATCH] FSAL_CEPH: don't clobber the return code with the getlk call If a lock is denied, the code will call getlk to get the conflicting lock info. That action then clobbers the return code and makes the lock appear to be a success. Also, no need to check conflicting_lock twice here. See: https://github.com/nfs-ganesha/nfs-ganesha/issues/205 Change-Id: Ibfc8ca92bec84518573f425131ce969479ae15dd Signed-off-by: Jeff Layton --- src/FSAL/FSAL_CEPH/handle.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/FSAL/FSAL_CEPH/handle.c b/src/FSAL/FSAL_CEPH/handle.c index e69506c158..a52f8c9b7c 100644 --- a/src/FSAL/FSAL_CEPH/handle.c +++ b/src/FSAL/FSAL_CEPH/handle.c @@ -1854,23 +1854,22 @@ fsal_status_t ceph_lock_op2(struct fsal_obj_handle *obj_hdl, -retval, strerror(-retval)); if (conflicting_lock != NULL) { + int retval2; + /* Get the conflicting lock */ - retval = ceph_ll_getlk(export->cmount, my_fd, + retval2 = ceph_ll_getlk(export->cmount, my_fd, &lock_args, (uint64_t) owner); - if (retval < 0) { + if (retval2 < 0) { LogCrit(COMPONENT_FSAL, "After failing a lock request, I couldn't even get the details of who owns the lock, error %d %s", - -retval, strerror(-retval)); + -retval2, strerror(-retval2)); goto err; } - if (conflicting_lock != NULL) { - conflicting_lock->lock_length = lock_args.l_len; - conflicting_lock->lock_start = - lock_args.l_start; - conflicting_lock->lock_type = lock_args.l_type; - } + conflicting_lock->lock_length = lock_args.l_len; + conflicting_lock->lock_start = lock_args.l_start; + conflicting_lock->lock_type = lock_args.l_type; } goto err;