summaryrefslogtreecommitdiff
path: root/source3/locking
AgeCommit message (Collapse)AuthorFilesLines
2019-07-17smbd: Increase a debug levelVolker Lendecke1-2/+2
This is not a real error, it happens when the share mode record is not around. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Uri Simchoni <uri@samba.org>
2019-07-08smbd: Make find_share_mode_entry() static to locking.cVolker Lendecke2-3/+1
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2019-07-04smbd: Don't store num_read_oplocks in brlock.tdbVolker Lendecke2-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>
2019-07-04smbd: Set SHARE_MODE_HAS_READ_LEASE when downgrading an oplockVolker Lendecke1-0/+1
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2019-07-04smbd: Add file_has_read_lease()Volker Lendecke2-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>
2019-07-04smbd: Add flags to the beginning of share_mode_dataVolker Lendecke1-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>
2019-07-04smbd: Send do_lock() through share_mode_do_locked()Volker Lendecke1-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>
2019-07-04smbd: Add share_mode_do_locked()Volker Lendecke2-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>
2019-07-04smbd: Introduce static_share_mode_recordVolker Lendecke1-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>
2019-07-04smbd: Simplify share_mode_lock.cVolker Lendecke1-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>
2019-07-02smbd: Remove unused "msg_ctx" from locking_close_file()Volker Lendecke2-4/+2
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-07-02smbd: Remove unused "msg_ctx" from do_unlock()Volker Lendecke2-12/+10
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-07-02smbd: Remove unused "msg_ctx" from brl_close_fnum()Volker Lendecke3-5/+3
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-07-02smbd: Remove unused "msg_ctx" from brl_unlock()Volker Lendecke3-7/+4
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-07-02vfs: Remove unused "msg_ctx" from SMB_VFS_BRL_UNLOCK_WINDOWSVolker Lendecke2-11/+7
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-07-02smbd: Remove unused "msg_ctx" from brl_unlock_posix()Volker Lendecke1-3/+2
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-07-02smbd: Remove unused "msg_ctx" from do_lock()Volker Lendecke2-4/+2
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-07-02smbd: Remove unused "msg_ctx" from brl_lock()Volker Lendecke3-21/+20
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-07-02smbd: Remove unused "msg_ctx" from brl_lock_posixVolker Lendecke1-3/+2
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-07-02smbd: Remove unused "blocking_lock" from brl_lock_windows_default()Volker Lendecke2-3/+2
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-07-02vfs: Remove "blocking_lock" from SMB_VFS_BRL_LOCK_WINDOWSVolker Lendecke1-6/+3
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-07-02smbd: brl_lock() never sees blocking locks anymoreVolker Lendecke3-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>
2019-07-02smbd: do_lock() never sees blocking locks anymoreVolker Lendecke2-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>
2019-07-02smbd: Make do_lock() return NTSTATUSVolker Lendecke2-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>
2019-07-02smbd: Avoid casts in do_lock()Volker Lendecke1-5/+9
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-07-02smbd: Ensure initialized vars in do_lockVolker Lendecke1-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>
2019-06-28smbd: Fix broken brlock for clusteringVolker Lendecke1-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>
2019-06-20vfs: Remove SMB_VFS_BRL_CANCEL_WINDOWSVolker Lendecke2-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
2019-06-20smbd: Remove unused brlock codeVolker Lendecke3-360/+9
No PENDING locks in brlock.tdb anymore. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-06-20smbd: Add a clarifying comment on triggering waitersVolker Lendecke1-0/+6
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-06-20smbd: Don't call cancel_pending_lock_requests_by_fid on closeVolker Lendecke1-1/+0
We don't use that queue anymore Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-06-20smbd: Remove SMB1 special case handling from brlock.cVolker Lendecke1-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>
2019-06-20smbd: Return "blocker_pid" from do_lock()Volker Lendecke2-0/+5
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-06-20smbd: Add some paranoia against NULL dereferenceVolker Lendecke1-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>
2019-06-20smbd: Add "blocker_pid" to brl_lock()Volker Lendecke3-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>
2019-05-28smbd: Adapt brl_pending_overlap to README.CodingVolker Lendecke1-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
2019-05-28smbd: Avoid casts in do_unlock()Volker Lendecke1-3/+6
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-05-28smbd: Fix a typoVolker Lendecke1-2/+2
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-05-28brlock: Remove clustering special caseVolker Lendecke1-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>
2019-05-27Fix ubsan null pointer passed as argument 2Gary Lockyer1-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
2019-05-23smbd: Merge "print_lock_struct" into one DBGVolker Lendecke1-12/+12
Also, avoid some casts Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-05-18smbd: Send "share_file_id" with the rename msgVolker Lendecke1-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
2019-05-18smbd: Add file_rename_message in idlVolker Lendecke1-57/+38
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-04-14smbd: Remove share_mode_lease and the leases array from share_mode_entryVolker Lendecke2-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
2019-04-14smbd: Use share_mode_forall_leases in share_mode_cleanup_disconnected()Volker Lendecke1-8/+31
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
2019-04-14smbd: Use share_mode_forall_leases in rename_share_filename()Volker Lendecke1-22/+33
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
2019-04-14smbd: Add share_mode_forall_leases()Volker Lendecke2-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>
2019-04-14smbd: Don't pass lease_idx down to set_share_mode()Volker Lendecke2-15/+48
Temporary patch to keep the code running. The new code in set_share_mode() will leave again once the patchset to remove share_mode_lease and thus the lease_idx in share_mode_entry goes away. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
2019-04-14smbd: Use share_mode_entry's lease data in remove_share_mode_lease()Volker Lendecke1-10/+3
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
2019-04-14smbd: Use share_mode_entry's lease data in remove_share_mode_lease()Volker Lendecke1-3/+8
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>