shithub: gefs

Download patch

ref: 93c6b9578dc1999c2eaf01b08ede3bf400e159a7
parent: 7119fdec0b6fd8b3d1b0c6034950644d108400a3
author: Ori Bernstein <ori@eigenstate.org>
date: Fri Oct 20 00:47:01 EDT 2023

fs: move qlock closer to clear op, reorder epoch enter with locking

--- a/fs.c
+++ b/fs.c
@@ -2177,8 +2177,8 @@
 			continue;
 		}
 
-		epochstart(id);
 		qlock(&fs->mutlk);
+		epochstart(id);
 		switch(m->type){
 		case Tcreate:	fscreate(m);	break;
 		case Twrite:	fswrite(m);	break;
@@ -2188,8 +2188,8 @@
 		default:	abort();	break;
 		}
  		epochend(id);
- 		epochclean();
-		qunlock(&fs->mutlk);
+ 		qunlock(&fs->mutlk);
+		epochclean();
 
 		if(a != nil)
 			chsend(fs->admchan, a);
@@ -2246,8 +2246,8 @@
 			qunlock(&fs->mutlk);
 			break;
 		case AOclear:
-			qlock(&fs->mutlk);
 			for(off = 0; off < a->length; off += Blksz){
+				qlock(&fs->mutlk);
 				epochstart(id);
 				m.k = buf;
 				m.nk = sizeof(buf);
@@ -2262,8 +2262,9 @@
 					fs->broken++;
 				}
 				epochend(id);
+				qunlock(&fs->mutlk);
+				epochclean();
 			}
-			qunlock(&fs->mutlk);
 			clunkmount(a->mnt);
 			break;
 		}