summaryrefslogtreecommitdiff
path: root/source3/smbd/oplock.c
Commit message (Collapse)AuthorAgeFilesLines
* smbd: Use file_id_str_buf() in contend_level2_oplocks_begin_default()Volker Lendecke2019-11-061-1/+2
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Use file_id_str_buf() in process_kernel_oplock_break()Volker Lendecke2019-11-061-3/+5
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Use file_id_str_buf() in process_oplock_break_message()Volker Lendecke2019-11-061-7/+9
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Use file_id_str_buf() in initial_break_processing()Volker Lendecke2019-11-061-9/+13
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Use file_id_str_buf() in downgrade_lease()Volker Lendecke2019-11-061-8/+17
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Use file_id_str_buf() in downgrade_oplock()Volker Lendecke2019-11-061-4/+6
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Use file_id_str_buf() in set_file_oplock()Volker Lendecke2019-11-061-2/+4
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Use file_id_str_buf() in set_file_oplock()Volker Lendecke2019-11-061-1/+2
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Remove #define serverid_equal server_id_equalVolker Lendecke2019-11-061-1/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Add share mode flagsVolker Lendecke2019-09-171-1/+1
| | | | | | | | | | | This will contain a summary of the "most restrictive" share mode and lease, i.e. intersection of all share_access entries and the union of all access_mask and leases in the share mode array. This way open_mode_check in the non-conflicting case will only have to look at the summary and not walk the share mode array. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Stop passing "share_mode_lock" via share_mode_forall_leases()Volker Lendecke2019-09-171-2/+1
| | | | | | | | | | | Why? Next commit will make share_mode_forall_leases() use share_mode_forall_entries(), and that does not necessarily have to depend on "share_mode_lock". And as we can pass the required information via "private_data", don't embed the "share_mode_lock" reference into this lowlevel library routine. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Pass "struct file_id" to get_lease_type()Volker Lendecke2019-09-171-3/+2
| | | | | | | It does not have to depend on the whole struct share_mode_data. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Use share_mode_forall_entries() in contend_level2_oplocks_begin_default()Volker Lendecke2019-09-171-43/+42
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* vfs: Make "fd_handle->gen_id" 64-bit everywhereVolker Lendecke2019-09-171-9/+13
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Inline remove_oplock_under_lock() into its only callerVolker Lendecke2019-08-061-21/+8
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Make remove_oplock_under_lock staticVolker Lendecke2019-08-061-1/+1
| | | | | | | | | | | We have support for nested get_share_mode_lock calls, so we can avoid this additional function. It's one more talloc/free per close, but I hope this can't be measurable. Our open/close path is pretty expensive anyway. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Slightly simplify fsp_lease_update()Volker Lendecke2019-07-081-1/+1
| | | | | | | We have already dereferenced fsp->lease Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* smbd: Don't store num_read_oplocks in brlock.tdbVolker Lendecke2019-07-041-85/+0
| | | | | | | | | | | | | | This removes a kludgy implementation that worked around a locking hierarchy problem: Setting a byte range lock had to contend the level2 oplocks, which are stored in locking.tdb/leases.tdb. We could not access locking.tdb in the brlock.tdb code, as brlock.tdb might have been locked first without locking.tdb, violating the locking hierarchy locking.tdb->brlock.tdb. Now that that problem is gone (see the commit wrapping do_lock() in share_mode_do_locked()), we can remove this kludge. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* smbd: Use share_mode's flags in contend_level2_oplocksVolker Lendecke2019-07-041-116/+68
| | | | | | | | | | | | Here we traverse the oplocks and leases when breaking read leases. We find out here whether any of those are still left. As it's the receivers of the messages that downgrade the database entries, we might do that more than once. Possible future optimization? Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* smbd: Factor out fsps_lease_update()Volker Lendecke2019-05-281-22/+17
| | | | | | | Less lines of code, less .text bytes with -O3 Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Simplify fsp_lease_update()Volker Lendecke2019-05-281-8/+8
| | | | | | | | | | We don't need a share mode lock from a data dependency point of view anymore, the leases data moved to leases.tdb. However, from a coherency point of view it's probably wise to do this under a share mode lock. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Use "fsp->lease" instead of "lease"Volker Lendecke2019-05-281-1/+1
| | | | | | | | See the SMB_ASSERT a few lines above. Why this? It makes the next commit more obvious. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Do oplock break messages in ndrVolker Lendecke2019-05-161-17/+24
| | | | | | | | | | | The previous scheme was overloaded, a idl definition is easier to print, and it clarifies what data is actually needed 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): Thu May 16 23:48:18 UTC 2019 on sn-devel-184
* smbd: Use send_break_message() in send_break_to_none()Volker Lendecke2019-05-161-8/+6
| | | | | | | Centralize the marshalling code Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Remove share_mode_lease and the leases array from share_mode_entryVolker Lendecke2019-04-141-19/+8
| | | | | | | | | | This also removes the temporary functions introduced during the patchset. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org> Autobuild-User(master): Christof Schmitt <cs@samba.org> Autobuild-Date(master): Sun Apr 14 05:18:14 UTC 2019 on sn-devel-144
* smbd: Use share_mode_forall_leases in do_break_to_none()Volker Lendecke2019-04-141-36/+55
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* smbd: Use leases_db in process_oplock_break_message()Volker Lendecke2019-04-141-59/+78
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* smbd: Use leases_db in downgrade_lease()Volker Lendecke2019-04-141-60/+72
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* smbd: Use leases_db in fsp_lease_update()Volker Lendecke2019-04-141-12/+20
| | | | | | | Remove a reference to "struct share_mode_lease" Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* smbd: Use leases_db in get_lease_type()Volker Lendecke2019-04-141-1/+15
| | | | | | | Remove a reference to share_mode_data->leases[] Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* smbd: Use leases_db_set()Volker Lendecke2019-04-141-0/+63
| | | | | | | | Whenever we update the share_mode_lease struct, also update the leases.tdb entry. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* smbd: Small optimization for break_to_noneVolker Lendecke2019-04-141-3/+4
| | | | | | | | We don't need to memzero the struct when we can struct-initialize it a bit later, implicitly initializing the rest to zero. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* Revert "smbd: explain that/why we use the raw tevent_context for ↵Ralph Boehme2019-01-111-11/+1
| | | | | | | | | | | | | | | | lease_timeout_handler()" This reverts commit 52f098d38da72d6eff3c4cac61487da897a8651c. See the discussion in https://lists.samba.org/archive/samba-technical/2018-December/131731.html for the reasoning behind this revert. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* Revert "smbd: explain that/why we use the raw tevent_context for ↵Ralph Boehme2019-01-111-13/+1
| | | | | | | | | | | | | | | | oplock_timeout_handler()" This reverts commit e73eaa3c8004d3d8aff316cdb26b0bef85eceaca. See the discussion in https://lists.samba.org/archive/samba-technical/2018-December/131731.html for the reasoning behind this revert. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* Revert "smbd: explain that/why we use the raw tevent_context for ↵Ralph Boehme2019-01-111-14/+1
| | | | | | | | | | | | | | | | do_break_to_none()" This reverts commit 1d5210b615035e46b90758ac7aa4ceec9174bee5. See the discussion in https://lists.samba.org/archive/samba-technical/2018-December/131731.html for the reasoning behind this revert. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* smbd: Don't try to release a kernel oplock for a leased fileVolker Lendecke2018-12-181-7/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | If we have [global] smb2 leases = yes kernel oplocks = no [share] kernel oplocks = yes for clients requesting leases we don't even try to acquire kernel oplocks, because the kernel API is not compatible. Kernel oplocks are per fd, leases are roughly "per inode". We don't however special-case the LEASE_OPLOCK case in release_file_oplock, leading to nasty error messages like "bad file descriptor" on the fcntl(fd,F_SETLEASE,F_UNLCK) call. They are harmless, but they raise eyebrows. To simplify the if-condition, I factored out the kernel call and applied early returns. 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 Dec 18 02:00:44 CET 2018 on sn-devel-144
* s3:smbd: Use #ifdef instead of #if for config.h definitionsAndreas Schneider2018-11-281-1/+1
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* smbd: Simplify downgrade_share_leaseVolker Lendecke2018-10-021-9/+6
| | | | | | | | | | | Coalesce the NT_STATUS_OPLOCK_BREAK_IN_PROGRESS case into just one if-condition Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Tue Oct 2 22:22:37 CEST 2018 on sn-devel-144
* smbd: Move downgrade_share_lease into downgrade_leaseVolker Lendecke2018-10-021-55/+49
| | | | | | | The next step will simplify the logic of the code. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* smbd: Simplify downgrade_leaseVolker Lendecke2018-10-021-2/+2
| | | | | | | | To me, the "additive" SMB2_LEASE_WRITE|SMB2_LEASE_HANDLE is easier to read than the negated ~SMB2_LEASE_READ. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* smbd: Slightly simplify downgrade_lease()Volker Lendecke2018-10-021-4/+4
| | | | | | | | As much as I dislike }else{ and prefer early returns, I even more dislike asking for the same condition in two different ways. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* smbd: Use find_share_mode_lease() in downgrade_share_leaseVolker Lendecke2018-10-021-11/+5
| | | | | | | | Simple simplification: In locking/ we did not have the direct reference to find_share_mode_lock. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* smbd: Move downgrade_share_lease() to smbd/oplock.cVolker Lendecke2018-10-021-0/+85
| | | | | | | | | | This function is pretty closely entangled with its only caller. In particular the NT_STATUS_OPLOCK_BREAK_IN_PROGRESS triggers acitivity in the caller, and that's the only case where "*_l" is being set to non-NULL. Prepare for cleanup Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* smbd: Add a paranoia check for leasesVolker Lendecke2018-09-141-0/+6
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* smbd: Remove an unneeded #includeVolker Lendecke2018-09-111-1/+0
| | | | | | | ndr_open_files already includes open_files.h Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Simplify logic in fsp_lease_updateVolker Lendecke2018-09-071-5/+3
| | | | | | | One if-condition is better than two Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* smbd: Factor out file_has_read_oplocks()Volker Lendecke2018-09-071-10/+20
| | | | | | | | | Why? This makes it clearer to me that we're not interested in the actual number of read oplocks. We only want to know if there are any read oplocks at all. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* smbd: Remove unused KOPLOCK flagsChristof Schmitt2018-08-251-22/+5
| | | | | | | | | | | | This effectively reverts commit 17eba16b. It looks like these flags have been introduced as part of the onefs support which has been removed again. As there is no other use for the flags, remove them. Signed-off-by: Christof Schmitt <cs@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org> Autobuild-User(master): Christof Schmitt <cs@samba.org> Autobuild-Date(master): Sat Aug 25 03:23:05 CEST 2018 on sn-devel-144
* smbd: Remove koplocks->contend_level2 callbacksVolker Lendecke2018-08-221-19/+1
| | | | | | | | | | | | This was only implemented by onefs in this way. If we get around to use for example fanotify or something similar, we can either re-add them or do it in a different way. For now, simplify the code. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org> Autobuild-User(master): Ralph Böhme <slow@samba.org> Autobuild-Date(master): Wed Aug 22 00:57:31 CEST 2018 on sn-devel-144
* smbd: Fix a typoVolker Lendecke2018-08-171-1/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>