From: Stefan Metzmacher Date: Thu, 18 Aug 2022 10:52:54 +0000 (+0200) Subject: s3:smbd: inline fsp_lease_type_is_exclusive() logic into contend_level2_oplocks_begin... X-Git-Tag: talloc-2.4.0~1391 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=76da56aa65bb9fe7f2f8c4a2e30e278a61db1ff5;p=thirdparty%2Fsamba.git s3:smbd: inline fsp_lease_type_is_exclusive() logic into contend_level2_oplocks_begin_default 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 Reviewed-by: Jeremy Allison --- diff --git a/source3/locking/leases_util.c b/source3/locking/leases_util.c index cb62bffbd7d..9ae4081cd7b 100644 --- a/source3/locking/leases_util.c +++ b/source3/locking/leases_util.c @@ -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; diff --git a/source3/locking/proto.h b/source3/locking/proto.h index 52452e56a7b..7fc177d7aa6 100644 --- a/source3/locking/proto.h +++ b/source3/locking/proto.h @@ -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_ */ diff --git a/source3/smbd/smb2_oplock.c b/source3/smbd/smb2_oplock.c index 1f143840b34..404746d6f6a 100644 --- a/source3/smbd/smb2_oplock.c +++ b/source3/smbd/smb2_oplock.c @@ -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. */