summaryrefslogtreecommitdiff
path: root/sys/kern/vfs_bio.c
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>1999-12-05 08:09:02 +0000
committerArtur Grabowski <art@cvs.openbsd.org>1999-12-05 08:09:02 +0000
commit0c333d0b6b7319a29626c8b56baa1ad5eabd4e54 (patch)
tree5e963bc336e3e6e3bc577ffc7695fafa10215be2 /sys/kern/vfs_bio.c
parente690db303b6664ee0669697c9e72c4aef8d7e5cd (diff)
Collect statistics on sync and async writes.
From NetBSD.
Diffstat (limited to 'sys/kern/vfs_bio.c')
-rw-r--r--sys/kern/vfs_bio.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c
index f6fad6d3201..0588efe6b1f 100644
--- a/sys/kern/vfs_bio.c
+++ b/sys/kern/vfs_bio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_bio.c,v 1.25 1999/12/02 20:55:47 art Exp $ */
+/* $OpenBSD: vfs_bio.c,v 1.26 1999/12/05 08:09:01 art Exp $ */
/* $NetBSD: vfs_bio.c,v 1.44 1996/06/11 11:15:36 pk Exp $ */
/*-
@@ -282,6 +282,8 @@ bwrite(bp)
struct buf *bp;
{
int rv, async, wasdelayed, s;
+ struct vnode *vp;
+ struct mount *mp;
/*
* Remember buffer type, to switch on it later. If the write was
@@ -296,6 +298,25 @@ bwrite(bp)
bdwrite(bp);
return (0);
}
+
+ /*
+ * 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 (vp->v_type == VBLK)
+ mp = vp->v_specmountpoint;
+ else
+ mp = vp->v_mount;
+ if (mp != NULL) {
+ if (async)
+ mp->mnt_stat.f_asyncwrites++;
+ else
+ mp->mnt_stat.f_syncwrites++;
+ }
+ }
+
wasdelayed = ISSET(bp->b_flags, B_DELWRI);
CLR(bp->b_flags, (B_READ | B_DONE | B_ERROR | B_DELWRI));