code: mafs

Download patch

ref: 4210fbecf4d94bd5873037bc3f5c721f47f42a2c
parent: 71313e391acdd31721f9c67f83717eecafb7ed0c
author: 9ferno <gophone2015@gmail.com>
date: Fri Nov 25 15:20:50 EST 2022

fixed bug in flushtime

--- a/iobuf.c
+++ b/iobuf.c
@@ -13,7 +13,7 @@
 Extents memunits = {0};
 u8 *memunitpool = nil;
 u8 *memunitstart = nil;
-static lastflushtime = 0;
+static u64 lastflushtime = 0;
 static RWLock flushlck;
 
 /* using nunits + 1 for alignment */
@@ -65,12 +65,13 @@
 	Hiob *hp;
 	u64 nchecked, i;
 
+	nchecked = 0;
 Again:
 	for(i = 0; i < nbuckets; i++){
 		hp=&hiob[i];
 		qlock(hp);
 		if((p = hp->link) != nil){
-			for(p = hp->link->back; p != hp->link; p = p->back){
+			for(p = p->back; p != hp->link; p = p->back){
 				if(p->ref == 0 &&
 					p->atime < nsec()-Nrefresh){
 					if(canwlock(p)){
--- a/mafs.c
+++ b/mafs.c
@@ -80,9 +80,7 @@
 		and 1/3rd for the buffer cache
 	 */
 	if(nmemunits == 0)
-		nmemunits = size/Blocksize > 8*MiB ? 8*MiB : size/Blocksize;
-	if(nmemunits < 16*MiB)
-		nmemunits = 16*MiB;
+		nmemunits = size/Blocksize > 1*MiB ? 1*MiB : size/Blocksize;
 	if(nbuckets == 0)
 		nbuckets = nmemunits/(4*Ncollisions*Maxdatablockunits);
 	if(nbuckets == 0)