summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_sysctl.c6
-rw-r--r--sys/kern/subr_disk.c12
2 files changed, 14 insertions, 4 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);
diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c
index 2bf6f11b7e0..a07904647e4 100644
--- a/sys/kern/subr_disk.c
+++ b/sys/kern/subr_disk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_disk.c,v 1.67 2007/12/16 20:57:17 otto Exp $ */
+/* $OpenBSD: subr_disk.c,v 1.68 2007/12/23 01:59:58 dlg Exp $ */
/* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */
/*
@@ -712,6 +712,7 @@ int
disk_construct(struct disk *diskp, char *lockname)
{
rw_init(&diskp->dk_lock, lockname);
+ mtx_init(&diskp->dk_mtx, IPL_BIO);
diskp->dk_flags |= DKF_CONSTRUCTED;
@@ -784,9 +785,10 @@ disk_busy(struct disk *diskp)
* XXX We'd like to use something as accurate as microtime(),
* but that doesn't depend on the system TOD clock.
*/
- if (diskp->dk_busy++ == 0) {
+ mtx_enter(&diskp->dk_mtx);
+ if (diskp->dk_busy++ == 0)
microuptime(&diskp->dk_timestamp);
- }
+ mtx_leave(&diskp->dk_mtx);
}
/*
@@ -798,6 +800,8 @@ disk_unbusy(struct disk *diskp, long bcount, int read)
{
struct timeval dv_time, diff_time;
+ mtx_enter(&diskp->dk_mtx);
+
if (diskp->dk_busy-- == 0)
printf("disk_unbusy: %s: dk_busy < 0\n", diskp->dk_name);
@@ -818,6 +822,8 @@ disk_unbusy(struct disk *diskp, long bcount, int read)
} else
diskp->dk_seek++;
+ mtx_leave(&diskp->dk_mtx);
+
add_disk_randomness(bcount ^ diff_time.tv_usec);
}