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)
committerRalph Boehme <slow@samba.org>
Sat, 6 May 2017 20:58:47 +0000 (22:58 +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

source3/smbd/oplock.c

index cd92c8334f0b05875a0778c09ee87d2c6b99e3cf..aa060ad3747c2fc011798e2775966387154bb614 100644 (file)
@@ -166,13 +166,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;
        }