diff options
author | Volker Lendecke <vl@samba.org> | 2019-08-13 16:56:58 +0200 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2019-08-20 00:33:12 +0000 |
commit | 8a05d2b074d588a481aa372f2923f55cfb3e3a23 (patch) | |
tree | 2302a157792f886cba52e357b737283872a11d46 | |
parent | 9a11f361cc19d3b8da3469424697486d0fd8dd6d (diff) | |
download | samba-8a05d2b074d588a481aa372f2923f55cfb3e3a23.tar.gz |
smbd: Move lease type detection in delay_for_oplock()
Walk the share_modes array only once.
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Aug 20 00:33:12 UTC 2019 on sn-devel-184
-rw-r--r-- | source3/smbd/open.c | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 85ef284e4f1..b654b3ceb9c 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -2109,6 +2109,7 @@ static NTSTATUS delay_for_oplock(files_struct *fsp, SMB2_LEASE_HANDLE : SMB2_LEASE_WRITE; bool got_handle_lease = false; bool got_oplock = false; + bool have_other_lease = false; uint32_t granted; NTSTATUS status; @@ -2156,6 +2157,24 @@ static NTSTATUS delay_for_oplock(files_struct *fsp, SMB_ASSERT(NT_STATUS_IS_OK(status)); } + if (!got_handle_lease && + ((e_lease_type & SMB2_LEASE_HANDLE) != 0) && + !share_mode_stale_pid(d, i)) { + got_handle_lease = true; + } + + if (!got_oplock && + (e->op_type != LEASE_OPLOCK) && + !share_mode_stale_pid(d, i)) { + got_oplock = true; + } + + if (!have_other_lease && + !is_same_lease(fsp, e, lease) && + !share_mode_stale_pid(d, i)) { + have_other_lease = true; + } + break_to = e_lease_type & ~delay_mask; if (will_overwrite) { @@ -2251,30 +2270,11 @@ grant: granted &= ~SMB2_LEASE_READ; } - for (i=0; i<d->num_share_modes; i++) { - struct share_mode_entry *e = &d->share_modes[i]; - - if ((granted & SMB2_LEASE_WRITE) && - !is_same_lease(fsp, e, lease) && - !share_mode_stale_pid(d, i)) { - /* - * Can grant only one writer - */ - granted &= ~SMB2_LEASE_WRITE; - } - - if (!got_handle_lease) { - uint32_t e_lease_type = get_lease_type(d, e); - if ((e_lease_type & SMB2_LEASE_HANDLE) && - !share_mode_stale_pid(d, i)) { - got_handle_lease = true; - } - } - - if ((e->op_type != LEASE_OPLOCK) && !got_oplock && - !share_mode_stale_pid(d, i)) { - got_oplock = true; - } + if (have_other_lease) { + /* + * Can grant only one writer + */ + granted &= ~SMB2_LEASE_WRITE; } if ((granted & SMB2_LEASE_READ) && !(granted & SMB2_LEASE_WRITE)) { |