Module Name:    src
Committed By:   riz
Date:           Tue Jun 12 17:13:58 UTC 2012

Modified Files:
        src/sys/dev/acpi [netbsd-6]: asus_acpi.c
        src/sys/dev/bluetooth [netbsd-6]: bcsp.c
        src/sys/kern [netbsd-6]: vfs_bio.c
        src/sys/miscfs/syncfs [netbsd-6]: sync_subr.c

Log Message:
Pull up following revision(s) (requested by dsl in ticket #306):
        sys/kern/vfs_bio.c: revision 1.238
        sys/dev/bluetooth/bcsp.c: revision 1.21
        sys/dev/acpi/asus_acpi.c: revision 1.24
        sys/miscfs/syncfs/sync_subr.c: revision 1.48
Some calls to sysctl_createv() have mismatches betwwen the data type
and the CTLTYPE_xxx flags.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
  sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
The vm.bufmem_lowater (etc) sysctls needs to be processed with a
  64bit temporary value on 64bit systems.
Fixes PR kern/46536.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.23.2.1 src/sys/dev/acpi/asus_acpi.c
cvs rdiff -u -r1.20 -r1.20.8.1 src/sys/dev/bluetooth/bcsp.c
cvs rdiff -u -r1.236 -r1.236.2.1 src/sys/kern/vfs_bio.c
cvs rdiff -u -r1.47 -r1.47.8.1 src/sys/miscfs/syncfs/sync_subr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/acpi/asus_acpi.c
diff -u src/sys/dev/acpi/asus_acpi.c:1.23 src/sys/dev/acpi/asus_acpi.c:1.23.2.1
--- src/sys/dev/acpi/asus_acpi.c:1.23	Sat Jan 21 18:13:56 2012
+++ src/sys/dev/acpi/asus_acpi.c	Tue Jun 12 17:13:57 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: asus_acpi.c,v 1.23 2012/01/21 18:13:56 jmcneill Exp $ */
+/* $NetBSD: asus_acpi.c,v 1.23.2.1 2012/06/12 17:13:57 riz Exp $ */
 
 /*-
  * Copyright (c) 2007, 2008, 2009 Jared D. McNeill <[email protected]>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: asus_acpi.c,v 1.23 2012/01/21 18:13:56 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: asus_acpi.c,v 1.23.2.1 2012/06/12 17:13:57 riz Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -355,7 +355,7 @@ asus_sysctl_setup(struct asus_softc *sc)
 		goto sysctl_err;
 	node_mib = node->sysctl_num;
 	err = sysctl_createv(&sc->sc_log, 0, NULL, &node_ncfv,
-	    CTLFLAG_READONLY, CTLTYPE_INT, "ncfv",
+	    CTLFLAG_READONLY, CTLTYPE_QUAD, "ncfv",
 	    SYSCTL_DESCR("Number of CPU frequency/voltage modes"),
 	    NULL, 0, &sc->sc_cfvnum, 0,
 	    CTL_HW, node_mib, CTL_CREATE, CTL_EOL);
@@ -365,7 +365,7 @@ asus_sysctl_setup(struct asus_softc *sc)
 	err = sysctl_createv(&sc->sc_log, 0, NULL, &node_cfv,
 	    CTLFLAG_READWRITE, CTLTYPE_INT, "cfv",
 	    SYSCTL_DESCR("Current CPU frequency/voltage mode"),
-	    asus_sysctl_verify, 0, sc, 0,
+	    asus_sysctl_verify, 0, (void *)sc, 0,
 	    CTL_HW, node_mib, CTL_CREATE, CTL_EOL);
 	if (err)
 		goto sysctl_err;

Index: src/sys/dev/bluetooth/bcsp.c
diff -u src/sys/dev/bluetooth/bcsp.c:1.20 src/sys/dev/bluetooth/bcsp.c:1.20.8.1
--- src/sys/dev/bluetooth/bcsp.c:1.20	Sun Jul 31 13:51:53 2011
+++ src/sys/dev/bluetooth/bcsp.c	Tue Jun 12 17:13:57 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcsp.c,v 1.20 2011/07/31 13:51:53 uebayasi Exp $	*/
+/*	$NetBSD: bcsp.c,v 1.20.8.1 2012/06/12 17:13:57 riz Exp $	*/
 /*
  * Copyright (c) 2007 KIYOHARA Takashi
  * All rights reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bcsp.c,v 1.20 2011/07/31 13:51:53 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcsp.c,v 1.20.8.1 2012/06/12 17:13:57 riz Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -300,7 +300,7 @@ bcsp_attach(device_t parent __unused, de
 	}
 	bcsp_node_num = node->sysctl_num;
 	if ((rc = sysctl_createv(&sc->sc_log, 0, NULL, &node,
-	    CTLFLAG_READWRITE, CTLTYPE_INT,
+	    CTLFLAG_READWRITE, CTLTYPE_BOOL,
 	    "muzzled", SYSCTL_DESCR("muzzled for Link-establishment Layer"),
 	    NULL, 0, &sc->sc_le_muzzled,
 	    0, CTL_HW, bcsp_node_num, CTL_CREATE, CTL_EOL)) != 0) {

Index: src/sys/kern/vfs_bio.c
diff -u src/sys/kern/vfs_bio.c:1.236 src/sys/kern/vfs_bio.c:1.236.2.1
--- src/sys/kern/vfs_bio.c:1.236	Wed Feb  1 23:43:49 2012
+++ src/sys/kern/vfs_bio.c	Tue Jun 12 17:13:56 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_bio.c,v 1.236 2012/02/01 23:43:49 para Exp $	*/
+/*	$NetBSD: vfs_bio.c,v 1.236.2.1 2012/06/12 17:13:56 riz 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.236 2012/02/01 23:43:49 para Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.236.2.1 2012/06/12 17:13:56 riz Exp $");
 
 #include "opt_bufcache.h"
 
@@ -1730,39 +1730,41 @@ sysctl_dobuf(SYSCTLFN_ARGS)
 static int
 sysctl_bufvm_update(SYSCTLFN_ARGS)
 {
-	int t, error, rv;
+	int error, rv;
 	struct sysctlnode node;
+	union u_int_long { unsigned int i; unsigned long l; } t;
 
+	/* Take a copy of the supplied node and its data */
 	node = *rnode;
 	node.sysctl_data = &t;
-	t = *(int *)rnode->sysctl_data;
+	t = *(union u_int_long *)rnode->sysctl_data;
+
+	/* Update the copy */
 	error = sysctl_lookup(SYSCTLFN_CALL(&node));
 	if (error || newp == NULL)
 		return (error);
 
-	if (t < 0)
-		return EINVAL;
 	if (rnode->sysctl_data == &bufcache) {
-		if (t > 100)
+		if (t.i > 100)
 			return (EINVAL);
-		bufcache = t;
+		bufcache = t.i;
 		buf_setwm();
 	} else if (rnode->sysctl_data == &bufmem_lowater) {
-		if (bufmem_hiwater - t < 16)
+		if (bufmem_hiwater - t.l < 16)
 			return (EINVAL);
-		bufmem_lowater = t;
+		bufmem_lowater = t.l;
 	} else if (rnode->sysctl_data == &bufmem_hiwater) {
-		if (t - bufmem_lowater < 16)
+		if (t.l - bufmem_lowater < 16)
 			return (EINVAL);
-		bufmem_hiwater = t;
+		bufmem_hiwater = t.l;
 	} else
 		return (EINVAL);
 
 	/* Drain until below new high water mark */
 	sysctl_unlock();
 	mutex_enter(&bufcache_lock);
-	while ((t = bufmem - bufmem_hiwater) >= 0) {
-		rv = buf_drain(t / (2 * 1024));
+	while (bufmem > bufmem_hiwater) {
+		rv = buf_drain((bufmem - bufmem_hiwater) / (2 * 1024));
 		if (rv <= 0)
 			break;
 	}
@@ -1809,21 +1811,21 @@ sysctl_vm_buf_setup(void)
 		       CTL_VM, CTL_CREATE, CTL_EOL);
 	sysctl_createv(&vfsbio_sysctllog, 0, NULL, NULL,
 		       CTLFLAG_PERMANENT|CTLFLAG_READONLY,
-		       CTLTYPE_INT, "bufmem",
+		       CTLTYPE_LONG, "bufmem",
 		       SYSCTL_DESCR("Amount of kernel memory used by buffer "
 				    "cache"),
 		       NULL, 0, &bufmem, 0,
 		       CTL_VM, CTL_CREATE, CTL_EOL);
 	sysctl_createv(&vfsbio_sysctllog, 0, NULL, NULL,
 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
-		       CTLTYPE_INT, "bufmem_lowater",
+		       CTLTYPE_LONG, "bufmem_lowater",
 		       SYSCTL_DESCR("Minimum amount of kernel memory to "
 				    "reserve for buffer cache"),
 		       sysctl_bufvm_update, 0, &bufmem_lowater, 0,
 		       CTL_VM, CTL_CREATE, CTL_EOL);
 	sysctl_createv(&vfsbio_sysctllog, 0, NULL, NULL,
 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
-		       CTLTYPE_INT, "bufmem_hiwater",
+		       CTLTYPE_LONG, "bufmem_hiwater",
 		       SYSCTL_DESCR("Maximum amount of kernel memory to use "
 				    "for buffer cache"),
 		       sysctl_bufvm_update, 0, &bufmem_hiwater, 0,

Index: src/sys/miscfs/syncfs/sync_subr.c
diff -u src/sys/miscfs/syncfs/sync_subr.c:1.47 src/sys/miscfs/syncfs/sync_subr.c:1.47.8.1
--- src/sys/miscfs/syncfs/sync_subr.c:1.47	Fri Sep 23 01:57:32 2011
+++ src/sys/miscfs/syncfs/sync_subr.c	Tue Jun 12 17:13:58 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: sync_subr.c,v 1.47 2011/09/23 01:57:32 manu Exp $	*/
+/*	$NetBSD: sync_subr.c,v 1.47.8.1 2012/06/12 17:13:58 riz Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sync_subr.c,v 1.47 2011/09/23 01:57:32 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sync_subr.c,v 1.47.8.1 2012/06/12 17:13:58 riz Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -317,28 +317,28 @@ sysctl_vfs_syncfs_setup(struct sysctllog
 
 	sysctl_createv(clog, 0, &rnode, &cnode,
 			CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
-			CTLTYPE_INT, "delay",
+			CTLTYPE_QUAD, "delay",
 			SYSCTL_DESCR("max time to delay syncing data"),
 			NULL, 0, &syncdelay, 0,
 			CTL_CREATE, CTL_EOL);
 
 	sysctl_createv(clog, 0, &rnode, &cnode,
 			CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
-			CTLTYPE_INT, "filedelay",
+			CTLTYPE_QUAD, "filedelay",
 			SYSCTL_DESCR("time to delay syncing files"),
 			NULL, 0, &filedelay, 0,
 			CTL_CREATE, CTL_EOL);
 
 	sysctl_createv(clog, 0, &rnode, &cnode,
 			CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
-			CTLTYPE_INT, "dirdelay",
+			CTLTYPE_QUAD, "dirdelay",
 			SYSCTL_DESCR("time to delay syncing directories"),
 			NULL, 0, &dirdelay, 0,
 			CTL_CREATE, CTL_EOL);
 
 	sysctl_createv(clog, 0, &rnode, &cnode,
 			CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
-			CTLTYPE_INT, "metadelay",
+			CTLTYPE_QUAD, "metadelay",
 			SYSCTL_DESCR("time to delay syncing metadata"),
 			NULL, 0, &metadelay, 0,
 			CTL_CREATE, CTL_EOL);

Reply via email to