]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Optimize delay_for_oplock()
authorVolker Lendecke <vl@samba.org>
Sat, 10 Aug 2019 12:44:08 +0000 (14:44 +0200)
committerJeremy Allison <jra@samba.org>
Mon, 19 Aug 2019 23:14:38 +0000 (23:14 +0000)
get_lease_type() can involve a database access. Do that only if
necessary, and that is at most once in this loop.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
source3/smbd/open.c

index 1fd2cb721f4c7d09a3488ff9914ef2167866d6bb..a28f70fbc4170780f8f55fe51dad9547204eefb4 100644 (file)
@@ -2264,9 +2264,6 @@ static NTSTATUS grant_fsp_oplock_type(struct smb_request *req,
 
        for (i=0; i<d->num_share_modes; i++) {
                struct share_mode_entry *e = &d->share_modes[i];
-               uint32_t e_lease_type;
-
-               e_lease_type = get_lease_type(d, e);
 
                if ((granted & SMB2_LEASE_WRITE) &&
                    !is_same_lease(fsp, d, e, lease) &&
@@ -2277,9 +2274,12 @@ static NTSTATUS grant_fsp_oplock_type(struct smb_request *req,
                        granted &= ~SMB2_LEASE_WRITE;
                }
 
-               if ((e_lease_type & SMB2_LEASE_HANDLE) && !got_handle_lease &&
-                   !share_mode_stale_pid(d, i)) {
-                       got_handle_lease = true;
+               if (!got_handle_lease) {
+                       uint32_t e_lease_type = get_lease_type(d, e);
+                       if ((e_lease_type & SMB2_LEASE_HANDLE) &&
+                           !share_mode_stale_pid(d, i)) {
+                               got_handle_lease = true;
+                       }
                }
 
                if ((e->op_type != LEASE_OPLOCK) && !got_oplock &&