ref: 3c5258b1c6d5c81cc13e1236af6ab3f35d0661f9
parent: d75b52f173865461df0265daeb79faec068642cb
author: Ori Bernstein <ori@eigenstate.org>
date: Tue Dec 5 16:56:33 EST 2023
ream: correct backup superblock addressing also clean up arena boundary calculations
--- a/ream.c
+++ b/ream.c
@@ -173,6 +173,10 @@
asz -= Blksz;
}
addr = start+Blksz; /* leave room for arena hdr */
+ if(addr == 512*MiB){
+ addr += Blksz;
+ asz -= Blksz;
+ }
a->loghd.addr = -1;
a->loghd.hash = -1;
@@ -181,10 +185,6 @@
memset(b->buf, 0, sizeof(b->buf));
b->type = Tlog;
b->bp.addr = addr+Blksz;
- if(b->bp.addr == 512*MiB){
- b->bp.addr += Blksz;
- asz -= Blksz;
- }
b->logsz = 0;
b->logp = (Bptr){-1, -1, -1};
b->data = b->buf + Loghdsz;
@@ -268,19 +268,18 @@
adm = mallocz(sizeof(Mount), 1);
adm->root = mallocz(sizeof(Tree), 1);
- sz = sz - sz%Blksz - 2*Blksz;
-
- fs->narena = (sz + 64ULL*GiB - 1) / (64ULL*GiB);
- if(fs->narena < 8)
- fs->narena = 8;
- if(fs->narena >= 128)
- fs->narena = 128;
+ sz = sz - sz%Blksz;
+ fs->narena = (sz + 4096ULL*GiB - 1) / (4096ULL*GiB);
+ if(fs->narena < 4)
+ fs->narena = 4;
+ if(fs->narena >= 32)
+ fs->narena = 32;
fs->arenas = emalloc(fs->narena*sizeof(Arena), 1);
off = Blksz;
asz = sz/fs->narena;
- asz = asz - (asz % Blksz) - Blksz;
+ asz = asz - (asz % Blksz) - 2*Blksz;
fs->arenasz = asz;
sb0 = cachepluck();
@@ -294,7 +293,8 @@
print("\tarena %d: %lld blocks at %llx\n", i, asz/Blksz, off);
initarena(a, off, asz);
fs->arenabp[i] = a->hd->bp;
- off += asz+Blksz;
+ off += asz+2*Blksz;
+
}
for(i = 0; i < fs->narena; i++){