ref: fcbd2eba891e3799fcd8d0ec211e333a4a35effb
parent: c36ed06ba0fd376ca0e346d0639d8cbf18c1cb45
author: Ori Bernstein <ori@eigenstate.org>
date: Sun May 28 17:26:51 EDT 2023
blk: we have a perfectly good qgen
--- a/blk.c
+++ b/blk.c
@@ -394,7 +394,7 @@
case LogSync:
gen = ent >> 8;
dprint("\tlog@%d: sync %llx\n", i, gen);
- if(gen >= fs->syncgen){
+ if(gen >= fs->qgen){
if(a->logtl == nil){
b->logsz = i;
a->logtl = holdblk(b);
@@ -1140,6 +1140,7 @@
void
sync(void)
{
+ uvlong gen;
Arena *a;
Blk *b;
int i;
@@ -1152,7 +1153,7 @@
return;
}
flushdlcache(0);
- aincv(&fs->qgen, 1);
+ gen = aincv(&fs->qgen, 1);
fs->syncing = fs->nsyncers;
for(i = 0; i < fs->nsyncers; i++){
b = cachepluck();
@@ -1161,7 +1162,6 @@
}
while(fs->syncing != 0)
rsleep(&fs->syncrz);
- fs->syncgen++;
/* pass 0: sync arena contents */
for(i = 0; i < fs->narena; i++){
a = &fs->arenas[i];
@@ -1173,7 +1173,7 @@
a->deferhd = (Bptr){-1, -1, -1};
a->defertl = nil;
}
- syncbarrier(a, fs->syncgen);
+ syncbarrier(a, gen);
finalize(a->logtl);
if(syncblk(a->logtl) == -1)
sysfatal("sync arena: %r");
--- a/dat.h
+++ b/dat.h
@@ -441,7 +441,7 @@
vlong arenasz;
vlong nextqid;
vlong nextgen;
- vlong syncgen;
+ vlong qgen;
Bptr *arenabp;
};
@@ -475,7 +475,6 @@
Chan **rdchan;
int nworker;
- vlong qgen;
long epoch;
long lepoch[32];
Bfree *limbo[3];
--- a/load.c
+++ b/load.c
@@ -114,6 +114,7 @@
fprint(2, "\tarenasz:\t%lld MiB\n", fs->arenasz/MiB);
fprint(2, "\tnextqid:\t%lld\n", fs->nextqid);
fprint(2, "\tnextgen:\t%lld\n", fs->nextgen);
+ fprint(2, "\tsyncgen:\t%lld\n", fs->qgen);
fprint(2, "\tblocksize:\t%lld\n", Blksz);
fprint(2, "\tcachesz:\t%lld MiB\n", fs->cmax*Blksz/MiB);
if((t = opensnap("adm")) == nil)
--- a/pack.c
+++ b/pack.c
@@ -575,7 +575,7 @@
PACK64(p, fi->arenasz); p += 8;
PACK64(p, fi->nextqid); p += 8;
PACK64(p, fi->nextgen); p += 8;
- PACK64(p, fi->syncgen); p += 8;
+ PACK64(p, fi->qgen); p += 8;
for(i = 0; i < fi->narena; i++){
PACK64(p, fi->arenabp[i].addr); p += 8;
PACK64(p, fi->arenabp[i].hash); p += 8;
@@ -604,7 +604,7 @@
fi->arenasz = UNPACK64(p); p += 8;
fi->nextqid = UNPACK64(p); p += 8;
fi->nextgen = UNPACK64(p); p += 8;
- fi->syncgen = UNPACK64(p); p += 8;
+ fi->qgen = UNPACK64(p); p += 8;
fi->arenabp = malloc(fi->narena * sizeof(Bptr));
for(i = 0; i < fi->narena; i++){
fi->arenabp[i].addr = UNPACK64(p); p += 8;