summaryrefslogtreecommitdiff
path: root/sys/kern/kern_sysctl.c
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2007-12-23 01:59:59 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2007-12-23 01:59:59 +0000
commitb138fdba471acf705e1bea127c1da17179e67dd5 (patch)
treef141eb33d15eefe36bb2684c7f216113ae1eb4a6 /sys/kern/kern_sysctl.c
parent8602dbb5d540b780ded7baca4f0f52226105a1b2 (diff)
protect the disk statistics with a mutex.
ok tedu@ kettenis@
Diffstat (limited to 'sys/kern/kern_sysctl.c')
-rw-r--r--sys/kern/kern_sysctl.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index c9b12d50fab..a855b835c6a 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sysctl.c,v 1.158 2007/10/10 15:53:53 art Exp $ */
+/* $OpenBSD: kern_sysctl.c,v 1.159 2007/12/23 01:59:58 dlg Exp $ */
/* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */
/*-
@@ -1587,6 +1587,7 @@ sysctl_diskinit(int update, struct proc *p)
sdk = diskstats + i;
strlcpy(sdk->ds_name, dk->dk_name,
sizeof(sdk->ds_name));
+ mtx_enter(&dk->dk_mtx);
sdk->ds_busy = dk->dk_busy;
sdk->ds_rxfer = dk->dk_rxfer;
sdk->ds_wxfer = dk->dk_wxfer;
@@ -1596,6 +1597,7 @@ sysctl_diskinit(int update, struct proc *p)
sdk->ds_attachtime = dk->dk_attachtime;
sdk->ds_timestamp = dk->dk_timestamp;
sdk->ds_time = dk->dk_time;
+ mtx_leave(&dk->dk_mtx);
}
/* Eliminate trailing comma */
@@ -1609,6 +1611,7 @@ sysctl_diskinit(int update, struct proc *p)
sdk = diskstats + i;
strlcpy(sdk->ds_name, dk->dk_name,
sizeof(sdk->ds_name));
+ mtx_enter(&dk->dk_mtx);
sdk->ds_busy = dk->dk_busy;
sdk->ds_rxfer = dk->dk_rxfer;
sdk->ds_wxfer = dk->dk_wxfer;
@@ -1618,6 +1621,7 @@ sysctl_diskinit(int update, struct proc *p)
sdk->ds_attachtime = dk->dk_attachtime;
sdk->ds_timestamp = dk->dk_timestamp;
sdk->ds_time = dk->dk_time;
+ mtx_leave(&dk->dk_mtx);
}
}
rw_exit_write(&sysctl_disklock);