shithub: gefs

Download patch

ref: 5fc13b08deef36bbf24c6c23d2fa397de63604e7
parent: c441666e73e2625e4f5208eb4d64af56be370ec1
author: Michael Forney <mforney@mforney.org>
date: Mon Feb 21 05:53:20 EST 2022

pack: save nextgen in arena block and remove snap root gen

--- a/load.c
+++ b/load.c
@@ -20,7 +20,7 @@
 		sysfatal("parameter mismatch");
 	if(fs->gotinfo && fs->narena != fi->narena)
 		sysfatal("arena count mismatch");
-	if(fs->gotinfo && fi->snap.gen < fs->snap.gen)
+	if(fs->gotinfo && fi->nextgen != fs->nextgen)
 		fprint(2, "not all arenas synced: rolling back\n");
 	fs->Fshdr = *fi;
 }
--- a/pack.c
+++ b/pack.c
@@ -449,11 +449,10 @@
 	PBIT32(p, fi->snap.ht);		p += 4;
 	PBIT64(p, fi->snap.bp.addr);	p += 8;
 	PBIT64(p, fi->snap.bp.hash);	p += 8;
-	PBIT64(p, fi->snap.bp.gen);	p += 8;
 	PBIT32(p, fi->narena);		p += 4;
 	PBIT64(p, fi->arenasz);		p += 8;
 	PBIT64(p, fi->nextqid);		p += 8;
-	fi->nextgen = fi->snap.bp.gen + 1;
+	PBIT64(p, fi->nextgen);		p += 8;
 	PBIT64(p, a->head.addr);	p += 8;	/* freelist addr */
 	PBIT64(p, a->head.hash);	p += 8;	/* freelist hash */
 	PBIT64(p, a->size);		p += 8;	/* arena size */
@@ -477,10 +476,11 @@
 	fi->snap.ht = GBIT32(p);	p += 4;
 	fi->snap.bp.addr = GBIT64(p);	p += 8;
 	fi->snap.bp.hash = GBIT64(p);	p += 8;
-	fi->snap.bp.gen = GBIT64(p);	p += 8;
+	fi->snap.bp.gen = -1;		p += 0;
 	fi->narena = GBIT32(p);		p += 4;
 	fi->arenasz = GBIT64(p);	p += 8;
 	fi->nextqid = GBIT64(p);	p += 8;
+	fi->nextgen = GBIT64(p);	p += 8;
 	a->head.addr = GBIT64(p);	p += 8;
 	a->head.hash = GBIT64(p);	p += 8;
 	a->head.gen = -1;		p += 0;
--- a/ream.c
+++ b/ream.c
@@ -64,7 +64,7 @@
 	memset(&t, 0, sizeof(Tree));
 	t.ref = 2;
 	t.ht = 1;
-	t.gen = 0;
+	t.gen = fs->nextgen++;
 	t.bp = r->bp;
 	for(i = 0; i < Ndead; i++){
 		t.dead[i].prev = -1;