ref: 8585477a0d205a33c9d89a69f73c7ebf4727cd72
parent: f0de08f79d1d6931c3829f4ad33818de5479b283
author: Ori Bernstein <ori@eigenstate.org>
date: Mon Nov 13 01:22:34 EST 2023
cons: more debug of block states
--- a/blk.c
+++ b/blk.c
@@ -838,10 +838,12 @@
abort();
f->op = DFblk;
f->bp = bp;
- if(b != nil)
+ f->b = nil;
+ if(b != nil){
+ setflag(b, Blimbo);
+ b->freed = getcallerpc(&t);
f->b = holdblk(b);
- else
- f->b = nil;
+ }
ge = agetl(&fs->epoch);
f->next = fs->limbo[ge];
@@ -897,6 +899,7 @@
qe.b = nil;
qput(a->sync, qe);
if(p->b != nil){
+ clrflag(p->b, Blimbo);
setflag(p->b, Bfreed);
dropblk(p->b);
}
@@ -920,6 +923,8 @@
assert(b->bp.addr >= 0);
holdblk(b);
finalize(b);
+ setflag(b, Bqueued);
+ b->queued = getcallerpc(&b);
qe.op = Qwrite;
qe.bp = b->bp;
qe.b = b;
@@ -1007,6 +1012,10 @@
Out:
rwakeup(&q->fullrz);
qunlock(&q->lk);
+ if(e.b != nil){
+ clrflag(e.b, Bqueued);
+ e.b->queued = 0;
+ }
return e;
}
--- a/cons.c
+++ b/cons.c
@@ -119,6 +119,26 @@
}
static void
+showbstate(int fd, char**, int)
+{
+ char *p, fbuf[8];
+ Blk *b;
+
+ for(b = blkbuf; b != blkbuf+fs->cmax; b++){
+ p = fbuf;
+ if(b->flag & Bdirty) *p++ = 'd';
+ if(b->flag & Bfinal) *p++ = 'f';
+ if(b->flag & Bfreed) *p++ = 'F';
+ if(b->flag & Bcached) *p++ = 'c';
+ if(b->flag & Bqueued) *p++ = 'q';
+ if(b->flag & Blimbo) *p++ = 'L';
+ *p = 0;
+ fprint(fd, "blk %#p type %d flag %s bp %B ref %ld alloc %#p queued %#p, hold %#p drop %#p cached %#p\n",
+ b, b->type, fbuf, b->bp, b->ref, b->alloced, b->queued, b->lasthold, b->lastdrop, b->cached);
+ }
+}
+
+static void
showusers(int fd, char**, int)
{
User *u, *v;
@@ -313,6 +333,7 @@
{.name="show", .sub="snap", .minarg=0, .maxarg=1, .fn=showsnap},
{.name="show", .sub="tree", .minarg=0, .maxarg=1, .fn=showtree},
{.name="show", .sub="users", .minarg=0, .maxarg=0, .fn=showusers},
+ {.name="show", .sub="bstate", .minarg=0, .maxarg=0, .fn=showbstate},
{.name="debug", .sub=nil, .minarg=0, .maxarg=1, .fn=setdbg},
{.name=nil, .sub=nil},
--- a/dat.h
+++ b/dat.h
@@ -110,6 +110,8 @@
Bfinal = 1 << 1,
Bfreed = 1 << 2,
Bcached = 1 << 3,
+ Bqueued = 1 << 4,
+ Blimbo = 1 << 5,
};
enum {
@@ -553,6 +555,7 @@
usize cmax;
RWLock flushq[Nflushtab];
+ int flushop[Nflushtab];
Stats stats;
};
@@ -707,6 +710,7 @@
};
/* debug */
+ uintptr queued;
uintptr lasthold;
uintptr lastdrop;
uintptr enqueued;
--- a/fs.c
+++ b/fs.c
@@ -2069,7 +2069,7 @@
}
void
-runfs(int id, void *pc)
+runfs(int, void *pc)
{
char err[128];
RWLock *lk;