- vflushbuf(ump->um_devvp, waitfor == MNT_WAIT ? B_SYNC : 0);
-#ifdef QUOTA
- qsync(mp);
-#endif
- return (allerror);
-}
-
-/*
- * Write a superblock and associated information back to disk.
- */
-sbupdate(mp, waitfor)
- struct ufsmount *mp;
- int waitfor;
-{
- register struct fs *fs = mp->um_fs;
- register struct buf *bp;
- int blks;
- caddr_t space;
- int i, size, error = 0;
-
-#ifdef SECSIZE
- bp = getblk(mp->m_dev, (daddr_t)fsbtodb(fs, SBOFF / fs->fs_fsize),
- (int)fs->fs_sbsize, fs->fs_dbsize);
-#else SECSIZE
- bp = getblk(mp->um_devvp, SBLOCK, (int)fs->fs_sbsize);
-#endif SECSIZE
- bcopy((caddr_t)fs, bp->b_un.b_addr, (u_int)fs->fs_sbsize);
- /* Restore compatibility to old file systems. XXX */
- if (fs->fs_postblformat == FS_42POSTBLFMT) /* XXX */
- bp->b_un.b_fs->fs_nrpos = -1; /* XXX */
-#ifdef SECSIZE
-#ifdef tahoe
- /* restore standard fsbtodb shift */
- bp->b_un.b_fs->fs_fsbtodb = fs->fs_sparecon[0];
- bp->b_un.b_fs->fs_sparecon[0] = 0;
-#endif
-#endif SECSIZE
- if (waitfor == MNT_WAIT)
- error = bwrite(bp);
- else
- bawrite(bp);
- blks = howmany(fs->fs_cssize, fs->fs_fsize);
- space = (caddr_t)fs->fs_csp[0];
- for (i = 0; i < blks; i += fs->fs_frag) {
- size = fs->fs_bsize;
- if (i + fs->fs_frag > blks)
- size = (blks - i) * fs->fs_fsize;
-#ifdef SECSIZE
- bp = getblk(mp->m_dev, fsbtodb(fs, fs->fs_csaddr + i), size,
- fs->fs_dbsize);
-#else SECSIZE
- bp = getblk(mp->um_devvp, fsbtodb(fs, fs->fs_csaddr + i), size);
-#endif SECSIZE
- bcopy(space, bp->b_un.b_addr, (u_int)size);
- space += size;
- if (waitfor == MNT_WAIT)
- error = bwrite(bp);
- else
- bawrite(bp);
- }
- return (error);
-}
-
-/*
- * Print out statistics on the current allocation of the buffer pool.
- * Can be enabled to print out on every ``sync'' by setting "syncprt"
- * above.
- */
-bufstats()
-{
- int s, i, j, count;
- register struct buf *bp, *dp;
- int counts[MAXBSIZE/CLBYTES+1];
- static char *bname[BQUEUES] = { "LOCKED", "LRU", "AGE", "EMPTY" };
-
- for (bp = bfreelist, i = 0; bp < &bfreelist[BQUEUES]; bp++, i++) {
- count = 0;
- for (j = 0; j <= MAXBSIZE/CLBYTES; j++)
- counts[j] = 0;
- s = splbio();
- for (dp = bp->av_forw; dp != bp; dp = dp->av_forw) {
- counts[dp->b_bufsize/CLBYTES]++;
- count++;
- }
- splx(s);
- printf("%s: total-%d", bname[i], count);
- for (j = 0; j <= MAXBSIZE/CLBYTES; j++)
- if (counts[j] != 0)
- printf(", %d-%d", j * CLBYTES, counts[j]);
- printf("\n");