shithub: gefs

Download patch

ref: 9244c8930f982302093f84016987a91fa7f007b3
parent: 285abe87a61e6e66f3a5948e022fc523864788dc
author: glenda <glenda@9front.local>
date: Wed Dec 15 19:47:50 EST 2021

fs, tree: don't flag zombies on free, logging tweaks

The point of RCU is that we can keep using blocks
after they're zombies, so asserting and failing on
this assert is wrong.

--- a/blk.c
+++ b/blk.c
@@ -723,19 +723,10 @@
 	free(b);
 }
 
-void
-freeblk(Blk *b)
+static void
+deadlist(Bptr bp)
 {
-	lock(b);
-	assert((b->flag & Bqueued) == 0);
-	b->flag |= Bzombie;
-	b->freed = getcallerpc(&b);
-	unlock(b);
-	dprint("freeing block %B @ %ld, from 0x%p\n", b->bp, b->ref, getcallerpc(&b));
-	if(b->bp.gen == fs->nextgen)
-		freebp(b->bp);
-//	else
-//		deadlist(b->bp);
+	fprint(2, "cross-snap free: %B\n", bp);
 }
 
 void
@@ -750,6 +741,20 @@
 	f->next = fs->freehd;
 	fs->freehd = f;
 	unlock(&fs->freelk);
+}
+
+void
+freeblk(Blk *b)
+{
+	lock(b);
+	assert((b->flag & Bqueued) == 0);
+	b->freed = getcallerpc(&b);
+	unlock(b);
+	dprint("freeing block %B @ %ld, from 0x%p\n", b->bp, b->ref, getcallerpc(&b));
+	if(b->bp.gen == fs->nextgen)
+		freebp(b->bp);
+	else
+		deadlist(b->bp);
 }
 
 void
--- a/cache.c
+++ b/cache.c
@@ -48,10 +48,6 @@
 	u32int h;
 
 	assert(b->bp.addr != 0);
-	if(b->flag & Bzombie){
-		print("caching zombie: %B, flg=%x, freed=0x%p\n", b->bp, b->flag, b->freed);
-		abort();
-	}
 	h = ihash(b->bp.addr);
 	bkt = &fs->cache[h % fs->cmax];
 	lock(bkt);
--- a/dat.h
+++ b/dat.h
@@ -84,7 +84,6 @@
 	Bqueued	= 1 << 1,
 	Bfinal	= 1 << 2,
 	Bcached	= 1 << 3,
-	Bzombie	= 1 << 4,
 };
 
 //#define Efs	"i will not buy this fs, it is scratched"
--- a/fs.c
+++ b/fs.c
@@ -504,7 +504,6 @@
 		rerror(m, e);
 		return;
 	}
-print("got root %B\n", mnt->root.bp);
 
 	err = 0;
 	p = dbuf;
@@ -1308,7 +1307,7 @@
 		m = chrecv(fs->wrchan);
 		quiesce(wid);
 		switch(m->type){
-		case Tflush:	rerror(m, "unimplemented flush");	break;
+		case Tflush:	rerror(m, Eimpl);	break;
 		case Tcreate:	fscreate(m);	break;
 		case Twrite:	fswrite(m);	break;
 		case Twstat:	fswstat(m);	break;
--- a/load.c
+++ b/load.c
@@ -46,7 +46,6 @@
 	if((d = dirfstat(fs->fd)) == nil)
 		sysfatal("ream: %r");
 	sb = d->length - (d->length % Blksz) - Blksz;
-print("superblock @%llx\n", sb);
 	free(d);
 
 	if((b = readblk(sb, 0)) == nil)