smbd: Make do_lock() return NTSTATUS
authorVolker Lendecke <vl@samba.org>
Mon, 1 Jul 2019 12:30:15 +0000 (14:30 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 2 Jul 2019 17:01:27 +0000 (17:01 +0000)
This routine did a NO-GO: It returned something on talloc_tos(), for
later consumption by push_blocking_lock_request. This is now gone, no
caller uses the "struct byte_range_lock" returned anymore.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/locking/locking.c
source3/locking/proto.h
source3/modules/vfs_fruit.c
source3/smbd/blocking.c

index 7e5807f306df58a0020d70ac6fbb0761f772e033..cda1d9d82652510214818c4e9b4c1ed8e836f4f6 100644 (file)
@@ -230,36 +230,36 @@ static void decrement_current_lock_count(files_struct *fsp,
  Utility function called by locking requests.
 ****************************************************************************/
 
-struct byte_range_lock *do_lock(struct messaging_context *msg_ctx,
-                       files_struct *fsp,
-                       uint64_t smblctx,
-                       uint64_t count,
-                       uint64_t offset,
-                       enum brl_type lock_type,
-                       enum brl_flavour lock_flav,
-                       bool blocking_lock,
-                       NTSTATUS *perr,
-                       struct server_id *pblocker_pid,
-                       uint64_t *psmblctx)
+NTSTATUS do_lock(struct messaging_context *msg_ctx,
+                files_struct *fsp,
+                uint64_t smblctx,
+                uint64_t count,
+                uint64_t offset,
+                enum brl_type lock_type,
+                enum brl_flavour lock_flav,
+                bool blocking_lock,
+                struct server_id *pblocker_pid,
+                uint64_t *psmblctx)
 {
        struct byte_range_lock *br_lck = NULL;
        struct server_id blocker_pid = { 0 };
        uint64_t blocker_smblctx = 0;
+       NTSTATUS status;
 
        /* silently return ok on print files as we don't do locking there */
        if (fsp->print_file) {
-               *perr = NT_STATUS_OK;
-               return NULL;
+               return NT_STATUS_OK;
        }
 
        if (!fsp->can_lock) {
-               *perr = fsp->is_directory ? NT_STATUS_INVALID_DEVICE_REQUEST : NT_STATUS_INVALID_HANDLE;
-               return NULL;
+               if (fsp->is_directory) {
+                       return NT_STATUS_INVALID_DEVICE_REQUEST;
+               }
+               return NT_STATUS_INVALID_HANDLE;
        }
 
        if (!lp_locking(fsp->conn->params)) {
-               *perr = NT_STATUS_OK;
-               return NULL;
+               return NT_STATUS_OK;
        }
 
        /* NOTE! 0 byte long ranges ARE allowed and should be stored  */
@@ -276,21 +276,23 @@ struct byte_range_lock *do_lock(struct messaging_context *msg_ctx,
 
        br_lck = brl_get_locks(talloc_tos(), fsp);
        if (!br_lck) {
-               *perr = NT_STATUS_NO_MEMORY;
-               return NULL;
+               return NT_STATUS_NO_MEMORY;
        }
 
-       *perr = brl_lock(msg_ctx,
-                       br_lck,
-                       smblctx,
-                       messaging_server_id(fsp->conn->sconn->msg_ctx),
-                       offset,
-                       count,
-                       lock_type,
-                       lock_flav,
-                       blocking_lock,
-                       &blocker_pid,
-                       &blocker_smblctx);
+       status = brl_lock(
+               msg_ctx,
+               br_lck,
+               smblctx,
+               messaging_server_id(fsp->conn->sconn->msg_ctx),
+               offset,
+               count,
+               lock_type,
+               lock_flav,
+               blocking_lock,
+               &blocker_pid,
+               &blocker_smblctx);
+
+       TALLOC_FREE(br_lck);
 
        if (psmblctx != NULL) {
                *psmblctx = blocker_smblctx;
@@ -299,10 +301,11 @@ struct byte_range_lock *do_lock(struct messaging_context *msg_ctx,
                *pblocker_pid = blocker_pid;
        }
 
-       DEBUG(10, ("do_lock: returning status=%s\n", nt_errstr(*perr)));
+       DBG_DEBUG("returning status=%s\n", nt_errstr(status));
 
        increment_current_lock_count(fsp, lock_flav);
-       return br_lck;
+
+       return status;
 }
 
 /****************************************************************************
index 1e90a40a9ea722bdeb5c0bb14349589ff1e887fb..aee8ce32e3b20790f031da44e51bc5a57f00ad0f 100644 (file)
@@ -101,17 +101,16 @@ NTSTATUS query_lock(files_struct *fsp,
                        uint64_t *poffset,
                        enum brl_type *plock_type,
                        enum brl_flavour lock_flav);
-struct byte_range_lock *do_lock(struct messaging_context *msg_ctx,
-                       files_struct *fsp,
-                       uint64_t smblctx,
-                       uint64_t count,
-                       uint64_t offset,
-                       enum brl_type lock_type,
-                       enum brl_flavour lock_flav,
-                       bool blocking_lock,
-                       NTSTATUS *perr,
-                       struct server_id *pblocker_pid,
-                       uint64_t *psmblctx);
+NTSTATUS do_lock(struct messaging_context *msg_ctx,
+                files_struct *fsp,
+                uint64_t smblctx,
+                uint64_t count,
+                uint64_t offset,
+                enum brl_type lock_type,
+                enum brl_flavour lock_flav,
+                bool blocking_lock,
+                struct server_id *pblocker_pid,
+                uint64_t *psmblctx);
 NTSTATUS do_unlock(struct messaging_context *msg_ctx,
                        files_struct *fsp,
                        uint64_t smblctx,
index 42beed2143fb85ab7c4446db23792911be3f695c..0952027baa43d162c8046458e85f4501fc5cdec5 100644 (file)
@@ -2743,10 +2743,8 @@ static NTSTATUS fruit_check_access(vfs_handle_struct *handle,
 
        /* Set NetAtalk locks matching our access */
        if (access_mask & FILE_READ_DATA) {
-               struct byte_range_lock *br_lck = NULL;
-
                off = access_to_netatalk_brl(fork_type, FILE_READ_DATA);
-               br_lck = do_lock(
+               status = do_lock(
                        handle->conn->sconn->msg_ctx,
                        fsp,
                        fsp->op->global->open_persistent_id,
@@ -2755,22 +2753,17 @@ static NTSTATUS fruit_check_access(vfs_handle_struct *handle,
                        READ_LOCK,
                        POSIX_LOCK,
                        false,  /* blocking_lock */
-                       &status,
                        NULL,
                        NULL);
 
-               TALLOC_FREE(br_lck);
-
                if (!NT_STATUS_IS_OK(status))  {
                        return status;
                }
        }
 
        if (!share_for_read) {
-               struct byte_range_lock *br_lck = NULL;
-
                off = denymode_to_netatalk_brl(fork_type, DENY_READ);
-               br_lck = do_lock(
+               status = do_lock(
                        handle->conn->sconn->msg_ctx,
                        fsp,
                        fsp->op->global->open_persistent_id,
@@ -2779,22 +2772,17 @@ static NTSTATUS fruit_check_access(vfs_handle_struct *handle,
                        READ_LOCK,
                        POSIX_LOCK,
                        false,  /* blocking_lock */
-                       &status,
                        NULL,
                        NULL);
 
-               TALLOC_FREE(br_lck);
-
                if (!NT_STATUS_IS_OK(status)) {
                        return status;
                }
        }
 
        if (access_mask & FILE_WRITE_DATA) {
-               struct byte_range_lock *br_lck = NULL;
-
                off = access_to_netatalk_brl(fork_type, FILE_WRITE_DATA);
-               br_lck = do_lock(
+               status = do_lock(
                        handle->conn->sconn->msg_ctx,
                        fsp,
                        fsp->op->global->open_persistent_id,
@@ -2803,22 +2791,17 @@ static NTSTATUS fruit_check_access(vfs_handle_struct *handle,
                        READ_LOCK,
                        POSIX_LOCK,
                        false,
-                       &status,
                        NULL,
                        NULL);
 
-               TALLOC_FREE(br_lck);
-
                if (!NT_STATUS_IS_OK(status)) {
                        return status;
                }
        }
 
        if (!share_for_write) {
-               struct byte_range_lock *br_lck = NULL;
-
                off = denymode_to_netatalk_brl(fork_type, DENY_WRITE);
-               br_lck = do_lock(
+               status = do_lock(
                        handle->conn->sconn->msg_ctx,
                        fsp,
                        fsp->op->global->open_persistent_id,
@@ -2827,12 +2810,9 @@ static NTSTATUS fruit_check_access(vfs_handle_struct *handle,
                        READ_LOCK,
                        POSIX_LOCK,
                        false,
-                       &status,
                        NULL,
                        NULL);
 
-               TALLOC_FREE(br_lck);
-
                if (!NT_STATUS_IS_OK(status)) {
                        return status;
                }
index eee08c7a31ef2c6f90a522fd9dda24cf584def7b..30357d7ce2b43810dedf2e52942c0e811f692717 100644 (file)
@@ -59,9 +59,8 @@ NTSTATUS smbd_do_locks_try(
 
        for (i=0; i<num_locks; i++) {
                struct smbd_lock_element *e = &locks[i];
-               struct byte_range_lock *br_lck;
 
-               br_lck = do_lock(
+               status = do_lock(
                        msg_ctx,
                        fsp,
                        e->smblctx,
@@ -70,14 +69,8 @@ NTSTATUS smbd_do_locks_try(
                        e->brltype,
                        lock_flav,
                        false,  /* blocking_lock */
-                       &status,
                        blocking_pid,
                        blocking_smblctx);
-               if (br_lck == NULL) {
-                       return status;
-               }
-               TALLOC_FREE(br_lck);
-
                if (!NT_STATUS_IS_OK(status)) {
                        break;
                }