summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2019-08-10 21:23:24 +0200
committerJeremy Allison <jra@samba.org>2019-08-19 23:14:39 +0000
commit9a11f361cc19d3b8da3469424697486d0fd8dd6d (patch)
treee23503c0b325c9f2820f26484e746214c100df7e /source3
parent7a6fa34130e8e6bea4672d08637af49097654119 (diff)
downloadsamba-9a11f361cc19d3b8da3469424697486d0fd8dd6d.tar.gz
smbd: Merge grant_fsp_oplock_type() into delay_for_oplock()
This is a preparation for the next commit: Only walk the share_modes[] array once when handling oplocks and leases. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3')
-rw-r--r--source3/smbd/open.c40
1 files changed, 14 insertions, 26 deletions
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index e07396773a5..85ef284e4f1 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -2107,9 +2107,13 @@ static NTSTATUS delay_for_oplock(files_struct *fsp,
bool will_overwrite;
const uint32_t delay_mask = have_sharing_violation ?
SMB2_LEASE_HANDLE : SMB2_LEASE_WRITE;
+ bool got_handle_lease = false;
+ bool got_oplock = false;
+ uint32_t granted;
+ NTSTATUS status;
if (is_stat_open(fsp->access_mask)) {
- return NT_STATUS_OK;
+ goto grant;
}
switch (create_disposition) {
@@ -2131,8 +2135,6 @@ static NTSTATUS delay_for_oplock(files_struct *fsp,
bool lease_is_breaking = false;
if (e_is_lease) {
- NTSTATUS status;
-
if (lease != NULL) {
bool our_lease = is_same_lease(fsp, e, lease);
if (our_lease) {
@@ -2206,20 +2208,11 @@ static NTSTATUS delay_for_oplock(files_struct *fsp,
if (delay) {
return NT_STATUS_RETRY;
}
- return NT_STATUS_OK;
-}
-static NTSTATUS grant_fsp_oplock_type(struct files_struct *fsp,
- struct share_mode_lock *lck,
- int oplock_request,
- const struct smb2_lease *lease)
-{
- struct share_mode_data *d = lck->data;
- bool got_handle_lease = false;
- bool got_oplock = false;
- uint32_t i;
- uint32_t granted;
- NTSTATUS status;
+grant:
+ if (have_sharing_violation) {
+ return NT_STATUS_SHARING_VIOLATION;
+ }
if (oplock_request == LEASE_OPLOCK) {
if (lease == NULL) {
@@ -2253,8 +2246,8 @@ static NTSTATUS grant_fsp_oplock_type(struct files_struct *fsp,
}
if (lp_locking(fsp->conn->params) && file_has_brlocks(fsp)) {
- DEBUG(10,("grant_fsp_oplock_type: file %s has byte range locks\n",
- fsp_str_dbg(fsp)));
+ DBG_DEBUG("file %s has byte range locks\n",
+ fsp_str_dbg(fsp));
granted &= ~SMB2_LEASE_READ;
}
@@ -2328,8 +2321,8 @@ static NTSTATUS grant_fsp_oplock_type(struct files_struct *fsp,
lck->data->flags |= SHARE_MODE_HAS_READ_LEASE;
}
- DEBUG(10,("grant_fsp_oplock_type: oplock type 0x%x on file %s\n",
- fsp->oplock_type, fsp_str_dbg(fsp)));
+ DBG_DEBUG("oplock type 0x%x on file %s\n",
+ fsp->oplock_type, fsp_str_dbg(fsp));
return NT_STATUS_OK;
}
@@ -2385,12 +2378,7 @@ static NTSTATUS handle_share_mode_lease(
return status;
}
- if (sharing_violation) {
- return NT_STATUS_SHARING_VIOLATION;
- }
-
- status = grant_fsp_oplock_type(fsp, lck, oplock_request, lease);
- return status;
+ return NT_STATUS_OK;
}
static bool request_timed_out(struct smb_request *req, struct timeval timeout)