]> 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:31:14 +0000 (11:31 +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 79ea220984f3169e92a308d847ffe9e6c6aa146a..77311151b54eb1c16c61287cb0714d80b5676752 100644 (file)
@@ -146,7 +146,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) {
                /*
@@ -157,7 +157,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 015aba1b78dd946eb3a81b446e0ba95bc0a429c4..418799a1855a5198cb2e8e4450fa7438eafb0457 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,