shithub: gefs

Download patch

ref: c424d52fc0dd25568851549bf1e6a309cf74983f
parent: cb50c004a6b8062439ee685c1707a93b0058f62d
author: Ori Bernstein <ori@eigenstate.org>
date: Thu Apr 27 20:54:55 EDT 2023

cache: leave bp address alone when caching

blocks may be syncing while being removed from
cache, so we can't touch any of the data that
the syncer uses for them.

--- a/blk.c
+++ b/blk.c
@@ -54,6 +54,7 @@
 syncblk(Blk *b)
 {
 	assert(checkflag(b, Bfinal));
+	assert(b->bp.addr >= 0);
 	clrflag(b, Bdirty);
 	return pwrite(fs->fd, b->buf, Blksz, b->bp.addr);
 }
@@ -999,6 +1000,7 @@
 	b->qgen = aincv(&fs->qgen, 1);
 	a = getarena(b->bp.addr);
 	assert(checkflag(b, Bdirty));
+	assert(b->bp.addr >= 0);
 	holdblk(b);
 	finalize(b);
 	qput(a->sync, b);
--- a/cache.c
+++ b/cache.c
@@ -119,8 +119,6 @@
 	for(b = bkt->b; b != nil; b = b->hnext){
 		if(b->bp.addr == addr){
 			*p = b->hnext;
-			b->bp.addr = -1;
-			b->bp.hash = -1;
 			clrflag(b, Bcached);
 			b->uncached = getcallerpc(&addr);
 			b->hnext = nil;