s3/smbd: update exclusive oplock optimisation to the lease area
authorRalph Boehme <slow@samba.org>
Thu, 4 May 2017 09:52:16 +0000 (11:52 +0200)
committerKarolin Seeger <kseeger@samba.org>
Fri, 12 May 2017 06:54:19 +0000 (08:54 +0200)
Update an optimisation in update_num_read_oplocks() that checks for
exclusive oplocks to the lease area.

The idea of the optimisation is to avoid expensive db queries in
brlock.tdb if we *know* we're the only open.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=12766

Signed-off-by: Ralph Boehme <slow@samba.org>
Signed-off-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Sat May  6 22:58:47 CEST 2017 on sn-devel-144

(cherry picked from commit a50343779a8a92d6f53095b36506b1d47ef68513)

source3/smbd/oplock.c

index fb5abfe3a7a7eb03216e98aef38a3fcf6162732a..ff7c0371689d4c88e28770bc23e3a54b60c5c246 100644 (file)
@@ -165,13 +165,18 @@ bool update_num_read_oplocks(files_struct *fsp, struct share_mode_lock *lck)
        uint32_t num_read_oplocks = 0;
        uint32_t i;
 
-       if (EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type)) {
+       if (fsp_lease_type_is_exclusive(fsp)) {
                /*
-                * If we're the only one, we don't need a brlock entry
+                * If we're fully exclusive, we don't need a brlock entry
                 */
                remove_stale_share_mode_entries(d);
-               SMB_ASSERT(d->num_share_modes == 1);
-               SMB_ASSERT(EXCLUSIVE_OPLOCK_TYPE(d->share_modes[0].op_type));
+
+               for (i=0; i<d->num_share_modes; i++) {
+                       struct share_mode_entry *e = &d->share_modes[i];
+                       uint32_t e_lease_type = get_lease_type(d, e);
+
+                       SMB_ASSERT(lease_type_is_exclusive(e_lease_type));
+               }
                return true;
        }