]> 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)
committerRalph Boehme <slow@samba.org>
Wed, 2 Apr 2025 18:05:48 +0000 (18:05 +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>
source3/locking/brlock.c
source3/locking/locking.c
source3/locking/proto.h

index 2da06d6de4ab6f6c0800df2020ffbde432b827af..d73a81d4b80355d0a131cb170d9d92b1f90a3cf9 100644 (file)
@@ -1194,7 +1194,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;
@@ -1207,7 +1208,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 9a3de3e3ac3e7101b428d43bf196df769e3437df..e04377e4a5ca3bb2637f764668461d4eee797eb7 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 1243588330e397974b30424fc093af0bd0166825..d63c2828b0c4e4fd425b1e4503357da4bcc27b8f 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,