ref: 3482fd60b47db33b1873fe1912799360ff38c493
parent: d828be291c9d41905eee8a92ac51326589e0ac93
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Jul 29 17:47:56 EDT 2023
fs: fix block leak
--- a/blk.c
+++ b/blk.c
@@ -1180,7 +1180,6 @@
a = &fs->arenas[i];
lock(a);
if(a->deferhd.addr != -1){
-print("sync\n");
finalize(a->defertl);
chainlog(a->logtl, a->deferhd.addr);
loadlog(a, a->deferhd);
--- a/fs.c
+++ b/fs.c
@@ -365,19 +365,19 @@
if(b == nil)
return -1;
t = nil;
- if(fb < sz && (fo != 0 || n != Blksz)){
- e = lookup(f->mnt, m, &kv, buf, sizeof(buf));
- if(e == nil){
- bp = unpackbp(kv.v, kv.nv);
+ e = lookup(f->mnt, m, &kv, buf, sizeof(buf));
+ if(e == nil){
+ bp = unpackbp(kv.v, kv.nv);
+ if(fb < sz && (fo != 0 || n != Blksz)){
if((t = getblk(bp, GBraw)) == nil)
return -1;
memcpy(b->buf, t->buf, Blksz);
- freeblk(f->mnt->root, t);
dropblk(t);
- }else if(e != Esrch){
- werrstr("%s", e);
- return -1;
}
+ freebp(f->mnt->root, bp);
+ }else if(e != Esrch){
+ werrstr("%s", e);
+ return -1;
}
if(fo+n > Blksz)
n = Blksz-fo;
@@ -2222,8 +2222,7 @@
Amsg *a;
while(1){
- //sleep(5000);
-sleep(30*1000);
+ sleep(5000);
m = mallocz(sizeof(Fmsg), 1);
a = mallocz(sizeof(Amsg), 1);
if(m == nil || a == nil){