ref: da92726a25879c4e00f7bd6399d07b24cc43597b
parent: c0e7c83c5eb13de7e799f7bf0b3359b6c1569b24
author: Ori Bernstein <[email protected]>
date: Fri Dec 29 13:37:15 EST 2023
snap: stop playing games with re-enqueing blocks this is inherently racy, and we probably don't want to be modifying a block that we're in the process of writing back; stop doing it, and instead ither enqueue and nil it out, or mutate the block in place synchronously.
--- a/snap.c
+++ b/snap.c
@@ -15,11 +15,9 @@
if(dl->ins == nil)
return;
- if(!checkflag(dl->ins, Bdirty))
- return;
-
traceb("dlflush", dl->ins->bp);
enqueue(dl->ins);
+ dl->ins = nil;
m.op = Oinsert;
dlist2kv(dl, &m, kvbuf, sizeof(kvbuf));
btupsert(&fs->snap, &m, 1);
@@ -209,15 +207,15 @@
if(d->ins != nil)
holdblk(d->ins);
}else{
- if(m->ins != nil && checkflag(m->ins, Bdirty))
+ if(m->ins != nil){
enqueue(m->ins);
- if(d->tl.addr == d->ins->bp.addr)
- b = holdblk(d->ins);
- else
- b = getblk(d->tl, 0);
+ dropblk(m->ins);
+ m->ins = nil;
+ }
+ b = getblk(d->tl, 0);
b->logp = m->hd;
- setflag(b, Bdirty);
- enqueue(b);
+ finalize(b);
+ syncblk(b);
dropblk(b);
}
msg[0].op = Odelete;
@@ -562,7 +560,7 @@
}
if(dl->ins == nil || Logspc - dl->ins->logsz < Logslop){
b = newblk(&fs->snap, Tdlist, 0);
- if(dl->ins != nil && checkflag(b, Bdirty))
+ if(dl->ins != nil)
enqueue(dl->ins);
if(dl->tl.addr == -1)
dl->tl = b->bp;