ref: 9eaeb41d951cda9fad195a4cf39cc7be37b001b0
parent: 49c690ea8dbcb17be8cd01deffa719a3c659a5d9
author: 9ferno <[email protected]>
date: Sun Jan 15 06:12:43 EST 2023
bug fixes
--- a/extents.c
+++ b/extents.c
@@ -873,7 +873,7 @@
sizeofextents(Extents *es)
{
/* Do I need a lock? */
- return es->n**3*sizeof(u64);
+ return es->n*3*sizeof(u64);
}
/*
write to *buf returns the length written.
@@ -885,6 +885,7 @@
saveextents(Extents *es, s8 *buf, u32 nbuf)
{
u64 *p, *sp;
+ Extent *e;
sp = p = (u64*)buf;
qlock(&es->lck);
@@ -893,11 +894,10 @@
return -1;
}
for(e = lowest(es); e != nil; e = e->high){
- *p++ = e->start;
- *p++ = e->start+e->len-1;
- *p++ = e->len;
+ *p = e->start; p++;
+ *p = e->start+e->len-1; p++;
+ *p = e->len; p++;
}
-end:
qunlock(&es->lck);
return (s32)(p-sp);
}
@@ -908,21 +908,21 @@
s32
loadextents(Extents *es, s8 *buf, u32 nbuf)
{
- u64 *p, *ep;
+ u64 *p, *sp;
u64 start, end, nunits, n;
- p = buf;
+ sp = p = (u64*)buf;
if(es->lru != nil || es->n != 0){
es->panic("extents already loaded.\n"
" Do I need to make loadextents() be called multiple times?");
}
for(n = nbuf/(3*sizeof(u64)); n>0; n--){
- start = *p++;
- end = *p++;
- nunits = *p++;
- ufree(es, start, nblocks);
+ start = *p; p++;
+ end = *p; p++;
+ nunits = *p; p++;
+ ufree(es, start, nunits);
}
- return es->n;
+ return (s32)(p-sp);
}
void