ref: a4bafdabf7903cd35a2918db44991ab1a20421eb
parent: f2456e4c89f7b8d7513772f9e24c41f3070c16d8
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Dec 9 22:09:25 EST 2023
fs: go readonly when running check to prevent deadlocks a long running check holds the epoch open for a long time, so if a mutator is generating a lot of garbage, we can run out of cache blocks and deadlock; this prevents mutation until the check has finished to prevent this.
--- a/check.c
+++ b/check.c
@@ -2,6 +2,7 @@
#include <libc.h>
#include <fcall.h>
#include <avl.h>
+#include <atomic.h>
#include "dat.h"
#include "fns.h"
@@ -182,6 +183,8 @@
Blk *b;
ok = 1;
+ aincl(&fs->rdonly, 1);
+ epochwait();
if(waserror()){
fprint(fd, "error checking %s\n", errmsg());
return 0;
@@ -220,6 +223,7 @@
poperror();
}
btexit(&s);
+ aincl(&fs->rdonly, -1);
poperror();
return ok;
}
--
⑨