]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:smbd: inline fsp_lease_type_is_exclusive() logic into contend_level2_oplocks_begin...
authorStefan Metzmacher <metze@samba.org>
Thu, 18 Aug 2022 10:52:54 +0000 (12:52 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 19 Aug 2022 18:41:34 +0000 (18:41 +0000)
SMB2_LEASE_WRITE is the indication for an exclusive lease,
the fact that a SMB2_LEASE_WRITE can't exists without
SMB2_LEASE_READ is not important here.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/locking/leases_util.c
source3/locking/proto.h
source3/smbd/smb2_oplock.c

index cb62bffbd7d66835e997c58bf1fc2e5a62955e23..9ae4081cd7bb0bcd3563e3e3be6f8547aef190a0 100644 (file)
@@ -71,23 +71,6 @@ uint32_t fsp_lease_type(struct files_struct *fsp)
        return fsp->lease_type;
 }
 
-static uint32_t lease_type_is_exclusive(uint32_t lease_type)
-{
-       if ((lease_type & (SMB2_LEASE_READ | SMB2_LEASE_WRITE)) ==
-           (SMB2_LEASE_READ | SMB2_LEASE_WRITE)) {
-               return true;
-       }
-
-       return false;
-}
-
-bool fsp_lease_type_is_exclusive(struct files_struct *fsp)
-{
-       uint32_t lease_type = fsp_lease_type(fsp);
-
-       return lease_type_is_exclusive(lease_type);
-}
-
 const struct GUID *fsp_client_guid(const files_struct *fsp)
 {
        return &fsp->conn->sconn->client->global->client_guid;
index 52452e56a7b775bd1a71ba7bdc49800503897e3a..7fc177d7aa6d097039f6cfd920f3d64f6230b4fa 100644 (file)
@@ -210,7 +210,6 @@ bool release_posix_lock_posix_flavour(files_struct *fsp,
 /* The following definitions come from locking/leases_util.c */
 uint32_t map_oplock_to_lease_type(uint16_t op_type);
 uint32_t fsp_lease_type(struct files_struct *fsp);
-bool fsp_lease_type_is_exclusive(struct files_struct *fsp);
 const struct GUID *fsp_client_guid(const files_struct *fsp);
 
 #endif /* _LOCKING_PROTO_H_ */
index 1f143840b34103860ddf7d961118d00441d57e04..404746d6f6aa56238d0e9aee6f62129c411cac57 100644 (file)
@@ -1248,6 +1248,7 @@ static void contend_level2_oplocks_begin_default(files_struct *fsp,
                .sconn = fsp->conn->sconn, .id = fsp->file_id,
        };
        struct share_mode_lock *lck = NULL;
+       uint32_t fsp_lease = fsp_lease_type(fsp);
        bool ok, has_read_lease;
 
        /*
@@ -1258,7 +1259,7 @@ static void contend_level2_oplocks_begin_default(files_struct *fsp,
         * the shared memory area whilst doing this.
         */
 
-       if (fsp_lease_type_is_exclusive(fsp)) {
+       if (fsp_lease & SMB2_LEASE_WRITE) {
                /*
                 * There can't be any level2 oplocks, we're alone.
                 */