Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Use separate temporaries for the 'int' percentage a...
details: https://anonhg.NetBSD.org/src/rev/6fe176b64438
branches: trunk
changeset: 779570:6fe176b64438
user: dsl <dsl%NetBSD.org@localhost>
date: Sun Jun 03 16:23:44 2012 +0000
description:
Use separate temporaries for the 'int' percentage and the 'long'
water marks.
Previous paniced on sparc64 due to a misaligned copy.
diffstat:
sys/kern/vfs_bio.c | 28 +++++++++++++++++-----------
1 files changed, 17 insertions(+), 11 deletions(-)
diffs (65 lines):
diff -r 8a952cb36757 -r 6fe176b64438 sys/kern/vfs_bio.c
--- a/sys/kern/vfs_bio.c Sun Jun 03 13:52:46 2012 +0000
+++ b/sys/kern/vfs_bio.c Sun Jun 03 16:23:44 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_bio.c,v 1.238 2012/06/03 11:37:44 dsl Exp $ */
+/* $NetBSD: vfs_bio.c,v 1.239 2012/06/03 16:23:44 dsl Exp $ */
/*-
* Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -123,7 +123,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.238 2012/06/03 11:37:44 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.239 2012/06/03 16:23:44 dsl Exp $");
#include "opt_bufcache.h"
@@ -1732,12 +1732,18 @@
{
int error, rv;
struct sysctlnode node;
- union u_int_long { unsigned int i; unsigned long l; } t;
+ unsigned int temp_bufcache;
+ unsigned long temp_water;
/* Take a copy of the supplied node and its data */
node = *rnode;
- node.sysctl_data = &t;
- t = *(union u_int_long *)rnode->sysctl_data;
+ if (node.sysctl_data == &bufcache) {
+ node.sysctl_data = &temp_bufcache;
+ temp_bufcache = *(unsigned int *)rnode->sysctl_data;
+ } else {
+ node.sysctl_data = &temp_water;
+ temp_water = *(unsigned long *)rnode->sysctl_data;
+ }
/* Update the copy */
error = sysctl_lookup(SYSCTLFN_CALL(&node));
@@ -1745,18 +1751,18 @@
return (error);
if (rnode->sysctl_data == &bufcache) {
- if (t.i > 100)
+ if (temp_bufcache > 100)
return (EINVAL);
- bufcache = t.i;
+ bufcache = temp_bufcache;
buf_setwm();
} else if (rnode->sysctl_data == &bufmem_lowater) {
- if (bufmem_hiwater - t.l < 16)
+ if (bufmem_hiwater - temp_water < 16)
return (EINVAL);
- bufmem_lowater = t.l;
+ bufmem_lowater = temp_water;
} else if (rnode->sysctl_data == &bufmem_hiwater) {
- if (t.l - bufmem_lowater < 16)
+ if (temp_water - bufmem_lowater < 16)
return (EINVAL);
- bufmem_hiwater = t.l;
+ bufmem_hiwater = temp_water;
} else
return (EINVAL);
Home |
Main Index |
Thread Index |
Old Index