shithub: gefs

Download patch

ref: c660119c2be0afecd22e6e533dd103173be8c361
parent: 0605c3789558e9e0494270c311bedb82f7319731
author: Ori Bernstein <ori@eigenstate.org>
date: Mon Dec 18 13:58:22 EST 2023

fs: return error on out of space

now that reserve space is manual, we should error when out of log space,
rather than panicking.

--- a/blk.c
+++ b/blk.c
@@ -294,7 +294,7 @@
 	 */
 	if(lb == nil || lb->logsz >= Logspc - Logslop){
 		if((o = blkalloc_lk(a)) == -1)
-			error(Efs);
+			error(Efull);
 		nl = mklogblk(a, o);
 		p = lb->data + lb->logsz;
 		PACK64(p, o|LogAlloc1);
@@ -433,10 +433,13 @@
 		free(blks);
 		return -1;
 	}
-	for(i = 0; i < nblks; i++)
-		if((blks[i] = blkalloc_lk(a)) == -1)
-			error(Efs);
-
+	for(i = 0; i < nblks; i++){
+		if((blks[i] = blkalloc_lk(a)) == -1){
+			fprint(2, "out of space to compress log");
+			free(blks);
+			return -1;
+		}
+	}
 	/* fill up the log with the ranges from the tree */
 	i = 0;
 	hd = (Bptr){blks[0], -1, -1};