summaryrefslogtreecommitdiff
path: root/source3/locking/brlock.c
AgeCommit message (Collapse)AuthorFilesLines
2026-04-21s3/brlock: map nt-error from correct errno-valueShachar Sharon1-2/+2
The functions 'brl_lock_windows_default' and 'brl_lock_posix' uses explicit 'errno_ret' value to avoid possible errno overwrite. Use in failure case. Signed-off-by: Shachar Sharon <ssharon@redhat.com> Reviewed-by: Anoop C S <anoopcs@samba.org> Reviewed-by: Shwetha Acharya <Shwetha.K.Acharya@ibm.com> Reviewed-by: Martin Schwenke <martin@meltin.net> Autobuild-User(master): Martin Schwenke <martins@samba.org> Autobuild-Date(master): Tue Apr 21 02:05:57 UTC 2026 on atb-devel-224
2026-04-07s3:locking: make leases.tdb none readable for othersRalph Wuerthner1-1/+1
Signed-off-by: Ralph Wuerthner <ralph.wuerthner@de.ibm.com> Reviewed-by: Xavi Hernandez <xhernandez@redhat.com> Reviewed-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Anoop C S <anoopcs@samba.org>
2025-10-10smbd: move lp_locking() check inside file_has_brlocks()Ralph Boehme1-0/+4
Avoids doing the check at every caller. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2025-08-15s3/locking: fix checking for byterange locks when granting RH leaseRalph Boehme1-1/+14
From MS-FSA 2.1.5.18 "Server Requests an Oplock": ... * Else If Type is LEVEL_GRANULAR: * If RequestedOplockLevel is READ_CACHING or (READ_CACHING|HANDLE_CACHING): * The operation MUST be failed with STATUS_OPLOCK_NOT_GRANTED under either of the following conditions: * Open.Stream.ByteRangeLockList is not empty and Open.Stream.AllocationSize is greater than any ByteRangeLock.LockOffset in Open.Stream.ByteRangeLockList. ... BUG: https://bugzilla.samba.org/show_bug.cgi?id=15894 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2025-08-15s3/locking: modernize file_has_brlocks()Ralph Boehme1-2/+3
No change in behaviour. Minimizes diff in the next commit that introduce a behaviour change. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15894 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2025-08-15smbd: make file_has_brlocks() publicRalph Boehme1-0/+11
Prepares for a change to file_has_brlocks() in the next commit. No change in behaviour. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15894 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2025-04-02smbd: use share_mode_do_locked_brl() in vfs_default_durable_reconnect()Ralph Boehme1-13/+2
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15767 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2025-04-02smbd: use share_mode_do_locked_brl() in vfs_default_durable_disconnect()Ralph Boehme1-12/+2
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15767 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2025-04-02s3/locking: prepare brl_locktest() for upgradable read-only locksRalph Boehme1-2/+3
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15767 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2025-04-02s3/brlock: remove brl_get_locks_for_locking()Stefan Metzmacher1-19/+0
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15767 Pair-Programmed-With: Ralph Boehme <slow@samba.org> Signed-off-by: Ralph Boehme <slow@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
2025-04-02s3/locking: add brl_set_modified()Ralph Boehme1-0/+5
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15767 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2025-04-02s3/brlock: add share_mode_do_locked_brl()Ralph Boehme1-0/+103
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15767 Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Ralph Boehme <slow@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
2025-04-02s3/brlock: add brl_req_set()Stefan Metzmacher1-0/+9
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15767 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2025-04-02s3/brlock: split out brl_get_locks_readonly_parse()Stefan Metzmacher1-15/+28
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15767 Pair-Programmed-With: Ralph Boehme <slow@samba.org> Signed-off-by: Ralph Boehme <slow@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
2025-03-07s3:locking: make sure brl_conflict_posix() is only called with 2 POSIX_LOCKSRalph Boehme1-5/+3
Otherwise we hit the assert if the caller is a windows lock and the conflicting one a posix lock. Or in the non-developer build we don't enforce the windows locking rules. Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Ralph Boehme <slow@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
2025-03-07s3:locking: assert POSIX_LOCK in brl_[un]lock_posix()Ralph Boehme1-0/+4
This makes it clearer and prevents possible problems in future. Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Ralph Boehme <slow@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
2024-05-22smbd: Remove the ZERO_ZERO defineVolker Lendecke1-88/+0
This code went in with e8e98c9ea06 in 2001 without any mention in the commit message. I don't remember all details, but there was some discussion around the offset=0,length=0 lock being somehow special. These days [MS-FSA] defines the required behaviour (don't conflict) and we implement that behaviour. If someone still remembers why this code is in and thinks it's worthwhile, that's what version control is for. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2024-04-23s3:brlock: use NUMERIC_CMP in #ifdef-zeroed lock_compareDouglas Bagnall1-5/+2
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15625 Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-07-17s3:locking: Fix code spellingAndreas Schneider1-1/+1
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2022-12-19smbd/locking: make use of the same tdb hash_size and flags for all SMB ↵Stefan Metzmacher1-7/+2
related tdb's It's good to have a consistent set of hash_size/flags for all aspects of an open file handle. Currently we're using 4 databases: smbXsrv_open_global.tdb, leases.tdb, locking.tdb and brlock.tdb. While at it also crank up the hashsize if the smbXsrv_tcon and smbXsrv_session TDBs. The default TDB hash size is insanely small and disk space is cheap these days, by going with the much larger hash size we get O(1) lookup instead of O(n) for moderate to large loads with a few thousand objects. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Mon Dec 19 16:40:15 UTC 2022 on sn-devel-184
2022-09-20s3:smbd: move locking related vfs functions to smbd/vfs.cStefan Metzmacher1-16/+0
This allows us to make VFS_FIND local to smbd/vfs.c in the next step. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2020-03-26smbd: Use ARRAY_DEL_ELEMENT() in brl_unlock_windows_default()Volker Lendecke1-12/+1
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2019-11-06lib: Remove #define serverid_equal server_id_equalVolker Lendecke1-3/+4
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-09-10smbd: Use file_id_str_buf() in brl_cleanup_disconnected()Volker Lendecke1-23/+24
Also avoid some casts and use DBG_ instead of DEBUG() Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-09-10smbd: Use file_id_str_buf() in brl_get_locks()Volker Lendecke1-3/+4
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-09-09s3:locking: add brl_req_guid() and brl_req_mem_ctx() helper functionsStefan Metzmacher1-4/+41
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>
2019-09-09s3:brlock: always return LOCK_NOT_GRANTED instead of FILE_LOCK_CONFLICTStefan Metzmacher1-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>
2019-09-09s3:locking: add/split out byte_range_{valid,overlap}() helper functionsStefan Metzmacher1-16/+93
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>
2019-07-04smbd: Don't store num_read_oplocks in brlock.tdbVolker Lendecke1-38/+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-02smbd: Remove unused "msg_ctx" from brl_close_fnum()Volker Lendecke1-2/+1
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 Lendecke1-3/+2
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 Lendecke1-8/+5
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 brl_lock()Volker Lendecke1-10/+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_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 Lendecke1-1/+1
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 Lendecke1-3/+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-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 Lendecke1-14/+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 Lendecke1-291/+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: 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: Add "blocker_pid" to brl_lock()Volker Lendecke1-0/+2
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-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>
2018-08-17lib: Pass mem_ctx to lock_path()Volker Lendecke1-1/+1
Fix a confusing API: Many places TALLOC_FREE the path where it's not clear you have to do it. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2017-01-22lib: Add lib/util/server_id.hVolker Lendecke1-0/+1
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2016-05-21s3: locking: Add a const struct lock_context * paramter to ↵Jeremy Allison1-0/+1
set_posix_lock_posix_flavour() We will need this to implement open file description record locks. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Jeff Layton <jlayton@samba.org>