git: 9467c1a69b81 - main - rangelock: assert that we never insert or remove our entry after a logically deleted one

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Wed, 21 Aug 2024 15:21:43 UTC
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=9467c1a69b81fff65b85f1e142c6dff196e66ba7

commit 9467c1a69b81fff65b85f1e142c6dff196e66ba7
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-08-11 04:25:21 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-08-21 15:19:15 +0000

    rangelock: assert that we never insert or remove our entry after a logically deleted one
    
    Tested by:      markj, pho
    Sponsored by:   The FreeBSD Foundation
---
 sys/kern/kern_rangelock.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sys/kern/kern_rangelock.c b/sys/kern/kern_rangelock.c
index 992a19701611..2667bf30fb6f 100644
--- a/sys/kern/kern_rangelock.c
+++ b/sys/kern/kern_rangelock.c
@@ -478,6 +478,7 @@ static bool
 rl_q_cas(struct rl_q_entry **prev, struct rl_q_entry *old,
     struct rl_q_entry *new)
 {
+	MPASS(!rl_e_is_marked(old));
 	return (atomic_cmpset_rel_ptr((uintptr_t *)prev, (uintptr_t)old,
 	    (uintptr_t)new) != 0);
 }
@@ -647,6 +648,7 @@ again:
 			}
 		}
 
+		MPASS(!rl_e_is_marked(cur));
 		r = rl_e_compare(cur, e);
 		if (r == -1) {
 			prev = &cur->rl_q_next;