Carefully label SMB1-specific locking calls.
authorJeremy Allison <jra@samba.org>
Fri, 30 Apr 2010 00:08:12 +0000 (17:08 -0700)
committerJeremy Allison <jra@samba.org>
Fri, 30 Apr 2010 00:08:12 +0000 (17:08 -0700)
Jeremy.

source3/include/proto.h
source3/smbd/blocking.c
source3/smbd/globals.h
source3/smbd/nttrans.c
source3/smbd/reply.c
source3/smbd/smb2_lock.c
source3/smbd/trans2.c

index 1eaa008320d2cf991fbbb08d6069dc49253585bf..929d1ecb32e84290e1b3d7f7aa16e28cf113aa6b 100644 (file)
@@ -6114,9 +6114,9 @@ bool push_blocking_lock_request( struct byte_range_lock *br_lck,
                uint64_t count,
                uint32 blocking_pid);
 void cancel_pending_lock_requests_by_fid(files_struct *fsp, struct byte_range_lock *br_lck);
-void remove_pending_lock_requests_by_mid(uint64_t mid);
-bool blocking_lock_was_deferred(uint64_t mid);
-struct blocking_lock_record *blocking_lock_cancel(files_struct *fsp,
+void remove_pending_lock_requests_by_mid_smb1(uint64_t mid);
+bool blocking_lock_was_deferred_smb1(uint64_t mid);
+struct blocking_lock_record *blocking_lock_cancel_smb1(files_struct *fsp,
                        uint32 lock_pid,
                        uint64_t offset,
                        uint64_t count,
index f399e6b3c75e741e9049a79fdebf1f0b9d270316..c10899f5e60db005b029d77a034be0d503b0074f 100644 (file)
@@ -561,6 +561,7 @@ static bool blocking_lock_record_process(struct blocking_lock_record *blr)
 
 /****************************************************************************
  Cancel entries by fnum from the blocking lock pending queue.
+ Called when a file is closed.
 *****************************************************************************/
 
 void cancel_pending_lock_requests_by_fid(files_struct *fsp, struct byte_range_lock *br_lck)
@@ -568,6 +569,11 @@ void cancel_pending_lock_requests_by_fid(files_struct *fsp, struct byte_range_lo
        struct smbd_server_connection *sconn = smbd_server_conn;
        struct blocking_lock_record *blr, *blr_cancelled, *next = NULL;
 
+       if (sconn->allow_smb2) {
+               cancel_pending_lock_requests_by_fid_smb2(fsp, br_lck);
+               return;
+       }
+
        for(blr = sconn->smb1.locks.blocking_lock_queue; blr; blr = next) {
                unsigned char locktype = 0;
 
@@ -584,7 +590,7 @@ void cancel_pending_lock_requests_by_fid(files_struct *fsp, struct byte_range_lo
                           "request type %d for file %s fnum = %d\n",
                           blr->req->cmd, fsp_str_dbg(fsp), fsp->fnum));
 
-               blr_cancelled = blocking_lock_cancel(fsp,
+               blr_cancelled = blocking_lock_cancel_smb1(fsp,
                                     blr->lock_pid,
                                     blr->offset,
                                     blr->count,
@@ -610,9 +616,10 @@ void cancel_pending_lock_requests_by_fid(files_struct *fsp, struct byte_range_lo
 
 /****************************************************************************
  Delete entries by mid from the blocking lock pending queue. Always send reply.
+ Only called from the SMB1 cancel code.
 *****************************************************************************/
 
-void remove_pending_lock_requests_by_mid(uint64_t mid)
+void remove_pending_lock_requests_by_mid_smb1(uint64_t mid)
 {
        struct smbd_server_connection *sconn = smbd_server_conn;
        struct blocking_lock_record *blr, *next = NULL;
@@ -631,7 +638,7 @@ void remove_pending_lock_requests_by_mid(uint64_t mid)
                br_lck = brl_get_locks(talloc_tos(), fsp);
 
                if (br_lck) {
-                       DEBUG(10, ("remove_pending_lock_requests_by_mid - "
+                       DEBUG(10, ("remove_pending_lock_requests_by_mid_smb1 - "
                                   "removing request type %d for file %s fnum "
                                   "= %d\n", blr->req->cmd, fsp_str_dbg(fsp),
                                   fsp->fnum ));
@@ -654,9 +661,10 @@ void remove_pending_lock_requests_by_mid(uint64_t mid)
 
 /****************************************************************************
  Is this mid a blocking lock request on the queue ?
+ Currently only called from the SMB1 unix extensions POSIX lock code.
 *****************************************************************************/
 
-bool blocking_lock_was_deferred(uint64_t mid)
+bool blocking_lock_was_deferred_smb1(uint64_t mid)
 {
        struct smbd_server_connection *sconn = smbd_server_conn;
        struct blocking_lock_record *blr, *next = NULL;
@@ -823,9 +831,10 @@ static void process_blocking_lock_cancel_message(struct messaging_context *ctx,
 /****************************************************************************
  Send ourselves a blocking lock cancelled message. Handled asynchronously above.
  Returns the blocking_lock_record that is being cancelled.
+ Only called from the SMB1 code.
 *****************************************************************************/
 
-struct blocking_lock_record *blocking_lock_cancel(files_struct *fsp,
+struct blocking_lock_record *blocking_lock_cancel_smb1(files_struct *fsp,
                        uint32 lock_pid,
                        uint64_t offset,
                        uint64_t count,
index 614d8fcdb5d37cf8b3dc1f9c1c5c0ef6a6d95731..be140ba4454dc50870824ce00567777e07048e0c 100644 (file)
@@ -324,6 +324,8 @@ bool push_blocking_lock_request_smb2( struct byte_range_lock *br_lck,
                                uint64_t offset,
                                uint64_t count,
                                uint32_t blocking_pid);
+void cancel_pending_lock_requests_by_fid_smb2(files_struct *fsp,
+                       struct byte_range_lock *br_lck);
 /* From smbd/smb2_create.c */
 int map_smb2_oplock_levels_to_samba(uint8_t in_oplock_level);
 uint8_t map_samba_oplock_levels_to_smb2(int oplock_type);
index b594b7e4bc1b242c5103138bbae802659599d463..496c38db84e5cf6d120ec75e429d636605b0cd95 100644 (file)
@@ -1278,7 +1278,7 @@ void reply_ntcancel(struct smb_request *req)
        START_PROFILE(SMBntcancel);
        srv_cancel_sign_response(smbd_server_conn);
        remove_pending_change_notify_requests_by_mid(req->mid);
-       remove_pending_lock_requests_by_mid(req->mid);
+       remove_pending_lock_requests_by_mid_smb1(req->mid);
 
        DEBUG(3,("reply_ntcancel: cancel called on mid = %llu.\n",
                (unsigned long long)req->mid));
index 56c067f4dc4dfe5eaeb25bbb98d13465b90bbb20..6469ad8306a8b5bd9ca9feb94066e3214b2938ac 100644 (file)
@@ -7174,7 +7174,7 @@ NTSTATUS smbd_do_locking(struct smb_request *req,
                                   remove the blocking lock record and
                                   return the right error. */
 
-                               blr = blocking_lock_cancel(fsp,
+                               blr = blocking_lock_cancel_smb1(fsp,
                                                e->smbpid,
                                                e->offset,
                                                e->count,
index 597034c1da0573efd793bec2a75ae61332598e3f..d7a6cb13768490feaa6c92f9599e7582b211acd4 100644 (file)
@@ -401,3 +401,8 @@ bool push_blocking_lock_request_smb2( struct byte_range_lock *br_lck,
 {
        return false;
 }
+
+void cancel_pending_lock_requests_by_fid_smb2(files_struct *fsp,
+                       struct byte_range_lock *br_lck)
+{
+}
index 102b41f91aa34868cfcbb084b7aa5e0c639e0d99..811a647ab340cef212a36f494edc2046aac1f5a5 100644 (file)
@@ -7842,7 +7842,7 @@ static void call_trans2setfilepathinfo(connection_struct *conn,
                        /* We have re-scheduled this call. */
                        return;
                }
-               if (blocking_lock_was_deferred(req->mid)) {
+               if (blocking_lock_was_deferred_smb1(req->mid)) {
                        /* We have re-scheduled this call. */
                        return;
                }