ref: 857d06b64451d5810cfaa014187625090d5688e8
parent: 89017223e127f17dd7b3b3ce2c250ade8bd1655f
author: Ori Bernstein <ori@eigenstate.org>
date: Mon May 27 21:57:52 EDT 2024
gefs: skip writeback on data blocks when writing back data blocks, we didn't read the data back from disk, and instead just enqueued the block pointer; This means that we don't have the Blk struct to set the freed flag on, so we would commit every IO operation to a data block. This change opportunistically reaches into the cache and flags the data block as dead, so we can skip writeback.
--- a/sys/src/cmd/gefs/blk.c
+++ b/sys/src/cmd/gefs/blk.c
@@ -937,6 +937,7 @@
qe.bp = p->bp;
qe.b = nil;
qput(a->sync, qe);
+ cacheflag(p->bp.addr, Bfreed);
if(p->b != nil){
clrflag(p->b, Blimbo);
setflag(p->b, Bfreed);
--- a/sys/src/cmd/gefs/cache.c
+++ b/sys/src/cmd/gefs/cache.c
@@ -137,6 +137,25 @@
qunlock(&fs->lrulk);
}
+void
+cacheflag(vlong addr, int flg)
+{
+ Bucket *bkt;
+ u32int h;
+ Blk *b;
+
+ h = ihash(addr);
+ bkt = &fs->bcache[h % fs->cmax];
+ qlock(&fs->lrulk);
+ lock(bkt);
+ for(b = bkt->b; b != nil; b = b->hnext)
+ if(b->bp.addr == addr)
+ setflag(b, flg);
+ unlock(bkt);
+ qunlock(&fs->lrulk);
+
+}
+
Blk*
cacheget(vlong addr)
{
--- a/sys/src/cmd/gefs/fns.h
+++ b/sys/src/cmd/gefs/fns.h
@@ -47,6 +47,7 @@
void lrubot(Blk*);
void cacheins(Blk*);
void cachedel(vlong);
+void cacheflag(vlong, int);
Blk* cacheget(vlong);
Blk* cachepluck(void);
--
⑨