summaryrefslogtreecommitdiff
path: root/source3/locking
Commit message (Collapse)AuthorAgeFilesLines
* s3:locking: add brl_req_guid() and brl_req_mem_ctx() helper functionsStefan Metzmacher2019-09-093-5/+59
| | | | | | | | | | | This allows the vfs backend to detect a retry and keep state between the retries. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> (cherry picked from commit 66d92f37c3a643d97489a59bb6d1e75e91528c20)
* s3:brlock: always return LOCK_NOT_GRANTED instead of FILE_LOCK_CONFLICTStefan Metzmacher2019-09-091-4/+4
| | | | | | | | | | | | | | Returning NT_STATUS_FILE_LOCK_CONFLICT is a SMB1 only detail for delayed brlock requests, which is handled in smbd_smb1_do_locks*(). The brlock layer should be consistent even for posix locks. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113 Signed-off-by: Stefan Metzmacher <metze@samba.org> Signed-off-by: Volker Lendecke <vl@samba.org> (cherry picked from commit ad98eec6090430ba5296a5111dde2e53b9cd217a)
* s3:locking: add share_mode_wakeup_waiters() helper functionStefan Metzmacher2019-09-092-0/+13
| | | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> (cherry picked from commit bd8884e5722cbbb7783fb4ae53e4f35b31031b01)
* s3:locking: add/split out byte_range_{valid,overlap}() helper functionsStefan Metzmacher2019-09-092-16/+99
| | | | | | | | | | | | They implement the logic from [MS-FSA]. The following commits will use these functions in other locations. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> (cherry picked from commit 0e5613e39d6c6bb892fed939c63b4f14b878803b)
* smbd: Make find_share_mode_entry() static to locking.cVolker Lendecke2019-07-082-3/+1
| | | | | 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-042-41/+6
| | | | | | | | | | | | | | 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: Set SHARE_MODE_HAS_READ_LEASE when downgrading an oplockVolker Lendecke2019-07-041-0/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* smbd: Add file_has_read_lease()Volker Lendecke2019-07-042-1/+67
| | | | | | | | This caches share_mode_data->flags in the fsp, cache flush happening on tdb_seqnum change. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* smbd: Add flags to the beginning of share_mode_dataVolker Lendecke2019-07-041-4/+6
| | | | | | | | | They are put at the beginning for easy parsing without reading the full struct. First step to remove the number of read oplocks/leases from brlock.tdb, where it does not belong. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* smbd: Send do_lock() through share_mode_do_locked()Volker Lendecke2019-07-041-23/+58
| | | | | | | | | | | | | | | | We need to maintain the locking hierarchy locking.tdb->brlock.tdb at all times. vfs_fruit directly calls do_lock(), which might fail to maintain the locking hierarchy: In brlock.c we call contend_level2_oplocks_begin(), which will soon look at the locking.tdb record. For the SMB1 and SMB2 callers we already have the share mode locked, we might want to watch that record for unlocks. For those callers share_mode_do_locked() is practically free to call, we share the underlying db_record. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* smbd: Add share_mode_do_locked()Volker Lendecke2019-07-042-2/+116
| | | | | | | | | | | | | | This is made for efficient locking of share mode records in locking.tdb. Right now we already need that when accessing leases.tdb, and soon it will be required for brlock.tdb as well. It does not give direct access to the parsed share mode entry, but the record is available for dbwrap_watched_wakeup() within downgrade_lease(). It can be freely nested with get_share_mode_lock calls, the record will be shared and proper nesting should be checked. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* smbd: Introduce static_share_mode_recordVolker Lendecke2019-07-041-22/+38
| | | | | | | | | | The next commit will introduce share_mode_do_locked(), which allocates a share mode record on the stack. We have to expect nested get_share_mode_lock() calls from within share_mode_do_locked() for which we need to share a db_record. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* smbd: Simplify share_mode_lock.cVolker Lendecke2019-07-041-157/+142
| | | | | | | | | | | | | | | | | | | Do explicit refcounting instead of talloc_reference(). A later patch will introduce a share_mode_do_locked() routine that can be nested arbitrarily with get_share_mode_lock(). To do sanity checks for proper nesting, share_mode_do_locked needs to be aware of the reference counts for "static_share_mode_lock". Why is share_mode_memcache_delete() gone? In parse_share_modes() we already move the data out of the cache, share_mode_lock_destructor() we don't even bother re-adding the share_mode_data to the cache if it does not have share entries, because the next opener will invent a new seqnum anyway. Also: Less talloc_reference(), less lines of code. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* smbd: Remove unused "msg_ctx" from locking_close_file()Volker Lendecke2019-07-022-4/+2
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Remove unused "msg_ctx" from do_unlock()Volker Lendecke2019-07-022-12/+10
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Remove unused "msg_ctx" from brl_close_fnum()Volker Lendecke2019-07-023-5/+3
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Remove unused "msg_ctx" from brl_unlock()Volker Lendecke2019-07-023-7/+4
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* vfs: Remove unused "msg_ctx" from SMB_VFS_BRL_UNLOCK_WINDOWSVolker Lendecke2019-07-022-11/+7
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Remove unused "msg_ctx" from brl_unlock_posix()Volker Lendecke2019-07-021-3/+2
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Remove unused "msg_ctx" from do_lock()Volker Lendecke2019-07-022-4/+2
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Remove unused "msg_ctx" from brl_lock()Volker Lendecke2019-07-023-21/+20
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Remove unused "msg_ctx" from brl_lock_posixVolker Lendecke2019-07-021-3/+2
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Remove unused "blocking_lock" from brl_lock_windows_default()Volker Lendecke2019-07-022-3/+2
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* vfs: Remove "blocking_lock" from SMB_VFS_BRL_LOCK_WINDOWSVolker Lendecke2019-07-021-6/+3
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: brl_lock() never sees blocking locks anymoreVolker Lendecke2019-07-023-5/+2
| | | | | | | This is now all handled in protocol-specific layers Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: do_lock() never sees blocking locks anymoreVolker Lendecke2019-07-022-5/+2
| | | | | | | This is now all handled in protocol-specific layers Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Make do_lock() return NTSTATUSVolker Lendecke2019-07-022-43/+45
| | | | | | | | | This routine did a NO-GO: It returned something on talloc_tos(), for later consumption by push_blocking_lock_request. This is now gone, no caller uses the "struct byte_range_lock" returned anymore. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Avoid casts in do_lock()Volker Lendecke2019-07-021-5/+9
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Ensure initialized vars in do_lockVolker Lendecke2019-07-021-2/+2
| | | | | | | brl_lock does not initialize these variables in all cases Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Fix broken brlock for clusteringVolker Lendecke2019-06-281-10/+6
| | | | | | | | This should have been in f11c5887f4fb4b766, sorry. We now always need TDB_SEQNUM on brlock.tdb. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* vfs: Remove SMB_VFS_BRL_CANCEL_WINDOWSVolker Lendecke2019-06-202-16/+0
| | | | | | | | | | | This is not called anymore, bump the VFS version number in a separate commit 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 Jun 20 18:34:20 UTC 2019 on sn-devel-184
* smbd: Remove unused brlock codeVolker Lendecke2019-06-203-360/+9
| | | | | | | No PENDING locks in brlock.tdb anymore. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Add a clarifying comment on triggering waitersVolker Lendecke2019-06-201-0/+6
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Don't call cancel_pending_lock_requests_by_fid on closeVolker Lendecke2019-06-201-1/+0
| | | | | | | We don't use that queue anymore Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Remove SMB1 special case handling from brlock.cVolker Lendecke2019-06-201-35/+1
| | | | | | | | | This is now handled in smbd_smb1_do_locks_send/recv. From here on for a few commits we won't survive make test. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Return "blocker_pid" from do_lock()Volker Lendecke2019-06-202-0/+5
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Add some paranoia against NULL dereferenceVolker Lendecke2019-06-201-1/+6
| | | | | | | | | Quite a few callers set "psmblctx" to NULL, and I could not really follow 100% that brl_lock only assigns that in the blocking lock case. Too many layers :-) Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Add "blocker_pid" to brl_lock()Volker Lendecke2019-06-203-0/+5
| | | | | | | | | | Soon we will wait on a conflicting lock to become free via dbwrap_watched_watch_send. That routine can take a server_id that blocks us, watching it to go away. To use that, we need to know which PID it is that blocks us. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Adapt brl_pending_overlap to README.CodingVolker Lendecke2019-05-281-6/+11
| | | | | | | | | | Just reformatting, no behaviour change. This just looked too ugly to me. 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 May 28 22:22:28 UTC 2019 on sn-devel-184
* smbd: Avoid casts in do_unlock()Volker Lendecke2019-05-281-3/+6
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Fix a typoVolker Lendecke2019-05-281-2/+2
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* brlock: Remove clustering special caseVolker Lendecke2019-05-281-16/+7
| | | | | | | | With e7424897a127 we don't need this special case for clustering anymore. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* Fix ubsan null pointer passed as argument 2Gary Lockyer2019-05-271-1/+3
| | | | | | | | | | | | Fix ubsan warning null pointer passed as argument 2 when the source pointer is NULL. The calls to memcpy are now guarded by an if (len > 0) Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Gary Lockyer <gary@samba.org> Autobuild-Date(master): Mon May 27 01:29:48 UTC 2019 on sn-devel-184
* smbd: Merge "print_lock_struct" into one DBGVolker Lendecke2019-05-231-12/+12
| | | | | | | Also, avoid some casts Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Send "share_file_id" with the rename msgVolker Lendecke2019-05-181-21/+22
| | | | | | | | | | | file_id plus share_file_id remotely specify the fsp. This avoids the explicit loop in the receiver. 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): Sat May 18 20:18:55 UTC 2019 on sn-devel-184
* smbd: Add file_rename_message in idlVolker Lendecke2019-05-181-57/+38
| | | | | 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-142-46/+0
| | | | | | | | | | 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 share_mode_cleanup_disconnected()Volker Lendecke2019-04-141-8/+31
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* smbd: Use share_mode_forall_leases in rename_share_filename()Volker Lendecke2019-04-141-22/+33
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* smbd: Add share_mode_forall_leases()Volker Lendecke2019-04-142-0/+80
| | | | | | | | Function to walk all leases for a file exactly once. This used to be simpler with the leases[] array, thus this function that encapsulates the complexity. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>