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: tevent-0.17.0~416 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f9387ceb5c94c7db92ab342e33c64b858c301b1;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 --- diff --git a/source3/locking/brlock.c b/source3/locking/brlock.c index 2da06d6de4a..d73a81d4b80 100644 --- a/source3/locking/brlock.c +++ b/source3/locking/brlock.c @@ -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; } diff --git a/source3/locking/locking.c b/source3/locking/locking.c index 9a3de3e3ac3..e04377e4a5c 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 1243588330e..d63c2828b0c 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,