shithub: neoventi

Download patch

ref: 368ded133c040ad7f2f9548e06457e3753662dee
parent: 94cbdc987cfb57a3be0dd23742dac4a57070684e
author: Noam Preil <noam@pixelhero.dev>
date: Wed Sep 17 23:20:38 EDT 2025

arena: always repair unindexed clumps

--- a/arena.c
+++ b/arena.c
@@ -13,9 +13,10 @@
 		return 0;
 	}
 	if(U32GET(buf) != arena->clumpmagic){
-		werrstr("arenarepair: corrupt");
+		werrstr("arenarepair: magic is incorrect. If this block was not written by old-venti, you may have a problem.");
 		return 0;
 	}
+	// Update the clumpinfo, just in case.
 	ci[0] = 1;
 	U16PUT(ci + 1, tmp);
 	U16PUT(ci + 3, U16GET(buf + 7));
@@ -53,13 +54,11 @@
 		}
 		off += ClumpInfoSize;
 		ci = &buf[off];
-		if(ci[0] != 1){
-			if(!arenarepair(arena, (u8int*)ci, addr)){
-				fprint(2, "clump %d is broken, at address %llud: %r\n", m, addr);
-				// Skip. old venti creates corruption in some easy-to-repro cases
-				// (e.g. write, kill venti within a few seconds) and I don't need people
-				// complaining about it.
-			}
+		if(!arenarepair(arena, (u8int*)ci, addr)){
+			fprint(2, "clump %d is broken, at address %llud: %r\n", m, addr);
+			// Skip. old venti creates corruption in some easy-to-repro cases
+			// (e.g. write, kill venti within a few seconds) and I don't need people
+			// complaining about it.
 		}
 		addr += (((u64int)(U16GET(ci + 1))) + 38);
 	}
--- a/notebook
+++ b/notebook
@@ -3420,3 +3420,16 @@
 
 ...should we try to reuse this space, if there's a full tail of broken blocks? Probably.
 
+As far as repair goes, we should probably just be unconditional in this scanning for unindexed blocks.
+
+Arena startup scan process:
+
+- For each clump known to be present [in arenastats] but not indexed [not in indexstats]:
+	- Read the clump info
+	- Read the clump
+	- Validate the clump
+	- Update the clumpinfo and clump if necessary
+		- Size, hash, ...
+	- Queue the clump for indexing
+	- Advance to the next one
+- Index all queued clumps at once (possibly in parallel if it makes sense to do so)
--