ref: 8e49cdfd1994af3ca0f112220b3614d685da4759
parent: 609d8e27749a12c41f527bbc43afe2b66f01449c
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Dec 23 16:02:00 EST 2023
check: lock arenas while checking them
--- a/check.c
+++ b/check.c
@@ -169,12 +169,15 @@
static int
checkfree(int fd)
{
+ Arena *a;
Arange *r, *n;
int i, fail;
fail = 0;
for(i = 0; i < fs->narena; i++){
- r = (Arange*)avlmin(fs->arenas[i].free);
+ a = &fs->arenas[i];
+ qlock(a);
+ r = (Arange*)avlmin(a->free);
for(n = (Arange*)avlnext(r); n != nil; n = (Arange*)avlnext(n)){
if(r->off >= n->off){
fprint(2, "misordered length %llx >= %llx\n", r->off, n->off);
@@ -187,10 +190,10 @@
}
r = n;
}
- }
- for(i = 0; i < fs->narena; i++)
- if(!checklog(fd, fs->arenas[i].loghd))
+ if(!checklog(fd, a->loghd))
fprint(fd, "arena %d: broken freelist\n", i);
+ qunlock(a);
+ }
return fail;
}