shithub: gefs

Download patch

ref: 324d4e977b0d8fdab6aa0ce2853395f9275b9799
parent: cb88262dcfd151367d2a168f2b88034132ddc6c4
author: Ori Bernstein <ori@eigenstate.org>
date: Thu Dec 7 14:23:54 EST 2023

fs: report errors on clear/sync ops

this prevents a nexterror panic, and makes the
file system go read-only when we run into problems.

--- a/fs.c
+++ b/fs.c
@@ -2209,6 +2209,10 @@
 		am = chrecv(fs->admchan);
 		switch(am->op){
 		case AOsync:
+			if(waserror()){
+				fprint(2, "sync error: %s\n", errmsg());
+				ainc(&fs->rdonly);
+			}
 			for(i = 0; i < fs->narena; i++){
 				a = &fs->arenas[i];
 				qlock(a);
@@ -2254,6 +2258,7 @@
 				postnote(PNGROUP, getpid(), "halted");
 				exits(nil);
 			}
+			poperror();
 			break;
 
 		case AOsnap:
@@ -2283,6 +2288,10 @@
 			break;
 
 		case AOclear:
+			if(waserror()){
+				fprint(2, "clear file %llx: %s\n", am->qpath, errmsg());
+				ainc(&fs->rdonly);
+			}
 			for(off = am->off; off < am->length; off += Blksz){
 				qlock(&fs->mutlk);
 				epochstart(id);
@@ -2304,6 +2313,7 @@
 				clunkdent(am->dent);
 			}
 			clunkmount(am->mnt);
+			poperror();
 			break;
 		}
 		assert(estacksz() == 0);