From: Ralph Boehme Date: Thu, 30 Jan 2025 16:35:26 +0000 (+0100) Subject: s3/locking: prepare brl_locktest() for upgradable read-only locks X-Git-Tag: samba-4.22.1~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0bfec37cda95a902e145fa5109bbd8d85b70400c;p=thirdparty%2Fsamba.git s3/locking: prepare brl_locktest() for upgradable read-only locks BUG: https://bugzilla.samba.org/show_bug.cgi?id=15767 Signed-off-by: Ralph Boehme Reviewed-by: Stefan Metzmacher (cherry picked from commit 8f9387ceb5c94c7db92ab342e33c64b858c301b1) --- diff --git a/source3/locking/brlock.c b/source3/locking/brlock.c index b9decbc9e2a..92621c41577 100644 --- a/source3/locking/brlock.c +++ b/source3/locking/brlock.c @@ -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; } diff --git a/source3/locking/locking.c b/source3/locking/locking.c index 79ea220984f..77311151b54 100644 --- a/source3/locking/locking.c +++ b/source3/locking/locking.c @@ -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); } diff --git a/source3/locking/proto.h b/source3/locking/proto.h index 015aba1b78d..418799a1855 100644 --- a/source3/locking/proto.h +++ b/source3/locking/proto.h @@ -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,