diff --git a/sys/fs/specfs/spec_vnops.c b/sys/fs/specfs/spec_vnops.c index a66597dcea12..9a8ad4536a5a 100644 --- a/sys/fs/specfs/spec_vnops.c +++ b/sys/fs/specfs/spec_vnops.c @@ -406,11 +406,32 @@ spec_strategy(ap) } */ *ap; { struct buf *bp; + struct vnode *vp; + struct mount *mp; bp = ap->a_bp; if (((bp->b_flags & B_READ) == 0) && (LIST_FIRST(&bp->b_dep)) != NULL && bioops.io_start) (*bioops.io_start)(bp); + + /* + * Collect statistics on synchronous and asynchronous read + * and write counts for disks that have associated filesystems. + */ + vp = ap->a_vp; + if (vn_isdisk(vp) && (mp = vp->v_specmountpoint) != NULL) { + if ((bp->b_flags & B_READ) == 0) { + if (bp->b_lock.lk_lockholder == LK_KERNPROC) + mp->mnt_stat.f_asyncwrites++; + else + mp->mnt_stat.f_syncwrites++; + } else { + if (bp->b_lock.lk_lockholder == LK_KERNPROC) + mp->mnt_stat.f_asyncreads++; + else + mp->mnt_stat.f_syncreads++; + } + } KASSERT(devsw(bp->b_dev) != NULL, ("No devsw on dev %s responsible for buffer %p\n", devtoname(bp->b_dev), bp)); diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index c3dc70ea8f55..dd135cf62115 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -589,8 +589,6 @@ int bwrite(struct buf * bp) { int oldflags, s; - struct vnode *vp; - struct mount *mp; if (bp->b_flags & B_INVAL) { brelse(bp); @@ -618,24 +616,6 @@ bwrite(struct buf * bp) BUF_KERNPROC(bp); VOP_STRATEGY(bp->b_vp, bp); - /* - * Collect statistics on synchronous and asynchronous writes. - * Writes to block devices are charged to their associated - * filesystem (if any). - */ - if ((vp = bp->b_vp) != NULL) { - if (vn_isdisk(vp)) - mp = vp->v_specmountpoint; - else - mp = vp->v_mount; - if (mp != NULL) { - if ((oldflags & B_ASYNC) == 0) - mp->mnt_stat.f_syncwrites++; - else - mp->mnt_stat.f_asyncwrites++; - } - } - if ((oldflags & B_ASYNC) == 0) { int rtval = biowait(bp); brelse(bp); diff --git a/sys/miscfs/specfs/spec_vnops.c b/sys/miscfs/specfs/spec_vnops.c index a66597dcea12..9a8ad4536a5a 100644 --- a/sys/miscfs/specfs/spec_vnops.c +++ b/sys/miscfs/specfs/spec_vnops.c @@ -406,11 +406,32 @@ spec_strategy(ap) } */ *ap; { struct buf *bp; + struct vnode *vp; + struct mount *mp; bp = ap->a_bp; if (((bp->b_flags & B_READ) == 0) && (LIST_FIRST(&bp->b_dep)) != NULL && bioops.io_start) (*bioops.io_start)(bp); + + /* + * Collect statistics on synchronous and asynchronous read + * and write counts for disks that have associated filesystems. + */ + vp = ap->a_vp; + if (vn_isdisk(vp) && (mp = vp->v_specmountpoint) != NULL) { + if ((bp->b_flags & B_READ) == 0) { + if (bp->b_lock.lk_lockholder == LK_KERNPROC) + mp->mnt_stat.f_asyncwrites++; + else + mp->mnt_stat.f_syncwrites++; + } else { + if (bp->b_lock.lk_lockholder == LK_KERNPROC) + mp->mnt_stat.f_asyncreads++; + else + mp->mnt_stat.f_syncreads++; + } + } KASSERT(devsw(bp->b_dev) != NULL, ("No devsw on dev %s responsible for buffer %p\n", devtoname(bp->b_dev), bp)); diff --git a/sys/sys/mount.h b/sys/sys/mount.h index 25c59564c3ad..e7680fd387a2 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -67,7 +67,7 @@ struct fid { */ #define MFSNAMELEN 16 /* length of fs type name, including null */ -#define MNAMELEN 90 /* length of buffer for returned name */ +#define MNAMELEN 80 /* length of buffer for returned name */ struct statfs { long f_spare2; /* placeholder */ @@ -86,7 +86,12 @@ struct statfs { long f_asyncwrites; /* count of async writes since mount */ char f_fstypename[MFSNAMELEN]; /* fs type name */ char f_mntonname[MNAMELEN]; /* directory on which mounted */ + long f_syncreads; /* count of sync reads since mount */ + long f_asyncreads; /* count of async reads since mount */ + short f_spares1; /* unused spare */ char f_mntfromname[MNAMELEN];/* mounted filesystem */ + short f_spares2; /* unused spare */ + long f_spare[2]; /* unused spare */ }; /*