]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Move resetting "oplock_request" to before delay_for_oplock()
authorVolker Lendecke <vl@samba.org>
Thu, 25 Jul 2019 09:52:21 +0000 (11:52 +0200)
committerJeremy Allison <jra@samba.org>
Mon, 19 Aug 2019 23:14:39 +0000 (23:14 +0000)
It seems to make little sense to me to do the oplock break with one
setting and then later on grant_fsp_oplock_type with another
one. Survives tests, I can't think of any scenario where this (to me)
simplification would break anything

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/open.c

index ceb117c924d12afc15ace582369d947eb51cc6bd..23f80925840d30d93877036071eb510450102336 100644 (file)
@@ -3236,6 +3236,23 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
                open_access_mask |= FILE_WRITE_DATA; /* This will cause oplock breaks. */
        }
 
+       if (file_existed) {
+               /*
+                * stat opens on existing files don't get oplocks.
+                * They can get leases.
+                *
+                * Note that we check for stat open on the *open_access_mask*,
+                * i.e. the access mask we actually used to do the open,
+                * not the one the client asked for (which is in
+                * fsp->access_mask). This is due to the fact that
+                * FILE_OVERWRITE and FILE_OVERWRITE_IF add in O_TRUNC,
+                * which adds FILE_WRITE_DATA to open_access_mask.
+                */
+               if (is_stat_open(open_access_mask) && lease == NULL) {
+                       oplock_request = NO_OPLOCK;
+               }
+       }
+
        DEBUG(10, ("open_file_ntcreate: fname=%s, after mapping "
                   "access_mask=0x%x\n", smb_fname_str_dbg(smb_fname),
                    access_mask));
@@ -3596,23 +3613,6 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
                fsp->access_mask = access_mask | FILE_READ_ATTRIBUTES;
        }
 
-       if (file_existed) {
-               /*
-                * stat opens on existing files don't get oplocks.
-                * They can get leases.
-                *
-                * Note that we check for stat open on the *open_access_mask*,
-                * i.e. the access mask we actually used to do the open,
-                * not the one the client asked for (which is in
-                * fsp->access_mask). This is due to the fact that
-                * FILE_OVERWRITE and FILE_OVERWRITE_IF add in O_TRUNC,
-                * which adds FILE_WRITE_DATA to open_access_mask.
-                */
-               if (is_stat_open(open_access_mask) && lease == NULL) {
-                       oplock_request = NO_OPLOCK;
-               }
-       }
-
        if (new_file_created) {
                info = FILE_WAS_CREATED;
        } else {