]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3/locking: prepare brl_locktest() for upgradable read-only locks
authorRalph Boehme <slow@samba.org>
Thu, 30 Jan 2025 16:35:26 +0000 (17:35 +0100)
committerJule Anger <janger@samba.org>
Thu, 17 Apr 2025 11:16:13 +0000 (11:16 +0000)
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>
(cherry picked from commit 8f9387ceb5c94c7db92ab342e33c64b858c301b1)

source3/locking/brlock.c
source3/locking/locking.c
source3/locking/proto.h

index b9decbc9e2ac33adb22dc82ce172b539a4534c9b..92621c4157781f47d33444d7f596e25ad1dabe68 100644 (file)
@@ -1192,7 +1192,8 @@ bool brl_unlock(struct byte_range_lock *br_lck,
 ****************************************************************************/
 
 bool brl_locktest(struct byte_range_lock *br_lck,
-                 const struct lock_struct *rw_probe)
+                 const struct lock_struct *rw_probe,
+                 bool upgradable)
 {
        bool ret = True;
        unsigned int i;
@@ -1205,7 +1206,7 @@ bool brl_locktest(struct byte_range_lock *br_lck,
                 * Our own locks don't conflict.
                 */
                if (brl_conflict_other(&locks[i], rw_probe)) {
-                       if (br_lck->record == NULL) {
+                       if (!upgradable) {
                                /* readonly */
                                return false;
                        }
index ffb89378cb520f59e8685f8ffee7a7d64938de69..993d3a9659185f8a4052ab965605917e3fcbf76d 100644 (file)
@@ -145,7 +145,7 @@ bool strict_lock_check_default(files_struct *fsp, struct lock_struct *plock)
        if (!br_lck) {
                return true;
        }
-       ret = brl_locktest(br_lck, plock);
+       ret = brl_locktest(br_lck, plock, false);
 
        if (!ret) {
                /*
@@ -156,7 +156,7 @@ bool strict_lock_check_default(files_struct *fsp, struct lock_struct *plock)
                if (br_lck == NULL) {
                        return true;
                }
-               ret = brl_locktest(br_lck, plock);
+               ret = brl_locktest(br_lck, plock, true);
                TALLOC_FREE(br_lck);
        }
 
index 44b43c1b1e2cf3dfc246869cb5647a5c1ce05115..44808171f1a3130b4c61f66b58423bd0f1ed1a4a 100644 (file)
@@ -66,7 +66,8 @@ bool brl_unlock(struct byte_range_lock *br_lck,
 bool brl_unlock_windows_default(struct byte_range_lock *br_lck,
                                const struct lock_struct *plock);
 bool brl_locktest(struct byte_range_lock *br_lck,
-                 const struct lock_struct *rw_probe);
+                 const struct lock_struct *rw_probe,
+                 bool upgradable);
 NTSTATUS brl_lockquery(struct byte_range_lock *br_lck,
                uint64_t *psmblctx,
                struct server_id pid,