git: 9front

Download patch

ref: af3706392366acebd7324d78df249ebe215907ce
parent: 176debe446a8317687e2cca165ead3c1015462ba
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Jun 8 12:21:16 EDT 2024

gefs: only start epochs for console procs that need them

we shouldn't need to defer reclamation for procs that
don't actually interact with the tree directly, especially
since if they send on a channel they can stall for a while.

--- a/sys/src/cmd/gefs/cons.c
+++ b/sys/src/cmd/gefs/cons.c
@@ -14,6 +14,7 @@
 	char	*sub;
 	int	minarg;
 	int	maxarg;
+	int	epoch;
 	void	(*fn)(int, char**, int);
 };
 
@@ -391,7 +392,7 @@
 
 Cmd cmdtab[] = {
 	/* admin */
-	{.name="check",		.sub=nil,	.minarg=0, .maxarg=0, .fn=fsckfs},
+	{.name="check",		.sub=nil,	.minarg=0, .maxarg=0, .fn=fsckfs, .epoch=1},
 	{.name="df",		.sub=nil, 	.minarg=0, .maxarg=0, .fn=showdf},
 	{.name="halt",		.sub=nil,	.minarg=0, .maxarg=0, .fn=haltfs},
 	{.name="help",		.sub=nil,	.minarg=0, .maxarg=0, .fn=help},
@@ -403,9 +404,9 @@
 
 	/* debugging */
 	{.name="show",		.sub="fid",	.minarg=0, .maxarg=0, .fn=showfid},
-	{.name="show",		.sub="tree",	.minarg=0, .maxarg=1, .fn=showtree},
+	{.name="show",		.sub="tree",	.minarg=0, .maxarg=1, .fn=showtree, .epoch=1},
 	{.name="show",		.sub="users",	.minarg=0, .maxarg=0, .fn=showusers},
-	{.name="show",		.sub="bstate",	.minarg=0, .maxarg=0, .fn=showbstate},
+	{.name="show",		.sub="bstate",	.minarg=0, .maxarg=0, .fn=showbstate, .epoch=1},
 	{.name="show",		.sub="free",	.minarg=0, .maxarg=0, .fn=showfree},
 	{.name="debug",		.sub=nil,	.minarg=0, .maxarg=1, .fn=setdbg},
 	{.name="save",		.sub="trace",	.minarg=0, .maxarg=1, .fn=savetrace},
@@ -424,11 +425,10 @@
 		fprint(fd, "gefs# ");
 		if((n = read(fd, buf, sizeof(buf)-1)) == -1)
 			break;
-		epochstart(tid);
 		buf[n] = 0;
 		nf = tokenize(buf, f, nelem(f));
 		if(nf == 0 || strlen(f[0]) == 0)
-			goto Next;
+			continue;
 		for(c = cmdtab; c->name != nil; c++){
 			ap = f;
 			na = nf;
@@ -444,7 +444,15 @@
 			}
 			if(na < c->minarg || na > c->maxarg)
 				continue;
-			c->fn(fd, ap, na);
+			if(c->epoch)
+				epochstart(tid);
+			if(!waserror()){
+				c->fn(fd, ap, na);
+				poperror();
+			}else
+				fprint(fd, "%s: %s\n", f[0], errmsg());
+			if(c->epoch)
+				epochend(tid);
 			break;
 		}
 		if(c->name == nil){
@@ -453,7 +461,5 @@
 				fprint(fd, " %s", f[i]);
 			fprint(fd, "'\n");
 		}
-Next:
-		epochend(tid);
 	}
 }
--