ref: dcbb9930ea0098005a4d8e0c6b2e299e10bf7e5f
parent: 9600b2bd0271198a18f5acc22ed5f8bda43b3618
author: Ori Bernstein <ori@eigenstate.org>
date: Mon Oct 27 10:25:37 EDT 2025
gefs: ensure all tree access is wrapped in an epoch technically, some of the write-only accesses may have been safe, but lets be conservative.
--- a/sys/src/cmd/gefs/cons.c
+++ b/sys/src/cmd/gefs/cons.c
@@ -417,10 +417,10 @@
{.name="halt", .sub=nil, .minarg=0, .maxarg=0, .fn=haltfs}, {.name="help", .sub=nil, .minarg=0, .maxarg=0, .fn=help}, {.name="permit", .sub=nil, .minarg=1, .maxarg=1, .fn=permflip},- {.name="snap", .sub=nil, .minarg=1, .maxarg=3, .fn=snapfs},+ {.name="snap", .sub=nil, .minarg=1, .maxarg=3, .fn=snapfs, .epoch=1}, {.name="sync", .sub=nil, .minarg=0, .maxarg=0, .fn=syncfs}, {.name="reserve", .sub=nil, .minarg=0, .maxarg=1, .fn=unreserve},- {.name="users", .sub=nil, .minarg=0, .maxarg=1, .fn=refreshusers},+ {.name="users", .sub=nil, .minarg=0, .maxarg=1, .fn=refreshusers, .epoch=1},/* debugging */
{.name="show", .sub="fid", .minarg=0, .maxarg=0, .fn=showfid},--- a/sys/src/cmd/gefs/fs.c
+++ b/sys/src/cmd/gefs/fs.c
@@ -80,7 +80,7 @@
}
static void
-sync(void)
+sync(int id)
{Mount *mnt;
Arena *a;
@@ -98,7 +98,7 @@
nexterror();
}
- /*
+ /*
* Wait for data that we're syncing to hit disk
*/
tracem("flush1");@@ -112,7 +112,9 @@
* can take a consistent snapshot.
*/
qlock(&fs->mutlk);
+ epochstart(id);
if(waserror()){+ epochend(id);
aincl(&fs->rdonly, 1);
qunlock(&fs->mutlk);
nexterror();
@@ -162,6 +164,7 @@
finalize(fs->sb0);
finalize(fs->sb1);
fs->snap.dirty = 0;
+ epochend(id);
qunlock(&fs->mutlk);
poperror();
@@ -2819,7 +2822,7 @@
epochwait();
epochclean();
}
- sync();
+ sync(id);
}
postnote(PNGROUP, getpid(), "halted");
exits(nil);
@@ -2861,7 +2864,7 @@
epochclean();
}
- sync(); /* oldhd blocks leaked on error() */
+ sync(id); /* oldhd blocks leaked on error() */
for(i = 0; i < fs->narena; i++){ for(bp = oldhd[i]; bp.addr != -1; bp = nb){@@ -2915,7 +2918,7 @@
qunlock(&fs->mutlk);
poperror();
- sync(); /* t leaked on error() */
+ sync(id); /* t leaked on error() */
if(t != nil){epochwait();
--
⑨