]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: reshuffle requested/granted lease level logic of Directory Leases
authorRalph Boehme <slow@samba.org>
Fri, 10 Oct 2025 13:24:31 +0000 (15:24 +0200)
committerVolker Lendecke <vl@samba.org>
Thu, 27 Nov 2025 10:04:47 +0000 (10:04 +0000)
This moves the logic to adjust the lease levels for Directory Leases to the same
place where we do it for other cases.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Thu Nov 27 10:04:47 UTC 2025 on atb-devel-224

source3/smbd/open.c

index 02f3c53598f9f41b53fd5c5af5aa2aac208d62bf..83bdf67f6715d4bd641633e05e2b5526dc0fa37f 100644 (file)
@@ -2516,15 +2516,6 @@ static NTSTATUS delay_for_oplock(files_struct *fsp,
                }
 
                requested = lease->lease_state;
-               if (fsp->fsp_flags.is_directory) {
-                       /*
-                        * According to "MS-FSA 2.1.5.18 Server Requests an
-                        * Oplock" this should fail with
-                        * STATUS_INVALID_PARAMETER, but Windows 2022 just
-                        * ignores the SMB2_LEASE_WRITE bit.
-                        */
-                       requested &= ~SMB2_LEASE_WRITE;
-               }
        } else {
                requested = map_oplock_to_lease_type(
                        oplock_request & ~SAMBA_PRIVATE_OPLOCK_MASK);
@@ -2584,6 +2575,16 @@ grant:
 
        granted = requested;
 
+       if (fsp->fsp_flags.is_directory) {
+               /*
+                * According to "MS-FSA 2.1.5.18 Server Requests an
+                * Oplock" this should fail with
+                * STATUS_INVALID_PARAMETER, but Windows 2022 just
+                * ignores the SMB2_LEASE_WRITE bit.
+                */
+               granted &= ~SMB2_LEASE_WRITE;
+       }
+
        if (oplock_request == LEASE_OPLOCK) {
                if (lp_kernel_oplocks(SNUM(fsp->conn))) {
                        DEBUG(10, ("No lease granted because kernel oplocks are enabled\n"));