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.21.6~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=343479f944f599c175aa5c5a53834196a9d0ab02;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 ffb89378cb5..993d3a96591 100644 --- a/source3/locking/locking.c +++ b/source3/locking/locking.c @@ -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); } diff --git a/source3/locking/proto.h b/source3/locking/proto.h index 44b43c1b1e2..44808171f1a 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,