ref: 508c4a4206a5c92ce5d8cb6bf394d11af881b270
parent: 1116d39c89da6c6647f0a7d7314a1e148009c2c3
author: 9ferno <[email protected]>
date: Thu Oct 20 07:59:12 EDT 2022
fix extents debug prints messing the stdio operation
--- a/extents.c
+++ b/extents.c
@@ -20,13 +20,9 @@
* When freed, adjacent extents are coalesced to create larger extents when
* possible.
*/
-/*
- * Verbosity induces the dumping of the pool via p->print at each lock operation.
- * By default, only one line is logged for each alloc, free, and realloc.
- */
Extent *sortbysize(Extents *es, Extent *e);
-void showextent(char *pre, Extent *e);
+void showextent(int fd, char *pre, Extent *e);
Extent *
smallest(Extents *es)
@@ -81,7 +77,7 @@
{
Extent *dsmall, *fbig, *f, *d;
- if(chatty9p > 5)
+ if(chatty9p > 7)
print(" +size %llud .. %llud\n", e->blkno, e->blkno+e->len-1);
for(f = d = smallest(es);
@@ -122,7 +118,7 @@
c->blkno = blkno;
c->len = len;
es->n++;
- if(chatty9p > 5)
+ if(chatty9p > 7)
print(" +%llud .. %llud\n", blkno, blkno+len-1);
if(blkno < e->blkno){
@@ -304,7 +300,7 @@
/* using the previously used extent */
e = es->lru;
dir = belongs(es->lru, blkno, len);
- if(chatty9p > 5){
+ if(chatty9p > 7){
print(" belongs(e %llud %llud blkno %llud .. %llud) %d\n",
e->blkno, e->blkno+e->len-1, blkno, blkno+len-1, dir);
}
@@ -353,14 +349,14 @@
{
Extent *e;
- if(chatty9p > 5){
+/* if(chatty9p > 7){
showextents(" before\n", es);
print(" +%llud %llud\n", blkno, len);
- }
+ }*/
e = doadd(es, blkno, len);
es->lru = e;
- if(chatty9p > 5)
- showextents(" after\n", es);
+/* if(chatty9p > 7)
+ showextents(" after\n", es);*/
return e;
}
@@ -438,21 +434,21 @@
{
Extent *e;
u64 blkno;
- char msg[64];
+ // char msg[64];
if(es == nil)
panic("balloc: es == nil");
blkno = 0;
qlock(&es->el);
- if(chatty9p > 5){
+/* if(chatty9p > 7){
snprint(msg, 64, "balloc() %llud blocks:\n", n);
showextents(msg, es);
- }
+ }*/
for(e = smallest(es); e != nil && e->len < n; e = e->big)
;
if(e == nil){
- snprint(msg, 64, "balloc() %llud blocks:\n", n);
- showextents(msg, es);
+ // snprint(msg, 64, "balloc() %llud blocks:\n", n);
+ // showextents(msg, es);
panic("balloc: out of free blocks");
}
else if(e->len == n)
@@ -683,28 +679,28 @@
}
void
-showextent(char *pre, Extent *e)
+showextent(int fd, char *pre, Extent *e)
{
- print("%s small %8#p low %8#p e %8#p %llud %llud high %8#p big %8#p",
+ fprint(fd, "%s small %8#p low %8#p e %8#p %llud %llud high %8#p big %8#p",
pre, e->small, e->low, e, e->blkno, e->len, e->high, e->big);
}
void
-showextents(char *msg, Extents *es)
+showextents(int fd, char *msg, Extents *es)
{
Extent *e;
- print("%s", msg);
+ fprint(fd, "%s", msg);
for(e = lowest(es); e != nil; e = e->high){
- print(" %llud .. %llud", e->blkno, e->blkno+e->len-1);
+ fprint(fd, " %llud .. %llud", e->blkno, e->blkno+e->len-1);
// showextent(" ", e);
- print("\n");
+ fprint(fd, "\n");
}
- print(" ordered by size\n");
+ fprint(fd, " ordered by size\n");
for(e = smallest(es); e != nil; e = e->big){
- print(" %llud .. %llud has %llud blocks", e->blkno, e->blkno+e->len-1, e->len);
+ fprint(fd, " %llud .. %llud has %llud blocks", e->blkno, e->blkno+e->len-1, e->len);
// showextent(" ", e);
- print("\n");
+ fprint(fd, "\n");
}
}
--- a/extents.h
+++ b/extents.h
@@ -31,7 +31,7 @@
Extent *add(Extents *es, u64 blkno, u64 len);
void showblocknos(Extents *es);
-void showextents(char *msg, Extents *es);
+void showextents(int fd, char *msg, Extents *es);
s32 sizeofextents(Extents *es);
s32 saveextents(Extents *es, s8 *buf, u32 nbuf);
s32 loadextents(Extents *es, s8 *buf, u32 nbuf);
--- a/reconcile.c
+++ b/reconcile.c
@@ -173,5 +173,5 @@
print("nil\n");
return;
}
- showextents("show stream: ", s->es);
+ showextents(1, "show stream: ", s->es);
}
--- a/sub.c
+++ b/sub.c
@@ -417,7 +417,7 @@
bfree(&frees, config.config.dest[1]+1, config.root.dest[0]-config.config.dest[1]-1);
bfree(&frees, nbused, config.root.dest[1]-nbused);
if(chatty9p > 1)
- showextents("free extents: ", &frees);
+ showextents(2, "free extents: ", &frees);
if(chatty9p > 1)
dprint("done\n");
--- a/tests/testextents.c
+++ b/tests/testextents.c
@@ -45,7 +45,7 @@
free(line);
}
- showextents("", &es);
+ showextents(1, "", &es);
/* why bother? just exits(nil) as cinap suggests */
Bterm(bp);