From: Ralph Boehme Date: Thu, 17 Jul 2025 10:52:22 +0000 (+0200) Subject: s3/brlock: handle persistent byterange locks in byte_range_lock_flush() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=58cc2bc3290c532dc12201c3af1b860a3309fd6b;p=thirdparty%2Fsamba.git s3/brlock: handle persistent byterange locks in byte_range_lock_flush() Signed-off-by: Ralph Boehme Reviewed-by: Anoop C S --- diff --git a/source3/locking/brlock.c b/source3/locking/brlock.c index f46147b7153..a01c2cc5443 100644 --- a/source3/locking/brlock.c +++ b/source3/locking/brlock.c @@ -1586,6 +1586,7 @@ static void byte_range_lock_flush(struct byte_range_lock *br_lck) { unsigned i; struct lock_struct *locks = br_lck->lock_data; + bool have_persistent_lock = false; if (!br_lck->modified) { DEBUG(10, ("br_lck not modified\n")); @@ -1604,6 +1605,9 @@ static void byte_range_lock_flush(struct byte_range_lock *br_lck) br_lck->num_locks -= 1; continue; } + if (locks[i].persistent) { + have_persistent_lock = true; + } i += 1; } @@ -1624,13 +1628,18 @@ static void byte_range_lock_flush(struct byte_range_lock *br_lck) [1].dptr = (uint8_t *)br_lck->lock_data, }; NTSTATUS status; + int store_flags = DBWRAP_REPLACE; + + if (have_persistent_lock) { + store_flags |= DBWRAP_STORE_PERSISTENT; + } PUSH_BE_U32(version_buf, 0, smbXsrv_version_global_current()); status = dbwrap_record_storev(br_lck->record, data, ARRAY_SIZE(data), - DBWRAP_REPLACE); + store_flags); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("store returned %s\n", nt_errstr(status))); smb_panic("Could not store byte range mode entry");