code: mafs

Download patch

ref: 9976d0283cfac6c187e061a0f827026fddb18ef5
parent: 2384cc1cb309d0759ad6790eea79f903d04ebad5
author: 9ferno <gophone2015@gmail.com>
date: Sun Dec 25 10:50:12 EST 2022

use the lowest when there is no least recently used extent

--- a/extents.c
+++ b/extents.c
@@ -34,10 +34,14 @@
 	Extent *e, *eclosest;
 	s64 howclose;
 
+	if(es == nil || es->lowest == nil)
+		panic("searchlrus: should not happen");
+
 	if(es->lru == nil)
-		panic("searchlrus: should not happen");;
+		eclosest = e = es->lowest;
+	else
+		eclosest = e = es->lru;
 
-	eclosest = e = es->lru;
 	*closest = belongs(e, blkno);
 	if(*closest == 0)
 		return es->lru;
@@ -62,6 +66,7 @@
 
 	if(es == nil || es->lowest == nil)
 		panic("searchlrusbysize: should not happen");
+
 	if(es->lru == nil){
 		*closest = len - es->lowest->len;
 		return es->lowest;