ref: 64e0f1ce721df11448b56c4a38e20bb94cd27ae9
parent: 56ef20bc838039f49024bf5d09d5b610ac72bdde
author: Ori Bernstein <ori@eigenstate.org>
date: Sun Nov 5 20:02:38 EST 2023
snap: don't reclaim all old deadlists, only the ones unused by the predecessor
--- a/blk.c
+++ b/blk.c
@@ -99,7 +99,7 @@
switch(b->type){
default:
fprint(2, "invalid block type %d @%llx\n", b->type, bp);
- abort();
+ return nil;
break;
case Tdat:
case Tsuper:
@@ -752,6 +752,7 @@
return b;
}
if((b = readblk(bp.addr, flg)) == nil){
+ fprint(2, "could not read %B\n", bp);
qunlock(&fs->blklk[i]);
return nil;
}
--- a/check.c
+++ b/check.c
@@ -71,7 +71,7 @@
fail++;
}
if((c = getblk(bp, 0)) == nil){
- fprint(fd, "corrupt block: %r\n");
+ fprint(fd, "corrupt block: %B\n", bp);
fail++;
continue;
}
@@ -102,7 +102,7 @@
getval(b, b->nval-1, &y);
bp = getptr(&x, &fill);
if((c = getblk(bp, 0)) == nil){
- fprint(fd, "corrupt block: %r\n");
+ fprint(fd, "corrupt block: %B\n", bp);
fail++;
}
if(c != nil && badtree(fd, c, h - 1, &y, nil))
@@ -190,7 +190,7 @@
fprint(fd, "checking freelist\n");
if(badfree())
ok = 0;
- fprint(fd, "checking snap tree\n");
+ fprint(fd, "checking snap tree: %B\n", fs->snap.bp);
if((b = getroot(&fs->snap, &height)) != nil){
if(badtree(fd, b, height-1, nil, 0))
ok = 0;
@@ -212,12 +212,12 @@
break;
memcpy(name, s.kv.k+1, s.kv.nk-1);
name[s.kv.nk-1] = 0;
- fprint(fd, "checking snap %s\n", name);
if((t = opensnap(name, nil)) == nil){
fprint(2, "invalid snap label %s\n", name);
ok = 0;
break;
}
+ fprint(fd, "checking snap %s: %B\n", name, t->bp);
if((b = getroot(t, &height)) == nil){
fprint(fd, "unable to get root %B\n", t->bp);
ok = 0;
--- a/fs.c
+++ b/fs.c
@@ -45,8 +45,10 @@
t = nil;
for(mnt = fs->mounts; mnt != nil; mnt = mnt->next){
if(strcmp(a->old, mnt->name) == 0){
+ updatesnap(&mnt->root, mnt->root, mnt->name);
t = agetp(&mnt->root);
ainc(&t->memref);
+ break;
}
}
if(t == nil && (t = opensnap(a->old, nil)) == nil){
@@ -2266,11 +2268,8 @@
case AOsnap:
qlock(&fs->mutlk);
epochstart(id);
- for(mnt = fs->mounts; mnt != nil; mnt = mnt->next)
- updatesnap(&mnt->root, mnt->root, mnt->name);
- sync();
-
snapfs(am);
+ sync();
epochend(id);
qunlock(&fs->mutlk);
break;
@@ -2312,7 +2311,7 @@
Amsg *a;
while(1){
- sleep(5000);
+ sleep(30*1000);
a = mallocz(sizeof(Amsg), 1);
if(a == nil){
fprint(2, "alloc sync msg: %r\n");
--- a/snap.c
+++ b/snap.c
@@ -282,20 +282,10 @@
*/
m.op = Odelete;
m.Kvp = s.kv;
-char *op;
-if(succ == -1)
- op = "free";
-else if(dl.bgen > prev)
- op = "clear";
-else
- op = "merge";
-print("reclaim dlist (%lld,%lld): %s\n", dl.gen, dl.bgen, op);
if((e = btupsert(&fs->snap, &m, 1)) != nil)
break;
- if(succ == -1)
+ if(succ == -1 && dl.bgen > prev)
e = freedl(&dl, 1);
- else if(dl.bgen > prev)
- e = freedl(&dl, 0);
else
e = mergedl(succ, dl.gen, dl.bgen);
if(e != nil)
@@ -407,6 +397,8 @@
retag2kv(t->gen, 1, 0, &m[i], buf[i], sizeof(buf[i]));
i++;
m[i].op = Oinsert;
+ t->prev = t->gen;
+ t->nlbl++;
lbl2kv(name, t->gen, 0, &m[i], buf[i], sizeof(buf[i]));
i++;
}