#define RDEV(d) ((d)->cw.ro)
enum {
- DEBUG = 0,
FIRST = SUPER_ADDR,
ADDFREE = 100,
/* print stats in terms of (first-)disc sides */
dsize = wormsizeside(dev, 0);
if (dsize < 1) {
- if (DEBUG)
- print("wormsizeside returned size %lld for %Z side 0\n",
- (Wideoff)dsize, dev);
dsize = h->wsize; /* it's probably a fake worm */
if (dsize < 1)
dsize = 1000; /* don't divide by zero */
}
putbuf(p);
}
- if(cw->ncopy) {
- print("%lld blocks copied to worm\n", (Wideoff)cw->ncopy);
+ if(cw->ncopy){
+ if(chatty)
+ print("%lld blocks copied to worm\n", (Wideoff)cw->ncopy);
cw->ncopy = 0;
}
cw->nodump = 1;
if(s1)
goto stop1;
if(memcmp(p1->iobuf, p2->iobuf, RBUFSIZE)) {
- print("reread C%lld W%lld didnt compare\n",
+ fprint(2, "reread C%lld W%lld didnt compare\n",
(Wideoff)a, (Wideoff)m);
goto stop1;
}
h->time = time(nil);
m = h->wsize;
if(l != m) {
- print("wdev changed size %lld to %lld\n",
- (Wideoff)m, (Wideoff)l);
+ if(chatty)
+ print("wdev changed size %lld to %lld\n",
+ (Wideoff)m, (Wideoff)l);
h->wsize = l;
cb->flags |= Bmod;
}
switch(dev->type) {
default:
- print("unknown dev in cwraddr %Z\n", dev);
+ fprint(2, "unknown dev in cwraddr %Z\n", dev);
return 1;
case Devcw:
d = dev->ro.parent;
if(d == 0 || d->type != Devcw ||
d->private == 0 || RDEV(d) != dev) {
- print("bad rodev %Z\n", dev);
+ fprint(2, "bad rodev %Z\n", dev);
return 1;
}
s = cwio(d, b, 0, Onone);
c = getcentry(b, addr);
if(c == 0) {
putbuf(p);
- print("%Z disk cache bucket %lld is full\n",
+ fprint(2, "%Z disk cache bucket %lld is full\n",
cw->cdev, (Wideoff)a1);
return Cerror;
}
p1 = getbuf(devnone, Cwio1, 0);
if(devread(cw->cdev, a2, p1->iobuf)) {
putbuf(p1);
- print("cwio: write induced dump error - r cache\n");
+ fprint(2, "cwio: write induced dump error - r cache\n");
casenone:
if(devwrite(cw->cdev, a2, buf)) {
if(devread(cw->wdev, addr, p2->iobuf)) {
putbuf(p1);
putbuf(p2);
- print("cwio: write induced dump error - r+w worm\n");
+ fprint(2, "cwio: write induced dump error - r+w worm\n");
goto casenone;
}
if(memcmp(p1->iobuf, p2->iobuf, RBUFSIZE)) {
putbuf(p1);
putbuf(p2);
- print("cwio: write induced dump error - w worm\n");
+ fprint(2, "cwio: write induced dump error - w worm\n");
goto casenone;
}
putbuf(p2);
case Ogrow:
if(state != Cnone) {
- print("%Z for block %lld cwgrow with state = %s\n",
+ fprint(2, "%Z for block %lld cwgrow with state = %s\n",
cw->cdev, (Wideoff)addr, cwnames[state]);
break;
}
case Odump:
if(state != Cdirty) { /* BOTCH */
- print("%Z for block %lld cwdump with state = %s\n",
+ fprint(2, "%Z for block %lld cwdump with state = %s\n",
cw->cdev, (Wideoff)addr, cwnames[state]);
break;
}
case Orele:
if(state != Cwrite) {
if(state != Cdump1)
- print("%Z for block %lld cwrele with state = %s\n",
+ fprint(2, "%Z for block %lld cwrele with state = %s\n",
cw->cdev, (Wideoff)addr, cwnames[state]);
break;
}
c->state = Cnone;
break;
}
- if(DEBUG)
+ if(chatty > 1)
print("cwio: %Z %lld s=%s o=%s ns=%s\n",
dev, (Wideoff)addr, cwnames[state],
cwnames[opcode],
return state;
bad:
- print("%Z block %lld cw state = %s; cw opcode = %s",
+ fprint(2, "%Z block %lld cw state = %s; cw opcode = %s",
dev, (Wideoff)addr, cwnames[state], cwnames[opcode]);
return Cerror;
}
Device *cdev;
Off m;
- print("cache init %Z\n", dev);
+ if(chatty)
+ print("cache init %Z\n", dev);
cdev = CDEV(dev);
devinit(cdev);
settag(p, Tbuck, m);
putbuf(p);
}
- print("done cacheinit\n");
return cb;
}
Filsys *f;
Startsb *s;
- for(f=filsys; f->name; f++)
+ for(f=filsys; f->name; f++){
if(devcmpr(f->dev, dev) == 0) {
for(s=startsb; s->name; s++)
if(strcmp(f->name, s->name) == 0)
return s->startsb;
- print(
- "getstartsb: no special starting superblock for %Z %s\n",
+ fprint(2, "getstartsb: no special starting superblock for %Z %s\n",
dev, f->name);
return FIRST;
}
- print("getstartsb: no filsys for device %Z\n", dev);
+ }
+ fprint(2, "getstartsb: no filsys for device %Z\n", dev);
return FIRST;
}
Off m, baddr;
Device *wdev;
-// print("cwrecover %Z\n", dev); // DEBUG
+ if(chatty)
+ print("cwrecover %Z\n", dev);
cwinit1(dev);
wdev = WDEV(dev);
break;
baddr = m;
m = s->next;
- print("dump %lld is good; %lld next\n", (Wideoff)baddr, (Wideoff)m);
+ if(chatty)
+ print("dump %lld is good; %lld next\n", (Wideoff)baddr, (Wideoff)m);
if(baddr == conf.recovsb)
break;
}
s->roraddr = conf.recovro;
putbuf(p);
- print("done recover\n");
}
/*
Off m, baddr;
Device *cdev;
- print("cwream %Z\n", dev);
+ if(chatty)
+ print("cwream %Z\n", dev);
cwinit1(dev);
cdev = CDEV(dev);
devinit(cdev);
p = getbuf(cw->dev, up->addr, Brd|Bmod);
d = getdir(p, up->slot);
if(!d || !(d->mode & DALLOC)) {
- print("rewalk1 1\n");
+ fprint(2, "rewalk1 1\n");
if(p)
putbuf(p);
return addr;
}
p1 = dnodebuf(p, d, slot/DIRPERBUF, 0, 0);
if(!p1) {
- print("rewalk1 2\n");
+ fprint(2, "rewalk1 2\n");
if(p)
putbuf(p);
return addr;
}
- if(DEBUG)
+ if(chatty > 1)
print("rewalk1 %lld to %lld \"%s\"\n",
(Wideoff)addr, (Wideoff)p1->addr, d->name);
addr = p1->addr;
p = getbuf(cw->rodev, up->addr, Brd);
d = getdir(p, up->slot);
if(!d || !(d->mode & DALLOC)) {
- print("rewalk2 1\n");
+ fprint(2, "rewalk2 1\n");
if(p)
putbuf(p);
return addr;
}
p1 = dnodebuf(p, d, slot/DIRPERBUF, 0, 0);
if(!p1) {
- print("rewalk2 2\n");
+ fprint(2, "rewalk2 2\n");
if(p)
putbuf(p);
return addr;
}
- if(DEBUG)
+ if(chatty > 1)
print("rewalk2 %lld to %lld \"%s\"\n",
(Wideoff)addr, (Wideoff)p1->addr, d->name);
addr = p1->addr;
*/
if(!p) {
p = getbuf(cw->dev, addr, Brd);
- if(!p) {
- print("split: null getbuf\n");
+ if(p == nil) {
+ fprint(2, "split: null getbuf\n");
break;
}
}
p = getbuf(cw->dev, addr, Bprobe);
if(!isdirty(cw, p, addr, tag)) {
if(!cw->all) {
- if(DEBUG)
+ if(chatty > 1)
print("cwrecur: %lld t=%s not dirty %s\n",
(Wideoff)addr, tagnames[tag], cw->name);
if(p)
}
shouldstop = 1;
}
- if(DEBUG)
+ if(chatty > 1)
print("cwrecur: %lld t=%s %s\n",
(Wideoff)addr, tagnames[tag], cw->name);
if(cw->depth >= 100) {
- print("dump depth too great %s\n", cw->name);
+ fprint(2, "dump depth too great %s\n", cw->name);
if(p)
putbuf(p);
return 0;
switch(tag) {
default:
- print("cwrecur: unknown tag %d %s\n", tag, cw->name);
+ fprint(2, "cwrecur: unknown tag %d %s\n", tag, cw->name);
case Tfile:
break;
case Tdir:
if(!p) {
p = getbuf(cw->dev, addr, Brd);
- if(!p) {
- print("cwrecur: Tdir p null %s\n",
+ if(p == nil) {
+ fprint(2, "cwrecur: Tdir p null %s\n",
cw->name);
break;
}
strncpy(np, d->name, NAMELEN);
else
if(i > 0)
- print("cwrecur: root with >1 directory\n");
+ fprint(2, "cwrecur: root with >1 directory\n");
tag1 = Tfile;
if(d->mode & DDIR)
tag1 = Tdir;
tind:
if(!p) {
p = getbuf(cw->dev, addr, Brd);
- if(!p) {
- print("cwrecur: Tind p null %s\n", cw->name);
+ if(p == nil) {
+ fprint(2, "cwrecur: Tind p null %s\n", cw->name);
break;
}
}
cw->depth--;
if(na && shouldstop) {
if(cw->falsehits < 10)
- print("shouldstop %lld %lld t=%s %s\n",
+ fprint(2, "shouldstop %lld %lld t=%s %s\n",
(Wideoff)addr, (Wideoff)na,
tagnames[tag], cw->name);
cw->falsehits++;
Cw *cw;
if(fs->dev->type != Devcw) {
- print("cant dump; not cw device: %Z\n", fs->dev);
+ fprint(2, "cant dump; not cw device: %Z\n", fs->dev);
return;
}
cw = fs->dev->private;
if(cw == 0) {
- print("cant dump: has not been inited: %Z\n", fs->dev);
+ fprint(2, "cant dump: has not been inited: %Z\n", fs->dev);
return;
}
sync("before dump");
cw->fsize = cwsize(cw->dev);
orba = cwraddr(cw->dev);
- print("cwroot %lld", (Wideoff)orba);
+ if(chatty)
+ print("cwroot %lld", (Wideoff)orba);
cons.noage = 1;
cw->all = cw->allflag;
rba = cwrecur(cw, orba, Tsuper, 0, QPROOT);
if(rba == 0)
rba = orba;
- print("->%lld\n", (Wideoff)rba);
+ if(chatty)
+ print("->%lld\n", (Wideoff)rba);
sync("after cw");
/*
cw->fsize = cwsize(cw->dev);
oroa = cwraddr(cw->rodev); /* probably redundant */
- print("roroot %lld", (Wideoff)oroa);
+ if(chatty)
+ print("roroot %lld", (Wideoff)oroa);
cons.noage = 0;
cw->all = 0;
roa = cwrecur(cw, oroa, Tsuper, 0, QPROOT);
- if(roa == 0) {
- print("[same]");
+ if(roa == 0)
roa = oroa;
- }
- print("->%lld /%.4s/%s\n", (Wideoff)roa, tstr, tstr+4);
+ if(chatty)
+ print("->%lld /%.4s/%s\n", (Wideoff)roa, tstr, tstr+4);
sync("after ro");
/*
* final super block
*/
a = cwsaddr(cw->dev);
- print("sblock %lld", (Wideoff)a);
+ if(chatty)
+ print("sblock %lld", (Wideoff)a);
p = getbuf(cw->dev, a, Brd|Bmod|Bimm);
s = (Superb*)p->iobuf;
s->last = a;
cwio(cw->dev, sba, 0, Ogrow);
cwio(cw->dev, sba, p->iobuf, Owrite);
cwio(cw->dev, sba, 0, Odump);
- print("->%lld (->%lld)\n", (Wideoff)sba, (Wideoff)s->next);
+ if(chatty)
+ print("->%lld (->%lld)\n", (Wideoff)sba, (Wideoff)s->next);
putbuf(p);
rewalk(cw);
sync("all done");
- print("%lld blocks queued for worm\n", (Wideoff)cw->ndump);
- print("%lld falsehits\n", (Wideoff)cw->falsehits);
+ if(chatty){
+ print("%lld blocks queued for worm\n", (Wideoff)cw->ndump);
+ print("%lld falsehits\n", (Wideoff)cw->falsehits);
+ }
cw->nodump = 0;
/*
memset(p->iobuf, 0, RBUFSIZE);
if(devread(WDEV(dev), m, p->iobuf) ||
checktag(p, Tsuper, QPSUPER))
- print("%Z block %lld WORM SUPER BLOCK READ FAILED\n",
+ fprint(2, "%Z block %lld WORM SUPER BLOCK READ FAILED\n",
WDEV(dev), (Wideoff)m);
- else
+ else if(chatty)
print("%Z touch superblock %lld\n", WDEV(dev), (Wideoff)m);
putbuf(p);
}
ps = getbuf(devnone, Cwxx2, 0);
if(!ps) {
- print("sbstore: getbuf\n");
+ fprint(2, "sbstore: getbuf\n");
return;
}
Device *cdev;
if(walkto("/adm/cache") || con_open(FID2, OWRITE|OTRUNC)) {
- print("cant open /adm/cache\n");
+ fprint(2, "cant open /adm/cache\n");
return;
}
cdev = CDEV(dev);
Sidestarts ss;
if(walkto("/adm/cache") || con_open(FID2, OREAD)) {
- print("cant open /adm/cache\n");
+ fprint(2, "cant open /adm/cache\n");
return;
}
p1 = getbuf(WDEV(dev), wa, Brd);
if(!p1) {
- print("blockcmp: wdev error\n");
+ fprint(2, "blockcmp: wdev error\n");
return;
}
p2 = getbuf(CDEV(dev), ca, Brd);
if(!p2) {
- print("blockcmp: cdev error\n");
+ fprint(2, "blockcmp: cdev error\n");
putbuf(p1);
return;
}
break;
}
- if(c == 0)
- print("no error\n");
putbuf(p1);
putbuf(p2);
}