]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3/brlock: handle persistent byterange locks in byte_range_lock_flush()
authorRalph Boehme <slow@samba.org>
Thu, 17 Jul 2025 10:52:22 +0000 (12:52 +0200)
committerRalph Boehme <slow@samba.org>
Fri, 17 Jul 2026 10:18:37 +0000 (10:18 +0000)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source3/locking/brlock.c

index f46147b7153f03e699affca2ff29dc2b9e7f3efd..a01c2cc5443e87d15aefedec79f790f9c7d03eb8 100644 (file)
@@ -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");