ref: 011d7f3a9030fc56deeae7998b7ca4e9082a4822
parent: d7e8668fd291573b480868494d35ff59f433a2ae
author: Ori Bernstein <[email protected]>
date: Wed Nov 22 15:19:14 EST 2023
dump: remove old, useless debug dumps these debug dumps are a bunch of code for not much useful information; better to grub around memory with acid.
--- a/cons.c
+++ b/cons.c
@@ -55,6 +55,28 @@
}
static void
+listsnap(int fd)
+{
+ char *fnam, pfx[Snapsz];
+ Scan s;
+ uint flg;
+ int sz;
+
+ pfx[0] = Klabel;
+ sz = 1;
+ btnewscan(&s, pfx, sz);
+ btenter(&fs->snap, &s);
+ while(1){
+ if(!btnext(&s, &s.kv))
+ break;
+ flg = UNPACK32(s.kv.v+1+8);
+ fnam = (flg & Lmut) ? "mutable" : "";
+ fprint(fd, "snap %.*s %s\n", s.kv.nk-1, s.kv.k+1, fnam);
+ }
+ btexit(&s);
+}
+
+static void
snapfs(int fd, char **ap, int na)
{
Amsg *a;
@@ -63,7 +85,6 @@
fprint(fd, "alloc sync msg: %r\n");
return;
}
-
a->op = AOsnap;
a->fd = fd;
if(ap[0][0] == '-'){
@@ -70,6 +91,9 @@
switch(ap[0][1]){
case 'm': a->mutable++; break;
case 'd': a->delete++; break;
+ case 'l':
+ listsnap(fd);
+ return;
default:
fprint(fd, "usage: snap -[md] old [new]\n");
free(a);
@@ -212,45 +236,6 @@
}
static void
-showent(int fd, char **ap, int na)
-{
- char *p, *name, kbuf[Keymax], kvbuf[Kvmax];
- Tree *t;
- Kvp kv;
- Key k;
- vlong pqid;
- Scan s;
-
- if((t = opensnap("main", nil)) == nil){
- fprint(fd, "could not open main snap\n");
- return;
- }
- pqid = strtoll(ap[0], nil, 16);
- name = na == 2 ? ap[1] : nil;
- p = packdkey(kbuf, sizeof(kbuf), pqid, name);
- k.k = kbuf;
- k.nk = p - kbuf;
- if(name != nil){
- if(!btlookup(t, &k, &kv, kvbuf, sizeof(kvbuf))){
- fprint(fd, "lookup failed: %s\n", name);
- closesnap(t);
- return;
- }
- fprint(fd, "%P\n", &kv);
- }else{
- btnewscan(&s, k.k, k.nk);
- btenter(t, &s);
- while(1){
- if(!btnext(&s, &kv))
- break;
- fprint(fd, "%P\n", &kv);
- }
- btexit(&s);
- }
- closesnap(t);
-}
-
-static void
permflip(int fd, char **ap, int)
{
if(strcmp(ap[0], "on") == 0)
@@ -285,16 +270,10 @@
"show\n"
" show debug debug information, the following dumps\n"
" are supported:\n"
- " cache\n"
- " the contents of the in-memory cache\n"
- " ent pqid [name]\n"
- " the contents of a directory entry\n"
" tree [name]\n"
" the contents of the tree associated with a\n"
" snapshot. The special name 'snap' shows the\n"
" snapshot tree\n"
- " snap\n"
- " the summary of the existing snapshots\n"
" fid\n"
" the summary of open fids\n"
" users\n"
@@ -309,18 +288,13 @@
{.name="halt", .sub=nil, .minarg=0, .maxarg=0, .fn=haltfs},
{.name="help", .sub=nil, .minarg=0, .maxarg=0, .fn=help},
{.name="permissive", .sub=nil, .minarg=1, .maxarg=1, .fn=permflip},
- {.name="snap", .sub=nil, .minarg=2, .maxarg=3, .fn=snapfs},
+ {.name="snap", .sub=nil, .minarg=1, .maxarg=3, .fn=snapfs},
{.name="stats", .sub=nil, .minarg=0, .maxarg=0, .fn=stats},
{.name="sync", .sub=nil, .minarg=0, .maxarg=0, .fn=syncfs},
{.name="users", .sub=nil, .minarg=0, .maxarg=1, .fn=refreshusers},
/* debugging */
- {.name="show", .sub="cache", .minarg=0, .maxarg=0, .fn=showcache},
- {.name="show", .sub="dlist", .minarg=0, .maxarg=0, .fn=showdlist},
- {.name="show", .sub="ent", .minarg=1, .maxarg=2, .fn=showent},
{.name="show", .sub="fid", .minarg=0, .maxarg=0, .fn=showfid},
- {.name="show", .sub="free", .minarg=0, .maxarg=0, .fn=showfree},
- {.name="show", .sub="snap", .minarg=0, .maxarg=1, .fn=showsnap},
{.name="show", .sub="tree", .minarg=0, .maxarg=1, .fn=showtree},
{.name="show", .sub="users", .minarg=0, .maxarg=0, .fn=showusers},
{.name="show", .sub="bstate", .minarg=0, .maxarg=0, .fn=showbstate},
--- a/dump.c
+++ b/dump.c
@@ -281,8 +281,7 @@
if(b->type == Tpivot){
fprint(fd, "%.*s[%03d]|%#P\n", 4*indent, spc, i, &kv);
bp = unpackbp(kv.v, kv.nv);
- if((c = getblk(bp, 0)) == nil)
- sysfatal("failed load: %r");
+ c = getblk(bp, 0);
if(recurse)
rshowblk(fd, c, indent + 1, 1);
dropblk(c);
@@ -368,128 +367,6 @@
fprint(fd, "\tnlbl:\t%d\n", t->nlbl);
fprint(fd, "\tht:\t%d\n", t->ht);
fprint(fd, "\tbp:\t%B\n", t->bp);
-}
-
-void
-showsnap(int fd, char **ap, int na)
-{
- char pfx[Snapsz];
- vlong id;
- Scan s;
- uint flg;
- int sz;
- Tree t;
-
- /* dump the labels */
- if(na == 0){
- pfx[0] = Klabel;
- sz = 1;
- btnewscan(&s, pfx, sz);
- btenter(&fs->snap, &s);
- while(1){
- if(!btnext(&s, &s.kv))
- break;
- flg = UNPACK32(s.kv.v+1+8);
- fprint(fd, "label: %P 0x%x\n", &s.kv, flg);
- }
- btexit(&s);
- }
-
- /* dump the snapshots */
- pfx[0] = Ksnap;
- sz = 1;
- if(na != 0){
- sz = Snapsz;
- id = atoll(ap[0]);
- PACK64(pfx+1, id);
- }
- btnewscan(&s, pfx, sz);
- btenter(&fs->snap, &s);
- while(1){
- if(!btnext(&s, &s.kv))
- break;
- fprint(fd, "snap: %P\n", &s.kv);
- if(unpacktree(&t, s.kv.v, s.kv.nv) == nil){
- fprint(fd, "unpack: garbled tree\n");
- break;
- }
- showtreeroot(fd, &t);
- }
- btexit(&s);
-}
-
-void
-showdlist(int fd, char** ap, int na)
-{
- char *p, *e, pfx[Kvmax];
- Dlist dl;
- Bptr hd;
- Scan s;
- Blk *b;
- vlong id;
- int sz;
-
- pfx[0] = Kdlist;
- sz = 1;
- if(na != 0){
- sz = 9;
- id = atoll(ap[0]);
- PACK64(pfx+1, id);
- }
- btnewscan(&s, pfx, sz);
- btenter(&fs->snap, &s);
- while(1){
- if(!btnext(&s, &s.kv))
- break;
- fprint(fd, "dlist: %P\n", &s.kv);
- kv2dlist(&s.kv, &dl);
- hd = dl.hd;
- while(hd.addr != -1){
- if((b = getblk(hd, 0)) == nil){
- fprint(fd, "broken: %B\n", hd);
- break;
- }
- fprint(fd, "logsz: %x logp=%B\n", b->logsz, b->logp);
- e = b->data + b->logsz;
- for(p = b->data; p != e; p += 8)
- fprint(fd, "\tdead: %llx\n", UNPACK64(p));
- hd = b->logp;
- dropblk(b);
- }
- }
- btexit(&s);
-}
-
-void
-showcache(int fd, char**, int)
-{
- Bucket *bkt;
- Blk *b;
- int i;
-
- for(i = 0; i < fs->cmax; i++){
- bkt = &fs->bcache[i];
- lock(bkt);
- if(bkt->b != nil)
- fprint(fd, "bkt%d\n", i);
- for(b = bkt->b; b != nil; b = b->hnext)
- if(b->ref != 1)
- fprint(fd, "\t%p[ref=%ld, t=%d] => %B\n", b, b->ref, b->type, b->bp);
- unlock(bkt);
- }
-}
-
-void
-showfree(int fd, char **, int)
-{
- Arange *r;
- int i;
-
- for(i = 0; i < fs->narena; i++){
- fprint(fd, "arena %d:\n", i);
- for(r = (Arange*)avlmin(fs->arenas[i].free); r != nil; r = (Arange*)avlnext(r))
- fprint(fd, "\t%llx+%llx\n", r->off, r->len);
- }
}
void
--- a/fns.h
+++ b/fns.h
@@ -123,13 +123,8 @@
void showblk(int, Blk*, char*, int);
void showbp(int, Bptr, int);
void showtreeroot(int, Tree*);
-void showballoc(int, char**, int);
-void showdlist(int, char**, int);
void showtree(int, char**, int);
-void showsnap(int, char**, int);
void showfid(int, char**, int);
-void showcache(int, char**, int);
-void showfree(int, char**, int);
int checkfs(int);
#define dprint(...) \