1 /* 2 * Copyright (c) 1991 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * @(#)lfs_debug.c 7.4 (Berkeley) 12/31/91 8 */ 9 10 #ifdef DEBUG 11 #include <sys/param.h> 12 #include <sys/namei.h> 13 #include <sys/vnode.h> 14 15 #include <ufs/ufs/quota.h> 16 #include <ufs/ufs/inode.h> 17 18 #include <ufs/lfs/lfs.h> 19 #include <ufs/lfs/lfs_extern.h> 20 21 void 22 lfs_dump_super(lfsp) 23 struct lfs *lfsp; 24 { 25 int i; 26 27 (void)printf("%s%lx\t%s%lx\t%s%d\t%s%d\n", 28 "magic ", lfsp->lfs_magic, 29 "version ", lfsp->lfs_version, 30 "size ", lfsp->lfs_size, 31 "ssize ", lfsp->lfs_ssize); 32 (void)printf("%s%d\t%s%d\t%s%d\t%s%d\n", 33 "dsize ", lfsp->lfs_dsize, 34 "bsize ", lfsp->lfs_bsize, 35 "fsize ", lfsp->lfs_fsize, 36 "frag ", lfsp->lfs_frag); 37 38 (void)printf("%s%d\t%s%d\t%s%d\t%s%d\n", 39 "minfree ", lfsp->lfs_minfree, 40 "inopb ", lfsp->lfs_inopb, 41 "ifpb ", lfsp->lfs_ifpb, 42 "nindir ", lfsp->lfs_nindir); 43 44 (void)printf("%s%d\t%s%d\t%s%d\n", 45 "nseg ", lfsp->lfs_nseg, 46 "nspf ", lfsp->lfs_nspf, 47 "segtabsz ", lfsp->lfs_segtabsz); 48 49 (void)printf("%s%lx\t%s%d\t%s%lx\t%s%d\n", 50 "segmask ", lfsp->lfs_segmask, 51 "segshift ", lfsp->lfs_segshift, 52 "bmask ", lfsp->lfs_bmask, 53 "bshift ", lfsp->lfs_bshift); 54 55 (void)printf("%s%lx\t%s%d\t%s%lx\t%s%d\n", 56 "ffmask ", lfsp->lfs_ffmask, 57 "ffshift ", lfsp->lfs_ffshift, 58 "fbmask ", lfsp->lfs_fbmask, 59 "fbshift ", lfsp->lfs_fbshift); 60 61 (void)printf("%s%d\t%s%lx\n", 62 "fsbtodb ", lfsp->lfs_fsbtodb, 63 "cksum ", lfsp->lfs_cksum); 64 65 (void)printf("Superblock disk addresses:"); 66 for (i = 0; i < LFS_MAXNUMSB; i++) 67 (void)printf(" %lx", lfsp->lfs_sboffs[i]); 68 (void)printf("\n"); 69 70 (void)printf("Checkpoint Info\n"); 71 (void)printf("%s%d\t%s%lx\t%s%d\n", 72 "free ", lfsp->lfs_free, 73 "idaddr ", lfsp->lfs_idaddr, 74 "ifile ", lfsp->lfs_ifile); 75 (void)printf("%s%lx\t%s%d\t%s%lx\t%s%lx\n", 76 "bfree ", lfsp->lfs_bfree, 77 "nfiles ", lfsp->lfs_nfiles, 78 "lastseg ", lfsp->lfs_lastseg, 79 "nextseg ", lfsp->lfs_nextseg); 80 (void)printf("tstamp %lx\n", lfsp->lfs_tstamp); 81 } 82 83 void 84 lfs_dump_dinode(dip) 85 DINODE *dip; 86 { 87 int i; 88 89 (void)printf("%s%u\t%s%d\t%s%u\t%s%u\t%s%lu\n", 90 "mode ", dip->di_mode, 91 "nlink ", dip->di_nlink, 92 "uid ", dip->di_uid, 93 "gid ", dip->di_gid, 94 "size ", dip->di_size); 95 (void)printf("inum %ld\n", dip->di_inum); 96 (void)printf("Direct Addresses\n"); 97 for (i = 0; i < NDADDR; i++) { 98 (void)printf("\t%lx", dip->di_db[i]); 99 if ((i % 6) == 5) 100 (void)printf("\n"); 101 } 102 for (i = 0; i < NIADDR; i++) 103 (void)printf("\t%lx", dip->di_ib[i]); 104 (void)printf("\n"); 105 } 106 107 /* XXX TEMPORARY */ 108 #include <sys/buf.h> 109 #include <sys/mount.h> 110 int 111 lfs_umountdebug(mp) 112 struct mount *mp; 113 { 114 struct vnode *vp; 115 int dirty; 116 117 dirty = 0; 118 if ((mp->mnt_flag & MNT_MPBUSY) == 0) 119 panic("umountdebug: not busy"); 120 loop: 121 for (vp = mp->mnt_mounth; vp; vp = vp->v_mountf) { 122 if (vget(vp)) 123 goto loop; 124 dirty += lfs_vinvalbuf(vp); 125 vput(vp); 126 if (vp->v_mount != mp) 127 goto loop; 128 } 129 return (dirty); 130 } 131 132 int 133 lfs_vinvalbuf(vp) 134 register struct vnode *vp; 135 { 136 register struct buf *bp; 137 struct buf *nbp, *blist; 138 int s, dirty = 0; 139 140 for (;;) { 141 if (blist = vp->v_dirtyblkhd) 142 /* void */; 143 else if (blist = vp->v_cleanblkhd) 144 /* void */; 145 else 146 break; 147 for (bp = blist; bp; bp = nbp) { 148 printf("lfs_vinvalbuf: ino %d, lblkno %d, blkno %lx flags %xl\n", 149 VTOI(vp)->i_number, bp->b_lblkno, bp->b_blkno, bp->b_flags); 150 nbp = bp->b_blockf; 151 s = splbio(); 152 if (bp->b_flags & B_BUSY) { 153 printf("lfs_vinvalbuf: buffer busy, would normally sleep\n"); 154 /* 155 bp->b_flags |= B_WANTED; 156 sleep((caddr_t)bp, PRIBIO + 1); 157 */ 158 splx(s); 159 break; 160 } 161 bremfree(bp); 162 bp->b_flags |= B_BUSY; 163 splx(s); 164 if (bp->b_flags & B_DELWRI) { 165 dirty++; /* XXX */ 166 printf("lfs_vinvalbuf: buffer dirty (DELWRI). would normally write\n"); 167 break; 168 } 169 if (bp->b_vp != vp) 170 reassignbuf(bp, bp->b_vp); 171 else 172 bp->b_flags |= B_INVAL; 173 brelse(bp); 174 } 175 } 176 if (vp->v_dirtyblkhd || vp->v_cleanblkhd) 177 panic("lfs_vinvalbuf: flush failed"); 178 return (dirty); 179 } 180 #endif /* DEBUG */ 181