shithub: gefs

Download patch

ref: bf7d857ba8ddf36e9433ccffa2ed01136c003cd7
parent: 75476e2449c20db4b07d583f114c968f2a7f04a5
author: Ori Bernstein <ori@eigenstate.org>
date: Mon May 1 00:16:05 EDT 2023

misc concurrency fixes

--- a/blk.c
+++ b/blk.c
@@ -21,7 +21,10 @@
 int
 checkflag(Blk *b, int f)
 {
-	return (b->flag & f) == f;
+	long v;
+
+	v = agetl(&b->flag);
+	return (v & f) == f;
 }
 
 void
@@ -30,7 +33,7 @@
 	long ov, nv;
 
 	while(1){
-		ov = b->flag;
+		ov = agetl(&b->flag);
 		nv = ov | f;
 		if(acasl(&b->flag, ov, nv))
 			break;
@@ -43,7 +46,7 @@
 	long ov, nv;
 
 	while(1){
-		ov = b->flag;
+		ov = agetl(&b->flag);
 		nv = ov & ~f;
 		if(acasl(&b->flag, ov, nv))
 			break;
@@ -512,6 +515,7 @@
 	}
 	PACK64(p, LogChain|graft);
 	free(log);
+	free(rng);
 	finalize(tl);
 	if(syncblk(tl) == -1)
 		return -1;
--- a/dump.c
+++ b/dump.c
@@ -353,12 +353,6 @@
 	dropblk(b);
 }
 
-static void
-showdeadbp(Bptr bp, void *p)
-{
-	fprint(*(int*)p, "\t\t\t%B\n", bp);
-}
-
 void
 showtreeroot(int fd, Tree *t)
 {
--- a/snap.c
+++ b/snap.c
@@ -62,7 +62,7 @@
 	uint h;
 
 	h = ihash(gen) ^ ihash(bgen);
-	for(dl = fs->dlcache[h % nelem(fs->dlcache)]; dl != nil; dl = dl->chain)
+	for(dl = fs->dlcache[h %fs->dlcmax]; dl != nil; dl = dl->chain)
 		if(dl->gen == gen && dl->bgen == bgen)
 			break;
 	if(dl != nil)