svn commit: r258658 - head/contrib/gcclibs/libcpp

2013-11-26 Thread Matthew D Fleming
Author: mdf
Date: Tue Nov 26 17:11:43 2013
New Revision: 258658
URL: http://svnweb.freebsd.org/changeset/base/258658

Log:
  Fix a segfault / internal compiler error.
  
  Among other causes, when gcc throws a warning before parsing any tokens,
  the cur_token pointer is at the beginning of malloc'd memory.
  Dereferencing cur_token[-1] can cause a segfault.
  
  Code taken from OpenBSD
  http://www.openbsd.org/cgi-bin/cvsweb/src/gnu/gcc/libcpp/errors.c
  which was a more complete fix than the one I originally coded.
  
  MFC after:1 week

Modified:
  head/contrib/gcclibs/libcpp/errors.c

Modified: head/contrib/gcclibs/libcpp/errors.c
==
--- head/contrib/gcclibs/libcpp/errors.cTue Nov 26 16:13:48 2013
(r258657)
+++ head/contrib/gcclibs/libcpp/errors.cTue Nov 26 17:11:43 2013
(r258658)
@@ -153,7 +153,20 @@ cpp_error (cpp_reader * pfile, int level
}
   else
{
- src_loc = pfile-cur_token[-1].src_loc;
+ /* Find actual previous token.  */
+ cpp_token *t;
+
+ if (pfile-cur_token != pfile-cur_run-base)
+   t = pfile-cur_token - 1;
+ else
+   {
+ if (pfile-cur_run-prev != NULL)
+   t = pfile-cur_run-prev-limit;
+ else
+   t = NULL;
+   }
+ /* Retrieve corresponding source location, unless we failed.  */
+ src_loc = t ? t-src_loc : 0;
}
 
   if (_cpp_begin_message (pfile, level, src_loc, 0))
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r250247 - head/sys/kern

2013-05-04 Thread Matthew D Fleming
Author: mdf
Date: Sat May  4 18:38:16 2013
New Revision: 250247
URL: http://svnweb.freebsd.org/changeset/base/250247

Log:
  Add missing vdrop() in error case.
  
  Submitted by: Fahad (mohd.fahadul...@isilon.com)
  MFC after:1 week

Modified:
  head/sys/kern/vfs_subr.c

Modified: head/sys/kern/vfs_subr.c
==
--- head/sys/kern/vfs_subr.cSat May  4 18:24:30 2013(r250246)
+++ head/sys/kern/vfs_subr.cSat May  4 18:38:16 2013(r250247)
@@ -731,6 +731,7 @@ vlrureclaim(struct mount *mp)
(vp-v_object != NULL 
vp-v_object-resident_page_count  trigger)) {
VOP_UNLOCK(vp, LK_INTERLOCK);
+   vdrop(vp);
goto next_iter_mntunlocked;
}
KASSERT((vp-v_iflag  VI_DOOMED) == 0,
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r248995 - in head: contrib/libarchive/libarchive contrib/libarchive/libarchive/test lib/libc/sys sys/compat/freebsd32 sys/kern sys/sys usr.sbin/extattr

2013-04-01 Thread Matthew D Fleming
Author: mdf
Date: Tue Apr  2 05:30:41 2013
New Revision: 248995
URL: http://svnweb.freebsd.org/changeset/base/248995

Log:
  Fix return type of extattr_set_* and fix rmextattr(8) utility.
  
  extattr_set_{fd,file,link} is logically a write(2)-like operation and
  should return ssize_t, just like extattr_get_*.  Also, the user-space
  utility was using an int for the return value of extattr_get_* and
  extattr_list_*, both of which return an ssize_t.
  
  MFC after:1 week

Modified:
  head/contrib/libarchive/libarchive/archive_write_disk_posix.c
  head/contrib/libarchive/libarchive/test/test_extattr_freebsd.c
  head/lib/libc/sys/extattr_get_file.2
  head/sys/compat/freebsd32/syscalls.master
  head/sys/kern/syscalls.master
  head/sys/sys/extattr.h
  head/usr.sbin/extattr/rmextattr.c

Modified: head/contrib/libarchive/libarchive/archive_write_disk_posix.c
==
--- head/contrib/libarchive/libarchive/archive_write_disk_posix.c   Tue Apr 
 2 04:12:17 2013(r248994)
+++ head/contrib/libarchive/libarchive/archive_write_disk_posix.c   Tue Apr 
 2 05:30:41 2013(r248995)
@@ -3707,7 +3707,7 @@ set_xattrs(struct archive_write_disk *a)
size_t size;
archive_entry_xattr_next(entry, name, value, size);
if (name != NULL) {
-   int e;
+   ssize_t e;
int namespace;
 
if (strncmp(name, user., 5) == 0) {
@@ -3734,7 +3734,7 @@ set_xattrs(struct archive_write_disk *a)
e = 
extattr_set_file(archive_entry_pathname(entry),
namespace, name, value, size);
}
-   if (e != (int)size) {
+   if (e != (ssize_t)size) {
if (errno == ENOTSUP || errno == ENOSYS) {
if (!warning_done) {
warning_done = 1;

Modified: head/contrib/libarchive/libarchive/test/test_extattr_freebsd.c
==
--- head/contrib/libarchive/libarchive/test/test_extattr_freebsd.c  Tue Apr 
 2 04:12:17 2013(r248994)
+++ head/contrib/libarchive/libarchive/test/test_extattr_freebsd.c  Tue Apr 
 2 05:30:41 2013(r248995)
@@ -47,7 +47,8 @@ DEFINE_TEST(test_extattr_freebsd)
struct stat st;
struct archive *a;
struct archive_entry *ae;
-   int n, fd;
+   ssize_t n;
+   int fd;
int extattr_privilege_bug = 0;
 
/*

Modified: head/lib/libc/sys/extattr_get_file.2
==
--- head/lib/libc/sys/extattr_get_file.2Tue Apr  2 04:12:17 2013
(r248994)
+++ head/lib/libc/sys/extattr_get_file.2Tue Apr  2 05:30:41 2013
(r248995)
@@ -50,7 +50,7 @@
 .In sys/extattr.h
 .Ft ssize_t
 .Fn extattr_get_fd int fd int attrnamespace const char *attrname void 
*data size_t nbytes
-.Ft int
+.Ft ssize_t
 .Fn extattr_set_fd int fd int attrnamespace const char *attrname const 
void *data size_t nbytes
 .Ft int
 .Fn extattr_delete_fd int fd int attrnamespace const char *attrname
@@ -58,7 +58,7 @@
 .Fn extattr_list_fd int fd int attrnamespace void *data size_t nbytes
 .Ft ssize_t
 .Fn extattr_get_file const char *path int attrnamespace const char 
*attrname void *data size_t nbytes
-.Ft int
+.Ft ssize_t
 .Fn extattr_set_file const char *path int attrnamespace const char 
*attrname const void *data size_t nbytes
 .Ft int
 .Fn extattr_delete_file const char *path int attrnamespace const char 
*attrname
@@ -66,7 +66,7 @@
 .Fn extattr_list_file const char *path int attrnamespace void *data 
size_t nbytes
 .Ft ssize_t
 .Fn extattr_get_link const char *path int attrnamespace const char 
*attrname void *data size_t nbytes
-.Ft int
+.Ft ssize_t
 .Fn extattr_set_link const char *path int attrnamespace const char 
*attrname const void *data size_t nbytes
 .Ft int
 .Fn extattr_delete_link const char *path int attrnamespace const char 
*attrname

Modified: head/sys/compat/freebsd32/syscalls.master
==
--- head/sys/compat/freebsd32/syscalls.master   Tue Apr  2 04:12:17 2013
(r248994)
+++ head/sys/compat/freebsd32/syscalls.master   Tue Apr  2 05:30:41 2013
(r248995)
@@ -634,7 +634,7 @@
 355AUE_EXTATTRCTL  NOPROTO { int extattrctl(const char *path, int cmd, \
const char *filename, int attrnamespace, \
const char *attrname); }
-356AUE_EXTATTR_SET_FILENOPROTO { int extattr_set_file( \
+356AUE_EXTATTR_SET_FILENOPROTO { ssize_t extattr_set_file( \
const char *path, int attrnamespace, \
 

svn commit: r248996 - in head/sys: compat/freebsd32 kern sys

2013-04-01 Thread Matthew D Fleming
Author: mdf
Date: Tue Apr  2 05:30:52 2013
New Revision: 248996
URL: http://svnweb.freebsd.org/changeset/base/248996

Log:
  Regen.
  
  MFC after:1 week

Modified:
  head/sys/compat/freebsd32/freebsd32_proto.h
  head/sys/compat/freebsd32/freebsd32_syscall.h
  head/sys/compat/freebsd32/freebsd32_syscalls.c
  head/sys/compat/freebsd32/freebsd32_sysent.c
  head/sys/compat/freebsd32/freebsd32_systrace_args.c
  head/sys/kern/init_sysent.c
  head/sys/kern/syscalls.c
  head/sys/kern/systrace_args.c
  head/sys/sys/syscall.h
  head/sys/sys/syscall.mk
  head/sys/sys/sysproto.h

Modified: head/sys/compat/freebsd32/freebsd32_proto.h
==
--- head/sys/compat/freebsd32/freebsd32_proto.h Tue Apr  2 05:30:41 2013
(r248995)
+++ head/sys/compat/freebsd32/freebsd32_proto.h Tue Apr  2 05:30:52 2013
(r248996)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 248599 
2013-03-21 22:59:01Z pjd 
+ * created from FreeBSD
  */
 
 #ifndef _FREEBSD32_SYSPROTO_H_

Modified: head/sys/compat/freebsd32/freebsd32_syscall.h
==
--- head/sys/compat/freebsd32/freebsd32_syscall.h   Tue Apr  2 05:30:41 
2013(r248995)
+++ head/sys/compat/freebsd32/freebsd32_syscall.h   Tue Apr  2 05:30:52 
2013(r248996)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 248599 
2013-03-21 22:59:01Z pjd 
+ * created from FreeBSD
  */
 
 #defineFREEBSD32_SYS_syscall   0

Modified: head/sys/compat/freebsd32/freebsd32_syscalls.c
==
--- head/sys/compat/freebsd32/freebsd32_syscalls.c  Tue Apr  2 05:30:41 
2013(r248995)
+++ head/sys/compat/freebsd32/freebsd32_syscalls.c  Tue Apr  2 05:30:52 
2013(r248996)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 248599 
2013-03-21 22:59:01Z pjd 
+ * created from FreeBSD
  */
 
 const char *freebsd32_syscallnames[] = {

Modified: head/sys/compat/freebsd32/freebsd32_sysent.c
==
--- head/sys/compat/freebsd32/freebsd32_sysent.cTue Apr  2 05:30:41 
2013(r248995)
+++ head/sys/compat/freebsd32/freebsd32_sysent.cTue Apr  2 05:30:52 
2013(r248996)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 248599 
2013-03-21 22:59:01Z pjd 
+ * created from FreeBSD
  */
 
 #include opt_compat.h

Modified: head/sys/compat/freebsd32/freebsd32_systrace_args.c
==
--- head/sys/compat/freebsd32/freebsd32_systrace_args.c Tue Apr  2 05:30:41 
2013(r248995)
+++ head/sys/compat/freebsd32/freebsd32_systrace_args.c Tue Apr  2 05:30:52 
2013(r248996)
@@ -9493,7 +9493,7 @@ systrace_return_setargdesc(int sysnum, i
/* extattr_set_file */
case 356:
if (ndx == 0 || ndx == 1)
-   p = int;
+   p = ssize_t;
break;
/* extattr_get_file */
case 357:
@@ -9530,7 +9530,7 @@ systrace_return_setargdesc(int sysnum, i
/* extattr_set_fd */
case 371:
if (ndx == 0 || ndx == 1)
-   p = int;
+   p = ssize_t;
break;
/* extattr_get_fd */
case 372:
@@ -9645,7 +9645,7 @@ systrace_return_setargdesc(int sysnum, i
/* extattr_set_link */
case 412:
if (ndx == 0 || ndx == 1)
-   p = int;
+   p = ssize_t;
break;
/* extattr_get_link */
case 413:

Modified: head/sys/kern/init_sysent.c
==
--- head/sys/kern/init_sysent.c Tue Apr  2 05:30:41 2013(r248995)
+++ head/sys/kern/init_sysent.c Tue Apr  2 05:30:52 2013(r248996)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: head/sys/kern/syscalls.master 248599 2013-03-21 
22:59:01Z pjd 
+ * created from FreeBSD
  */
 
 #include opt_compat.h

Modified: head/sys/kern/syscalls.c
==
--- head/sys/kern/syscalls.cTue Apr  2 05:30:41 2013(r248995)
+++ head/sys/kern/syscalls.cTue Apr  2 05:30:52 2013(r248996)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  

svn commit: r248933 - head/sys/kern

2013-03-30 Thread Matthew D Fleming
Author: mdf
Date: Sat Mar 30 15:09:04 2013
New Revision: 248933
URL: http://svnweb.freebsd.org/changeset/base/248933

Log:
  Use a shared lock for VOP_GETEXTATTR, as it is a read-like operation.
  
  MFC after:1 week

Modified:
  head/sys/kern/vfs_extattr.c
  head/sys/kern/vfs_vnops.c

Modified: head/sys/kern/vfs_extattr.c
==
--- head/sys/kern/vfs_extattr.c Sat Mar 30 13:30:27 2013(r248932)
+++ head/sys/kern/vfs_extattr.c Sat Mar 30 15:09:04 2013(r248933)
@@ -326,7 +326,7 @@ extattr_get_vp(struct vnode *vp, int att
size_t size, *sizep;
int error;
 
-   vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
+   vn_lock(vp, LK_SHARED | LK_RETRY);
 
/*
 * Slightly unusual semantics: if the user provides a NULL data

Modified: head/sys/kern/vfs_vnops.c
==
--- head/sys/kern/vfs_vnops.c   Sat Mar 30 13:30:27 2013(r248932)
+++ head/sys/kern/vfs_vnops.c   Sat Mar 30 15:09:04 2013(r248933)
@@ -1758,7 +1758,7 @@ vn_extattr_get(struct vnode *vp, int iof
auio.uio_resid = *buflen;
 
if ((ioflg  IO_NODELOCKED) == 0)
-   vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
+   vn_lock(vp, LK_SHARED | LK_RETRY);
 
ASSERT_VOP_LOCKED(vp, IO_NODELOCKED with no vp lock held);
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r242152 - in head: lib/libmemstat sys/vm

2012-10-26 Thread Matthew D Fleming
Author: mdf
Date: Fri Oct 26 17:51:05 2012
New Revision: 242152
URL: http://svn.freebsd.org/changeset/base/242152

Log:
  Const-ify the zone name argument to uma_zcreate(9).
  
  MFC after:3 days

Modified:
  head/lib/libmemstat/memstat_uma.c
  head/sys/vm/uma.h
  head/sys/vm/uma_core.c
  head/sys/vm/uma_int.h

Modified: head/lib/libmemstat/memstat_uma.c
==
--- head/lib/libmemstat/memstat_uma.c   Fri Oct 26 17:31:35 2012
(r242151)
+++ head/lib/libmemstat/memstat_uma.c   Fri Oct 26 17:51:05 2012
(r242152)
@@ -254,7 +254,7 @@ kread(kvm_t *kvm, void *kvm_pointer, voi
 }
 
 static int
-kread_string(kvm_t *kvm, void *kvm_pointer, char *buffer, int buflen)
+kread_string(kvm_t *kvm, const void *kvm_pointer, char *buffer, int buflen)
 {
ssize_t ret;
int i;

Modified: head/sys/vm/uma.h
==
--- head/sys/vm/uma.h   Fri Oct 26 17:31:35 2012(r242151)
+++ head/sys/vm/uma.h   Fri Oct 26 17:51:05 2012(r242152)
@@ -165,9 +165,9 @@ typedef void (*uma_fini)(void *mem, int 
  * A pointer to a structure which is intended to be opaque to users of
  * the interface.  The value may be null if the wait flag is not set.
  */
-uma_zone_t uma_zcreate(char *name, size_t size, uma_ctor ctor, uma_dtor dtor,
-   uma_init uminit, uma_fini fini, int align,
-   u_int32_t flags);
+uma_zone_t uma_zcreate(const char *name, size_t size, uma_ctor ctor,
+   uma_dtor dtor, uma_init uminit, uma_fini fini,
+   int align, u_int32_t flags);
 
 /*
  * Create a secondary uma zone

Modified: head/sys/vm/uma_core.c
==
--- head/sys/vm/uma_core.c  Fri Oct 26 17:31:35 2012(r242151)
+++ head/sys/vm/uma_core.c  Fri Oct 26 17:51:05 2012(r242152)
@@ -158,7 +158,7 @@ static struct callout uma_callout;
  * a special allocation function just for zones.
  */
 struct uma_zctor_args {
-   char *name;
+   const char *name;
size_t size;
uma_ctor ctor;
uma_dtor dtor;
@@ -1828,7 +1828,7 @@ uma_set_align(int align)
 
 /* See uma.h */
 uma_zone_t
-uma_zcreate(char *name, size_t size, uma_ctor ctor, uma_dtor dtor,
+uma_zcreate(const char *name, size_t size, uma_ctor ctor, uma_dtor dtor,
uma_init uminit, uma_fini fini, int align, u_int32_t flags)
 
 {

Modified: head/sys/vm/uma_int.h
==
--- head/sys/vm/uma_int.h   Fri Oct 26 17:31:35 2012(r242151)
+++ head/sys/vm/uma_int.h   Fri Oct 26 17:51:05 2012(r242152)
@@ -202,7 +202,7 @@ struct uma_keg {
struct mtx  uk_lock;/* Lock for the keg */
struct uma_hash uk_hash;
 
-   char*uk_name;   /* Name of creating zone. */
+   const char  *uk_name;   /* Name of creating zone. */
LIST_HEAD(,uma_zone)uk_zones;   /* Keg's zones */
LIST_HEAD(,uma_slab)uk_part_slab;   /* partially allocated slabs */
LIST_HEAD(,uma_slab)uk_free_slab;   /* empty slab list */
@@ -305,7 +305,7 @@ typedef struct uma_klink *uma_klink_t;
  *
  */
 struct uma_zone {
-   char*uz_name;   /* Text name of the zone */
+   const char  *uz_name;   /* Text name of the zone */
struct mtx  *uz_lock;   /* Lock for the zone (keg's lock) */
 
LIST_ENTRY(uma_zone)uz_link;/* List of all zones in keg */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r241035 - head/sbin/fsck_ffs

2012-09-28 Thread Matthew D Fleming
Author: mdf
Date: Fri Sep 28 17:34:34 2012
New Revision: 241035
URL: http://svn.freebsd.org/changeset/base/241035

Log:
  Fix some nearby type and style errors.
  
  Pointed out by:   bde

Modified:
  head/sbin/fsck_ffs/main.c
  head/sbin/fsck_ffs/pass1.c
  head/sbin/fsck_ffs/suj.c

Modified: head/sbin/fsck_ffs/main.c
==
--- head/sbin/fsck_ffs/main.c   Fri Sep 28 16:23:01 2012(r241034)
+++ head/sbin/fsck_ffs/main.c   Fri Sep 28 17:34:34 2012(r241035)
@@ -210,12 +210,11 @@ checkfilesys(char *filesys)
struct statfs *mntp;
struct stat snapdir;
struct group *grp;
-   ufs2_daddr_t blks;
struct iovec *iov;
char errmsg[255];
int iovlen;
int cylno;
-   ino_t files;
+   intmax_t blks, files;
size_t size;
 
iov = NULL;
@@ -382,9 +381,9 @@ checkfilesys(char *filesys)
clean:
pwarn(clean, %ld free , (long)(sblock.fs_cstotal.cs_nffree +
sblock.fs_frag * sblock.fs_cstotal.cs_nbfree));
-   printf((%lld frags, %lld blocks, %.1f%% fragmentation)\n,
-   (long long)sblock.fs_cstotal.cs_nffree,
-   (long long)sblock.fs_cstotal.cs_nbfree,
+   printf((%jd frags, %jd blocks, %.1f%% fragmentation)\n,
+   (intmax_t)sblock.fs_cstotal.cs_nffree,
+   (intmax_t)sblock.fs_cstotal.cs_nbfree,
sblock.fs_cstotal.cs_nffree * 100.0 / sblock.fs_dsize);
return (0);
}
@@ -481,8 +480,8 @@ checkfilesys(char *filesys)
blks = maxfsblock - (n_ffree + sblock.fs_frag * n_bfree) - blks;
if (bkgrdflag  (files  0 || blks  0)) {
countdirs = sblock.fs_cstotal.cs_ndir - countdirs;
-   pwarn(Reclaimed: %ld directories, %ld files, %lld fragments\n,
-   countdirs, (long)files - countdirs, (long long)blks);
+   pwarn(Reclaimed: %ld directories, %jd files, %jd fragments\n,
+   countdirs, files - countdirs, blks);
}
pwarn(%ld files, %jd used, %ju free ,
(long)n_files, (intmax_t)n_blks,
@@ -492,13 +491,13 @@ checkfilesys(char *filesys)
n_ffree * 100.0 / sblock.fs_dsize);
if (debug) {
if (files  0)
-   printf(%jd inodes missing\n, (intmax_t)-files);
+   printf(%jd inodes missing\n, -files);
if (blks  0)
-   printf(%lld blocks missing\n, -(long long)blks);
+   printf(%jd blocks missing\n, -blks);
if (duplist != NULL) {
printf(The following duplicate blocks remain:);
for (dp = duplist; dp; dp = dp-next)
-   printf( %lld,, (long long)dp-dup);
+   printf( %jd,, (intmax_t)dp-dup);
printf(\n);
}
}

Modified: head/sbin/fsck_ffs/pass1.c
==
--- head/sbin/fsck_ffs/pass1.c  Fri Sep 28 16:23:01 2012(r241034)
+++ head/sbin/fsck_ffs/pass1.c  Fri Sep 28 17:34:34 2012(r241035)
@@ -99,11 +99,10 @@ pass1(void)
if (!rebuildcg  sblock.fs_magic == FS_UFS2_MAGIC) {
inosused = cgrp.cg_initediblk;
if (inosused  sblock.fs_ipg) {
-   pfatal(%s (%ju  %d) %s %d\nReset to %d\n,
-   Too many initialized inodes,
+   pfatal(
+Too many initialized inodes (%ju  %d) in cylinder group %d\nReset to %d\n,
(uintmax_t)inosused,
-   sblock.fs_ipg, in cylinder group, c,
-   sblock.fs_ipg);
+   sblock.fs_ipg, c, sblock.fs_ipg);
inosused = sblock.fs_ipg;
}
} else {

Modified: head/sbin/fsck_ffs/suj.c
==
--- head/sbin/fsck_ffs/suj.cFri Sep 28 16:23:01 2012(r241034)
+++ head/sbin/fsck_ffs/suj.cFri Sep 28 17:34:34 2012(r241035)
@@ -1401,9 +1401,8 @@ ino_adjust(struct suj_ino *sino)
ip = ino_read(ino);
mode = DIP(ip, di_mode)  IFMT;
if (nlink  LINK_MAX)
-   err_suj(ino %ju %s, new link %d, old link %d\n,
-   (uintmax_t)ino, nlink manipulation error, nlink,
-   DIP(ip, di_nlink));
+   err_suj(ino %ju nlink manipulation error, new %d, old %d\n,
+   (uintmax_t)ino, nlink, DIP(ip, di_nlink));
if (debug)
printf(Adjusting ino %ju, nlink %d, old link %d lastmode %o\n,
(uintmax_t)ino, 

svn commit: r241011 - in head/sys: fs/ext2fs fs/hpfs fs/ntfs fs/tmpfs kern ufs/ffs ufs/ufs

2012-09-27 Thread Matthew D Fleming
Author: mdf
Date: Thu Sep 27 23:30:49 2012
New Revision: 241011
URL: http://svn.freebsd.org/changeset/base/241011

Log:
  Fix up kernel sources to be ready for a 64-bit ino_t.
  
  Original code by: Gleb Kurtsou

Modified:
  head/sys/fs/ext2fs/ext2_alloc.c
  head/sys/fs/ext2fs/ext2_inode_cnv.c
  head/sys/fs/hpfs/hpfs_vfsops.c
  head/sys/fs/ntfs/ntfs_subr.c
  head/sys/fs/ntfs/ntfs_vfsops.c
  head/sys/fs/ntfs/ntfs_vnops.c
  head/sys/fs/tmpfs/tmpfs_vfsops.c
  head/sys/kern/uipc_usrreq.c
  head/sys/ufs/ffs/ffs_alloc.c
  head/sys/ufs/ffs/ffs_snapshot.c
  head/sys/ufs/ffs/ffs_softdep.c
  head/sys/ufs/ufs/inode.h
  head/sys/ufs/ufs/ufs_acl.c
  head/sys/ufs/ufs/ufs_lookup.c
  head/sys/ufs/ufs/ufs_vnops.c

Modified: head/sys/fs/ext2fs/ext2_alloc.c
==
--- head/sys/fs/ext2fs/ext2_alloc.c Thu Sep 27 22:05:54 2012
(r241010)
+++ head/sys/fs/ext2fs/ext2_alloc.c Thu Sep 27 23:30:49 2012
(r241011)
@@ -1026,8 +1026,8 @@ ext2_vfree(pvp, ino, mode)
fs = pip-i_e2fs;
ump = pip-i_ump;
if ((u_int)ino  fs-e2fs_ipg * fs-e2fs_gcount)
-   panic(ext2_vfree: range: devvp = %p, ino = %d, fs = %s,
-   pip-i_devvp, ino, fs-e2fs_fsmnt);
+   panic(ext2_vfree: range: devvp = %p, ino = %ju, fs = %s,
+   pip-i_devvp, (uintmax_t)ino, fs-e2fs_fsmnt);
 
cg = ino_to_cg(fs, ino);
error = bread(pip-i_devvp,

Modified: head/sys/fs/ext2fs/ext2_inode_cnv.c
==
--- head/sys/fs/ext2fs/ext2_inode_cnv.c Thu Sep 27 22:05:54 2012
(r241010)
+++ head/sys/fs/ext2fs/ext2_inode_cnv.c Thu Sep 27 23:30:49 2012
(r241011)
@@ -45,7 +45,7 @@ ext2_print_inode( in )
 {
int i;
 
-   printf( Inode: %5d, in-i_number);
+   printf( Inode: %5ju, (uintmax_t)in-i_number);
printf( /* Inode: %5d */
 Type: %10s Mode: 0x%o Flags: 0x%x  Version: %d\n,
n/a, in-i_mode, in-i_flags, in-i_gen);

Modified: head/sys/fs/hpfs/hpfs_vfsops.c
==
--- head/sys/fs/hpfs/hpfs_vfsops.c  Thu Sep 27 22:05:54 2012
(r241010)
+++ head/sys/fs/hpfs/hpfs_vfsops.c  Thu Sep 27 23:30:49 2012
(r241011)
@@ -512,7 +512,7 @@ hpfs_vget(
 
error = bread(hpmp-hpm_devvp, ino, FNODESIZE, NOCRED, bp);
if (error) {
-   printf(hpfs_vget: can't read ino %d\n,ino);
+   printf(hpfs_vget: can't read ino %ju\n, (uintmax_t)ino);
vput(vp);
return (error);
}

Modified: head/sys/fs/ntfs/ntfs_subr.c
==
--- head/sys/fs/ntfs/ntfs_subr.cThu Sep 27 22:05:54 2012
(r241010)
+++ head/sys/fs/ntfs/ntfs_subr.cThu Sep 27 23:30:49 2012
(r241011)
@@ -84,8 +84,8 @@ int
 ntfs_ntvattrrele(vap)
struct ntvattr * vap;
 {
-   dprintf((ntfs_ntvattrrele: ino: %d, type: 0x%x\n,
-vap-va_ip-i_number, vap-va_type));
+   dprintf((ntfs_ntvattrrele: ino: %ju, type: 0x%x\n,
+   (uintmax_t)vap-va_ip-i_number, vap-va_type));
 
ntfs_ntrele(vap-va_ip);
 
@@ -109,12 +109,12 @@ ntfs_findvattr(ntmp, ip, lvapp, vapp, ty
struct ntvattr *vap;
 
if((ip-i_flag  IN_LOADED) == 0) {
-   dprintf((ntfs_findvattr: node not loaded, ino: %d\n,
-  ip-i_number));
+   dprintf((ntfs_findvattr: node not loaded, ino: %ju\n,
+   (uintmax_t)ip-i_number));
error = ntfs_loadntnode(ntmp,ip);
if (error) {
-   printf(ntfs_findvattr: FAILED TO LOAD INO: %d\n,
-  ip-i_number);
+   printf(ntfs_findvattr: FAILED TO LOAD INO: %ju\n,
+   (uintmax_t)ip-i_number);
return (error);
}
}
@@ -169,13 +169,13 @@ ntfs_ntvattrget(
 
if (name) {
dprintf((ntfs_ntvattrget:  \
-ino: %d, type: 0x%x, name: %s, vcn: %d\n, \
-ip-i_number, type, name, (u_int32_t) vcn));
+   ino: %ju, type: 0x%x, name: %s, vcn: %d\n, \
+   (uintmax_t)ip-i_number, type, name, (uint32_t)vcn));
namelen = strlen(name);
} else {
dprintf((ntfs_ntvattrget:  \
-ino: %d, type: 0x%x, vcn: %d\n, \
-ip-i_number, type, (u_int32_t) vcn));
+   ino: %ju, type: 0x%x, vcn: %d\n, \
+   (uintmax_t)ip-i_number, type, (uint32_t)vcn));
name = ;
namelen = 0;
}
@@ -186,8 +186,8 @@ ntfs_ntvattrget(
 
if (!lvap) {
dprintf((ntfs_ntvattrget: UNEXISTED ATTRIBUTE:  \
- 

svn commit: r241013 - in head/sbin: dump fsck_ffs fsdb fsirand growfs newfs quotacheck restore tunefs

2012-09-27 Thread Matthew D Fleming
Author: mdf
Date: Thu Sep 27 23:31:06 2012
New Revision: 241013
URL: http://svn.freebsd.org/changeset/base/241013

Log:
  Fix sbin/ build with a 64-bit ino_t.
  
  Original code by: Gleb Kurtsou

Modified:
  head/sbin/dump/traverse.c
  head/sbin/fsck_ffs/suj.c
  head/sbin/fsdb/fsdb.c
  head/sbin/fsdb/fsdbutil.c
  head/sbin/fsirand/fsirand.c
  head/sbin/growfs/growfs.c
  head/sbin/newfs/mkfs.c
  head/sbin/quotacheck/quotacheck.c
  head/sbin/restore/dirs.c
  head/sbin/restore/interactive.c
  head/sbin/restore/restore.c
  head/sbin/restore/symtab.c
  head/sbin/restore/tape.c
  head/sbin/tunefs/tunefs.c

Modified: head/sbin/dump/traverse.c
==
--- head/sbin/dump/traverse.c   Thu Sep 27 23:30:58 2012(r241012)
+++ head/sbin/dump/traverse.c   Thu Sep 27 23:31:06 2012(r241013)
@@ -197,8 +197,8 @@ mapfiles(ino_t maxino, long *tapesize)
(mode  IFMT) == 0)
continue;
if (ino = maxino) {
-   msg(Skipping inode %d = maxino %d\n,
-   ino, maxino);
+   msg(Skipping inode %ju = maxino %ju\n,
+   (uintmax_t)ino, (uintmax_t)maxino);
continue;
}
/*
@@ -400,15 +400,16 @@ searchdir(
for (loc = 0; loc  size; ) {
dp = (struct direct *)(dblk + loc);
if (dp-d_reclen == 0) {
-   msg(corrupted directory, inumber %d\n, ino);
+   msg(corrupted directory, inumber %ju\n,
+   (uintmax_t)ino);
break;
}
loc += dp-d_reclen;
if (dp-d_ino == 0)
continue;
if (dp-d_ino = maxino) {
-   msg(corrupted directory entry, d_ino %d = %d\n,
-   dp-d_ino, maxino);
+   msg(corrupted directory entry, d_ino %ju = %ju\n,
+   (uintmax_t)dp-d_ino, (uintmax_t)maxino);
break;
}
if (dp-d_name[0] == '.') {

Modified: head/sbin/fsck_ffs/suj.c
==
--- head/sbin/fsck_ffs/suj.cThu Sep 27 23:30:58 2012(r241012)
+++ head/sbin/fsck_ffs/suj.cThu Sep 27 23:31:06 2012(r241013)
@@ -1945,7 +1945,7 @@ ino_unlinked(void)
if (DIP(ip, di_nlink) == 0) {
if (debug)
printf(Freeing unlinked ino %ju mode %o\n,
-   ino, mode);
+   (uintmax_t)ino, mode);
ino_reclaim(ip, ino, mode);
} else if (debug)
printf(Skipping ino %ju mode %o with link %d\n,

Modified: head/sbin/fsdb/fsdb.c
==
--- head/sbin/fsdb/fsdb.c   Thu Sep 27 23:30:58 2012(r241012)
+++ head/sbin/fsdb/fsdb.c   Thu Sep 27 23:31:06 2012(r241013)
@@ -39,6 +39,7 @@ static const char rcsid[] =
 #include grp.h
 #include histedit.h
 #include pwd.h
+#include stdint.h
 #include string.h
 #include time.h
 #include timeconv.h
@@ -211,7 +212,8 @@ char *
 prompt(EditLine *el)
 {
 static char pstring[64];
-snprintf(pstring, sizeof(pstring), fsdb (inum: %d) , curinum);
+snprintf(pstring, sizeof(pstring), fsdb (inum: %ju) ,
+   (uintmax_t)curinum);
 return pstring;
 }
 
@@ -298,8 +300,8 @@ ino_t curinum, ocurrent;
 
 #define GETINUM(ac,inum)inum = strtoul(argv[ac], cp, 0); \
 if (inum  ROOTINO || inum  maxino || cp == argv[ac] || *cp != '\0' ) { \
-   printf(inode %d out of range; range is [%d,%d]\n, \
-  inum, ROOTINO, maxino); \
+   printf(inode %ju out of range; range is [%ju,%ju]\n,  \
+   (uintmax_t)inum, (uintmax_t)ROOTINO, (uintmax_t)maxino);\
return 1; \
 }
 
@@ -364,7 +366,8 @@ CMDFUNCSTART(uplink)
 if (!checkactive())
return 1;
 DIP_SET(curinode, di_nlink, DIP(curinode, di_nlink) + 1);
-printf(inode %d link count now %d\n, curinum, DIP(curinode, di_nlink));
+printf(inode %ju link count now %d\n,
+   (uintmax_t)curinum, DIP(curinode, di_nlink));
 inodirty();
 return 0;
 }
@@ -374,7 +377,8 @@ CMDFUNCSTART(downlink)
 if (!checkactive())
return 1;
 DIP_SET(curinode, di_nlink, DIP(curinode, di_nlink) - 1);
-printf(inode %d link count now %d\n, curinum, DIP(curinode, di_nlink));
+printf(inode %ju link count now %d\n,
+   (uintmax_t)curinum, DIP(curinode, di_nlink));
 inodirty();
 return 0;
 }
@@ -493,11 +497,11 @@ CMDFUNCSTART(findblk)
if (is_ufs2 ?
 

svn commit: r241014 - in head/bin: ls rm

2012-09-27 Thread Matthew D Fleming
Author: mdf
Date: Thu Sep 27 23:31:12 2012
New Revision: 241014
URL: http://svn.freebsd.org/changeset/base/241014

Log:
  Fix bin/ build with a 64-bit ino_t.
  
  Original code by: Gleb Kurtsou

Modified:
  head/bin/ls/ls.c
  head/bin/ls/print.c
  head/bin/rm/rm.c

Modified: head/bin/ls/ls.c
==
--- head/bin/ls/ls.cThu Sep 27 23:31:06 2012(r241013)
+++ head/bin/ls/ls.cThu Sep 27 23:31:12 2012(r241014)
@@ -561,7 +561,8 @@ display(const FTSENT *p, FTSENT *list, i
NAMES *np;
off_t maxsize;
long maxblock;
-   u_long btotal, labelstrlen, maxinode, maxlen, maxnlink;
+   uintmax_t maxinode;
+   u_long btotal, labelstrlen, maxlen, maxnlink;
u_long maxlabelstr;
u_int sizelen;
int maxflags;
@@ -580,8 +581,9 @@ display(const FTSENT *p, FTSENT *list, i
btotal = 0;
initmax = getenv(LS_COLWIDTHS);
/* Fields match -lios order.  New ones should be added at the end. */
-   maxlabelstr = maxblock = maxinode = maxlen = maxnlink =
-   maxuser = maxgroup = maxflags = maxsize = 0;
+   maxlabelstr = maxblock = maxlen = maxnlink = 0;
+   maxuser = maxgroup = maxflags = maxsize = 0;
+   maxinode = 0;
if (initmax != NULL  *initmax != '\0') {
char *initmax2, *jinitmax;
int ninitmax;
@@ -609,7 +611,7 @@ display(const FTSENT *p, FTSENT *list, i
strcpy(initmax2, 0);
 
ninitmax = sscanf(jinitmax,
-%lu : %ld : %lu : %u : %u : %i : %jd : %lu : %lu ,
+%ju : %ld : %lu : %u : %u : %i : %jd : %lu : %lu ,
maxinode, maxblock, maxnlink, maxuser,
maxgroup, maxflags, maxsize, maxlen, maxlabelstr);
f_notabs = 1;
@@ -839,7 +841,7 @@ label_out:
d.s_flags = maxflags;
d.s_label = maxlabelstr;
d.s_group = maxgroup;
-   d.s_inode = snprintf(NULL, 0, %lu, maxinode);
+   d.s_inode = snprintf(NULL, 0, %ju, maxinode);
d.s_nlink = snprintf(NULL, 0, %lu, maxnlink);
sizelen = f_humanval ? HUMANVALSTR_LEN :
snprintf(NULL, 0, %ju, maxsize);

Modified: head/bin/ls/print.c
==
--- head/bin/ls/print.c Thu Sep 27 23:31:06 2012(r241013)
+++ head/bin/ls/print.c Thu Sep 27 23:31:12 2012(r241014)
@@ -152,7 +152,8 @@ printlong(const DISPLAY *dp)
continue;
sp = p-fts_statp;
if (f_inode)
-   (void)printf(%*lu , dp-s_inode, (u_long)sp-st_ino);
+   (void)printf(%*ju ,
+   dp-s_inode, (uintmax_t)sp-st_ino);
if (f_size)
(void)printf(%*jd ,
dp-s_block, howmany(sp-st_blocks, blocksize));
@@ -328,7 +329,8 @@ printaname(const FTSENT *p, u_long inode
sp = p-fts_statp;
chcnt = 0;
if (f_inode)
-   chcnt += printf(%*lu , (int)inodefield, (u_long)sp-st_ino);
+   chcnt += printf(%*ju ,
+   (int)inodefield, (uintmax_t)sp-st_ino);
if (f_size)
chcnt += printf(%*jd ,
(int)sizefield, howmany(sp-st_blocks, blocksize));

Modified: head/bin/rm/rm.c
==
--- head/bin/rm/rm.cThu Sep 27 23:31:06 2012(r241013)
+++ head/bin/rm/rm.cThu Sep 27 23:31:12 2012(r241014)
@@ -51,6 +51,7 @@ __FBSDID($FreeBSD$);
 #include fts.h
 #include grp.h
 #include pwd.h
+#include stdint.h
 #include stdio.h
 #include stdlib.h
 #include string.h
@@ -429,8 +430,8 @@ rm_overwrite(char *file, struct stat *sb
if (!S_ISREG(sbp-st_mode))
return (1);
if (sbp-st_nlink  1  !fflag) {
-   warnx(%s (inode %u): not overwritten due to multiple links,
-   file, sbp-st_ino);
+   warnx(%s (inode %ju): not overwritten due to multiple links,
+   file, (uintmax_t)sbp-st_ino);
return (0);
}
if ((fd = open(file, O_WRONLY|O_NONBLOCK|O_NOFOLLOW, 0)) == -1)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r241015 - in head: usr.bin/find usr.sbin/lpr/lpr usr.sbin/makefs/ffs usr.sbin/quot usr.sbin/snapinfo

2012-09-27 Thread Matthew D Fleming
Author: mdf
Date: Thu Sep 27 23:31:19 2012
New Revision: 241015
URL: http://svn.freebsd.org/changeset/base/241015

Log:
  Fix usr.bin/ and usr.sbin/ build with a 64-bit ino_t.
  
  Original code by: Gleb Kurtsou

Modified:
  head/usr.bin/find/ls.c
  head/usr.sbin/lpr/lpr/lpr.c
  head/usr.sbin/makefs/ffs/ffs_alloc.c
  head/usr.sbin/quot/quot.c
  head/usr.sbin/snapinfo/snapinfo.c

Modified: head/usr.bin/find/ls.c
==
--- head/usr.bin/find/ls.c  Thu Sep 27 23:31:12 2012(r241014)
+++ head/usr.bin/find/ls.c  Thu Sep 27 23:31:19 2012(r241015)
@@ -63,7 +63,7 @@ printlong(char *name, char *accpath, str
 {
char modep[15];
 
-   (void)printf(%6lu %8PRId64 , (u_long) sb-st_ino, sb-st_blocks);
+   (void)printf(%6ju %8PRId64 , (uintmax_t)sb-st_ino, sb-st_blocks);
(void)strmode(sb-st_mode, modep);
(void)printf(%s %3u %-*s %-*s , modep, sb-st_nlink, MAXLOGNAME - 1,
user_from_uid(sb-st_uid, 0), MAXLOGNAME - 1,

Modified: head/usr.sbin/lpr/lpr/lpr.c
==
--- head/usr.sbin/lpr/lpr/lpr.c Thu Sep 27 23:31:12 2012(r241014)
+++ head/usr.sbin/lpr/lpr/lpr.c Thu Sep 27 23:31:19 2012(r241015)
@@ -75,6 +75,7 @@ __FBSDID($FreeBSD$);
 #include grp.h
 #include unistd.h
 #include stdlib.h
+#include stdint.h
 #include stdio.h
 #include ctype.h
 #include string.h
@@ -386,8 +387,8 @@ main(int argc, char *argv[])
continue;   /* file unreasonable */
 
if (sflag  (cp = linked(arg)) != NULL) {
-   (void) snprintf(buf, sizeof(buf), %u %u, statb.st_dev,
-   statb.st_ino);
+   (void)snprintf(buf, sizeof(buf), %u %ju,
+   statb.st_dev, (uintmax_t)statb.st_ino);
card('S', buf);
if (format == 'p')
card('T', title ? title : arg);

Modified: head/usr.sbin/makefs/ffs/ffs_alloc.c
==
--- head/usr.sbin/makefs/ffs/ffs_alloc.cThu Sep 27 23:31:12 2012
(r241014)
+++ head/usr.sbin/makefs/ffs/ffs_alloc.cThu Sep 27 23:31:19 2012
(r241015)
@@ -48,6 +48,7 @@ __FBSDID($FreeBSD$);
 #include sys/time.h
 
 #include errno.h
+#include stdint.h
 
 #include makefs.h
 
@@ -439,8 +440,8 @@ ffs_blkfree(struct inode *ip, daddr_t bn
}
cg = dtog(fs, bno);
if (bno = fs-fs_size) {
-   warnx(bad block %lld, ino %llu, (long long)bno,
-   (unsigned long long)ip-i_number);
+   warnx(bad block %lld, ino %ju, (long long)bno,
+   (uintmax_t)ip-i_number);
return;
}
error = bread(ip-i_fd, ip-i_fs, fsbtodb(fs, cgtod(fs, cg)),

Modified: head/usr.sbin/quot/quot.c
==
--- head/usr.sbin/quot/quot.c   Thu Sep 27 23:31:12 2012(r241014)
+++ head/usr.sbin/quot/quot.c   Thu Sep 27 23:31:19 2012(r241015)
@@ -484,8 +484,8 @@ static void
 donames(int fd, struct fs *super, char *name)
 {
int c;
-   ino_t inode;
ino_t maxino;
+   uintmax_t inode;
union dinode *dp;
 
maxino = super-fs_ncg * super-fs_ipg - 1;
@@ -493,9 +493,9 @@ donames(int fd, struct fs *super, char *
while ((c = getchar()) != EOF  (c  '0' || c  '9'))
while ((c = getchar()) != EOF  c != '\n');
ungetc(c,stdin);
-   while (scanf(%u,inode) == 1) {
+   while (scanf(%ju, inode) == 1) {
if (inode  maxino) {
-   warnx(illegal inode %d,inode);
+   warnx(illegal inode %ju, inode);
return;
}
errno = 0;

Modified: head/usr.sbin/snapinfo/snapinfo.c
==
--- head/usr.sbin/snapinfo/snapinfo.c   Thu Sep 27 23:31:12 2012
(r241014)
+++ head/usr.sbin/snapinfo/snapinfo.c   Thu Sep 27 23:31:19 2012
(r241015)
@@ -34,6 +34,7 @@
 #include errno.h
 #include ftw.h
 #include libufs.h
+#include stdint.h
 #include stdio.h
 #include stdlib.h
 #include string.h
@@ -149,7 +150,7 @@ compare_function(const char *path, const
printf(\tsnapshot );
printf(%s, path);
if (verbose)
-   printf( (inode %d), st-st_ino);
+   printf( (inode %ju), (uintmax_t)st-st_ino);
printf(\n);
if (!cont_search)
return (EEXIST);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to 

svn commit: r241012 - head/sbin/fsck_ffs

2012-09-27 Thread Matthew D Fleming
Author: mdf
Date: Thu Sep 27 23:30:58 2012
New Revision: 241012
URL: http://svn.freebsd.org/changeset/base/241012

Log:
  Fix fsck_ffs build with a 64-bit ino_t.
  
  Original code by: Gleb Kurtsou

Modified:
  head/sbin/fsck_ffs/fsutil.c
  head/sbin/fsck_ffs/gjournal.c
  head/sbin/fsck_ffs/inode.c
  head/sbin/fsck_ffs/main.c
  head/sbin/fsck_ffs/pass1.c
  head/sbin/fsck_ffs/pass2.c
  head/sbin/fsck_ffs/pass4.c
  head/sbin/fsck_ffs/suj.c

Modified: head/sbin/fsck_ffs/fsutil.c
==
--- head/sbin/fsck_ffs/fsutil.c Thu Sep 27 23:30:49 2012(r241011)
+++ head/sbin/fsck_ffs/fsutil.c Thu Sep 27 23:30:58 2012(r241012)
@@ -137,7 +137,8 @@ inoinfo(ino_t inum)
int iloff;
 
if (inum  maxino)
-   errx(EEXIT, inoinfo: inumber %d out of range, inum);
+   errx(EEXIT, inoinfo: inumber %ju out of range,
+   (uintmax_t)inum);
ilp = inostathead[inum / sblock.fs_ipg];
iloff = inum % sblock.fs_ipg;
if (iloff = ilp-il_numalloced)

Modified: head/sbin/fsck_ffs/gjournal.c
==
--- head/sbin/fsck_ffs/gjournal.c   Thu Sep 27 23:30:49 2012
(r241011)
+++ head/sbin/fsck_ffs/gjournal.c   Thu Sep 27 23:30:58 2012
(r241012)
@@ -448,7 +448,8 @@ gjournal_check(const char *filesys)
if (isclr(inosused, cino))
continue;
if (getino(disk, p, ino, mode) == -1)
-   err(1, getino(cg=%d ino=%d), cg, ino);
+   err(1, getino(cg=%d ino=%ju),
+   cg, (uintmax_t)ino);
dino = p;
/* Not a regular file nor directory? Skip it. */
if (!S_ISREG(dino-di_mode)  !S_ISDIR(dino-di_mode))
@@ -480,7 +481,8 @@ gjournal_check(const char *filesys)
*dino = ufs2_zino;
/* Write the inode back. */
if (putino(disk) == -1)
-   err(1, putino(cg=%d ino=%d), cg, ino);
+   err(1, putino(cg=%d ino=%ju),
+   cg, (uintmax_t)ino);
if (cgp-cg_unrefs == 0) {
//printf(No more unreferenced inodes in 
cg=%d.\n, cg);
break;

Modified: head/sbin/fsck_ffs/inode.c
==
--- head/sbin/fsck_ffs/inode.c  Thu Sep 27 23:30:49 2012(r241011)
+++ head/sbin/fsck_ffs/inode.c  Thu Sep 27 23:30:58 2012(r241012)
@@ -285,7 +285,8 @@ ginode(ino_t inumber)
ufs2_daddr_t iblk;
 
if (inumber  ROOTINO || inumber  maxino)
-   errx(EEXIT, bad inode number %d to ginode, inumber);
+   errx(EEXIT, bad inode number %ju to ginode,
+   (uintmax_t)inumber);
if (startinum == 0 ||
inumber  startinum || inumber = startinum + INOPB(sblock)) {
iblk = ino_to_fsba(sblock, inumber);
@@ -319,7 +320,8 @@ getnextinode(ino_t inumber, int rebuildc
static caddr_t nextinop;
 
if (inumber != nextino++ || inumber  lastvalidinum)
-   errx(EEXIT, bad inode number %d to nextinode, inumber);
+   errx(EEXIT, bad inode number %ju to nextinode,
+   (uintmax_t)inumber);
if (inumber = lastinum) {
readcnt++;
dblk = fsbtodb(sblock, ino_to_fsba(sblock, lastinum));
@@ -398,7 +400,8 @@ setinodebuf(ino_t inum)
 {
 
if (inum % sblock.fs_ipg != 0)
-   errx(EEXIT, bad inode number %d to setinodebuf, inum);
+   errx(EEXIT, bad inode number %ju to setinodebuf,
+   (uintmax_t)inum);
lastvalidinum = inum + sblock.fs_ipg - 1;
startinum = 0;
nextino = inum;
@@ -489,7 +492,7 @@ getinoinfo(ino_t inumber)
continue;
return (inp);
}
-   errx(EEXIT, cannot find inode %d, inumber);
+   errx(EEXIT, cannot find inode %ju, (uintmax_t)inumber);
return ((struct inoinfo *)0);
 }
 

Modified: head/sbin/fsck_ffs/main.c
==
--- head/sbin/fsck_ffs/main.c   Thu Sep 27 23:30:49 2012(r241011)
+++ head/sbin/fsck_ffs/main.c   Thu Sep 27 23:30:58 2012(r241012)
@@ -492,7 +492,7 @@ checkfilesys(char *filesys)
n_ffree * 100.0 / sblock.fs_dsize);
if (debug) {
if (files  0)
-   printf(%d inodes missing\n, -files);
+   printf(%jd inodes missing\n, (intmax_t)-files);
if (blks  0)
printf(%lld blocks missing\n, -(long long)blks);
 

svn commit: r238502 - in head/sys: kern vm

2012-07-15 Thread Matthew D Fleming
Author: mdf
Date: Sun Jul 15 20:29:48 2012
New Revision: 238502
URL: http://svn.freebsd.org/changeset/base/238502

Log:
  Fix a bug with memguard(9) on 32-bit architectures without a
  VM_KMEM_MAX_SIZE.
  
  The code was not taking into account the size of the kernel_map, which
  the kmem_map is allocated from, so it could produce a sub-map size too
  large to fit.  The simplest solution is to ignore VM_KMEM_MAX entirely
  and base the memguard map's size off the kernel_map's size, since this
  is always relevant and always smaller.
  
  Found by: Justin Hibbits

Modified:
  head/sys/kern/kern_malloc.c
  head/sys/vm/memguard.c
  head/sys/vm/memguard.h
  head/sys/vm/vm_map.h

Modified: head/sys/kern/kern_malloc.c
==
--- head/sys/kern/kern_malloc.c Sun Jul 15 20:16:17 2012(r238501)
+++ head/sys/kern/kern_malloc.c Sun Jul 15 20:29:48 2012(r238502)
@@ -744,7 +744,7 @@ kmeminit(void *dummy)
vm_kmem_size = 2 * mem_size * PAGE_SIZE;
 
 #ifdef DEBUG_MEMGUARD
-   tmp = memguard_fudge(vm_kmem_size, vm_kmem_size_max);
+   tmp = memguard_fudge(vm_kmem_size, kernel_map);
 #else
tmp = vm_kmem_size;
 #endif

Modified: head/sys/vm/memguard.c
==
--- head/sys/vm/memguard.c  Sun Jul 15 20:16:17 2012(r238501)
+++ head/sys/vm/memguard.c  Sun Jul 15 20:29:48 2012(r238502)
@@ -159,16 +159,18 @@ SYSCTL_ULONG(_vm_memguard, OID_AUTO, fre
  * the kmem_map.  The memguard memory will be a submap.
  */
 unsigned long
-memguard_fudge(unsigned long km_size, unsigned long km_max)
+memguard_fudge(unsigned long km_size, const struct vm_map *parent_map)
 {
-   u_long mem_pgs = cnt.v_page_count;
+   u_long mem_pgs, parent_size;
 
vm_memguard_divisor = 10;
TUNABLE_INT_FETCH(vm.memguard.divisor, vm_memguard_divisor);
 
+   parent_size = vm_map_max(parent_map) - vm_map_min(parent_map) +
+   PAGE_SIZE;
/* Pick a conservative value if provided value sucks. */
if ((vm_memguard_divisor = 0) ||
-   ((km_size / vm_memguard_divisor) == 0))
+   ((parent_size / vm_memguard_divisor) == 0))
vm_memguard_divisor = 10;
/*
 * Limit consumption of physical pages to
@@ -177,21 +179,19 @@ memguard_fudge(unsigned long km_size, un
 * This prevents memguard's page promotions from completely
 * using up memory, since most malloc(9) calls are sub-page.
 */
+   mem_pgs = cnt.v_page_count;
memguard_physlimit = (mem_pgs / vm_memguard_divisor) * PAGE_SIZE;
/*
 * We want as much KVA as we can take safely.  Use at most our
-* allotted fraction of kmem_max.  Limit this to twice the
-* physical memory to avoid using too much memory as pagetable
-* pages.
-*/
-   memguard_mapsize = km_max / vm_memguard_divisor;
-   /* size must be multiple of PAGE_SIZE */
-   memguard_mapsize = round_page(memguard_mapsize);
-   if (memguard_mapsize == 0 ||
-   memguard_mapsize / (2 * PAGE_SIZE)  mem_pgs)
+* allotted fraction of the parent map's size.  Limit this to
+* twice the physical memory to avoid using too much memory as
+* pagetable pages (size must be multiple of PAGE_SIZE).
+*/
+   memguard_mapsize = round_page(parent_size / vm_memguard_divisor);
+   if (memguard_mapsize / (2 * PAGE_SIZE)  mem_pgs)
memguard_mapsize = mem_pgs * 2 * PAGE_SIZE;
-   if (km_max  0  km_size + memguard_mapsize  km_max)
-   return (km_max);
+   if (km_size + memguard_mapsize  parent_size)
+   memguard_mapsize = 0;
return (km_size + memguard_mapsize);
 }
 

Modified: head/sys/vm/memguard.h
==
--- head/sys/vm/memguard.h  Sun Jul 15 20:16:17 2012(r238501)
+++ head/sys/vm/memguard.h  Sun Jul 15 20:29:48 2012(r238502)
@@ -35,7 +35,7 @@ struct malloc_type;
 struct vm_map;
 
 #ifdef DEBUG_MEMGUARD
-unsigned long  memguard_fudge(unsigned long, unsigned long);
+unsigned long  memguard_fudge(unsigned long, const struct vm_map *);
 void   memguard_init(struct vm_map *);
 void   *memguard_alloc(unsigned long, int);
 void   *memguard_realloc(void *, unsigned long, struct malloc_type *, int);

Modified: head/sys/vm/vm_map.h
==
--- head/sys/vm/vm_map.hSun Jul 15 20:16:17 2012(r238501)
+++ head/sys/vm/vm_map.hSun Jul 15 20:29:48 2012(r238502)
@@ -200,13 +200,13 @@ struct vm_map {
 
 #ifdef _KERNEL
 static __inline vm_offset_t
-vm_map_max(vm_map_t map)
+vm_map_max(const struct vm_map *map)
 {
return (map-max_offset);
 }
 
 static __inline vm_offset_t
-vm_map_min(vm_map_t map)

svn commit: r235297 - head/bin/kenv

2012-05-11 Thread Matthew D Fleming
Author: mdf
Date: Fri May 11 23:05:14 2012
New Revision: 235297
URL: http://svn.freebsd.org/changeset/base/235297

Log:
  Add a -v and -N option to kenv(1), so it can be more easily used in
  scripts the way sysctl(8) is.  The -N option, like in sysctl(8),
  displays only the kenv names, not their values.  The -v option prints an
  individual kenv variable name with its value as name=value.  This is
  the inverse of sysctl(8)'s -n flag, since the default behaviour of
  kenv(1) is already like sysctl(8) -n.
  
  Submitted by: Garrett Cooper  yanegomi AT gmail DOT com 
  MFC after:1 week

Modified:
  head/bin/kenv/kenv.1
  head/bin/kenv/kenv.c

Modified: head/bin/kenv/kenv.1
==
--- head/bin/kenv/kenv.1Fri May 11 22:41:58 2012(r235296)
+++ head/bin/kenv/kenv.1Fri May 11 23:05:14 2012(r235297)
@@ -32,9 +32,9 @@
 .Nd dump or modify the kernel environment
 .Sh SYNOPSIS
 .Nm
-.Op Fl hq
+.Op Fl hNq
 .Nm
-.Op Fl q
+.Op Fl qv
 .Ar variable Ns Op = Ns Ar value
 .Nm
 .Op Fl q
@@ -54,6 +54,11 @@ name is specified,
 .Nm
 will only report that value.
 If the
+.Fl N
+option is specified,
+.Nm
+will only display variable names and not their values.
+If the
 .Fl u
 option is specified,
 .Nm
@@ -68,6 +73,13 @@ If the
 option is set, warnings normally printed as a result of being unable to
 perform the requested operation will be suppressed.
 .Pp
+If the
+.Fl v
+option is set, the variable name will be printed out for the
+environment variable in addition to the value when
+.Nm
+is executed with a variable name.
+.Pp
 Variables can be added to the kernel environment using the
 .Pa /boot/loader.conf
 file, or also statically compiled into the kernel using the statement

Modified: head/bin/kenv/kenv.c
==
--- head/bin/kenv/kenv.cFri May 11 22:41:58 2012(r235296)
+++ head/bin/kenv/kenv.cFri May 11 23:05:14 2012(r235297)
@@ -42,15 +42,17 @@ static int  ksetenv(char *, char *);
 static int kunsetenv(char *);
 
 static int hflag = 0;
+static int Nflag = 0;
 static int qflag = 0;
 static int uflag = 0;
+static int vflag = 0;
 
 static void
 usage(void)
 {
(void)fprintf(stderr, %s\n%s\n%s\n,
-   usage: kenv [-hq],
-  kenv [-q] variable[=value],
+   usage: kenv [-hNq],
+  kenv [-qv] variable[=value],
   kenv [-q] -u variable);
exit(1);
 }
@@ -64,17 +66,23 @@ main(int argc, char **argv)
error = 0;
val = NULL;
env = NULL;
-   while ((ch = getopt(argc, argv, hqu)) != -1) {
+   while ((ch = getopt(argc, argv, hNquv)) != -1) {
switch (ch) {
case 'h':
hflag++;
break;
+   case 'N':
+   Nflag++;
+   break;
case 'q':
qflag++;
break;
case 'u':
uflag++;
break;
+   case 'v':
+   vflag++;
+   break;
default:
usage();
}
@@ -91,9 +99,9 @@ main(int argc, char **argv)
argv++;
argc--;
}
-   if (hflag  (env != NULL))
+   if ((hflag || Nflag)  env != NULL)
usage();
-   if ((argc  0) || (uflag  (env == NULL)))
+   if (argc  0 || ((uflag || vflag)  env == NULL))
usage();
if (env == NULL) {
error = kdumpenv();
@@ -152,7 +160,10 @@ kdumpenv(void)
if (cp == NULL)
continue;
*cp++ = '\0';
-   printf(%s=\%s\\n, buf, cp);
+   if (Nflag)
+   printf(%s\n, buf);
+   else
+   printf(%s=\%s\\n, buf, cp);
buf = cp;
}
return (0);
@@ -167,7 +178,10 @@ kgetenv(char *env)
ret = kenv(KENV_GET, env, buf, sizeof(buf));
if (ret == -1)
return (ret);
-   printf(%s\n, buf);
+   if (vflag)
+   printf(%s=\%s\\n, env, buf);
+   else
+   printf(%s\n, buf);
return (0);
 }
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r235316 - head/bin/kenv

2012-05-11 Thread Matthew D Fleming
Author: mdf
Date: Sat May 12 02:49:40 2012
New Revision: 235316
URL: http://svn.freebsd.org/changeset/base/235316

Log:
  I forgot to bump the manpage date.
  
  Reminded by:  Garrett Cooper
  MFC after:3 days
  X-MFC-with:   r235297

Modified:
  head/bin/kenv/kenv.1

Modified: head/bin/kenv/kenv.1
==
--- head/bin/kenv/kenv.1Sat May 12 00:55:49 2012(r235315)
+++ head/bin/kenv/kenv.1Sat May 12 02:49:40 2012(r235316)
@@ -24,7 +24,7 @@
 .\
 .\ $FreeBSD$
 .\
-.Dd January 13, 2009
+.Dd May 11, 2012
 .Dt KENV 1
 .Os
 .Sh NAME
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r228441 - head/sys/dev/e1000

2011-12-12 Thread Matthew D Fleming
Author: mdf
Date: Mon Dec 12 18:27:34 2011
New Revision: 228441
URL: http://svn.freebsd.org/changeset/base/228441

Log:
  Consistently use types in e1000 driver code:
  
   - Two struct members eee_disable are used in a function that expects
 an int *, so declare them int, not bool.
   - igb_tx_ctx_setup() returns a boolean value, so declare it bool, not int.
   - igb_header_split is passed to TUNABLE_INT, so delcare it int, not bool.
   - igb_tso_setup() returns a bool, so declare it bool, not boolean_t.
   - Do not re-define bool/true/false if the symbols already exist.
  
  MFC after:2 weeks
  Sponsored by: Isilon Systems, LLC

Modified:
  head/sys/dev/e1000/e1000_hw.h
  head/sys/dev/e1000/e1000_osdep.h
  head/sys/dev/e1000/if_igb.c

Modified: head/sys/dev/e1000/e1000_hw.h
==
--- head/sys/dev/e1000/e1000_hw.h   Mon Dec 12 18:27:28 2011
(r228440)
+++ head/sys/dev/e1000/e1000_hw.h   Mon Dec 12 18:27:34 2011
(r228441)
@@ -911,13 +911,13 @@ struct e1000_dev_spec_ich8lan {
E1000_MUTEX nvm_mutex;
E1000_MUTEX swflag_mutex;
bool nvm_k1_enabled;
-   bool eee_disable;
+   int eee_disable;
 };
 
 struct e1000_dev_spec_82575 {
bool sgmii_active;
bool global_device_reset;
-   bool eee_disable;
+   int eee_disable;
bool module_plugged;
u32 mtu;
 };

Modified: head/sys/dev/e1000/e1000_osdep.h
==
--- head/sys/dev/e1000/e1000_osdep.hMon Dec 12 18:27:28 2011
(r228440)
+++ head/sys/dev/e1000/e1000_osdep.hMon Dec 12 18:27:34 2011
(r228441)
@@ -73,9 +73,11 @@
 
 #define STATIC static
 #define FALSE  0
-#define false  FALSE 
 #define TRUE   1
+#ifndef __bool_true_false_are_defined
+#define false  FALSE
 #define true   TRUE
+#endif
 #define CMD_MEM_WRT_INVALIDATE 0x0010  /* BIT_4 */
 #define PCI_COMMAND_REGISTER   PCIR_COMMAND
 
@@ -96,7 +98,9 @@ typedef int64_t   s64;
 typedef int32_ts32;
 typedef int16_ts16;
 typedef int8_t s8;
+#ifndef __bool_true_false_are_defined
 typedef boolean_t  bool;
+#endif
 
 #define __le16 u16
 #define __le32 u32

Modified: head/sys/dev/e1000/if_igb.c
==
--- head/sys/dev/e1000/if_igb.c Mon Dec 12 18:27:28 2011(r228440)
+++ head/sys/dev/e1000/if_igb.c Mon Dec 12 18:27:34 2011(r228441)
@@ -223,7 +223,7 @@ static __inline void igb_rx_input(struct
 
 static booligb_rxeof(struct igb_queue *, int, int *);
 static voidigb_rx_checksum(u32, struct mbuf *, u32);
-static int igb_tx_ctx_setup(struct tx_ring *, struct mbuf *);
+static booligb_tx_ctx_setup(struct tx_ring *, struct mbuf *);
 static booligb_tso_setup(struct tx_ring *, struct mbuf *, int,
struct ip *, struct tcphdr *);
 static voidigb_set_promisc(struct adapter *);
@@ -335,7 +335,7 @@ TUNABLE_INT(hw.igb.max_interrupt_rate,
 ** into the header and thus use no cluster. Its
 ** a very workload dependent type feature.
 */
-static bool igb_header_split = FALSE;
+static int igb_header_split = FALSE;
 TUNABLE_INT(hw.igb.hdr_split, igb_header_split);
 
 /*
@@ -3441,7 +3441,7 @@ igb_free_transmit_buffers(struct tx_ring
  *  Setup work for hardware segmentation offload (TSO)
  *
  **/
-static boolean_t
+static bool
 igb_tso_setup(struct tx_ring *txr, struct mbuf *mp, int ehdrlen,
struct ip *ip, struct tcphdr *th)
 {
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r228442 - head/sys/cam/scsi

2011-12-12 Thread Matthew D Fleming
Author: mdf
Date: Mon Dec 12 18:43:18 2011
New Revision: 228442
URL: http://svn.freebsd.org/changeset/base/228442

Log:
  Do not use the sometimes-reserved work 'bool' for a variable name.
  
  MFC after:2 weeks
  Sponsored by: Isilon Systems, LLC

Modified:
  head/sys/cam/scsi/scsi_xpt.c

Modified: head/sys/cam/scsi/scsi_xpt.c
==
--- head/sys/cam/scsi/scsi_xpt.cMon Dec 12 18:27:34 2011
(r228441)
+++ head/sys/cam/scsi/scsi_xpt.cMon Dec 12 18:43:18 2011
(r228442)
@@ -1811,14 +1811,14 @@ scsi_find_quirk(struct cam_ed *device)
 static int
 sysctl_cam_search_luns(SYSCTL_HANDLER_ARGS)
 {
-   int error, bool;
+   int error, val;
 
-   bool = cam_srch_hi;
-   error = sysctl_handle_int(oidp, bool, 0, req);
+   val = cam_srch_hi;
+   error = sysctl_handle_int(oidp, val, 0, req);
if (error != 0 || req-newptr == NULL)
return (error);
-   if (bool == 0 || bool == 1) {
-   cam_srch_hi = bool;
+   if (val == 0 || val == 1) {
+   cam_srch_hi = val;
return (0);
} else {
return (EINVAL);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r223875 - head/sys/kern

2011-07-08 Thread Matthew D Fleming
Author: mdf
Date: Fri Jul  8 20:41:07 2011
New Revision: 223875
URL: http://svn.freebsd.org/changeset/base/223875

Log:
  style(9) and cleanup fixes.
  
  MFC after: 1 week

Modified:
  head/sys/kern/kern_fail.c

Modified: head/sys/kern/kern_fail.c
==
--- head/sys/kern/kern_fail.c   Fri Jul  8 17:45:38 2011(r223874)
+++ head/sys/kern/kern_fail.c   Fri Jul  8 20:41:07 2011(r223875)
@@ -52,6 +52,7 @@
 #include sys/cdefs.h
 __FBSDID($FreeBSD$);
 
+#include sys/ctype.h
 #include sys/errno.h
 #include sys/fail.h
 #include sys/kernel.h
@@ -88,16 +89,20 @@ enum fail_point_t {
FAIL_POINT_BREAK,   /** break into the debugger */
FAIL_POINT_PRINT,   /** print a message */
FAIL_POINT_SLEEP,   /** sleep for some msecs */
-   FAIL_POINT_INVALID, /** placeholder */
+   FAIL_POINT_NUMTYPES
 };
 
-static const char *fail_type_strings[] = {
-   off,
-   panic,
-   return,
-   break,
-   print,
-   sleep,
+static struct {
+   const char *name;
+   int nmlen;
+} fail_type_strings[] = {
+#defineFP_TYPE_NM_LEN(s)   { s, sizeof(s) - 1 }
+   [FAIL_POINT_OFF] =  FP_TYPE_NM_LEN(off),
+   [FAIL_POINT_PANIC] =FP_TYPE_NM_LEN(panic),
+   [FAIL_POINT_RETURN] =   FP_TYPE_NM_LEN(return),
+   [FAIL_POINT_BREAK] =FP_TYPE_NM_LEN(break),
+   [FAIL_POINT_PRINT] =FP_TYPE_NM_LEN(print),
+   [FAIL_POINT_SLEEP] =FP_TYPE_NM_LEN(sleep),
 };
 
 /**
@@ -120,7 +125,7 @@ fail_point_sleep(struct fail_point *fp, 
/* convert from millisecs to ticks, rounding up */
int timo = ((msecs * hz) + 999) / 1000;
 
-   if (timo) {
+   if (timo  0) {
if (fp-fp_sleep_fn == NULL) {
msleep(fp, g_fp_mtx, PWAIT, failpt, timo);
} else {
@@ -191,19 +196,13 @@ fail_point_init(struct fail_point *fp, c
 void
 fail_point_destroy(struct fail_point *fp)
 {
-   struct fail_point_entry *ent;
 
-   if (fp-fp_flags  FAIL_POINT_DYNAMIC_NAME  fp-fp_name != NULL) {
-   fp_free((void *)(intptr_t)fp-fp_name);
+   if ((fp-fp_flags  FAIL_POINT_DYNAMIC_NAME) != 0) {
+   fp_free(__DECONST(void *, fp-fp_name));
fp-fp_name = NULL;
}
fp-fp_flags = 0;
-
-   while (!TAILQ_EMPTY(fp-fp_entries)) {
-   ent = TAILQ_FIRST(fp-fp_entries);
-   TAILQ_REMOVE(fp-fp_entries, ent, fe_entries);
-   fp_free(ent);
-   }
+   clear_entries(fp-fp_entries);
 }
 
 /**
@@ -222,16 +221,12 @@ fail_point_eval_nontrivial(struct fail_p
 
FP_LOCK();
 
-   ent = TAILQ_FIRST(fp-fp_entries);
-   while (ent) {
+   TAILQ_FOREACH_SAFE(ent, fp-fp_entries, fe_entries, next) {
int cont = 0; /* don't continue by default */
-   next = TAILQ_NEXT(ent, fe_entries);
 
if (ent-fe_prob  PROB_MAX 
-   ent-fe_prob  random() % PROB_MAX) {
-   cont = 1;
-   goto loop_end;
-   }
+   ent-fe_prob  random() % PROB_MAX)
+   continue;
 
switch (ent-fe_type) {
case FAIL_POINT_PANIC:
@@ -239,13 +234,14 @@ fail_point_eval_nontrivial(struct fail_p
/* NOTREACHED */
 
case FAIL_POINT_RETURN:
-   if (return_value)
+   if (return_value != NULL)
*return_value = ent-fe_arg;
ret = FAIL_POINT_RC_RETURN;
break;
 
case FAIL_POINT_BREAK:
-   printf(fail point %s breaking to debugger\n, 
fp-fp_name);
+   printf(fail point %s breaking to debugger\n,
+   fp-fp_name);
breakpoint();
break;
 
@@ -273,13 +269,9 @@ fail_point_eval_nontrivial(struct fail_p
break;
}
 
-   if (ent  ent-fe_count  0  --ent-fe_count == 0)
+   if (ent != NULL  ent-fe_count  0  --ent-fe_count == 0)
free_entry(fp-fp_entries, ent);
-
-loop_end:
-   if (cont)
-   ent = next;
-   else
+   if (cont == 0)
break;
}
 
@@ -290,7 +282,7 @@ loop_end:
 
FP_UNLOCK();
 
-   return ret;
+   return (ret);
 }
 
 /**
@@ -320,7 +312,7 @@ fail_point_get(struct fail_point *fp, st
}
if (ent-fe_count  0)
sbuf_printf(sb, %d*, ent-fe_count);
-   sbuf_printf(sb, %s, fail_type_strings[ent-fe_type]);
+   sbuf_printf(sb, %s, fail_type_strings[ent-fe_type].name);
if (ent-fe_arg)
sbuf_printf(sb, (%d), ent-fe_arg);

svn commit: r223876 - in head: share/man/man9 sys/kern

2011-07-08 Thread Matthew D Fleming
Author: mdf
Date: Fri Jul  8 20:41:12 2011
New Revision: 223876
URL: http://svn.freebsd.org/changeset/base/223876

Log:
  Add an option to have a fail point term only execute when run by a
  specified pid.  This is helpful for automated testing involving a global
  knob that would otherwise be executed by many other threads.
  
  MFC after: 1 week

Modified:
  head/share/man/man9/fail.9
  head/sys/kern/kern_fail.c

Modified: head/share/man/man9/fail.9
==
--- head/share/man/man9/fail.9  Fri Jul  8 20:41:07 2011(r223875)
+++ head/share/man/man9/fail.9  Fri Jul  8 20:41:12 2011(r223876)
@@ -116,6 +116,7 @@ The sysctl variable may be set using the
   ( (float %) | (integer * ) )*
   type
   [ ( integer ) ]
+  [ [pid  integer ] ]
 
   float ::
   integer [ . integer ] |
@@ -161,6 +162,10 @@ For the purpose of this operator, the re
 are the only types that cascade.
 A return() term only cascades if the code executes, and a print()
 term only cascades when passed a non-zero argument.
+A pid can optionally be specified.
+The fail point term is only executed when invoked by a process with a
+matching p_pid.
+.Pp
 .Sh EXAMPLES
 .Bl -tag
 .It Sy sysctl debug.fail_point.foobar=2.1%return(5)
@@ -181,6 +186,8 @@ After that, 1/1000th of the time, return
 Return 5 for 1 in 1000 executions, but only 5 times total.
 .It Sy sysctl debug.fail_point.foobar=1%*sleep(50)
 1/100th of the time, sleep 50ms.
+.It Sy sysctl debug.fail_point.foobar=1*return(5)[pid 1234]
+Return 5 once, when pid 1234 executes the fail point.
 .El
 .Sh AUTHORS
 .An -nosplit

Modified: head/sys/kern/kern_fail.c
==
--- head/sys/kern/kern_fail.c   Fri Jul  8 20:41:07 2011(r223875)
+++ head/sys/kern/kern_fail.c   Fri Jul  8 20:41:12 2011(r223876)
@@ -60,6 +60,7 @@ __FBSDID($FreeBSD$);
 #include sys/lock.h
 #include sys/malloc.h
 #include sys/mutex.h
+#include sys/proc.h
 #include sys/sbuf.h
 
 #include machine/stdarg.h
@@ -114,7 +115,7 @@ struct fail_point_entry {
int fe_arg; /** argument to type (e.g. return 
value) */
int fe_prob;/** likelihood of firing in millionths 
*/
int fe_count;   /** number of times to fire, 0 means 
always */
-
+   pid_t   fe_pid; /** only fail for this process */
TAILQ_ENTRY(fail_point_entry) fe_entries; /** next entry in fail point 
*/
 };
 
@@ -227,6 +228,8 @@ fail_point_eval_nontrivial(struct fail_p
if (ent-fe_prob  PROB_MAX 
ent-fe_prob  random() % PROB_MAX)
continue;
+   if (ent-fe_pid != NO_PID  ent-fe_pid != curproc-p_pid)
+   continue;
 
switch (ent-fe_type) {
case FAIL_POINT_PANIC:
@@ -315,6 +318,8 @@ fail_point_get(struct fail_point *fp, st
sbuf_printf(sb, %s, fail_type_strings[ent-fe_type].name);
if (ent-fe_arg)
sbuf_printf(sb, (%d), ent-fe_arg);
+   if (ent-fe_pid != NO_PID)
+   sbuf_printf(sb, [pid %d], ent-fe_pid);
if (TAILQ_NEXT(ent, fe_entries))
sbuf_printf(sb, -);
}
@@ -451,6 +456,7 @@ parse_term(struct fail_point_entries *en
 
ent = fp_malloc(sizeof *ent, M_WAITOK | M_ZERO);
ent-fe_prob = PROB_MAX;
+   ent-fe_pid = NO_PID;
TAILQ_INSERT_TAIL(ents, ent, fe_entries);
 
/*
@@ -458,6 +464,7 @@ parse_term(struct fail_point_entries *en
 * ( (float %) | (integer * ) )*
 * type
 * [ ( integer ) ]
+* [ [pid  integer ] ]
 */
 
/* ( (float %) | (integer * ) )* */
@@ -500,6 +507,17 @@ parse_term(struct fail_point_entries *en
if (*p++ != ')')
return (NULL);
 
+   /* [ [pid  integer ] ] */
+#definePID_STRING  [pid 
+   if (strncmp(p, PID_STRING, sizeof(PID_STRING) - 1) != 0)
+   return (p);
+   p += sizeof(PID_STRING) - 1;
+   if (!isdigit(*p))
+   return (NULL);
+   ent-fe_pid = strtol(p, p, 0);
+   if (*p++ != ']')
+   return (NULL);
+
return (p);
 }
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r221836 - head/sys/kern

2011-05-13 Thread Matthew D Fleming
Author: mdf
Date: Fri May 13 14:29:28 2011
New Revision: 221836
URL: http://svn.freebsd.org/changeset/base/221836

Log:
  Correctly use INOUT for the offset/len parameters to vop_allocate.  As
  far as I can tell this is for documentation only at the moment.

Modified:
  head/sys/kern/vnode_if.src

Modified: head/sys/kern/vnode_if.src
==
--- head/sys/kern/vnode_if.src  Fri May 13 12:39:37 2011(r221835)
+++ head/sys/kern/vnode_if.src  Fri May 13 14:29:28 2011(r221836)
@@ -625,6 +625,6 @@ vop_vptocnp {
 
 vop_allocate {
IN struct vnode *vp;
-   IN off_t *offset;
-   IN off_t *len;
+   INOUT off_t *offset;
+   INOUT off_t *len;
 };
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r221843 - in head: share/man/man3 sys/sys

2011-05-13 Thread Matthew D Fleming
Author: mdf
Date: Fri May 13 15:49:23 2011
New Revision: 221843
URL: http://svn.freebsd.org/changeset/base/221843

Log:
  Note that the _SWAP operation is supported for all list/queue types.
  Also place STAILQ_REMOVE_HEAD in alphabetical order.  Lastly, document
  the _SWAP macros.
  
  PR:   kern/143033
  MFC after:1 week

Modified:
  head/share/man/man3/Makefile
  head/share/man/man3/queue.3
  head/sys/sys/queue.h

Modified: head/share/man/man3/Makefile
==
--- head/share/man/man3/MakefileFri May 13 15:21:31 2011
(r221842)
+++ head/share/man/man3/MakefileFri May 13 15:49:23 2011
(r221843)
@@ -53,6 +53,7 @@ MLINKS+=  queue.3 LIST_EMPTY.3 \
queue.3 LIST_INSERT_HEAD.3 \
queue.3 LIST_NEXT.3 \
queue.3 LIST_REMOVE.3 \
+   queue.3 LIST_SWAP.3 \
queue.3 SLIST_EMPTY.3 \
queue.3 SLIST_ENTRY.3 \
queue.3 SLIST_FIRST.3 \
@@ -67,6 +68,7 @@ MLINKS+=  queue.3 LIST_EMPTY.3 \
queue.3 SLIST_REMOVE.3 \
queue.3 SLIST_REMOVE_AFTER.3 \
queue.3 SLIST_REMOVE_HEAD.3 \
+   queue.3 SLIST_SWAP.3 \
queue.3 STAILQ_CONCAT.3 \
queue.3 STAILQ_EMPTY.3 \
queue.3 STAILQ_ENTRY.3 \
@@ -84,6 +86,7 @@ MLINKS+=  queue.3 LIST_EMPTY.3 \
queue.3 STAILQ_REMOVE.3 \
queue.3 STAILQ_REMOVE_AFTER.3 \
queue.3 STAILQ_REMOVE_HEAD.3 \
+   queue.3 STAILQ_SWAP.3 \
queue.3 TAILQ_CONCAT.3 \
queue.3 TAILQ_EMPTY.3 \
queue.3 TAILQ_ENTRY.3 \
@@ -102,7 +105,8 @@ MLINKS+=queue.3 LIST_EMPTY.3 \
queue.3 TAILQ_LAST.3 \
queue.3 TAILQ_NEXT.3 \
queue.3 TAILQ_PREV.3 \
-   queue.3 TAILQ_REMOVE.3
+   queue.3 TAILQ_REMOVE.3 \
+   queue.3 TAILQ_SWAP.3
 MLINKS+=   stdarg.3 va_arg.3 \
stdarg.3 va_copy.3 \
stdarg.3 va_end.3 \

Modified: head/share/man/man3/queue.3
==
--- head/share/man/man3/queue.3 Fri May 13 15:21:31 2011(r221842)
+++ head/share/man/man3/queue.3 Fri May 13 15:49:23 2011(r221843)
@@ -32,7 +32,7 @@
 .\@(#)queue.3 8.2 (Berkeley) 1/24/94
 .\ $FreeBSD$
 .\
-.Dd March 24, 2006
+.Dd May 13, 2011
 .Dt QUEUE 3
 .Os
 .Sh NAME
@@ -50,6 +50,7 @@
 .Nm SLIST_REMOVE_AFTER ,
 .Nm SLIST_REMOVE_HEAD ,
 .Nm SLIST_REMOVE ,
+.Nm SLIST_SWAP ,
 .Nm STAILQ_CONCAT ,
 .Nm STAILQ_EMPTY ,
 .Nm STAILQ_ENTRY ,
@@ -67,6 +68,7 @@
 .Nm STAILQ_REMOVE_AFTER ,
 .Nm STAILQ_REMOVE_HEAD ,
 .Nm STAILQ_REMOVE ,
+.Nm STAILQ_SWAP ,
 .Nm LIST_EMPTY ,
 .Nm LIST_ENTRY ,
 .Nm LIST_FIRST ,
@@ -80,6 +82,7 @@
 .Nm LIST_INSERT_HEAD ,
 .Nm LIST_NEXT ,
 .Nm LIST_REMOVE ,
+.Nm LIST_SWAP ,
 .Nm TAILQ_CONCAT ,
 .Nm TAILQ_EMPTY ,
 .Nm TAILQ_ENTRY ,
@@ -98,7 +101,8 @@
 .Nm TAILQ_LAST ,
 .Nm TAILQ_NEXT ,
 .Nm TAILQ_PREV ,
-.Nm TAILQ_REMOVE
+.Nm TAILQ_REMOVE ,
+.Nm TAILQ_SWAP
 .Nd implementations of singly-linked lists, singly-linked tail queues,
 lists and tail queues
 .Sh SYNOPSIS
@@ -118,6 +122,7 @@ lists and tail queues
 .Fn SLIST_REMOVE_AFTER TYPE *elm SLIST_ENTRY NAME
 .Fn SLIST_REMOVE_HEAD SLIST_HEAD *head SLIST_ENTRY NAME
 .Fn SLIST_REMOVE SLIST_HEAD *head TYPE *elm TYPE SLIST_ENTRY NAME
+.Fn SLIST_SWAP SLIST_HEAD *head1 SLIST_HEAD *head2 SLIST_ENTRY NAME
 .\
 .Fn STAILQ_CONCAT STAILQ_HEAD *head1 STAILQ_HEAD *head2
 .Fn STAILQ_EMPTY STAILQ_HEAD *head
@@ -136,6 +141,7 @@ lists and tail queues
 .Fn STAILQ_REMOVE_AFTER STAILQ_HEAD *head TYPE *elm STAILQ_ENTRY NAME
 .Fn STAILQ_REMOVE_HEAD STAILQ_HEAD *head STAILQ_ENTRY NAME
 .Fn STAILQ_REMOVE STAILQ_HEAD *head TYPE *elm TYPE STAILQ_ENTRY NAME
+.Fn STAILQ_SWAP STAILQ_HEAD *head1 STAILQ_HEAD *head2 STAILQ_ENTRY NAME
 .\
 .Fn LIST_EMPTY LIST_HEAD *head
 .Fn LIST_ENTRY TYPE
@@ -150,6 +156,7 @@ lists and tail queues
 .Fn LIST_INSERT_HEAD LIST_HEAD *head TYPE *elm LIST_ENTRY NAME
 .Fn LIST_NEXT TYPE *elm LIST_ENTRY NAME
 .Fn LIST_REMOVE TYPE *elm LIST_ENTRY NAME
+.Fn LIST_SWAP LIST_HEAD *head1 LIST_HEAD *head2 TYPE LIST_ENTRY NAME
 .\
 .Fn TAILQ_CONCAT TAILQ_HEAD *head1 TAILQ_HEAD *head2 TAILQ_ENTRY NAME
 .Fn TAILQ_EMPTY TAILQ_HEAD *head
@@ -170,6 +177,7 @@ lists and tail queues
 .Fn TAILQ_NEXT TYPE *elm TAILQ_ENTRY NAME
 .Fn TAILQ_PREV TYPE *elm HEADNAME TAILQ_ENTRY NAME
 .Fn TAILQ_REMOVE TAILQ_HEAD *head TYPE *elm TAILQ_ENTRY NAME
+.Fn TAILQ_SWAP TAILQ_HEAD *head1 TAILQ_HEAD *head2 TYPE TAILQ_ENTRY 
NAME
 .\
 .Sh DESCRIPTION
 These macros define and operate on four types of data structures:
@@ -184,6 +192,8 @@ Insertion of a new entry after any eleme
 O(1) removal of an entry from the head of the list.
 .It
 Forward traversal through the list.
+.It
+Swawpping the contents of two lists.
 .El
 .Pp
 

svn commit: r221853 - in head/sys: dev/md dev/null sys vm

2011-05-13 Thread Matthew D Fleming
Author: mdf
Date: Fri May 13 18:48:00 2011
New Revision: 221853
URL: http://svn.freebsd.org/changeset/base/221853

Log:
  Usa a globally visible region of zeros for both /dev/zero and the md
  device.  There are likely other kernel uses of blob of zeros than can
  be converted.
  
  Reviewed by:  alc
  MFC after:1 week

Modified:
  head/sys/dev/md/md.c
  head/sys/dev/null/null.c
  head/sys/sys/systm.h
  head/sys/vm/vm_kern.c

Modified: head/sys/dev/md/md.c
==
--- head/sys/dev/md/md.cFri May 13 18:46:20 2011(r221852)
+++ head/sys/dev/md/md.cFri May 13 18:48:00 2011(r221853)
@@ -205,9 +205,6 @@ struct md_s {
vm_object_t object;
 };
 
-/* Used for BIO_DELETE on MD_VNODE */
-static u_char zero[PAGE_SIZE];
-
 static struct indir *
 new_indir(u_int shift)
 {
@@ -560,7 +557,8 @@ mdstart_vnode(struct md_s *sc, struct bi
 * that the two cases end up having very little in common.
 */
if (bp-bio_cmd == BIO_DELETE) {
-   zerosize = sizeof(zero) - (sizeof(zero) % sc-sectorsize);
+   zerosize = ZERO_REGION_SIZE -
+   (ZERO_REGION_SIZE % sc-sectorsize);
auio.uio_iov = aiov;
auio.uio_iovcnt = 1;
auio.uio_offset = (vm_ooffset_t)bp-bio_offset;
@@ -573,7 +571,7 @@ mdstart_vnode(struct md_s *sc, struct bi
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
error = 0;
while (auio.uio_offset  end) {
-   aiov.iov_base = zero;
+   aiov.iov_base = __DECONST(void *, zero_region);
aiov.iov_len = end - auio.uio_offset;
if (aiov.iov_len  zerosize)
aiov.iov_len = zerosize;

Modified: head/sys/dev/null/null.c
==
--- head/sys/dev/null/null.cFri May 13 18:46:20 2011(r221852)
+++ head/sys/dev/null/null.cFri May 13 18:48:00 2011(r221853)
@@ -65,8 +65,6 @@ static struct cdevsw zero_cdevsw = {
.d_flags =  D_MMAP_ANON,
 };
 
-static void *zbuf;
-
 /* ARGSUSED */
 static int
 null_write(struct cdev *dev __unused, struct uio *uio, int flags __unused)
@@ -95,10 +93,19 @@ null_ioctl(struct cdev *dev __unused, u_
 static int
 zero_read(struct cdev *dev __unused, struct uio *uio, int flags __unused)
 {
+   void *zbuf;
+   ssize_t len;
int error = 0;
 
-   while (uio-uio_resid  0  error == 0)
-   error = uiomove(zbuf, MIN(uio-uio_resid, PAGE_SIZE), uio);
+   KASSERT(uio-uio_rw == UIO_READ,
+   (Can't be in %s for write, __func__));
+   zbuf = __DECONST(void *, zero_region);
+   while (uio-uio_resid  0  error == 0) {
+   len = uio-uio_resid;
+   if (len  ZERO_REGION_SIZE)
+   len = ZERO_REGION_SIZE;
+   error = uiomove(zbuf, len, uio);
+   }
 
return (error);
 }
@@ -111,7 +118,6 @@ null_modevent(module_t mod __unused, int
case MOD_LOAD:
if (bootverbose)
printf(null: null device, zero device\n);
-   zbuf = (void *)malloc(PAGE_SIZE, M_TEMP, M_WAITOK | M_ZERO);
null_dev = make_dev_credf(MAKEDEV_ETERNAL_KLD, null_cdevsw, 0,
NULL, UID_ROOT, GID_WHEEL, 0666, null);
zero_dev = make_dev_credf(MAKEDEV_ETERNAL_KLD, zero_cdevsw, 0,
@@ -121,7 +127,6 @@ null_modevent(module_t mod __unused, int
case MOD_UNLOAD:
destroy_dev(null_dev);
destroy_dev(zero_dev);
-   free(zbuf, M_TEMP);
break;
 
case MOD_SHUTDOWN:

Modified: head/sys/sys/systm.h
==
--- head/sys/sys/systm.hFri May 13 18:46:20 2011(r221852)
+++ head/sys/sys/systm.hFri May 13 18:48:00 2011(r221853)
@@ -125,6 +125,9 @@ extern char static_hints[]; /* by config
 
 extern char **kenvp;
 
+extern const void *zero_region;/* address space maps to a zeroed page  
*/
+#defineZERO_REGION_SIZE(2048 * 1024)
+
 /*
  * General function declarations.
  */

Modified: head/sys/vm/vm_kern.c
==
--- head/sys/vm/vm_kern.c   Fri May 13 18:46:20 2011(r221852)
+++ head/sys/vm/vm_kern.c   Fri May 13 18:48:00 2011(r221853)
@@ -91,6 +91,9 @@ vm_map_t exec_map=0;
 vm_map_t pipe_map;
 vm_map_t buffer_map=0;
 
+const void *zero_region;
+CTASSERT((ZERO_REGION_SIZE  PAGE_MASK) == 0);
+
 /*
  * kmem_alloc_nofault:
  *
@@ -527,6 +530,35 @@ kmem_free_wakeup(map, addr, size)
vm_map_unlock(map);
 }
 
+static void
+kmem_init_zero_region(void)
+{
+   vm_offset_t addr;
+   vm_page_t m;
+   unsigned int i;

svn commit: r221855 - in head/sys: amd64/include arm/include dev/md dev/null i386/include ia64/include mips/include powerpc/include sparc64/include sun4v/include sys vm

2011-05-13 Thread Matthew D Fleming
Author: mdf
Date: Fri May 13 19:35:01 2011
New Revision: 221855
URL: http://svn.freebsd.org/changeset/base/221855

Log:
  Move the ZERO_REGION_SIZE to a machine-dependent file, as on many
  architectures (i386, for example) the virtual memory space may be
  constrained enough that 2MB is a large chunk.  Use 64K for arches
  other than amd64 and ia64, with special handling for sparc64 due to
  differing hardware.
  
  Also commit the comment changes to kmem_init_zero_region() that I
  missed due to not saving the file.  (Darn the unfamiliar development
  environment).
  
  Arch maintainers, please feel free to adjust ZERO_REGION_SIZE as you
  see fit.
  
  Requested by: alc
  MFC after:1 week
  MFC with: r221853

Modified:
  head/sys/amd64/include/vmparam.h
  head/sys/arm/include/vmparam.h
  head/sys/dev/md/md.c
  head/sys/dev/null/null.c
  head/sys/i386/include/vmparam.h
  head/sys/ia64/include/vmparam.h
  head/sys/mips/include/vmparam.h
  head/sys/powerpc/include/vmparam.h
  head/sys/sparc64/include/vmparam.h
  head/sys/sun4v/include/vmparam.h
  head/sys/sys/systm.h
  head/sys/vm/vm_kern.c

Modified: head/sys/amd64/include/vmparam.h
==
--- head/sys/amd64/include/vmparam.hFri May 13 19:18:15 2011
(r221854)
+++ head/sys/amd64/include/vmparam.hFri May 13 19:35:01 2011
(r221855)
@@ -212,4 +212,6 @@
 #defineVM_INITIAL_PAGEIN   16
 #endif
 
+#defineZERO_REGION_SIZE(2 * 1024 * 1024)   /* 2MB */
+
 #endif /* _MACHINE_VMPARAM_H_ */

Modified: head/sys/arm/include/vmparam.h
==
--- head/sys/arm/include/vmparam.h  Fri May 13 19:18:15 2011
(r221854)
+++ head/sys/arm/include/vmparam.h  Fri May 13 19:35:01 2011
(r221855)
@@ -150,4 +150,7 @@
 #ifdef ARM_USE_SMALL_ALLOC
 #define UMA_MD_SMALL_ALLOC
 #endif /* ARM_USE_SMALL_ALLOC */
+
+#defineZERO_REGION_SIZE(64 * 1024) /* 64KB */
+
 #endif /* _MACHINE_VMPARAM_H_ */

Modified: head/sys/dev/md/md.c
==
--- head/sys/dev/md/md.cFri May 13 19:18:15 2011(r221854)
+++ head/sys/dev/md/md.cFri May 13 19:35:01 2011(r221855)
@@ -89,6 +89,8 @@
 #include vm/swap_pager.h
 #include vm/uma.h
 
+#include machine/vmparam.h
+
 #define MD_MODVER 1
 
 #define MD_SHUTDOWN0x1 /* Tell worker thread to terminate. */

Modified: head/sys/dev/null/null.c
==
--- head/sys/dev/null/null.cFri May 13 19:18:15 2011(r221854)
+++ head/sys/dev/null/null.cFri May 13 19:35:01 2011(r221855)
@@ -39,7 +39,9 @@ __FBSDID($FreeBSD$);
 #include sys/priv.h
 #include sys/disk.h
 #include sys/bus.h
+
 #include machine/bus.h
+#include machine/vmparam.h
 
 /* For use with destroy_dev(9). */
 static struct cdev *null_dev;

Modified: head/sys/i386/include/vmparam.h
==
--- head/sys/i386/include/vmparam.h Fri May 13 19:18:15 2011
(r221854)
+++ head/sys/i386/include/vmparam.h Fri May 13 19:35:01 2011
(r221855)
@@ -198,4 +198,6 @@
 #defineVM_INITIAL_PAGEIN   16
 #endif
 
+#defineZERO_REGION_SIZE(64 * 1024) /* 64KB */
+
 #endif /* _MACHINE_VMPARAM_H_ */

Modified: head/sys/ia64/include/vmparam.h
==
--- head/sys/ia64/include/vmparam.h Fri May 13 19:18:15 2011
(r221854)
+++ head/sys/ia64/include/vmparam.h Fri May 13 19:35:01 2011
(r221855)
@@ -215,4 +215,6 @@
 #defineVM_INITIAL_PAGEIN   16
 #endif
 
+#defineZERO_REGION_SIZE(2 * 1024 * 1024)   /* 2MB */
+
 #endif /* !_MACHINE_VMPARAM_H_ */

Modified: head/sys/mips/include/vmparam.h
==
--- head/sys/mips/include/vmparam.h Fri May 13 19:18:15 2011
(r221854)
+++ head/sys/mips/include/vmparam.h Fri May 13 19:35:01 2011
(r221855)
@@ -187,4 +187,6 @@
  */
 #defineVM_NFREEORDER   9
 
+#defineZERO_REGION_SIZE(64 * 1024) /* 64KB */
+
 #endif /* !_MACHINE_VMPARAM_H_ */

Modified: head/sys/powerpc/include/vmparam.h
==
--- head/sys/powerpc/include/vmparam.h  Fri May 13 19:18:15 2011
(r221854)
+++ head/sys/powerpc/include/vmparam.h  Fri May 13 19:35:01 2011
(r221855)
@@ -198,4 +198,6 @@ struct pmap_physseg {
 #endif
 #endif
 
+#defineZERO_REGION_SIZE(64 * 1024) /* 64KB */
+
 #endif /* _MACHINE_VMPARAM_H_ */

Modified: head/sys/sparc64/include/vmparam.h

svn commit: r221829 - in head/sys: kern sys ufs/ffs

2011-05-12 Thread Matthew D Fleming
Author: mdf
Date: Fri May 13 05:27:58 2011
New Revision: 221829
URL: http://svn.freebsd.org/changeset/base/221829

Log:
  Use a name instead of a magic number for kern_yield(9) when the priority
  should not change.  Fetch the td_user_pri under the thread lock.  This
  is probably not necessary but a magic number also seems preferable to
  knowing the implementation details here.
  
  Requested by: Jason Behmer  jason DOT behmer AT isilon DOT com 

Modified:
  head/sys/kern/kern_synch.c
  head/sys/kern/kern_sysctl.c
  head/sys/kern/vfs_bio.c
  head/sys/kern/vfs_mount.c
  head/sys/kern/vfs_subr.c
  head/sys/kern/vfs_vnops.c
  head/sys/sys/priority.h
  head/sys/ufs/ffs/ffs_softdep.c

Modified: head/sys/kern/kern_synch.c
==
--- head/sys/kern/kern_synch.c  Fri May 13 04:54:01 2011(r221828)
+++ head/sys/kern/kern_synch.c  Fri May 13 05:27:58 2011(r221829)
@@ -551,7 +551,7 @@ maybe_yield(void)
 {
 
if (should_yield())
-   kern_yield(curthread-td_user_pri);
+   kern_yield(PRI_USER);
 }
 
 void
@@ -562,6 +562,8 @@ kern_yield(int prio)
td = curthread;
DROP_GIANT();
thread_lock(td);
+   if (prio == PRI_USER)
+   prio = td-td_user_pri;
if (prio = 0)
sched_prio(td, prio);
mi_switch(SW_VOL | SWT_RELINQUISH, NULL);

Modified: head/sys/kern/kern_sysctl.c
==
--- head/sys/kern/kern_sysctl.c Fri May 13 04:54:01 2011(r221828)
+++ head/sys/kern/kern_sysctl.c Fri May 13 05:27:58 2011(r221829)
@@ -1590,7 +1590,7 @@ userland_sysctl(struct thread *td, int *
SYSCTL_XUNLOCK();
if (error != EAGAIN)
break;
-   kern_yield(curthread-td_user_pri);
+   kern_yield(PRI_USER);
}
 
CURVNET_RESTORE();

Modified: head/sys/kern/vfs_bio.c
==
--- head/sys/kern/vfs_bio.c Fri May 13 04:54:01 2011(r221828)
+++ head/sys/kern/vfs_bio.c Fri May 13 05:27:58 2011(r221829)
@@ -2234,7 +2234,7 @@ buf_daemon()
while (numdirtybuffers  lodirtybuffers) {
if (buf_do_flush(NULL) == 0)
break;
-   kern_yield(-1);
+   kern_yield(PRI_UNCHANGED);
}
lodirtybuffers = lodirtysave;
 

Modified: head/sys/kern/vfs_mount.c
==
--- head/sys/kern/vfs_mount.c   Fri May 13 04:54:01 2011(r221828)
+++ head/sys/kern/vfs_mount.c   Fri May 13 05:27:58 2011(r221829)
@@ -1644,7 +1644,7 @@ __mnt_vnode_next(struct vnode **mvp, str
KASSERT((*mvp)-v_mount == mp, (marker vnode mount list mismatch));
if (should_yield()) {
MNT_IUNLOCK(mp);
-   kern_yield(-1);
+   kern_yield(PRI_UNCHANGED);
MNT_ILOCK(mp);
}
vp = TAILQ_NEXT(*mvp, v_nmntvnodes);

Modified: head/sys/kern/vfs_subr.c
==
--- head/sys/kern/vfs_subr.cFri May 13 04:54:01 2011(r221828)
+++ head/sys/kern/vfs_subr.cFri May 13 05:27:58 2011(r221829)
@@ -718,7 +718,7 @@ next_iter:
continue;
MNT_IUNLOCK(mp);
 yield:
-   kern_yield(-1);
+   kern_yield(PRI_UNCHANGED);
 relock_mnt:
MNT_ILOCK(mp);
}
@@ -831,7 +831,7 @@ vnlru_proc(void)
vnlru_nowhere++;
tsleep(vnlruproc, PPAUSE, vlrup, hz * 3);
} else
-   kern_yield(-1);
+   kern_yield(PRI_UNCHANGED);
}
 }
 

Modified: head/sys/kern/vfs_vnops.c
==
--- head/sys/kern/vfs_vnops.c   Fri May 13 04:54:01 2011(r221828)
+++ head/sys/kern/vfs_vnops.c   Fri May 13 05:27:58 2011(r221829)
@@ -491,7 +491,7 @@ vn_rdwr_inchunks(rw, vp, base, len, offs
break;
offset += chunk;
base = (char *)base + chunk;
-   kern_yield(curthread-td_user_pri);
+   kern_yield(PRI_USER);
} while (len);
if (aresid)
*aresid = len + iaresid;

Modified: head/sys/sys/priority.h
==
--- head/sys/sys/priority.h Fri May 13 04:54:01 2011(r221828)
+++ head/sys/sys/priority.h Fri May 13 05:27:58 2011(r221829)
@@ -117,6 +117,12 @@
 #definePRI_MIN_IDLE(224)
 #definePRI_MAX_IDLE(PRI_MAX)
 
+#ifdef _KERNEL
+/* Other 

svn commit: r220846 - head/sys/kern

2011-04-19 Thread Matthew D Fleming
Author: mdf
Date: Tue Apr 19 16:36:24 2011
New Revision: 220846
URL: http://svn.freebsd.org/changeset/base/220846

Log:
  Allow VOP_ALLOCATE to be iterative, and have kern_posix_fallocate(9)
  drive looping and potentially yielding.
  
  Requested by: kib

Modified:
  head/sys/kern/vfs_default.c
  head/sys/kern/vfs_syscalls.c
  head/sys/kern/vnode_if.src

Modified: head/sys/kern/vfs_default.c
==
--- head/sys/kern/vfs_default.c Tue Apr 19 16:33:08 2011(r220845)
+++ head/sys/kern/vfs_default.c Tue Apr 19 16:36:24 2011(r220846)
@@ -865,25 +865,25 @@ vop_stdallocate(struct vop_allocate_args
struct iovec aiov;
struct vattr vattr, *vap;
struct uio auio;
-   off_t len, cur, offset;
+   off_t fsize, len, cur, offset;
uint8_t *buf;
struct thread *td;
struct vnode *vp;
size_t iosize;
-   int error, locked;
+   int error;
 
buf = NULL;
error = 0;
-   locked = 1;
td = curthread;
vap = vattr;
vp = ap-a_vp;
-   len = ap-a_len;
-   offset = ap-a_offset;
+   len = *ap-a_len;
+   offset = *ap-a_offset;
 
error = VOP_GETATTR(vp, vap, td-td_ucred);
if (error != 0)
goto out;
+   fsize = vap-va_size;
iosize = vap-va_blocksize;
if (iosize == 0)
iosize = BLKDEV_IOSIZE;
@@ -908,27 +908,22 @@ vop_stdallocate(struct vop_allocate_args
} else
 #endif
if (offset + len  vap-va_size) {
+   /*
+* Test offset + len against the filesystem's maxfilesize.
+*/
VATTR_NULL(vap);
vap-va_size = offset + len;
error = VOP_SETATTR(vp, vap, td-td_ucred);
if (error != 0)
goto out;
+   VATTR_NULL(vap);
+   vap-va_size = fsize;
+   error = VOP_SETATTR(vp, vap, td-td_ucred);
+   if (error != 0)
+   goto out;
}
 
-   while (len  0) {
-   if (should_yield()) {
-   VOP_UNLOCK(vp, 0);
-   locked = 0;
-   kern_yield(-1);
-   error = vn_lock(vp, LK_EXCLUSIVE);
-   if (error != 0)
-   break;
-   locked = 1;
-   error = VOP_GETATTR(vp, vap, td-td_ucred);
-   if (error != 0)
-   break;
-   }
-
+   for (;;) {
/*
 * Read and write back anything below the nominal file
 * size.  There's currently no way outside the filesystem
@@ -939,7 +934,7 @@ vop_stdallocate(struct vop_allocate_args
cur -= (offset % iosize);
if (cur  len)
cur = len;
-   if (offset  vap-va_size) {
+   if (offset  fsize) {
aiov.iov_base = buf;
aiov.iov_len = cur;
auio.uio_iov = aiov;
@@ -976,12 +971,15 @@ vop_stdallocate(struct vop_allocate_args
 
len -= cur;
offset += cur;
+   if (len == 0)
+   break;
+   if (should_yield())
+   break;
}
 
  out:
-   KASSERT(locked || error != 0, (How'd I get unlocked with no error?));
-   if (locked  error != 0)
-   VOP_UNLOCK(vp, 0);
+   *ap-a_len = len;
+   *ap-a_offset = offset;
free(buf, M_TEMP);
return (error);
 }

Modified: head/sys/kern/vfs_syscalls.c
==
--- head/sys/kern/vfs_syscalls.cTue Apr 19 16:33:08 2011
(r220845)
+++ head/sys/kern/vfs_syscalls.cTue Apr 19 16:36:24 2011
(r220846)
@@ -4678,12 +4678,11 @@ kern_posix_fallocate(struct thread *td, 
struct file *fp;
struct mount *mp;
struct vnode *vp;
-   int error, vfslocked, vnlocked;
+   off_t olen, ooffset;
+   int error, vfslocked;
 
fp = NULL;
-   mp = NULL;
vfslocked = 0;
-   vnlocked = 0;
error = fget(td, fd, fp);
if (error != 0)
goto out;
@@ -4718,28 +4717,44 @@ kern_posix_fallocate(struct thread *td, 
goto out;
}
 
-   bwillwrite();
-   vfslocked = VFS_LOCK_GIANT(vp-v_mount);
-   error = vn_start_write(vp, mp, V_WAIT | PCATCH);
-   if (error != 0)
-   goto out;
-   error = vn_lock(vp, LK_EXCLUSIVE);
-   if (error != 0)
-   goto out;
-   vnlocked = 1;
+   /* Allocating blocks may take a long time, so iterate. */
+   for (;;) {
+   olen = len;
+   ooffset = offset;
+
+   bwillwrite();
+ 

svn commit: r220871 - head/sys/dev/acpica

2011-04-19 Thread Matthew D Fleming
Author: mdf
Date: Tue Apr 19 20:44:43 2011
New Revision: 220871
URL: http://svn.freebsd.org/changeset/base/220871

Log:
  Correctly output the entire array for hw.acpi.thermal._ACx.
  
  Reported by:  Taku YAMAMOTO  taku AT tackymt DOT homeip DOT net 
  Tested by:Nick Ulen  uncle AT wolfman DOT devio DOT us 

Modified:
  head/sys/dev/acpica/acpi_thermal.c

Modified: head/sys/dev/acpica/acpi_thermal.c
==
--- head/sys/dev/acpica/acpi_thermal.c  Tue Apr 19 20:41:00 2011
(r220870)
+++ head/sys/dev/acpica/acpi_thermal.c  Tue Apr 19 20:44:43 2011
(r220871)
@@ -288,7 +288,8 @@ acpi_tz_attach(device_t dev)
critical temp setpoint (shutdown now));
 SYSCTL_ADD_PROC(sc-tz_sysctl_ctx, SYSCTL_CHILDREN(sc-tz_sysctl_tree),
OID_AUTO, _ACx, CTLTYPE_INT | CTLFLAG_RD,
-   sc-tz_zone.ac, 0, sysctl_handle_int, IK, );
+   sc-tz_zone.ac, sizeof(sc-tz_zone.ac),
+   sysctl_handle_opaque, IK, );
 SYSCTL_ADD_PROC(sc-tz_sysctl_ctx, SYSCTL_CHILDREN(sc-tz_sysctl_tree),
OID_AUTO, _TC1, CTLTYPE_INT | CTLFLAG_RW,
sc, offsetof(struct acpi_tz_softc, tz_zone.tc1),
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r220791 - in head: lib/libc/sys sys/compat/freebsd32 sys/kern sys/sys

2011-04-18 Thread Matthew D Fleming
Author: mdf
Date: Mon Apr 18 16:32:22 2011
New Revision: 220791
URL: http://svn.freebsd.org/changeset/base/220791

Log:
  Add the posix_fallocate(2) syscall.  The default implementation in
  vop_stdallocate() is filesystem agnostic and will run as slow as a
  read/write loop in userspace; however, it serves to correctly
  implement the functionality for filesystems that do not implement a
  VOP_ALLOCATE.
  
  Note that __FreeBSD_version was already bumped today to 900036 for any
  ports which would like to use this function.
  
  Also reserve space in the syscall table for posix_fadvise(2).
  
  Reviewed by:  -arch (previous version)

Added:
  head/lib/libc/sys/posix_fallocate.2   (contents, props changed)
Modified:
  head/lib/libc/sys/Makefile.inc
  head/lib/libc/sys/Symbol.map
  head/sys/compat/freebsd32/freebsd32_misc.c
  head/sys/compat/freebsd32/syscalls.master
  head/sys/kern/syscalls.master
  head/sys/kern/vfs_default.c
  head/sys/kern/vfs_syscalls.c
  head/sys/kern/vnode_if.src
  head/sys/sys/fcntl.h
  head/sys/sys/vnode.h

Modified: head/lib/libc/sys/Makefile.inc
==
--- head/lib/libc/sys/Makefile.inc  Mon Apr 18 16:15:59 2011
(r220790)
+++ head/lib/libc/sys/Makefile.inc  Mon Apr 18 16:32:22 2011
(r220791)
@@ -96,7 +96,7 @@ MAN+= abort2.2 accept.2 access.2 acct.2 
mq_setattr.2 \
msgctl.2 msgget.2 msgrcv.2 msgsnd.2 \
msync.2 munmap.2 nanosleep.2 nfssvc.2 ntp_adjtime.2 open.2 \
-   pathconf.2 pipe.2 poll.2 posix_openpt.2 profil.2 \
+   pathconf.2 pipe.2 poll.2 posix_fallocate.2 posix_openpt.2 profil.2 \
pselect.2 ptrace.2 quotactl.2 \
read.2 readlink.2 reboot.2 recv.2 rename.2 revoke.2 rfork.2 rmdir.2 \
rtprio.2

Modified: head/lib/libc/sys/Symbol.map
==
--- head/lib/libc/sys/Symbol.mapMon Apr 18 16:15:59 2011
(r220790)
+++ head/lib/libc/sys/Symbol.mapMon Apr 18 16:32:22 2011
(r220791)
@@ -364,6 +364,7 @@ FBSD_1.2 {
cap_enter;
cap_getmode;
getloginclass;
+   posix_fallocate;
rctl_get_racct;
rctl_get_rules;
rctl_get_limits;

Added: head/lib/libc/sys/posix_fallocate.2
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/lib/libc/sys/posix_fallocate.2 Mon Apr 18 16:32:22 2011
(r220791)
@@ -0,0 +1,146 @@
+.\ Copyright (c) 1980, 1991, 1993
+.\The Regents of the University of California.  All rights reserved.
+.\
+.\ Redistribution and use in source and binary forms, with or without
+.\ modification, are permitted provided that the following conditions
+.\ are met:
+.\ 1. Redistributions of source code must retain the above copyright
+.\notice, this list of conditions and the following disclaimer.
+.\ 2. Redistributions in binary form must reproduce the above copyright
+.\notice, this list of conditions and the following disclaimer in the
+.\documentation and/or other materials provided with the distribution.
+.\ 4. Neither the name of the University nor the names of its contributors
+.\may be used to endorse or promote products derived from this software
+.\without specific prior written permission.
+.\
+.\ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\ ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\ SUCH DAMAGE.
+.\
+.\ @(#)open.2 8.2 (Berkeley) 11/16/93
+.\ $FreeBSD$
+.\
+.Dd April 13, 2011
+.Dt POSIX_FALLOCATE 2
+.Os
+.Sh NAME
+.Nm posix_fallocate
+.Nd pre-allocate storage for a range in a file
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In fcntl.h
+.Ft int
+.Fn posix_fallocate int fd off_t offset off_t len
+.Sh DESCRIPTION
+Required storage for the range
+.Fa offset
+to
+.Fa offset +
+.Fa len
+in the file referenced by
+.Fa fd
+is guarateed to be allocated upon successful return.
+That is, if
+.Fn posix_fallocate
+returns successfully, subsequent writes to the specified file data
+will not fail due to lack of free space on the file system storage
+media.
+Any existing file data in the specified range is unmodified.
+If
+.Fa offset +
+.Fa len
+is beyond the current file size, then
+.Fn 

svn commit: r220793 - head/sys/kern

2011-04-18 Thread Matthew D Fleming
Author: mdf
Date: Mon Apr 18 16:40:47 2011
New Revision: 220793
URL: http://svn.freebsd.org/changeset/base/220793

Log:
  Fix a copy/paste whitespace error.

Modified:
  head/sys/kern/vfs_syscalls.c

Modified: head/sys/kern/vfs_syscalls.c
==
--- head/sys/kern/vfs_syscalls.cMon Apr 18 16:32:47 2011
(r220792)
+++ head/sys/kern/vfs_syscalls.cMon Apr 18 16:40:47 2011
(r220793)
@@ -4699,10 +4699,10 @@ kern_posix_fallocate(struct thread *td, 
error = ENODEV;
goto out;
}
-if ((fp-f_flag  FWRITE) == 0) {
-error = EBADF;
+   if ((fp-f_flag  FWRITE) == 0) {
+   error = EBADF;
goto out;
-}
+   }
vp = fp-f_vnode;
if (vp-v_type != VREG) {
error = ENODEV;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r220798 - head/sys/dev/acpica

2011-04-18 Thread Matthew D Fleming
Author: mdf
Date: Mon Apr 18 19:02:41 2011
New Revision: 220798
URL: http://svn.freebsd.org/changeset/base/220798

Log:
  Fix a few acpi sysctls that want IK formatting to specify CTLTYPE_INT.
  This got broken after r217586.
  
  Pointy hat:   to me
  Tested by:David Wolfskill  davit AT catwhisker DOT org 

Modified:
  head/sys/dev/acpica/acpi_thermal.c

Modified: head/sys/dev/acpica/acpi_thermal.c
==
--- head/sys/dev/acpica/acpi_thermal.c  Mon Apr 18 18:55:27 2011
(r220797)
+++ head/sys/dev/acpica/acpi_thermal.c  Mon Apr 18 19:02:41 2011
(r220798)
@@ -257,10 +257,10 @@ acpi_tz_attach(device_t dev)
 sc-tz_sysctl_tree = SYSCTL_ADD_NODE(sc-tz_sysctl_ctx,
 SYSCTL_CHILDREN(acpi_tz_sysctl_tree),
 OID_AUTO, oidname, CTLFLAG_RD, 0, );
-SYSCTL_ADD_OPAQUE(sc-tz_sysctl_ctx, SYSCTL_CHILDREN(sc-tz_sysctl_tree),
- OID_AUTO, temperature, CTLFLAG_RD, sc-tz_temperature,
- sizeof(sc-tz_temperature), IK,
- current thermal zone temperature);
+SYSCTL_ADD_PROC(sc-tz_sysctl_ctx, SYSCTL_CHILDREN(sc-tz_sysctl_tree),
+   OID_AUTO, temperature, CTLTYPE_INT | CTLFLAG_RD,
+   sc-tz_temperature, 0, sysctl_handle_int,
+   IK, current thermal zone temperature);
 SYSCTL_ADD_PROC(sc-tz_sysctl_ctx, SYSCTL_CHILDREN(sc-tz_sysctl_tree),
OID_AUTO, active, CTLTYPE_INT | CTLFLAG_RW,
sc, 0, acpi_tz_active_sysctl, I, cooling is active);
@@ -286,9 +286,9 @@ acpi_tz_attach(device_t dev)
sc, offsetof(struct acpi_tz_softc, tz_zone.crt),
acpi_tz_temp_sysctl, IK,
critical temp setpoint (shutdown now));
-SYSCTL_ADD_OPAQUE(sc-tz_sysctl_ctx, SYSCTL_CHILDREN(sc-tz_sysctl_tree),
- OID_AUTO, _ACx, CTLFLAG_RD, sc-tz_zone.ac,
- sizeof(sc-tz_zone.ac), IK, );
+SYSCTL_ADD_PROC(sc-tz_sysctl_ctx, SYSCTL_CHILDREN(sc-tz_sysctl_tree),
+   OID_AUTO, _ACx, CTLTYPE_INT | CTLFLAG_RD,
+   sc-tz_zone.ac, 0, sysctl_handle_int, IK, );
 SYSCTL_ADD_PROC(sc-tz_sysctl_ctx, SYSCTL_CHILDREN(sc-tz_sysctl_tree),
OID_AUTO, _TC1, CTLTYPE_INT | CTLFLAG_RW,
sc, offsetof(struct acpi_tz_softc, tz_zone.tc1),
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r219523 - in head/sys: amd64/amd64 ia64/ia64 powerpc/aim sparc64/sparc64 sun4v/sun4v sys

2011-03-11 Thread Matthew D Fleming
Author: mdf
Date: Fri Mar 11 18:56:55 2011
New Revision: 219523
URL: http://svn.freebsd.org/changeset/base/219523

Log:
  Mostly revert r219468, as I had misremembered the C standard regarding
  the size of an extern array.
  
  Keep one change from strncpy to strlcpy.

Modified:
  head/sys/amd64/amd64/machdep.c
  head/sys/ia64/ia64/machdep.c
  head/sys/powerpc/aim/machdep.c
  head/sys/sparc64/sparc64/machdep.c
  head/sys/sun4v/sun4v/machdep.c
  head/sys/sys/kernel.h

Modified: head/sys/amd64/amd64/machdep.c
==
--- head/sys/amd64/amd64/machdep.c  Fri Mar 11 18:51:42 2011
(r219522)
+++ head/sys/amd64/amd64/machdep.c  Fri Mar 11 18:56:55 2011
(r219523)
@@ -1758,7 +1758,7 @@ hammer_time(u_int64_t modulep, u_int64_t
 
 env = getenv(kernelname);
if (env != NULL)
-   strlcpy(kernelname, env, MAXPATHLEN);
+   strlcpy(kernelname, env, sizeof(kernelname));
 
 #ifdef XENHVM
if (inw(0x10) == 0x49d2) {

Modified: head/sys/ia64/ia64/machdep.c
==
--- head/sys/ia64/ia64/machdep.cFri Mar 11 18:51:42 2011
(r219522)
+++ head/sys/ia64/ia64/machdep.cFri Mar 11 18:56:55 2011
(r219523)
@@ -792,7 +792,7 @@ ia64_init(void)
 
p = getenv(kernelname);
if (p != NULL) {
-   strlcpy(kernelname, p, MAXPATHLEN);
+   strlcpy(kernelname, p, sizeof(kernelname));
freeenv(p);
}
 

Modified: head/sys/powerpc/aim/machdep.c
==
--- head/sys/powerpc/aim/machdep.c  Fri Mar 11 18:51:42 2011
(r219522)
+++ head/sys/powerpc/aim/machdep.c  Fri Mar 11 18:56:55 2011
(r219523)
@@ -540,7 +540,7 @@ powerpc_init(vm_offset_t startkernel, vm
 */
 env = getenv(kernelname);
 if (env != NULL) {
-   strlcpy(kernelname, env, MAXPATHLEN);
+   strlcpy(kernelname, env, sizeof(kernelname));
freeenv(env);
}
 

Modified: head/sys/sparc64/sparc64/machdep.c
==
--- head/sys/sparc64/sparc64/machdep.c  Fri Mar 11 18:51:42 2011
(r219522)
+++ head/sys/sparc64/sparc64/machdep.c  Fri Mar 11 18:56:55 2011
(r219523)
@@ -532,7 +532,7 @@ sparc64_init(caddr_t mdp, u_long o1, u_l
init_param2(physmem);
env = getenv(kernelname);
if (env != NULL) {
-   strlcpy(kernelname, env, MAXPATHLEN);
+   strlcpy(kernelname, env, sizeof(kernelname));
freeenv(env);
}
 

Modified: head/sys/sun4v/sun4v/machdep.c
==
--- head/sys/sun4v/sun4v/machdep.c  Fri Mar 11 18:51:42 2011
(r219522)
+++ head/sys/sun4v/sun4v/machdep.c  Fri Mar 11 18:56:55 2011
(r219523)
@@ -425,7 +425,7 @@ sparc64_init(caddr_t mdp, u_long o1, u_l
 
env = getenv(kernelname);
if (env != NULL) {
-   strlcpy(kernelname, env, MAXPATHLEN);
+   strlcpy(kernelname, env, sizeof(kernelname));
freeenv(env);
}
 

Modified: head/sys/sys/kernel.h
==
--- head/sys/sys/kernel.h   Fri Mar 11 18:51:42 2011(r219522)
+++ head/sys/sys/kernel.h   Fri Mar 11 18:56:55 2011(r219523)
@@ -55,7 +55,7 @@
 /* Global variables for the kernel. */
 
 /* 1.1 */
-extern char kernelname[/*MAXPATHLEN*/];
+extern char kernelname[MAXPATHLEN];
 
 extern int tick;   /* usec per tick (100 / hz) */
 extern int hz; /* system clock's frequency */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r218825 - in head/sys: ddb gdb kern

2011-02-18 Thread Matthew D Fleming
Author: mdf
Date: Fri Feb 18 22:25:11 2011
New Revision: 218825
URL: http://svn.freebsd.org/changeset/base/218825

Log:
  Modify kdb_trap() so that it re-calls the dbbe_trap function as long as
  the debugger back-end has changed.  This means that switching from ddb
  to gdb no longer requires a step which can be dangerous on an
  already-crashed kernel.
  
  Also add a capability to get from the gdb back-end back to ddb, by
  typing ^C in the console window.
  
  While here, simplify kdb_sysctl_available() by using
  sbuf_new_for_sysctl(), and use strlcpy() instead of strncpy() since the
  strlcpy semantic is desired.
  
  MFC after:1 month

Modified:
  head/sys/ddb/db_command.c
  head/sys/gdb/gdb_main.c
  head/sys/gdb/gdb_packet.c
  head/sys/kern/subr_kdb.c

Modified: head/sys/ddb/db_command.c
==
--- head/sys/ddb/db_command.c   Fri Feb 18 21:44:53 2011(r218824)
+++ head/sys/ddb/db_command.c   Fri Feb 18 22:25:11 2011(r218825)
@@ -723,10 +723,16 @@ static void
 db_gdb(db_expr_t dummy1, boolean_t dummy2, db_expr_t dummy3, char *dummy4)
 {
 
-   if (kdb_dbbe_select(gdb) != 0)
+   if (kdb_dbbe_select(gdb) != 0) {
db_printf(The remote GDB backend could not be selected.\n);
-   else
-   db_printf(Step to enter the remote GDB backend.\n);
+   return;
+   }
+   /*
+* Mark that we are done in the debugger.  kdb_trap()
+* should re-enter with the new backend.
+*/
+   db_cmd_loop_done = 1;
+   db_printf((ctrl-c will return control to ddb)\n);
 }
 
 static void

Modified: head/sys/gdb/gdb_main.c
==
--- head/sys/gdb/gdb_main.c Fri Feb 18 21:44:53 2011(r218824)
+++ head/sys/gdb/gdb_main.c Fri Feb 18 22:25:11 2011(r218825)
@@ -95,7 +95,17 @@ gdb_init(void)
 static int
 gdb_trap(int type, int code)
 {
+   jmp_buf jb;
struct thread *thr_iter;
+   void *prev_jb;
+
+   prev_jb = kdb_jmpbuf(jb);
+   if (setjmp(jb) != 0) {
+   printf(%s bailing, hopefully back to ddb!\n, __func__);
+   gdb_listening = 0;
+   (void)kdb_jmpbuf(prev_jb);
+   return (1);
+   }
 
gdb_listening = 0;
/*
@@ -291,5 +301,6 @@ gdb_trap(int type, int code)
break;
}
}
+   (void)kdb_jmpbuf(prev_jb);
return (0);
 }

Modified: head/sys/gdb/gdb_packet.c
==
--- head/sys/gdb/gdb_packet.c   Fri Feb 18 21:44:53 2011(r218824)
+++ head/sys/gdb/gdb_packet.c   Fri Feb 18 22:25:11 2011(r218825)
@@ -31,6 +31,7 @@ __FBSDID($FreeBSD$);
 #include sys/systm.h
 #include sys/ctype.h
 #include sys/kdb.h
+#include sys/ttydefaults.h
 
 #include machine/gdb_machdep.h
 #include machine/kdb.h
@@ -60,6 +61,17 @@ gdb_getc(void)
do
c = gdb_cur-gdb_getc();
while (c == -1);
+
+   if (c == CTRL('C')) {
+   printf(Received ^C; trying to switch back to ddb.\n);
+
+   if (kdb_dbbe_select(ddb) != 0)
+   printf(The ddb backend could not be selected.\n);
+   else {
+   printf(using longjmp, hope it works!\n);
+   kdb_reenter();
+   }
+   }
return (c);
 }
 

Modified: head/sys/kern/subr_kdb.c
==
--- head/sys/kern/subr_kdb.cFri Feb 18 21:44:53 2011(r218824)
+++ head/sys/kern/subr_kdb.cFri Feb 18 22:25:11 2011(r218825)
@@ -37,6 +37,7 @@ __FBSDID($FreeBSD$);
 #include sys/malloc.h
 #include sys/pcpu.h
 #include sys/proc.h
+#include sys/sbuf.h
 #include sys/smp.h
 #include sys/stack.h
 #include sys/sysctl.h
@@ -108,33 +109,17 @@ const char * volatile kdb_why = KDB_WHY_
 static int
 kdb_sysctl_available(SYSCTL_HANDLER_ARGS)
 {
-   struct kdb_dbbe *be, **iter;
-   char *avail, *p;
-   ssize_t len, sz;
+   struct kdb_dbbe **iter;
+   struct sbuf sbuf;
int error;
 
-   sz = 0;
+   sbuf_new_for_sysctl(sbuf, NULL, 64, req);
SET_FOREACH(iter, kdb_dbbe_set) {
-   be = *iter;
-   if (be-dbbe_active == 0)
-   sz += strlen(be-dbbe_name) + 1;
+   if ((*iter)-dbbe_active == 0)
+   sbuf_printf(sbuf, %s , (*iter)-dbbe_name);
}
-   sz++;
-   avail = malloc(sz, M_TEMP, M_WAITOK);
-   p = avail;
-   *p = '\0';
-
-   SET_FOREACH(iter, kdb_dbbe_set) {
-   be = *iter;
-   if (be-dbbe_active == 0) {
-   len = snprintf(p, sz, %s , be-dbbe_name);
-   p += len;
-   sz -= len;
-   }
-   }
-   

svn commit: r218685 - head/sys/dev/acpica

2011-02-14 Thread Matthew D Fleming
Author: mdf
Date: Mon Feb 14 17:20:20 2011
New Revision: 218685
URL: http://svn.freebsd.org/changeset/base/218685

Log:
  Prevent reading from the ACPI_RESOURCE past its actual end.  For
  paranoia limit to the size of the ACPI_RESOURCE as well.
  
  Reviewd by:   jhb (in spirit)
  MFC after:1 week

Modified:
  head/sys/dev/acpica/acpi_resource.c

Modified: head/sys/dev/acpica/acpi_resource.c
==
--- head/sys/dev/acpica/acpi_resource.c Mon Feb 14 16:54:03 2011
(r218684)
+++ head/sys/dev/acpica/acpi_resource.c Mon Feb 14 17:20:20 2011
(r218685)
@@ -60,6 +60,7 @@ static ACPI_STATUS
 acpi_lookup_irq_handler(ACPI_RESOURCE *res, void *context)
 {
 struct lookup_irq_request *req;
+size_t len;
 u_int irqnum, irq;
 
 switch (res-Type) {
@@ -82,7 +83,10 @@ acpi_lookup_irq_handler(ACPI_RESOURCE *r
req-found = 1;
KASSERT(irq == rman_get_start(req-res),
(IRQ resources do not match));
-   bcopy(res, req-acpi_res, sizeof(ACPI_RESOURCE));
+   len = res-Length;
+   if (len  sizeof(ACPI_RESOURCE))
+   len = sizeof(ACPI_RESOURCE);
+   bcopy(res, req-acpi_res, len);
return (AE_CTRL_TERMINATE);
 }
 return (AE_OK);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r218424 - in head/sys: dev/sio kern pc98/cbus sys ufs/ffs

2011-02-07 Thread Matthew D Fleming
Author: mdf
Date: Tue Feb  8 00:16:36 2011
New Revision: 218424
URL: http://svn.freebsd.org/changeset/base/218424

Log:
  Based on discussions on the svn-src mailing list, rework r218195:
  
   - entirely eliminate some calls to uio_yeild() as being unnecessary,
 such as in a sysctl handler.
  
   - move should_yield() and maybe_yield() to kern_synch.c and move the
 prototypes from sys/uio.h to sys/proc.h
  
   - add a slightly more generic kern_yield() that can replace the
 functionality of uio_yield().
  
   - replace source uses of uio_yield() with the functional equivalent,
 or in some cases do not change the thread priority when switching.
  
   - fix a logic inversion bug in vlrureclaim(), pointed out by bde@.
  
   - instead of using the per-cpu last switched ticks, use a per thread
 variable for should_yield().  With PREEMPTION, the only reasonable
 use of this is to determine if a lock has been held a long time and
 relinquish it.  Without PREEMPTION, this is essentially the same as
 the per-cpu variable.

Modified:
  head/sys/dev/sio/sio.c
  head/sys/kern/kern_synch.c
  head/sys/kern/kern_sysctl.c
  head/sys/kern/subr_uio.c
  head/sys/kern/vfs_bio.c
  head/sys/kern/vfs_mount.c
  head/sys/kern/vfs_subr.c
  head/sys/kern/vfs_vnops.c
  head/sys/pc98/cbus/sio.c
  head/sys/sys/proc.h
  head/sys/sys/uio.h
  head/sys/ufs/ffs/ffs_softdep.c

Modified: head/sys/dev/sio/sio.c
==
--- head/sys/dev/sio/sio.c  Mon Feb  7 23:00:24 2011(r218423)
+++ head/sys/dev/sio/sio.c  Tue Feb  8 00:16:36 2011(r218424)
@@ -1466,7 +1466,6 @@ sysctl_siots(SYSCTL_HANDLER_ARGS)
error = SYSCTL_OUT(req, buf, len);
if (error != 0)
return (error);
-   uio_yield();
}
return (0);
 }

Modified: head/sys/kern/kern_synch.c
==
--- head/sys/kern/kern_synch.c  Mon Feb  7 23:00:24 2011(r218423)
+++ head/sys/kern/kern_synch.c  Tue Feb  8 00:16:36 2011(r218424)
@@ -413,9 +413,10 @@ mi_switch(int flags, struct thread *newt
 */
if (kdb_active)
kdb_switch();
-   if (flags  SW_VOL)
+   if (flags  SW_VOL) {
td-td_ru.ru_nvcsw++;
-   else
+   td-td_swvoltick = ticks;
+   } else
td-td_ru.ru_nivcsw++;
 #ifdef SCHED_STATS
SCHED_STAT_INC(sched_switch_stats[flags  SW_TYPE_MASK]);
@@ -538,6 +539,36 @@ synch_setup(void *dummy)
loadav(NULL);
 }
 
+int
+should_yield(void)
+{
+
+   return (ticks - curthread-td_swvoltick = hogticks);
+}
+
+void
+maybe_yield(void)
+{
+
+   if (should_yield())
+   kern_yield(curthread-td_user_pri);
+}
+
+void
+kern_yield(int prio)
+{
+   struct thread *td;
+
+   td = curthread;
+   DROP_GIANT();
+   thread_lock(td);
+   if (prio = 0)
+   sched_prio(td, prio);
+   mi_switch(SW_VOL | SWT_RELINQUISH, NULL);
+   thread_unlock(td);
+   PICKUP_GIANT();
+}
+
 /*
  * General purpose yield system call.
  */

Modified: head/sys/kern/kern_sysctl.c
==
--- head/sys/kern/kern_sysctl.c Mon Feb  7 23:00:24 2011(r218423)
+++ head/sys/kern/kern_sysctl.c Tue Feb  8 00:16:36 2011(r218424)
@@ -1568,7 +1568,7 @@ userland_sysctl(struct thread *td, int *
SYSCTL_XUNLOCK();
if (error != EAGAIN)
break;
-   uio_yield();
+   kern_yield(curthread-td_user_pri);
}
 
CURVNET_RESTORE();

Modified: head/sys/kern/subr_uio.c
==
--- head/sys/kern/subr_uio.cMon Feb  7 23:00:24 2011(r218423)
+++ head/sys/kern/subr_uio.cTue Feb  8 00:16:36 2011(r218424)
@@ -352,33 +352,11 @@ again:
return (0);
 }
 
-int
-should_yield(void)
-{
-
-   return (ticks - PCPU_GET(switchticks) = hogticks);
-}
-
-void
-maybe_yield(void)
-{
-
-   if (should_yield())
-   uio_yield();
-}
-
 void
 uio_yield(void)
 {
-   struct thread *td;
 
-   td = curthread;
-   DROP_GIANT();
-   thread_lock(td);
-   sched_prio(td, td-td_user_pri);
-   mi_switch(SW_INVOL | SWT_RELINQUISH, NULL);
-   thread_unlock(td);
-   PICKUP_GIANT();
+   kern_yield(curthread-td_user_pri);
 }
 
 int

Modified: head/sys/kern/vfs_bio.c
==
--- head/sys/kern/vfs_bio.c Mon Feb  7 23:00:24 2011(r218423)
+++ head/sys/kern/vfs_bio.c Tue Feb  8 00:16:36 2011(r218424)
@@ -2234,7 +2234,7 @@ buf_daemon()
while (numdirtybuffers  lodirtybuffers) {
if (buf_do_flush(NULL) == 0)
 

svn commit: r218425 - in head: . sys/kern sys/sys

2011-02-07 Thread Matthew D Fleming
Author: mdf
Date: Tue Feb  8 00:36:46 2011
New Revision: 218425
URL: http://svn.freebsd.org/changeset/base/218425

Log:
  Remove the uio_yield prototype and symbol.  This function has been
  misnamed since it was introduced and should not be globally exposed
  with this name.  The equivalent functionality is now available using
  kern_yield(curthread-td_user_pri).  The function remains
  undocumented.
  
  Bump __FreeBSD_version.

Modified:
  head/UPDATING
  head/sys/kern/subr_uio.c
  head/sys/sys/param.h
  head/sys/sys/uio.h

Modified: head/UPDATING
==
--- head/UPDATING   Tue Feb  8 00:16:36 2011(r218424)
+++ head/UPDATING   Tue Feb  8 00:36:46 2011(r218425)
@@ -22,6 +22,13 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 9.
machines to maximize performance.  (To disable malloc debugging, run
ln -s aj /etc/malloc.conf.)
 
+20110207:
+   Remove the uio_yield prototype and symbol.  This function has
+   been misnamed since it was introduced and should not be
+   globally exposed with this name.  The equivalent functionality
+   is now available using kern_yield(curthread-td_user_pri).
+   The function remains undocumented.
+
 20110112:
A SYSCTL_[ADD_]UQUAD was added for unsigned uint64_t pointers,
symmetric with the existing SYSCTL_[ADD_]QUAD.  Type checking

Modified: head/sys/kern/subr_uio.c
==
--- head/sys/kern/subr_uio.cTue Feb  8 00:16:36 2011(r218424)
+++ head/sys/kern/subr_uio.cTue Feb  8 00:36:46 2011(r218425)
@@ -352,13 +352,6 @@ again:
return (0);
 }
 
-void
-uio_yield(void)
-{
-
-   kern_yield(curthread-td_user_pri);
-}
-
 int
 copyinfrom(const void * __restrict src, void * __restrict dst, size_t len,
 int seg)

Modified: head/sys/sys/param.h
==
--- head/sys/sys/param.hTue Feb  8 00:16:36 2011(r218424)
+++ head/sys/sys/param.hTue Feb  8 00:36:46 2011(r218425)
@@ -58,7 +58,7 @@
  * in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 900031   /* Master, propagated to newvers */
+#define __FreeBSD_version 900032   /* Master, propagated to newvers */
 
 #ifdef _KERNEL
 #defineP_OSREL_SIGSEGV 74

Modified: head/sys/sys/uio.h
==
--- head/sys/sys/uio.h  Tue Feb  8 00:16:36 2011(r218424)
+++ head/sys/sys/uio.h  Tue Feb  8 00:36:46 2011(r218425)
@@ -94,7 +94,6 @@ int   copyiniov(struct iovec *iovp, u_int 
 intcopyinstrfrom(const void * __restrict src, void * __restrict dst,
size_t len, size_t * __restrict copied, int seg);
 intcopyinuio(struct iovec *iovp, u_int iovcnt, struct uio **uiop);
-void   uio_yield(void);
 intuiomove(void *cp, int n, struct uio *uio);
 intuiomove_frombuf(void *buf, int buflen, struct uio *uio);
 intuiomove_fromphys(struct vm_page *ma[], vm_offset_t offset, int n,
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r218195 - in head/sys: amd64/amd64 arm/arm i386/i386 ia64/ia64 kern mips/mips powerpc/powerpc sparc64/sparc64 sun4v/sun4v sys ufs/ffs

2011-02-02 Thread Matthew D Fleming
Author: mdf
Date: Wed Feb  2 16:35:10 2011
New Revision: 218195
URL: http://svn.freebsd.org/changeset/base/218195

Log:
  Put the general logic for being a CPU hog into a new function
  should_yield().  Use this in various places.  Encapsulate the common
  case of check-and-yield into a new function maybe_yield().
  
  Change several checks for a magic number of iterations to use
  should_yield() instead.
  
  MFC after:1 week

Modified:
  head/sys/amd64/amd64/uio_machdep.c
  head/sys/arm/arm/uio_machdep.c
  head/sys/i386/i386/uio_machdep.c
  head/sys/ia64/ia64/uio_machdep.c
  head/sys/kern/imgact_elf.c
  head/sys/kern/subr_uio.c
  head/sys/kern/vfs_mount.c
  head/sys/kern/vfs_subr.c
  head/sys/mips/mips/uio_machdep.c
  head/sys/powerpc/powerpc/uio_machdep.c
  head/sys/sparc64/sparc64/uio_machdep.c
  head/sys/sun4v/sun4v/uio_machdep.c
  head/sys/sys/uio.h
  head/sys/sys/vnode.h
  head/sys/ufs/ffs/ffs_rawread.c
  head/sys/ufs/ffs/ffs_softdep.c

Modified: head/sys/amd64/amd64/uio_machdep.c
==
--- head/sys/amd64/amd64/uio_machdep.c  Wed Feb  2 15:53:09 2011
(r218194)
+++ head/sys/amd64/amd64/uio_machdep.c  Wed Feb  2 16:35:10 2011
(r218195)
@@ -88,8 +88,7 @@ uiomove_fromphys(vm_page_t ma[], vm_offs
page_offset;
switch (uio-uio_segflg) {
case UIO_USERSPACE:
-   if (ticks - PCPU_GET(switchticks) = hogticks)
-   uio_yield();
+   maybe_yield();
if (uio-uio_rw == UIO_READ)
error = copyout(cp, iov-iov_base, cnt);
else

Modified: head/sys/arm/arm/uio_machdep.c
==
--- head/sys/arm/arm/uio_machdep.c  Wed Feb  2 15:53:09 2011
(r218194)
+++ head/sys/arm/arm/uio_machdep.c  Wed Feb  2 16:35:10 2011
(r218195)
@@ -94,8 +94,7 @@ uiomove_fromphys(vm_page_t ma[], vm_offs
cp = (char*)sf_buf_kva(sf) + page_offset;
switch (uio-uio_segflg) {
case UIO_USERSPACE:
-   if (ticks - PCPU_GET(switchticks) = hogticks)
-   uio_yield();
+   maybe_yield();
if (uio-uio_rw == UIO_READ)
error = copyout(cp, iov-iov_base, cnt);
else

Modified: head/sys/i386/i386/uio_machdep.c
==
--- head/sys/i386/i386/uio_machdep.cWed Feb  2 15:53:09 2011
(r218194)
+++ head/sys/i386/i386/uio_machdep.cWed Feb  2 16:35:10 2011
(r218195)
@@ -90,8 +90,7 @@ uiomove_fromphys(vm_page_t ma[], vm_offs
cp = (char *)sf_buf_kva(sf) + page_offset;
switch (uio-uio_segflg) {
case UIO_USERSPACE:
-   if (ticks - PCPU_GET(switchticks) = hogticks)
-   uio_yield();
+   maybe_yield();
if (uio-uio_rw == UIO_READ)
error = copyout(cp, iov-iov_base, cnt);
else

Modified: head/sys/ia64/ia64/uio_machdep.c
==
--- head/sys/ia64/ia64/uio_machdep.cWed Feb  2 15:53:09 2011
(r218194)
+++ head/sys/ia64/ia64/uio_machdep.cWed Feb  2 16:35:10 2011
(r218195)
@@ -89,8 +89,7 @@ uiomove_fromphys(vm_page_t ma[], vm_offs
page_offset;
switch (uio-uio_segflg) {
case UIO_USERSPACE:
-   if (ticks - PCPU_GET(switchticks) = hogticks)
-   uio_yield();
+   maybe_yield();
if (uio-uio_rw == UIO_READ)
error = copyout(cp, iov-iov_base, cnt);
else

Modified: head/sys/kern/imgact_elf.c
==
--- head/sys/kern/imgact_elf.c  Wed Feb  2 15:53:09 2011(r218194)
+++ head/sys/kern/imgact_elf.c  Wed Feb  2 16:35:10 2011(r218195)
@@ -1622,8 +1622,7 @@ compress_core (gzFile file, char *inbuf,
}
inbuf += chunk_len;
len -= chunk_len;
-   if (ticks - PCPU_GET(switchticks) = hogticks)
-   uio_yield();
+   maybe_yield();
}
 
return (error);

Modified: head/sys/kern/subr_uio.c
==
--- head/sys/kern/subr_uio.cWed Feb  2 15:53:09 2011(r218194)
+++ head/sys/kern/subr_uio.cWed Feb  2 16:35:10 2011(r218195)
@@ -158,8 +158,7 @@ uiomove(void *cp, int n, struct uio *uio

svn commit: r217886 - in head/sys: amd64/amd64 i386/i386

2011-01-26 Thread Matthew D Fleming
Author: mdf
Date: Wed Jan 26 17:06:13 2011
New Revision: 217886
URL: http://svn.freebsd.org/changeset/base/217886

Log:
  Set td_kstack_pages for thread0.  This was already being done for most
  architectures, but i386 and amd64 were missing it.
  
  Submitted by: Mohd Fahadullah mfahadullah AT isilon DOT com

Modified:
  head/sys/amd64/amd64/machdep.c
  head/sys/i386/i386/machdep.c

Modified: head/sys/amd64/amd64/machdep.c
==
--- head/sys/amd64/amd64/machdep.c  Wed Jan 26 16:59:07 2011
(r217885)
+++ head/sys/amd64/amd64/machdep.c  Wed Jan 26 17:06:13 2011
(r217886)
@@ -1527,12 +1527,14 @@ hammer_time(u_int64_t modulep, u_int64_t
struct nmi_pcpu *np;
u_int64_t msr;
char *env;
+   size_t kstack0_sz;
 
thread0.td_kstack = physfree + KERNBASE;
-   bzero((void *)thread0.td_kstack, KSTACK_PAGES * PAGE_SIZE);
-   physfree += KSTACK_PAGES * PAGE_SIZE;
-   thread0.td_pcb = (struct pcb *)
-  (thread0.td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1;
+   thread0.td_kstack_pages = KSTACK_PAGES;
+   kstack0_sz = thread0.td_kstack_pages * PAGE_SIZE;
+   bzero((void *)thread0.td_kstack, kstack0_sz);
+   physfree += kstack0_sz;
+   thread0.td_pcb = (struct pcb *)(thread0.td_kstack + kstack0_sz) - 1;
 
/*
 * This may be done better later if it gets more high level
@@ -1674,8 +1676,8 @@ hammer_time(u_int64_t modulep, u_int64_t
initializecpucache();
 
/* make an initial tss so cpu can get interrupt stack on syscall! */
-   common_tss[0].tss_rsp0 = thread0.td_kstack + \
-   KSTACK_PAGES * PAGE_SIZE - sizeof(struct pcb);
+   common_tss[0].tss_rsp0 = thread0.td_kstack +
+   kstack0_sz - sizeof(struct pcb);
/* Ensure the stack is aligned to 16 bytes */
common_tss[0].tss_rsp0 = ~0xFul;
PCPU_SET(rsp0, common_tss[0].tss_rsp0);

Modified: head/sys/i386/i386/machdep.c
==
--- head/sys/i386/i386/machdep.cWed Jan 26 16:59:07 2011
(r217885)
+++ head/sys/i386/i386/machdep.cWed Jan 26 17:06:13 2011
(r217886)
@@ -2493,6 +2493,7 @@ init386(first)
 {
unsigned long gdtmachpfn;
int error, gsel_tss, metadata_missing, x, pa;
+   size_t kstack0_sz;
struct pcpu *pc;
struct callback_register event = {
.type = CALLBACKTYPE_event,
@@ -2504,8 +2505,9 @@ init386(first)
};
 
thread0.td_kstack = proc0kstack;
-   thread0.td_pcb = (struct pcb *)
-  (thread0.td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1;
+   thread0.td_kstack_pages = KSTACK_PAGES;
+   kstack0_sz = thread0.td_kstack_pages * PAGE_SIZE;
+   thread0.td_pcb = (struct pcb *)(thread0.td_kstack + kstack0_sz) - 1;
 
/*
 * This may be done better later if it gets more high level
@@ -2656,7 +2658,7 @@ init386(first)
/* make an initial tss so cpu can get interrupt stack on syscall! */
/* Note: -16 is so we can grow the trapframe if we came from vm86 */
PCPU_SET(common_tss.tss_esp0, thread0.td_kstack +
-   KSTACK_PAGES * PAGE_SIZE - sizeof(struct pcb) - 16);
+   kstack0_sz - sizeof(struct pcb) - 16);
PCPU_SET(common_tss.tss_ss0, GSEL(GDATA_SEL, SEL_KPL));
gsel_tss = GSEL(GPROC0_SEL, SEL_KPL);
HYPERVISOR_stack_switch(GSEL(GDATA_SEL, SEL_KPL),
@@ -2716,11 +2718,13 @@ init386(first)
 {
struct gate_descriptor *gdp;
int gsel_tss, metadata_missing, x, pa;
+   size_t kstack0_sz;
struct pcpu *pc;
 
thread0.td_kstack = proc0kstack;
-   thread0.td_pcb = (struct pcb *)
-  (thread0.td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1;
+   thread0.td_kstack_pages = KSTACK_PAGES;
+   kstack0_sz = thread0.td_kstack_pages * PAGE_SIZE;
+   thread0.td_pcb = (struct pcb *)(thread0.td_kstack + kstack0_sz) - 1;
 
/*
 * This may be done better later if it gets more high level
@@ -2912,7 +2916,7 @@ init386(first)
/* make an initial tss so cpu can get interrupt stack on syscall! */
/* Note: -16 is so we can grow the trapframe if we came from vm86 */
PCPU_SET(common_tss.tss_esp0, thread0.td_kstack +
-   KSTACK_PAGES * PAGE_SIZE - sizeof(struct pcb) - 16);
+   kstack0_sz - sizeof(struct pcb) - 16);
PCPU_SET(common_tss.tss_ss0, GSEL(GDATA_SEL, SEL_KPL));
gsel_tss = GSEL(GPROC0_SEL, SEL_KPL);
PCPU_SET(tss_gdt, gdt[GPROC0_SEL].sd);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r217915 - in head/sys: geom kern sys

2011-01-26 Thread Matthew D Fleming
Author: mdf
Date: Wed Jan 26 22:48:09 2011
New Revision: 217915
URL: http://svn.freebsd.org/changeset/base/217915

Log:
  Remove the CTLFLAG_NOLOCK as it seems to be both unused and
  unfunctional.  Wiring the user buffer has only been done explicitly
  since r101422.
  
  Mark the kern.disks sysctl as MPSAFE since it is and it seems to have
  been mis-using the NOLOCK flag.
  
  Partially break the KPI (but not the KBI) for the sysctl_req 'lock'
  field since this member should be private and the REQ_LOCKED state
  seems meaningless now.

Modified:
  head/sys/geom/geom_disk.c
  head/sys/kern/kern_sysctl.c
  head/sys/sys/sysctl.h

Modified: head/sys/geom/geom_disk.c
==
--- head/sys/geom/geom_disk.c   Wed Jan 26 21:59:59 2011(r217914)
+++ head/sys/geom/geom_disk.c   Wed Jan 26 22:48:09 2011(r217915)
@@ -527,6 +527,7 @@ sysctl_disks(SYSCTL_HANDLER_ARGS)
return error;
 }
  
-SYSCTL_PROC(_kern, OID_AUTO, disks, CTLTYPE_STRING | CTLFLAG_RD | 
CTLFLAG_NOLOCK, 0, 0, 
+SYSCTL_PROC(_kern, OID_AUTO, disks,
+CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0,
 sysctl_disks, A, names of available disks);
 

Modified: head/sys/kern/kern_sysctl.c
==
--- head/sys/kern/kern_sysctl.c Wed Jan 26 21:59:59 2011(r217914)
+++ head/sys/kern/kern_sysctl.c Wed Jan 26 22:48:09 2011(r217915)
@@ -1206,7 +1206,7 @@ kernel_sysctl(struct thread *td, int *na
 
req.oldfunc = sysctl_old_kernel;
req.newfunc = sysctl_new_kernel;
-   req.lock = REQ_LOCKED;
+   req.lock = REQ_UNWIRED;
 
SYSCTL_XLOCK();
error = sysctl_root(0, name, namelen, req);
@@ -1314,7 +1314,7 @@ sysctl_wire_old_buffer(struct sysctl_req
 
wiredlen = (len  0  len  req-oldlen) ? len : req-oldlen;
ret = 0;
-   if (req-lock == REQ_LOCKED  req-oldptr 
+   if (req-lock != REQ_WIRED  req-oldptr 
req-oldfunc == sysctl_old_user) {
if (wiredlen != 0) {
ret = vslock(req-oldptr, wiredlen);
@@ -1350,8 +1350,6 @@ sysctl_find_oid(int *name, u_int namelen
return (ENOENT);
 
indx++;
-   if (oid-oid_kind  CTLFLAG_NOLOCK)
-   req-lock = REQ_UNLOCKED;
if ((oid-oid_kind  CTLTYPE) == CTLTYPE_NODE) {
if (oid-oid_handler != NULL || indx == namelen) {
*noid = oid;
@@ -1548,7 +1546,7 @@ userland_sysctl(struct thread *td, int *
 
req.oldfunc = sysctl_old_user;
req.newfunc = sysctl_new_user;
-   req.lock = REQ_LOCKED;
+   req.lock = REQ_UNWIRED;
 
 #ifdef KTRACE
if (KTRPOINT(curthread, KTR_SYSCTL))

Modified: head/sys/sys/sysctl.h
==
--- head/sys/sys/sysctl.h   Wed Jan 26 21:59:59 2011(r217914)
+++ head/sys/sys/sysctl.h   Wed Jan 26 22:48:09 2011(r217915)
@@ -77,7 +77,6 @@ struct ctlname {
 #define CTLFLAG_RD 0x8000  /* Allow reads of variable */
 #define CTLFLAG_WR 0x4000  /* Allow writes to the variable */
 #define CTLFLAG_RW (CTLFLAG_RD|CTLFLAG_WR)
-#define CTLFLAG_NOLOCK 0x2000  /* XXX Don't Lock */
 #define CTLFLAG_ANYBODY0x1000  /* All users can set this var */
 #define CTLFLAG_SECURE 0x0800  /* Permit set only if securelevel=0 */
 #define CTLFLAG_PRISON 0x0400  /* Prisoned roots can fiddle */
@@ -122,9 +121,8 @@ struct ctlname {
struct sysctl_req *req
 
 /* definitions for sysctl_req 'lock' member */
-#define REQ_UNLOCKED   0   /* not locked and not wired */
-#define REQ_LOCKED 1   /* locked and not wired */
-#define REQ_WIRED  2   /* locked and wired */
+#defineREQ_UNWIRED 1
+#defineREQ_WIRED   2
 
 /* definitions for sysctl_req 'flags' member */
 #if defined(__amd64__) || defined(__ia64__) || defined(__powerpc64__)
@@ -137,7 +135,7 @@ struct ctlname {
  */
 struct sysctl_req {
struct thread   *td;/* used for access checking */
-   int lock;   /* locking/wiring state */
+   int lock;   /* wiring state */
void*oldptr;
size_t  oldlen;
size_t  oldidx;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r217916 - in head: share/man/man9 sys/dev/cxgb sys/kern sys/vm

2011-01-26 Thread Matthew D Fleming
Author: mdf
Date: Thu Jan 27 00:34:12 2011
New Revision: 217916
URL: http://svn.freebsd.org/changeset/base/217916

Log:
  Explicitly wire the user buffer rather than doing it implicitly in
  sbuf_new_for_sysctl(9).  This allows using an sbuf with a SYSCTL_OUT
  drain for extremely large amounts of data where the caller knows that
  appropriate references are held, and sleeping is not an issue.
  
  Inspired by:  rwatson

Modified:
  head/share/man/man9/sbuf.9
  head/sys/dev/cxgb/cxgb_sge.c
  head/sys/kern/kern_malloc.c
  head/sys/kern/kern_sysctl.c
  head/sys/kern/subr_lock.c
  head/sys/kern/subr_sleepqueue.c
  head/sys/kern/subr_witness.c
  head/sys/vm/uma_core.c
  head/sys/vm/vm_phys.c
  head/sys/vm/vm_reserv.c

Modified: head/share/man/man9/sbuf.9
==
--- head/share/man/man9/sbuf.9  Wed Jan 26 22:48:09 2011(r217915)
+++ head/share/man/man9/sbuf.9  Thu Jan 27 00:34:12 2011(r217916)
@@ -177,9 +177,9 @@ The
 function will set up an sbuf with a drain function to use
 .Fn SYSCTL_OUT
 when the internal buffer fills.
-The sysctl old buffer will be wired, which allows for doing an
-.Fn sbuf_printf
-while holding a mutex.
+Note that if the various functions which append to an sbuf are used while
+a non-sleepable lock is held, the user buffer should be wired using
+.Fn sysctl_wire_old_buffer .
 .Pp
 The
 .Fn sbuf_delete

Modified: head/sys/dev/cxgb/cxgb_sge.c
==
--- head/sys/dev/cxgb/cxgb_sge.cWed Jan 26 22:48:09 2011
(r217915)
+++ head/sys/dev/cxgb/cxgb_sge.cThu Jan 27 00:34:12 2011
(r217916)
@@ -3251,7 +3251,9 @@ t3_dump_rspq(SYSCTL_HANDLER_ARGS)
err = t3_sge_read_rspq(qs-port-adapter, rspq-cntxt_id, data);
if (err)
return (err);
-
+   err = sysctl_wire_old_buffer(req, 0);
+   if (err)
+   return (err);
sb = sbuf_new_for_sysctl(NULL, NULL, QDUMP_SBUF_SIZE, req);
 
sbuf_printf(sb,  \n index=%u size=%u MSI-X/RspQ=%u intr enable=%u intr 
armed=%u\n,
@@ -3316,7 +3318,9 @@ t3_dump_txq_eth(SYSCTL_HANDLER_ARGS)
err = t3_sge_read_ecntxt(qs-port-adapter, qs-rspq.cntxt_id, data);
if (err)
return (err);
-   
+   err = sysctl_wire_old_buffer(req, 0);
+   if (err)
+   return (err);
sb = sbuf_new_for_sysctl(NULL, NULL, QDUMP_SBUF_SIZE, req);
 
sbuf_printf(sb,  \n credits=%u GTS=%u index=%u size=%u rspq#=%u 
cmdq#=%u\n,
@@ -3381,6 +3385,9 @@ t3_dump_txq_ctrl(SYSCTL_HANDLER_ARGS)
return (EINVAL);
}
 
+   err = sysctl_wire_old_buffer(req, 0);
+   if (err != 0)
+   return (err);
sb = sbuf_new_for_sysctl(NULL, NULL, QDUMP_SBUF_SIZE, req);
sbuf_printf(sb,  qid=%d start=%d - end=%d\n, qs-idx,
txq-txq_dump_start,

Modified: head/sys/kern/kern_malloc.c
==
--- head/sys/kern/kern_malloc.c Wed Jan 26 22:48:09 2011(r217915)
+++ head/sys/kern/kern_malloc.c Thu Jan 27 00:34:12 2011(r217916)
@@ -862,6 +862,9 @@ sysctl_kern_malloc_stats(SYSCTL_HANDLER_
int error, i;
struct sbuf sbuf;
 
+   error = sysctl_wire_old_buffer(req, 0);
+   if (error != 0)
+   return (error);
sbuf_new_for_sysctl(sbuf, NULL, 128, req);
mtx_lock(malloc_mtx);
 
@@ -1019,6 +1022,9 @@ sysctl_kern_mprof(SYSCTL_HANDLER_ARGS)
waste = 0;
mem = 0;
 
+   error = sysctl_wire_old_buffer(req, 0);
+   if (error != 0)
+   return (error);
sbuf_new_for_sysctl(sbuf, NULL, 128, req);
sbuf_printf(sbuf, 
\n  SizeRequests  Real Size\n);

Modified: head/sys/kern/kern_sysctl.c
==
--- head/sys/kern/kern_sysctl.c Wed Jan 26 22:48:09 2011(r217915)
+++ head/sys/kern/kern_sysctl.c Thu Jan 27 00:34:12 2011(r217916)
@@ -1591,7 +1591,8 @@ userland_sysctl(struct thread *td, int *
 }
 
 /*
- * Drain into a sysctl struct.  The user buffer must be wired.
+ * Drain into a sysctl struct.  The user buffer should be wired if a page
+ * fault would cause issue.
  */
 static int
 sbuf_sysctl_drain(void *arg, const char *data, int len)
@@ -1609,9 +1610,6 @@ sbuf_new_for_sysctl(struct sbuf *s, char
 struct sysctl_req *req)
 {
 
-   /* Wire the user buffer, so we can write without blocking. */
-   sysctl_wire_old_buffer(req, 0);
-
s = sbuf_new(s, buf, length, SBUF_FIXEDLEN);
sbuf_set_drain(s, sbuf_sysctl_drain, req);
return (s);

Modified: head/sys/kern/subr_lock.c
==
--- head/sys/kern/subr_lock.c   Wed Jan 26 22:48:09 2011(r217915)
+++ head/sys/kern/subr_lock.c   Thu Jan 27 

svn commit: r217830 - head/share/man/man9

2011-01-25 Thread Matthew D Fleming
Author: mdf
Date: Tue Jan 25 17:39:52 2011
New Revision: 217830
URL: http://svn.freebsd.org/changeset/base/217830

Log:
  Document sbuf_new_for_sysctl(9).
  
  Pointed out by:   lstewart

Modified:
  head/share/man/man9/Makefile
  head/share/man/man9/sbuf.9

Modified: head/share/man/man9/Makefile
==
--- head/share/man/man9/MakefileTue Jan 25 17:15:23 2011
(r217829)
+++ head/share/man/man9/MakefileTue Jan 25 17:39:52 2011
(r217830)
@@ -1031,6 +1031,7 @@ MLINKS+=sbuf.9 sbuf_bcat.9 \
sbuf.9 sbuf_finish.9 \
sbuf.9 sbuf_len.9 \
sbuf.9 sbuf_new.9 \
+   sbuf.9 sbuf_new_for_sysctl.9 \
sbuf.9 sbuf_printf.9 \
sbuf.9 sbuf_putc.9 \
sbuf.9 sbuf_set_drain.9 \

Modified: head/share/man/man9/sbuf.9
==
--- head/share/man/man9/sbuf.9  Tue Jan 25 17:15:23 2011(r217829)
+++ head/share/man/man9/sbuf.9  Tue Jan 25 17:39:52 2011(r217830)
@@ -25,13 +25,14 @@
 .\
 .\ $FreeBSD$
 .\
-.Dd May 17, 2009
+.Dd January 25, 2011
 .Dt SBUF 9
 .Os
 .Sh NAME
 .Nm sbuf ,
 .Nm sbuf_new ,
 .Nm sbuf_new_auto ,
+.Nm sbuf_new_for_sysctl ,
 .Nm sbuf_clear ,
 .Nm sbuf_setpos ,
 .Nm sbuf_bcat ,
@@ -99,6 +100,9 @@
 .Fn sbuf_done struct sbuf *s
 .Ft void
 .Fn sbuf_delete struct sbuf *s
+.In sys/sysctl.h
+.Ft struct sbuf *
+.Fn sbuf_new_for_sysctl struct sbuf *s char *buf int length struct 
sysctl_req *req
 .Sh DESCRIPTION
 The
 .Nm
@@ -169,6 +173,15 @@ and
 .Dv SBUF_AUTOEXTEND .
 .Pp
 The
+.Fn sbuf_new_for_sysctl
+function will set up an sbuf with a drain function to use
+.Fn SYSCTL_OUT
+when the internal buffer fills.
+The sysctl old buffer will be wired, which allows for doing an
+.Fn sbuf_printf
+while holding a mutex.
+.Pp
+The
 .Fn sbuf_delete
 function clears the
 .Fa sbuf
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r217586 - in head: sbin/sysctl share/man/man9 sys/cam/scsi sys/dev/cxgb sys/dev/wi sys/net sys/sys

2011-01-19 Thread Matthew D Fleming
Author: mdf
Date: Wed Jan 19 17:04:07 2011
New Revision: 217586
URL: http://svn.freebsd.org/changeset/base/217586

Log:
  sysctl(8) should use the CTLTYPE to determine the type of data when
  reading.  (This was already done for writing to a sysctl).  This
  requires all SYSCTL setups to specify a type.  Most of them are now
  checked at compile-time.
  
  Remove SYSCTL_*X* sysctl additions as the print being in hex should be
  controlled by the -x flag to sysctl(8).
  
  Succested by: bde

Modified:
  head/sbin/sysctl/sysctl.c
  head/share/man/man9/Makefile
  head/share/man/man9/sysctl.9
  head/sys/cam/scsi/scsi_da.c
  head/sys/dev/cxgb/cxgb_sge.c
  head/sys/dev/wi/if_wi.c
  head/sys/net/if_enc.c
  head/sys/net/vnet.h
  head/sys/sys/sysctl.h

Modified: head/sbin/sysctl/sysctl.c
==
--- head/sbin/sysctl/sysctl.c   Wed Jan 19 16:55:32 2011(r217585)
+++ head/sbin/sysctl/sysctl.c   Wed Jan 19 17:04:07 2011(r217586)
@@ -510,7 +510,7 @@ show_var(int *oid, int nlen)
int qoid[CTL_MAXNAME+2];
uintmax_t umv;
intmax_t mv;
-   int i, hexlen;
+   int i, hexlen, sign, ctltype;
size_t intlen;
size_t j, len;
u_int kind;
@@ -575,46 +575,57 @@ show_var(int *oid, int nlen)
fmt = buf;
oidfmt(oid, nlen, fmt, kind);
p = val;
-   switch (*fmt) {
-   case 'A':
+   ctltype = (kind  CTLTYPE);
+   sign = (ctltype == CTLTYPE_INT || ctltype == CTLTYPE_LONG) ? 1 : 0;
+   switch (ctltype) {
+   case CTLTYPE_STRING:
if (!nflag)
printf(%s%s, name, sep);
printf(%.*s, (int)len, p);
free(oval);
return (0);
 
-   case 'I':
-   case 'L':
-   case 'Q':
+   case CTLTYPE_INT:
+   case CTLTYPE_UINT:
+   case CTLTYPE_LONG:
+   case CTLTYPE_ULONG:
+   case CTLTYPE_QUAD:
if (!nflag)
printf(%s%s, name, sep);
-   switch (*fmt) {
-   case 'I': intlen = sizeof(int); break;
-   case 'L': intlen = sizeof(long); break;
-   case 'Q': intlen = sizeof(quad_t); break;
+   switch (kind  CTLTYPE) {
+   case CTLTYPE_INT:
+   case CTLTYPE_UINT:
+   intlen = sizeof(int); break;
+   case CTLTYPE_LONG:
+   case CTLTYPE_ULONG:
+   intlen = sizeof(long); break;
+   case CTLTYPE_QUAD:
+   intlen = sizeof(quad_t); break;
}
hexlen = 2 + (intlen * CHAR_BIT + 3) / 4;
sep1 = ;
while (len = intlen) {
-   switch (*fmt) {
-   case 'I':
+   switch (kind  CTLTYPE) {
+   case CTLTYPE_INT:
+   case CTLTYPE_UINT:
umv = *(u_int *)p;
mv = *(int *)p;
break;
-   case 'L':
+   case CTLTYPE_LONG:
+   case CTLTYPE_ULONG:
umv = *(u_long *)p;
mv = *(long *)p;
break;
-   case 'Q':
+   case CTLTYPE_QUAD:
umv = *(u_quad_t *)p;
mv = *(quad_t *)p;
break;
}
fputs(sep1, stdout);
-   if (fmt[1] == 'U')
-   printf(hflag ? %'ju : %ju, umv);
-   else if (fmt[1] == 'X')
+   if (xflag)
printf(%#0*jx, hexlen, umv);
+   else if (!sign)
+   printf(hflag ? %'ju : %ju, umv);
else if (fmt[1] == 'K') {
if (mv  0)
printf(%jd, mv);
@@ -629,14 +640,7 @@ show_var(int *oid, int nlen)
free(oval);
return (0);
 
-   case 'P':
-   if (!nflag)
-   printf(%s%s, name, sep);
-   printf(%p, *(void **)p);
-   free(oval);
-   return (0);
-
-   case 'S':
+   case CTLTYPE_OPAQUE:
i = 0;
if (strcmp(fmt, S,clockinfo) == 0)
func = S_clockinfo;

Modified: head/share/man/man9/Makefile
==
--- head/share/man/man9/MakefileWed Jan 19 16:55:32 2011
(r217585)
+++ head/share/man/man9/MakefileWed Jan 19 17:04:07 2011
(r217586)
@@ -1193,8 +1193,7 @@ MLINKS+=sysctl.9 SYSCTL_DECL.9 \
sysctl.9 

svn commit: r217555 - head/sys/kern

2011-01-18 Thread Matthew D Fleming
Author: mdf
Date: Tue Jan 18 21:14:18 2011
New Revision: 217555
URL: http://svn.freebsd.org/changeset/base/217555

Log:
  Specify a CTLTYPE_FOO so that a future sysctl(8) change does not need
  to rely on the format string.

Modified:
  head/sys/kern/kern_linker.c
  head/sys/kern/kern_sysctl.c
  head/sys/kern/subr_bus.c
  head/sys/kern/sysv_msg.c
  head/sys/kern/sysv_sem.c
  head/sys/kern/sysv_shm.c
  head/sys/kern/uipc_usrreq.c
  head/sys/kern/vfs_subr.c

Modified: head/sys/kern/kern_linker.c
==
--- head/sys/kern/kern_linker.c Tue Jan 18 21:14:13 2011(r217554)
+++ head/sys/kern/kern_linker.c Tue Jan 18 21:14:18 2011(r217555)
@@ -2145,5 +2145,5 @@ sysctl_kern_function_list(SYSCTL_HANDLER
return (SYSCTL_OUT(req, , 1));
 }
 
-SYSCTL_PROC(_kern, OID_AUTO, function_list, CTLFLAG_RD,
+SYSCTL_PROC(_kern, OID_AUTO, function_list, CTLTYPE_OPAQUE | CTLFLAG_RD,
 NULL, 0, sysctl_kern_function_list, , kernel function list);

Modified: head/sys/kern/kern_sysctl.c
==
--- head/sys/kern/kern_sysctl.c Tue Jan 18 21:14:13 2011(r217554)
+++ head/sys/kern/kern_sysctl.c Tue Jan 18 21:14:18 2011(r217555)
@@ -876,7 +876,8 @@ sysctl_sysctl_name2oid(SYSCTL_HANDLER_AR
return (error);
 }
 
-SYSCTL_PROC(_sysctl, 3, name2oid, CTLFLAG_RW|CTLFLAG_ANYBODY|CTLFLAG_MPSAFE,
+SYSCTL_PROC(_sysctl, 3, name2oid,
+CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_ANYBODY | CTLFLAG_MPSAFE,
 0, 0, sysctl_sysctl_name2oid, I, );
 
 static int

Modified: head/sys/kern/subr_bus.c
==
--- head/sys/kern/subr_bus.cTue Jan 18 21:14:13 2011(r217554)
+++ head/sys/kern/subr_bus.cTue Jan 18 21:14:18 2011(r217555)
@@ -226,7 +226,7 @@ devclass_sysctl_init(devclass_t dc)
SYSCTL_STATIC_CHILDREN(_dev), OID_AUTO, dc-name,
CTLFLAG_RD, NULL, );
SYSCTL_ADD_PROC(dc-sysctl_ctx, SYSCTL_CHILDREN(dc-sysctl_tree),
-   OID_AUTO, %parent, CTLFLAG_RD,
+   OID_AUTO, %parent, CTLTYPE_STRING | CTLFLAG_RD,
dc, DEVCLASS_SYSCTL_PARENT, devclass_sysctl_handler, A,
parent class);
 }
@@ -289,23 +289,23 @@ device_sysctl_init(device_t dev)
dev-nameunit + strlen(dc-name),
CTLFLAG_RD, NULL, );
SYSCTL_ADD_PROC(dev-sysctl_ctx, SYSCTL_CHILDREN(dev-sysctl_tree),
-   OID_AUTO, %desc, CTLFLAG_RD,
+   OID_AUTO, %desc, CTLTYPE_STRING | CTLFLAG_RD,
dev, DEVICE_SYSCTL_DESC, device_sysctl_handler, A,
device description);
SYSCTL_ADD_PROC(dev-sysctl_ctx, SYSCTL_CHILDREN(dev-sysctl_tree),
-   OID_AUTO, %driver, CTLFLAG_RD,
+   OID_AUTO, %driver, CTLTYPE_STRING | CTLFLAG_RD,
dev, DEVICE_SYSCTL_DRIVER, device_sysctl_handler, A,
device driver name);
SYSCTL_ADD_PROC(dev-sysctl_ctx, SYSCTL_CHILDREN(dev-sysctl_tree),
-   OID_AUTO, %location, CTLFLAG_RD,
+   OID_AUTO, %location, CTLTYPE_STRING | CTLFLAG_RD,
dev, DEVICE_SYSCTL_LOCATION, device_sysctl_handler, A,
device location relative to parent);
SYSCTL_ADD_PROC(dev-sysctl_ctx, SYSCTL_CHILDREN(dev-sysctl_tree),
-   OID_AUTO, %pnpinfo, CTLFLAG_RD,
+   OID_AUTO, %pnpinfo, CTLTYPE_STRING | CTLFLAG_RD,
dev, DEVICE_SYSCTL_PNPINFO, device_sysctl_handler, A,
device identification);
SYSCTL_ADD_PROC(dev-sysctl_ctx, SYSCTL_CHILDREN(dev-sysctl_tree),
-   OID_AUTO, %parent, CTLFLAG_RD,
+   OID_AUTO, %parent, CTLTYPE_STRING | CTLFLAG_RD,
dev, DEVICE_SYSCTL_PARENT, device_sysctl_handler, A,
parent device);
 }

Modified: head/sys/kern/sysv_msg.c
==
--- head/sys/kern/sysv_msg.cTue Jan 18 21:14:13 2011(r217554)
+++ head/sys/kern/sysv_msg.cTue Jan 18 21:14:18 2011(r217555)
@@ -1284,7 +1284,7 @@ SYSCTL_INT(_kern_ipc, OID_AUTO, msgssz, 
 Size of a message segment);
 SYSCTL_INT(_kern_ipc, OID_AUTO, msgseg, CTLFLAG_RDTUN, msginfo.msgseg, 0,
 Number of message segments);
-SYSCTL_PROC(_kern_ipc, OID_AUTO, msqids, CTLFLAG_RD,
+SYSCTL_PROC(_kern_ipc, OID_AUTO, msqids, CTLTYPE_OPAQUE | CTLFLAG_RD,
 NULL, 0, sysctl_msqids, , Message queue IDs);
 
 #ifdef COMPAT_FREEBSD32

Modified: head/sys/kern/sysv_sem.c
==
--- head/sys/kern/sysv_sem.cTue Jan 18 21:14:13 2011(r217554)
+++ head/sys/kern/sysv_sem.cTue Jan 18 21:14:18 2011(r217555)
@@ -211,7 +211,7 @@ SYSCTL_INT(_kern_ipc, OID_AUTO, semvmx, 
 Semaphore maximum value);
 SYSCTL_INT(_kern_ipc, OID_AUTO, semaem, CTLFLAG_RW, seminfo.semaem, 0,
 Adjust on exit max value);
-SYSCTL_PROC(_kern_ipc, OID_AUTO, 

svn commit: r217556 - in head/sys/dev: e1000 en fatm iscsi/initiator ixgbe patm usb/net

2011-01-18 Thread Matthew D Fleming
Author: mdf
Date: Tue Jan 18 21:14:23 2011
New Revision: 217556
URL: http://svn.freebsd.org/changeset/base/217556

Log:
  Specify a CTLTYPE_FOO so that a future sysctl(8) change does not need
  to rely on the format string.

Modified:
  head/sys/dev/e1000/if_em.c
  head/sys/dev/e1000/if_igb.c
  head/sys/dev/e1000/if_lem.c
  head/sys/dev/en/midway.c
  head/sys/dev/fatm/if_fatm.c
  head/sys/dev/iscsi/initiator/isc_sm.c
  head/sys/dev/ixgbe/ixgbe.c
  head/sys/dev/patm/if_patm_attach.c
  head/sys/dev/usb/net/usb_ethernet.c

Modified: head/sys/dev/e1000/if_em.c
==
--- head/sys/dev/e1000/if_em.c  Tue Jan 18 21:14:18 2011(r217555)
+++ head/sys/dev/e1000/if_em.c  Tue Jan 18 21:14:23 2011(r217556)
@@ -5082,11 +5082,11 @@ em_add_hw_stats(struct adapter *adapter)
Watchdog timeouts);

SYSCTL_ADD_PROC(ctx, child, OID_AUTO, device_control,
-   CTLFLAG_RD, adapter, E1000_CTRL,
+   CTLTYPE_UINT | CTLFLAG_RD, adapter, E1000_CTRL,
em_sysctl_reg_handler, IU,
Device Control Register);
SYSCTL_ADD_PROC(ctx, child, OID_AUTO, rx_control,
-   CTLFLAG_RD, adapter, E1000_RCTL,
+   CTLTYPE_UINT | CTLFLAG_RD, adapter, E1000_RCTL,
em_sysctl_reg_handler, IU,
Receiver Control Register);
SYSCTL_ADD_UINT(ctx, child, OID_AUTO, fc_high_water,
@@ -5103,11 +5103,13 @@ em_add_hw_stats(struct adapter *adapter)
queue_list = SYSCTL_CHILDREN(queue_node);
 
SYSCTL_ADD_PROC(ctx, queue_list, OID_AUTO, txd_head, 
-   CTLFLAG_RD, adapter, E1000_TDH(txr-me),
+   CTLTYPE_UINT | CTLFLAG_RD, adapter,
+   E1000_TDH(txr-me),
em_sysctl_reg_handler, IU,
Transmit Descriptor Head);
SYSCTL_ADD_PROC(ctx, queue_list, OID_AUTO, txd_tail, 
-   CTLFLAG_RD, adapter, E1000_TDT(txr-me),
+   CTLTYPE_UINT | CTLFLAG_RD, adapter,
+   E1000_TDT(txr-me),
em_sysctl_reg_handler, IU,
Transmit Descriptor Tail);
SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO, tx_irq,
@@ -5118,11 +5120,13 @@ em_add_hw_stats(struct adapter *adapter)
Queue No Descriptor Available);

SYSCTL_ADD_PROC(ctx, queue_list, OID_AUTO, rxd_head, 
-   CTLFLAG_RD, adapter, E1000_RDH(rxr-me),
+   CTLTYPE_UINT | CTLFLAG_RD, adapter,
+   E1000_RDH(rxr-me),
em_sysctl_reg_handler, IU,
Receive Descriptor Head);
SYSCTL_ADD_PROC(ctx, queue_list, OID_AUTO, rxd_tail, 
-   CTLFLAG_RD, adapter, E1000_RDT(rxr-me),
+   CTLTYPE_UINT | CTLFLAG_RD, adapter,
+   E1000_RDT(rxr-me),
em_sysctl_reg_handler, IU,
Receive Descriptor Tail);
SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO, rx_irq,

Modified: head/sys/dev/e1000/if_igb.c
==
--- head/sys/dev/e1000/if_igb.c Tue Jan 18 21:14:18 2011(r217555)
+++ head/sys/dev/e1000/if_igb.c Tue Jan 18 21:14:23 2011(r217556)
@@ -5120,17 +5120,19 @@ igb_add_hw_stats(struct adapter *adapter
queue_list = SYSCTL_CHILDREN(queue_node);
 
SYSCTL_ADD_PROC(ctx, queue_list, OID_AUTO, interrupt_rate, 
-   CTLFLAG_RD, adapter-queues[i],
+   CTLTYPE_UINT | CTLFLAG_RD, adapter-queues[i],
sizeof(adapter-queues[i]),
igb_sysctl_interrupt_rate_handler,
IU, Interrupt Rate);
 
SYSCTL_ADD_PROC(ctx, queue_list, OID_AUTO, txd_head, 
-   CTLFLAG_RD, adapter, E1000_TDH(txr-me),
+   CTLTYPE_UINT | CTLFLAG_RD, adapter,
+   E1000_TDH(txr-me),
igb_sysctl_reg_handler, IU,
Transmit Descriptor Head);
SYSCTL_ADD_PROC(ctx, queue_list, OID_AUTO, txd_tail, 
-   CTLFLAG_RD, adapter, E1000_TDT(txr-me),
+   CTLTYPE_UINT | CTLFLAG_RD, adapter,
+   E1000_TDT(txr-me),
igb_sysctl_reg_handler, IU,

svn commit: r217566 - in head: share/examples/kld/dyn_sysctl sys/compat/ndis sys/dev/acpi_support sys/dev/acpica sys/dev/msk sys/dev/patm sys/dev/xen/netback sys/xen/xenbus

2011-01-18 Thread Matthew D Fleming
Author: mdf
Date: Wed Jan 19 00:57:58 2011
New Revision: 217566
URL: http://svn.freebsd.org/changeset/base/217566

Log:
  Fix a few more SYSCTL_PROC() that were missing a CTLFLAG type specifier.

Modified:
  head/share/examples/kld/dyn_sysctl/dyn_sysctl.c
  head/sys/compat/ndis/subr_ntoskrnl.c
  head/sys/dev/acpi_support/acpi_ibm.c
  head/sys/dev/acpi_support/atk0110.c
  head/sys/dev/acpica/acpi_video.c
  head/sys/dev/msk/if_msk.c
  head/sys/dev/patm/if_patm_attach.c
  head/sys/dev/xen/netback/netback.c
  head/sys/xen/xenbus/xenbusb.c

Modified: head/share/examples/kld/dyn_sysctl/dyn_sysctl.c
==
--- head/share/examples/kld/dyn_sysctl/dyn_sysctl.c Tue Jan 18 23:35:08 
2011(r217565)
+++ head/share/examples/kld/dyn_sysctl/dyn_sysctl.c Wed Jan 19 00:57:58 
2011(r217566)
@@ -100,8 +100,9 @@ load(module_t mod, int cmd, void *arg)
return (EINVAL);
}
SYSCTL_ADD_PROC(clist, SYSCTL_CHILDREN(a_root1),
-   OID_AUTO, procedure, CTLFLAG_RD, 0, 0,
-   sysctl_dyn_sysctl_test, A, I can be here, too);
+   OID_AUTO, procedure, CTLTYPE_STRING | CTLFLAG_RD,
+   NULL, 0, sysctl_dyn_sysctl_test, A,
+   I can be here, too);
printf(   (%p) /kern dyn_sysctl\n, clist);
 
/* Overlap second tree with the first. */

Modified: head/sys/compat/ndis/subr_ntoskrnl.c
==
--- head/sys/compat/ndis/subr_ntoskrnl.cTue Jan 18 23:35:08 2011
(r217565)
+++ head/sys/compat/ndis/subr_ntoskrnl.cWed Jan 19 00:57:58 2011
(r217566)
@@ -80,8 +80,9 @@ __FBSDID($FreeBSD$);
 #ifdef NTOSKRNL_DEBUG_TIMERS
 static int sysctl_show_timers(SYSCTL_HANDLER_ARGS);
 
-SYSCTL_PROC(_debug, OID_AUTO, ntoskrnl_timers, CTLFLAG_RW, 0, 0,
-   sysctl_show_timers, I, Show ntoskrnl timer stats);
+SYSCTL_PROC(_debug, OID_AUTO, ntoskrnl_timers, CTLTYPE_INT | CTLFLAG_RW,
+NULL, 0, sysctl_show_timers, I,
+Show ntoskrnl timer stats);
 #endif
 
 struct kdpc_queue {

Modified: head/sys/dev/acpi_support/acpi_ibm.c
==
--- head/sys/dev/acpi_support/acpi_ibm.cTue Jan 18 23:35:08 2011
(r217565)
+++ head/sys/dev/acpi_support/acpi_ibm.cWed Jan 19 00:57:58 2011
(r217566)
@@ -399,7 +399,7 @@ acpi_ibm_attach(device_t dev)
if (acpi_ibm_sysctl_init(sc, ACPI_IBM_METHOD_THERMAL)) {
SYSCTL_ADD_PROC(sc-sysctl_ctx,
SYSCTL_CHILDREN(sc-sysctl_tree), OID_AUTO,
-   thermal, CTLTYPE_STRING | CTLFLAG_RD,
+   thermal, CTLTYPE_INT | CTLFLAG_RD,
sc, 0, acpi_ibm_thermal_sysctl, I,
Thermal zones);
}

Modified: head/sys/dev/acpi_support/atk0110.c
==
--- head/sys/dev/acpi_support/atk0110.c Tue Jan 18 23:35:08 2011
(r217565)
+++ head/sys/dev/acpi_support/atk0110.c Wed Jan 19 00:57:58 2011
(r217566)
@@ -258,7 +258,7 @@ aibs_attach_sif(struct aibs_softc *sc, e
 #endif
snprintf(si, sizeof(si), %i, i);
SYSCTL_ADD_PROC(device_get_sysctl_ctx(sc-sc_dev),
-   SYSCTL_CHILDREN(so), i, si, CTLTYPE_OPAQUE | CTLFLAG_RD,
+   SYSCTL_CHILDREN(so), i, si, CTLTYPE_INT | CTLFLAG_RD,
sc, st, aibs_sysctl, st == AIBS_TEMP ? IK : I, desc);
}
 

Modified: head/sys/dev/acpica/acpi_video.c
==
--- head/sys/dev/acpica/acpi_video.cTue Jan 18 23:35:08 2011
(r217565)
+++ head/sys/dev/acpica/acpi_video.cWed Jan 19 00:57:58 2011
(r217566)
@@ -537,7 +537,7 @@ acpi_video_vo_init(UINT32 adr)
SYSCTL_ADD_PROC(vo-vo_sysctl_ctx,
SYSCTL_CHILDREN(vo-vo_sysctl_tree),
OID_AUTO, levels,
-   CTLTYPE_OPAQUE|CTLFLAG_RD, vo, 0,
+   CTLTYPE_INT | CTLFLAG_RD, vo, 0,
acpi_video_vo_levels_sysctl, I,
supported brightness levels);
} else

Modified: head/sys/dev/msk/if_msk.c
==
--- head/sys/dev/msk/if_msk.c   Tue Jan 18 23:35:08 2011(r217565)
+++ head/sys/dev/msk/if_msk.c   Wed Jan 19 00:57:58 2011(r217566)
@@ -4389,7 +4389,7 @@ msk_sysctl_stat64(SYSCTL_HANDLER_ARGS)
sc, offsetof(struct msk_hw_stats, n), msk_sysctl_stat32,\
IU, d)
 #define MSK_SYSCTL_STAT64(sc, c, o, p, n, d)   \
-   SYSCTL_ADD_PROC(c, p, OID_AUTO, o, CTLTYPE_UINT 

svn commit: r217522 - head/sbin/sysctl

2011-01-17 Thread Matthew D Fleming
Author: mdf
Date: Mon Jan 17 23:43:03 2011
New Revision: 217522
URL: http://svn.freebsd.org/changeset/base/217522

Log:
  Fix typo and bump date.

Modified:
  head/sbin/sysctl/sysctl.8

Modified: head/sbin/sysctl/sysctl.8
==
--- head/sbin/sysctl/sysctl.8   Mon Jan 17 23:36:53 2011(r217521)
+++ head/sbin/sysctl/sysctl.8   Mon Jan 17 23:43:03 2011(r217522)
@@ -28,7 +28,7 @@
 .\From: @(#)sysctl.8  8.1 (Berkeley) 6/6/93
 .\ $FreeBSD$
 .\
-.Dd February 6, 2010
+.Dd January 17, 2011
 .Dt SYSCTL 8
 .Os
 .Sh NAME
@@ -163,7 +163,7 @@ For a detailed description of these vari
 .Pp
 The changeable column indicates whether a process with appropriate
 privilege can change the value.
-String, and integer values can be set using
+String and integer values can be set using
 .Nm .
 .Bl -column security.bsd.unprivileged_read_msgbuf integerxxx
 .It Sy Name   TypeChangeable
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r217368 - in head/sys: amd64/amd64 cam dev/ath dev/sound/pcm kern

2011-01-13 Thread Matthew D Fleming
Author: mdf
Date: Thu Jan 13 18:20:27 2011
New Revision: 217368
URL: http://svn.freebsd.org/changeset/base/217368

Log:
  Fix up a few more sysctl(9) mis-typing found in various LINT builds.

Modified:
  head/sys/amd64/amd64/mp_machdep.c
  head/sys/cam/cam_xpt.c
  head/sys/dev/ath/if_ath.c
  head/sys/dev/sound/pcm/buffer.c
  head/sys/kern/kern_ntptime.c

Modified: head/sys/amd64/amd64/mp_machdep.c
==
--- head/sys/amd64/amd64/mp_machdep.c   Thu Jan 13 18:20:19 2011
(r217367)
+++ head/sys/amd64/amd64/mp_machdep.c   Thu Jan 13 18:20:27 2011
(r217368)
@@ -1045,23 +1045,23 @@ u_int ipi_global;
 u_int ipi_page;
 u_int ipi_range;
 u_int ipi_range_size;
-SYSCTL_INT(_debug_xhits, OID_AUTO, ipi_global, CTLFLAG_RW, ipi_global, 0, );
-SYSCTL_INT(_debug_xhits, OID_AUTO, ipi_page, CTLFLAG_RW, ipi_page, 0, );
-SYSCTL_INT(_debug_xhits, OID_AUTO, ipi_range, CTLFLAG_RW, ipi_range, 0, );
-SYSCTL_INT(_debug_xhits, OID_AUTO, ipi_range_size, CTLFLAG_RW, ipi_range_size,
-0, );
+SYSCTL_UINT(_debug_xhits, OID_AUTO, ipi_global, CTLFLAG_RW, ipi_global, 0, 
);
+SYSCTL_UINT(_debug_xhits, OID_AUTO, ipi_page, CTLFLAG_RW, ipi_page, 0, );
+SYSCTL_UINT(_debug_xhits, OID_AUTO, ipi_range, CTLFLAG_RW, ipi_range, 0, );
+SYSCTL_UINT(_debug_xhits, OID_AUTO, ipi_range_size, CTLFLAG_RW,
+ipi_range_size, 0, );
 
 u_int ipi_masked_global;
 u_int ipi_masked_page;
 u_int ipi_masked_range;
 u_int ipi_masked_range_size;
-SYSCTL_INT(_debug_xhits, OID_AUTO, ipi_masked_global, CTLFLAG_RW,
+SYSCTL_UINT(_debug_xhits, OID_AUTO, ipi_masked_global, CTLFLAG_RW,
 ipi_masked_global, 0, );
-SYSCTL_INT(_debug_xhits, OID_AUTO, ipi_masked_page, CTLFLAG_RW,
+SYSCTL_UINT(_debug_xhits, OID_AUTO, ipi_masked_page, CTLFLAG_RW,
 ipi_masked_page, 0, );
-SYSCTL_INT(_debug_xhits, OID_AUTO, ipi_masked_range, CTLFLAG_RW,
+SYSCTL_UINT(_debug_xhits, OID_AUTO, ipi_masked_range, CTLFLAG_RW,
 ipi_masked_range, 0, );
-SYSCTL_INT(_debug_xhits, OID_AUTO, ipi_masked_range_size, CTLFLAG_RW,
+SYSCTL_UINT(_debug_xhits, OID_AUTO, ipi_masked_range_size, CTLFLAG_RW,
 ipi_masked_range_size, 0, );
 #endif /* COUNT_XINVLTLB_HITS */
 

Modified: head/sys/cam/cam_xpt.c
==
--- head/sys/cam/cam_xpt.c  Thu Jan 13 18:20:19 2011(r217367)
+++ head/sys/cam/cam_xpt.c  Thu Jan 13 18:20:27 2011(r217368)
@@ -197,11 +197,11 @@ u_int32_t cam_dflags = CAM_DEBUG_FLAGS;
 u_int32_t cam_dflags = CAM_DEBUG_NONE;
 #endif
 TUNABLE_INT(kern.cam.dflags, cam_dflags);
-SYSCTL_INT(_kern_cam, OID_AUTO, dflags, CTLFLAG_RW,
+SYSCTL_UINT(_kern_cam, OID_AUTO, dflags, CTLFLAG_RW,
cam_dflags, 0, Cam Debug Flags);
 u_int32_t cam_debug_delay;
 TUNABLE_INT(kern.cam.debug_delay, cam_debug_delay);
-SYSCTL_INT(_kern_cam, OID_AUTO, debug_delay, CTLFLAG_RW,
+SYSCTL_UINT(_kern_cam, OID_AUTO, debug_delay, CTLFLAG_RW,
cam_debug_delay, 0, Cam Debug Flags);
 #endif
 

Modified: head/sys/dev/ath/if_ath.c
==
--- head/sys/dev/ath/if_ath.c   Thu Jan 13 18:20:19 2011(r217367)
+++ head/sys/dev/ath/if_ath.c   Thu Jan 13 18:20:27 2011(r217368)
@@ -6648,17 +6648,17 @@ ath_sysctlattach(struct ath_softc *sc)
 #ifdef IEEE80211_SUPPORT_TDMA
if (ath_hal_macversion(ah)  0x78) {
sc-sc_tdmadbaprep = 2;
-   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
+   SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
dbaprep, CTLFLAG_RW, sc-sc_tdmadbaprep, 0,
TDMA DBA preparation time);
sc-sc_tdmaswbaprep = 10;
-   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
+   SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
swbaprep, CTLFLAG_RW, sc-sc_tdmaswbaprep, 0,
TDMA SWBA preparation time);
-   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
+   SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
guardtime, CTLFLAG_RW, sc-sc_tdmaguard, 0,
TDMA slot guard time);
-   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
+   SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
superframe, CTLFLAG_RD, sc-sc_tdmabintval, 0,
TDMA calculated super frame);
SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,

Modified: head/sys/dev/sound/pcm/buffer.c
==
--- head/sys/dev/sound/pcm/buffer.c Thu Jan 13 18:20:19 2011
(r217367)
+++ head/sys/dev/sound/pcm/buffer.c Thu Jan 13 18:20:27 2011
(r217368)
@@ -666,11 +666,11 @@ sndbuf_dispose(struct snd_dbuf *b, u_int
 
 #ifdef SND_DIAGNOSTIC
 static uint32_t 

svn commit: r217367 - in head: cddl/contrib/opensolaris/lib/libzpool/common/sys sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2011-01-13 Thread Matthew D Fleming
Author: mdf
Date: Thu Jan 13 18:20:19 2011
New Revision: 217367
URL: http://svn.freebsd.org/changeset/base/217367

Log:
  Re-commit the zfs sysctl(9) type-safety changes.
  
  Thanks to dim and pjd for the pointer to zfs_context.h for building
  userland.

Modified:
  head/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_zfetch.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/txg.c

Modified: head/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h
==
--- head/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h Thu Jan 
13 17:47:22 2011(r217366)
+++ head/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h Thu Jan 
13 18:20:19 2011(r217367)
@@ -601,6 +601,7 @@ typedef uint32_tidmap_rid_t;
 #defineSYSCTL_UINT(...)
 #defineSYSCTL_ULONG(...)
 #defineSYSCTL_QUAD(...)
+#defineSYSCTL_UQUAD(...)
 #ifdef TUNABLE_INT
 #undef TUNABLE_INT
 #undef TUNABLE_ULONG

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c   Thu Jan 13 
17:47:22 2011(r217366)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c   Thu Jan 13 
18:20:19 2011(r217367)
@@ -188,9 +188,9 @@ TUNABLE_QUAD(vfs.zfs.arc_min, zfs_arc
 TUNABLE_QUAD(vfs.zfs.arc_meta_limit, zfs_arc_meta_limit);
 TUNABLE_INT(vfs.zfs.mdcomp_disable, zfs_mdcomp_disable);
 SYSCTL_DECL(_vfs_zfs);
-SYSCTL_QUAD(_vfs_zfs, OID_AUTO, arc_max, CTLFLAG_RDTUN, zfs_arc_max, 0,
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, arc_max, CTLFLAG_RDTUN, zfs_arc_max, 0,
 Maximum ARC size);
-SYSCTL_QUAD(_vfs_zfs, OID_AUTO, arc_min, CTLFLAG_RDTUN, zfs_arc_min, 0,
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, arc_min, CTLFLAG_RDTUN, zfs_arc_min, 0,
 Minimum ARC size);
 SYSCTL_INT(_vfs_zfs, OID_AUTO, mdcomp_disable, CTLFLAG_RDTUN,
 zfs_mdcomp_disable, 0, Disable metadata compression);
@@ -466,9 +466,9 @@ static uint64_t arc_loaned_bytes;
 static uint64_tarc_meta_used;
 static uint64_tarc_meta_limit;
 static uint64_tarc_meta_max = 0;
-SYSCTL_QUAD(_vfs_zfs, OID_AUTO, arc_meta_used, CTLFLAG_RDTUN,
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, arc_meta_used, CTLFLAG_RDTUN,
 arc_meta_used, 0, ARC metadata used);
-SYSCTL_QUAD(_vfs_zfs, OID_AUTO, arc_meta_limit, CTLFLAG_RDTUN,
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, arc_meta_limit, CTLFLAG_RDTUN,
 arc_meta_limit, 0, ARC metadata limit);
 
 typedef struct l2arc_buf_hdr l2arc_buf_hdr_t;
@@ -638,15 +638,15 @@ boolean_t l2arc_noprefetch = B_FALSE; /
 boolean_t l2arc_feed_again = B_TRUE;   /* turbo warmup */
 boolean_t l2arc_norw = B_TRUE; /* no reads during writes */
 
-SYSCTL_QUAD(_vfs_zfs, OID_AUTO, l2arc_write_max, CTLFLAG_RW,
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_write_max, CTLFLAG_RW,
 l2arc_write_max, 0, max write size);
-SYSCTL_QUAD(_vfs_zfs, OID_AUTO, l2arc_write_boost, CTLFLAG_RW,
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_write_boost, CTLFLAG_RW,
 l2arc_write_boost, 0, extra write during warmup);
-SYSCTL_QUAD(_vfs_zfs, OID_AUTO, l2arc_headroom, CTLFLAG_RW,
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_headroom, CTLFLAG_RW,
 l2arc_headroom, 0, number of dev writes);
-SYSCTL_QUAD(_vfs_zfs, OID_AUTO, l2arc_feed_secs, CTLFLAG_RW,
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_feed_secs, CTLFLAG_RW,
 l2arc_feed_secs, 0, interval seconds);
-SYSCTL_QUAD(_vfs_zfs, OID_AUTO, l2arc_feed_min_ms, CTLFLAG_RW,
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_feed_min_ms, CTLFLAG_RW,
 l2arc_feed_min_ms, 0, min interval milliseconds);
 
 SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_noprefetch, CTLFLAG_RW,
@@ -656,46 +656,46 @@ SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_fee
 SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_norw, CTLFLAG_RW,
 l2arc_norw, 0, no reads during writes);
 
-SYSCTL_QUAD(_vfs_zfs, OID_AUTO, anon_size, CTLFLAG_RD,
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, anon_size, CTLFLAG_RD,
 ARC_anon.arcs_size, 0, size of anonymous state);
-SYSCTL_QUAD(_vfs_zfs, OID_AUTO, anon_metadata_lsize, CTLFLAG_RD,
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, anon_metadata_lsize, CTLFLAG_RD,
 ARC_anon.arcs_lsize[ARC_BUFC_METADATA], 0, size of anonymous state);
-SYSCTL_QUAD(_vfs_zfs, OID_AUTO, anon_data_lsize, CTLFLAG_RD,
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, anon_data_lsize, CTLFLAG_RD,
 ARC_anon.arcs_lsize[ARC_BUFC_DATA], 0, size of anonymous state);
 
-SYSCTL_QUAD(_vfs_zfs, OID_AUTO, mru_size, CTLFLAG_RD,
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_size, CTLFLAG_RD,
 ARC_mru.arcs_size, 0, size of mru state);
-SYSCTL_QUAD(_vfs_zfs, OID_AUTO, mru_metadata_lsize, CTLFLAG_RD,
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_metadata_lsize, CTLFLAG_RD,
 

svn commit: r217369 - in head/sys: cam/scsi sys

2011-01-13 Thread Matthew D Fleming
Author: mdf
Date: Thu Jan 13 18:20:33 2011
New Revision: 217369
URL: http://svn.freebsd.org/changeset/base/217369

Log:
  Add a 64-bit hex-printed sysctl(9) since there is at least one place in
  the code that wanted it.  It is named X64 rather than XQUAD since the
  quad name is a historical abomination that should not be perpetuated.

Modified:
  head/sys/cam/scsi/scsi_da.c
  head/sys/sys/sysctl.h

Modified: head/sys/cam/scsi/scsi_da.c
==
--- head/sys/cam/scsi/scsi_da.c Thu Jan 13 18:20:27 2011(r217368)
+++ head/sys/cam/scsi/scsi_da.c Thu Jan 13 18:20:33 2011(r217369)
@@ -1127,9 +1127,9 @@ dasysctlinit(void *context, int pending)
struct ccb_trans_settings_fc *fc = cts.xport_specific.fc;
if (fc-valid  CTS_FC_VALID_WWPN) {
softc-wwpn = fc-wwpn;
-   SYSCTL_ADD_XLONG(softc-sysctl_ctx,
+   SYSCTL_ADD_X64(softc-sysctl_ctx,
SYSCTL_CHILDREN(softc-sysctl_tree),
-   OID_AUTO, wwpn, CTLTYPE_QUAD | CTLFLAG_RD,
+   OID_AUTO, wwpn, CTLFLAG_RD,
softc-wwpn, World Wide Port Name);
}
}

Modified: head/sys/sys/sysctl.h
==
--- head/sys/sys/sysctl.h   Thu Jan 13 18:20:27 2011(r217368)
+++ head/sys/sys/sysctl.h   Thu Jan 13 18:20:33 2011(r217369)
@@ -245,6 +245,8 @@ SYSCTL_ALLOWED_TYPES(ULONG, unsigned lon
 SYSCTL_ALLOWED_TYPES(XLONG, unsigned long *a; long *b; );
 SYSCTL_ALLOWED_TYPES(INT64, int64_t *a; long long *b; );
 SYSCTL_ALLOWED_TYPES(UINT64, uint64_t *a; unsigned long long *b; );
+SYSCTL_ALLOWED_TYPES(XINT64, uint64_t *a; int64_t *b;
+unsigned long long *c; long long *d; );
 
 #ifdef notyet
 #defineSYSCTL_ADD_ASSERT_TYPE(type, ptr)   \
@@ -389,7 +391,6 @@ SYSCTL_ALLOWED_TYPES(UINT64, uint64_t *a
SYSCTL_ADD_ASSERT_TYPE(INT64, ptr), 0,  \
sysctl_handle_quad, Q, __DESCR(descr))
 
-/* Oid for a quad.  The pointer must be non NULL. */
 #defineSYSCTL_UQUAD(parent, nbr, name, access, ptr, val, descr)
\
SYSCTL_ASSERT_TYPE(UINT64, ptr, parent, name);  \
SYSCTL_OID(parent, nbr, name,   \
@@ -402,6 +403,18 @@ SYSCTL_ALLOWED_TYPES(UINT64, uint64_t *a
SYSCTL_ADD_ASSERT_TYPE(UINT64, ptr), 0, \
sysctl_handle_quad, QU, __DESCR(descr))
 
+#defineSYSCTL_X64(parent, nbr, name, access, ptr, val, descr)  \
+   SYSCTL_ASSERT_TYPE(XINT64, ptr, parent, name);  \
+   SYSCTL_OID(parent, nbr, name,   \
+   CTLTYPE_QUAD | CTLFLAG_MPSAFE | (access),   \
+   ptr, val, sysctl_handle_quad, QX, descr)
+
+#defineSYSCTL_ADD_X64(ctx, parent, nbr, name, access, ptr, descr)  
\
+   sysctl_add_oid(ctx, parent, nbr, name,  \
+   CTLTYPE_QUAD | CTLFLAG_MPSAFE | (access),   \
+   SYSCTL_ADD_ASSERT_TYPE(XINT64, ptr), 0, \
+   sysctl_handle_quad, QX, __DESCR(descr))
+
 /* Oid for an opaque object.  Specified by a pointer and a length. */
 #define SYSCTL_OPAQUE(parent, nbr, name, access, ptr, len, fmt, descr) \
SYSCTL_OID(parent, nbr, name, CTLTYPE_OPAQUE|(access), \
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r217370 - head/sys/kern

2011-01-13 Thread Matthew D Fleming
Author: mdf
Date: Thu Jan 13 18:20:37 2011
New Revision: 217370
URL: http://svn.freebsd.org/changeset/base/217370

Log:
  One more sysctl(9) type-safety that I missed before.

Modified:
  head/sys/kern/sched_4bsd.c

Modified: head/sys/kern/sched_4bsd.c
==
--- head/sys/kern/sched_4bsd.c  Thu Jan 13 18:20:33 2011(r217369)
+++ head/sys/kern/sched_4bsd.c  Thu Jan 13 18:20:37 2011(r217370)
@@ -429,7 +429,7 @@ maybe_preempt(struct thread *td)
 
 /* decay 95% of `ts_pctcpu' in 60 seconds; see CCPU_SHIFT before changing */
 static fixpt_t ccpu = 0.95122942450071400909 * FSCALE; /* exp(-1/20) */
-SYSCTL_INT(_kern, OID_AUTO, ccpu, CTLFLAG_RD, ccpu, 0, );
+SYSCTL_UINT(_kern, OID_AUTO, ccpu, CTLFLAG_RD, ccpu, 0, );
 
 /*
  * If `ccpu' is not equal to `exp(-1/20)' and you still want to use the
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r217313 - in head: . sys/sys

2011-01-12 Thread Matthew D Fleming
Author: mdf
Date: Wed Jan 12 17:52:48 2011
New Revision: 217313
URL: http://svn.freebsd.org/changeset/base/217313

Log:
  Add type checking for static and dynamic sysctls using scalar types.
  The code is turned off until the tree is fixed up so it compiles.
  __FreeBSD_version was already bumped once today, so skip the bump, but
  add an entry to UPDATING.
  
  Note that __DESCR() is used in the SYSCTL_OID() macro and so is not
  needed in macros that invoke it.  This use was inconsistent in the
  file and I have made it consistent any lines already being changed.
  
  Reviewed by:  bde (previous version), -arch (previous version)

Modified:
  head/UPDATING
  head/sys/sys/sysctl.h

Modified: head/UPDATING
==
--- head/UPDATING   Wed Jan 12 16:16:54 2011(r217312)
+++ head/UPDATING   Wed Jan 12 17:52:48 2011(r217313)
@@ -23,6 +23,13 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 9.
ln -s aj /etc/malloc.conf.)
 
 20110112:
+   A SYSCTL_[ADD_]UQUAD was added for unsigned uint64_t pointers,
+   symmetric with the existing SYSCTL_[ADD_]QUAD.  Type checking
+   for scalar sysctls is defined but disabled.  Code that needs
+   UQUAD to pass the type checking that must compile on older
+   systems where the define is not present can check against
+   __FreeBSD_version = 900030.
+
The system dialog(1) has been replaced with a new version previously
in ports as devel/cdialog. dialog(1) is mostly command-line compatible
with the previous version, but the libdialog associated with it has

Modified: head/sys/sys/sysctl.h
==
--- head/sys/sys/sysctl.h   Wed Jan 12 16:16:54 2011(r217312)
+++ head/sys/sys/sysctl.h   Wed Jan 12 17:52:48 2011(r217313)
@@ -216,6 +216,55 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_e
 #define SYSCTL_NODE_CHILDREN(parent, name) \
sysctl_##parent##_##name##_children
 
+/*
+ * These macros provide type safety for sysctls.  SYSCTL_ALLOWED_TYPES()
+ * defines a transparent union of the allowed types.  SYSCTL_ASSERT_TYPE()
+ * and SYSCTL_ADD_ASSERT_TYPE() use the transparent union to assert that
+ * the pointer matches the allowed types.
+ *
+ * The allow_0 member allows a literal 0 to be passed for ptr.
+ */
+#defineSYSCTL_ALLOWED_TYPES(type, decls)   \
+   union sysctl_##type {   \
+   long allow_0;   \
+   decls   \
+   } __attribute__((__transparent_union__));   \
+   \
+   static inline void *\
+   __sysctl_assert_##type(union sysctl_##type ptr) \
+   {   \
+   return (ptr.a); \
+   }   \
+   struct __hack
+
+SYSCTL_ALLOWED_TYPES(INT, int *a; );
+SYSCTL_ALLOWED_TYPES(UINT, unsigned int *a; );
+SYSCTL_ALLOWED_TYPES(XINT, unsigned int *a; int *b; );
+SYSCTL_ALLOWED_TYPES(LONG, long *a; );
+SYSCTL_ALLOWED_TYPES(ULONG, unsigned long *a; );
+SYSCTL_ALLOWED_TYPES(XLONG, unsigned long *a; long b; );
+SYSCTL_ALLOWED_TYPES(INT64, int64_t *a; long long *b; );
+SYSCTL_ALLOWED_TYPES(UINT64, uint64_t *a; unsigned long long *b; );
+
+#ifdef notyet
+#defineSYSCTL_ADD_ASSERT_TYPE(type, ptr)   \
+   __sysctl_assert_ ## type (ptr)
+#defineSYSCTL_ASSERT_TYPE(type, ptr, parent, name) \
+   _SYSCTL_ASSERT_TYPE(type, ptr, __LINE__, parent##_##name)
+#else
+#defineSYSCTL_ADD_ASSERT_TYPE(type, ptr)   ptr
+#defineSYSCTL_ASSERT_TYPE(type, ptr, parent, name)
+#endif
+#define_SYSCTL_ASSERT_TYPE(t, p, l, id)\
+   __SYSCTL_ASSERT_TYPE(t, p, l, id)
+#define__SYSCTL_ASSERT_TYPE(type, ptr, line, id)   
\
+   static inline void  \
+   sysctl_assert_##line##_##id(void)   \
+   {   \
+   (void)__sysctl_assert_##type(ptr);  \
+   }   \
+   struct __hack
+
 #ifndef NO_SYSCTL_DESCR
 #define __DESCR(d) d
 #else
@@ -252,65 +301,106 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_e
arg, len, sysctl_handle_string, A, __DESCR(descr))
 
 /* Oid for an int.  If ptr is NULL, val is returned. */
-#define SYSCTL_INT(parent, nbr, name, access, ptr, val, descr) \
-   SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|CTLFLAG_MPSAFE|(access), \
-   ptr, val, sysctl_handle_int, I, descr)
-
-#define 

svn commit: r217319 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2011-01-12 Thread Matthew D Fleming
Author: mdf
Date: Wed Jan 12 19:53:30 2011
New Revision: 217319
URL: http://svn.freebsd.org/changeset/base/217319

Log:
  sysctl(9) cleanup checkpoint: amd64 GENERIC builds cleanly.
  
  Commit the zfs piece.

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_zfetch.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/txg.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c   Wed Jan 12 
19:53:23 2011(r217318)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c   Wed Jan 12 
19:53:30 2011(r217319)
@@ -188,9 +188,9 @@ TUNABLE_QUAD(vfs.zfs.arc_min, zfs_arc
 TUNABLE_QUAD(vfs.zfs.arc_meta_limit, zfs_arc_meta_limit);
 TUNABLE_INT(vfs.zfs.mdcomp_disable, zfs_mdcomp_disable);
 SYSCTL_DECL(_vfs_zfs);
-SYSCTL_QUAD(_vfs_zfs, OID_AUTO, arc_max, CTLFLAG_RDTUN, zfs_arc_max, 0,
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, arc_max, CTLFLAG_RDTUN, zfs_arc_max, 0,
 Maximum ARC size);
-SYSCTL_QUAD(_vfs_zfs, OID_AUTO, arc_min, CTLFLAG_RDTUN, zfs_arc_min, 0,
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, arc_min, CTLFLAG_RDTUN, zfs_arc_min, 0,
 Minimum ARC size);
 SYSCTL_INT(_vfs_zfs, OID_AUTO, mdcomp_disable, CTLFLAG_RDTUN,
 zfs_mdcomp_disable, 0, Disable metadata compression);
@@ -466,9 +466,9 @@ static uint64_t arc_loaned_bytes;
 static uint64_tarc_meta_used;
 static uint64_tarc_meta_limit;
 static uint64_tarc_meta_max = 0;
-SYSCTL_QUAD(_vfs_zfs, OID_AUTO, arc_meta_used, CTLFLAG_RDTUN,
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, arc_meta_used, CTLFLAG_RDTUN,
 arc_meta_used, 0, ARC metadata used);
-SYSCTL_QUAD(_vfs_zfs, OID_AUTO, arc_meta_limit, CTLFLAG_RDTUN,
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, arc_meta_limit, CTLFLAG_RDTUN,
 arc_meta_limit, 0, ARC metadata limit);
 
 typedef struct l2arc_buf_hdr l2arc_buf_hdr_t;
@@ -638,15 +638,15 @@ boolean_t l2arc_noprefetch = B_FALSE; /
 boolean_t l2arc_feed_again = B_TRUE;   /* turbo warmup */
 boolean_t l2arc_norw = B_TRUE; /* no reads during writes */
 
-SYSCTL_QUAD(_vfs_zfs, OID_AUTO, l2arc_write_max, CTLFLAG_RW,
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_write_max, CTLFLAG_RW,
 l2arc_write_max, 0, max write size);
-SYSCTL_QUAD(_vfs_zfs, OID_AUTO, l2arc_write_boost, CTLFLAG_RW,
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_write_boost, CTLFLAG_RW,
 l2arc_write_boost, 0, extra write during warmup);
-SYSCTL_QUAD(_vfs_zfs, OID_AUTO, l2arc_headroom, CTLFLAG_RW,
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_headroom, CTLFLAG_RW,
 l2arc_headroom, 0, number of dev writes);
-SYSCTL_QUAD(_vfs_zfs, OID_AUTO, l2arc_feed_secs, CTLFLAG_RW,
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_feed_secs, CTLFLAG_RW,
 l2arc_feed_secs, 0, interval seconds);
-SYSCTL_QUAD(_vfs_zfs, OID_AUTO, l2arc_feed_min_ms, CTLFLAG_RW,
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_feed_min_ms, CTLFLAG_RW,
 l2arc_feed_min_ms, 0, min interval milliseconds);
 
 SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_noprefetch, CTLFLAG_RW,
@@ -656,46 +656,46 @@ SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_fee
 SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_norw, CTLFLAG_RW,
 l2arc_norw, 0, no reads during writes);
 
-SYSCTL_QUAD(_vfs_zfs, OID_AUTO, anon_size, CTLFLAG_RD,
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, anon_size, CTLFLAG_RD,
 ARC_anon.arcs_size, 0, size of anonymous state);
-SYSCTL_QUAD(_vfs_zfs, OID_AUTO, anon_metadata_lsize, CTLFLAG_RD,
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, anon_metadata_lsize, CTLFLAG_RD,
 ARC_anon.arcs_lsize[ARC_BUFC_METADATA], 0, size of anonymous state);
-SYSCTL_QUAD(_vfs_zfs, OID_AUTO, anon_data_lsize, CTLFLAG_RD,
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, anon_data_lsize, CTLFLAG_RD,
 ARC_anon.arcs_lsize[ARC_BUFC_DATA], 0, size of anonymous state);
 
-SYSCTL_QUAD(_vfs_zfs, OID_AUTO, mru_size, CTLFLAG_RD,
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_size, CTLFLAG_RD,
 ARC_mru.arcs_size, 0, size of mru state);
-SYSCTL_QUAD(_vfs_zfs, OID_AUTO, mru_metadata_lsize, CTLFLAG_RD,
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_metadata_lsize, CTLFLAG_RD,
 ARC_mru.arcs_lsize[ARC_BUFC_METADATA], 0, size of metadata in mru 
state);
-SYSCTL_QUAD(_vfs_zfs, OID_AUTO, mru_data_lsize, CTLFLAG_RD,
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_data_lsize, CTLFLAG_RD,
 ARC_mru.arcs_lsize[ARC_BUFC_DATA], 0, size of data in mru state);
 
-SYSCTL_QUAD(_vfs_zfs, OID_AUTO, mru_ghost_size, CTLFLAG_RD,
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_ghost_size, CTLFLAG_RD,
 ARC_mru_ghost.arcs_size, 0, size of mru ghost state);
-SYSCTL_QUAD(_vfs_zfs, OID_AUTO, mru_ghost_metadata_lsize, CTLFLAG_RD,
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_ghost_metadata_lsize, CTLFLAG_RD,
 ARC_mru_ghost.arcs_lsize[ARC_BUFC_METADATA], 0,
 size of metadata in mru ghost state);
-SYSCTL_QUAD(_vfs_zfs, OID_AUTO, mru_ghost_data_lsize, CTLFLAG_RD,

svn commit: r217320 - in head/sys/netgraph: . bluetooth/common bluetooth/socket

2011-01-12 Thread Matthew D Fleming
Author: mdf
Date: Wed Jan 12 19:53:39 2011
New Revision: 217320
URL: http://svn.freebsd.org/changeset/base/217320

Log:
  sysctl(9) cleanup checkpoint: amd64 GENERIC builds cleanly.
  
  Commit the netgraph piece.

Modified:
  head/sys/netgraph/bluetooth/common/ng_bluetooth.c
  head/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c
  head/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c
  head/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap_raw.c
  head/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c
  head/sys/netgraph/bluetooth/socket/ng_btsocket_sco.c
  head/sys/netgraph/ng_socket.c

Modified: head/sys/netgraph/bluetooth/common/ng_bluetooth.c
==
--- head/sys/netgraph/bluetooth/common/ng_bluetooth.c   Wed Jan 12 19:53:30 
2011(r217319)
+++ head/sys/netgraph/bluetooth/common/ng_bluetooth.c   Wed Jan 12 19:53:39 
2011(r217320)
@@ -114,7 +114,7 @@ SYSCTL_PROC(_net_bluetooth_hci, OID_AUTO
bluetooth_set_hci_connect_timeout_value,
I, HCI connect timeout (sec));
 
-SYSCTL_INT(_net_bluetooth_hci, OID_AUTO, max_neighbor_age, CTLFLAG_RW,
+SYSCTL_UINT(_net_bluetooth_hci, OID_AUTO, max_neighbor_age, CTLFLAG_RW,
bluetooth_hci_max_neighbor_age_value, 600,
Maximal HCI neighbor cache entry age (sec));
 

Modified: head/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c
==
--- head/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.cWed Jan 12 
19:53:30 2011(r217319)
+++ head/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.cWed Jan 12 
19:53:39 2011(r217320)
@@ -125,19 +125,19 @@ static int
ng_btsocket_hci_raw_curpp
 SYSCTL_DECL(_net_bluetooth_hci_sockets);
 SYSCTL_NODE(_net_bluetooth_hci_sockets, OID_AUTO, raw, CTLFLAG_RW,
 0, Bluetooth raw HCI sockets family);
-SYSCTL_INT(_net_bluetooth_hci_sockets_raw, OID_AUTO, debug_level, CTLFLAG_RW,
+SYSCTL_UINT(_net_bluetooth_hci_sockets_raw, OID_AUTO, debug_level, CTLFLAG_RW,
 ng_btsocket_hci_raw_debug_level, NG_BTSOCKET_WARN_LEVEL,
Bluetooth raw HCI sockets debug level);
-SYSCTL_INT(_net_bluetooth_hci_sockets_raw, OID_AUTO, ioctl_timeout, CTLFLAG_RW,
+SYSCTL_UINT(_net_bluetooth_hci_sockets_raw, OID_AUTO, ioctl_timeout, 
CTLFLAG_RW,
 ng_btsocket_hci_raw_ioctl_timeout, 5,
Bluetooth raw HCI sockets ioctl timeout);
-SYSCTL_INT(_net_bluetooth_hci_sockets_raw, OID_AUTO, queue_len, CTLFLAG_RD,
+SYSCTL_UINT(_net_bluetooth_hci_sockets_raw, OID_AUTO, queue_len, CTLFLAG_RD,
 ng_btsocket_hci_raw_queue.len, 0,
 Bluetooth raw HCI sockets input queue length);
-SYSCTL_INT(_net_bluetooth_hci_sockets_raw, OID_AUTO, queue_maxlen, CTLFLAG_RD,
+SYSCTL_UINT(_net_bluetooth_hci_sockets_raw, OID_AUTO, queue_maxlen, CTLFLAG_RD,
 ng_btsocket_hci_raw_queue.maxlen, 0,
 Bluetooth raw HCI sockets input queue max. length);
-SYSCTL_INT(_net_bluetooth_hci_sockets_raw, OID_AUTO, queue_drops, CTLFLAG_RD,
+SYSCTL_UINT(_net_bluetooth_hci_sockets_raw, OID_AUTO, queue_drops, CTLFLAG_RD,
 ng_btsocket_hci_raw_queue.drops, 0,
 Bluetooth raw HCI sockets input queue drops);
 

Modified: head/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c
==
--- head/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c  Wed Jan 12 
19:53:30 2011(r217319)
+++ head/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c  Wed Jan 12 
19:53:39 2011(r217320)
@@ -110,19 +110,19 @@ static int
ng_btsocket_l2cap_curpps;
 SYSCTL_DECL(_net_bluetooth_l2cap_sockets);
 SYSCTL_NODE(_net_bluetooth_l2cap_sockets, OID_AUTO, seq, CTLFLAG_RW,
0, Bluetooth SEQPACKET L2CAP sockets family);
-SYSCTL_INT(_net_bluetooth_l2cap_sockets_seq, OID_AUTO, debug_level,
+SYSCTL_UINT(_net_bluetooth_l2cap_sockets_seq, OID_AUTO, debug_level,
CTLFLAG_RW,
ng_btsocket_l2cap_debug_level, NG_BTSOCKET_WARN_LEVEL,
Bluetooth SEQPACKET L2CAP sockets debug level);
-SYSCTL_INT(_net_bluetooth_l2cap_sockets_seq, OID_AUTO, queue_len, 
+SYSCTL_UINT(_net_bluetooth_l2cap_sockets_seq, OID_AUTO, queue_len,
CTLFLAG_RD,
ng_btsocket_l2cap_queue.len, 0,
Bluetooth SEQPACKET L2CAP sockets input queue length);
-SYSCTL_INT(_net_bluetooth_l2cap_sockets_seq, OID_AUTO, queue_maxlen, 
+SYSCTL_UINT(_net_bluetooth_l2cap_sockets_seq, OID_AUTO, queue_maxlen,
CTLFLAG_RD,
ng_btsocket_l2cap_queue.maxlen, 0,
Bluetooth SEQPACKET L2CAP sockets input queue max. length);
-SYSCTL_INT(_net_bluetooth_l2cap_sockets_seq, OID_AUTO, queue_drops, 
+SYSCTL_UINT(_net_bluetooth_l2cap_sockets_seq, OID_AUTO, queue_drops,
CTLFLAG_RD,
ng_btsocket_l2cap_queue.drops, 0,
Bluetooth SEQPACKET L2CAP sockets input queue drops);

Modified: 

svn commit: r217326 - in head/sys: amd64/acpica ddb kern nlm rpc ufs/ffs x86/x86

2011-01-12 Thread Matthew D Fleming
Author: mdf
Date: Wed Jan 12 19:54:19 2011
New Revision: 217326
URL: http://svn.freebsd.org/changeset/base/217326

Log:
  sysctl(9) cleanup checkpoint: amd64 GENERIC builds cleanly.
  
  Commit the kernel changes.

Modified:
  head/sys/amd64/acpica/acpi_machdep.c
  head/sys/ddb/db_capture.c
  head/sys/kern/kern_clocksource.c
  head/sys/kern/kern_et.c
  head/sys/kern/kern_mib.c
  head/sys/kern/kern_sx.c
  head/sys/kern/subr_kobj.c
  head/sys/kern/subr_smp.c
  head/sys/kern/vfs_subr.c
  head/sys/nlm/nlm_prot_impl.c
  head/sys/rpc/svc.c
  head/sys/ufs/ffs/ffs_softdep.c
  head/sys/x86/x86/busdma_machdep.c

Modified: head/sys/amd64/acpica/acpi_machdep.c
==
--- head/sys/amd64/acpica/acpi_machdep.cWed Jan 12 19:54:14 2011
(r217325)
+++ head/sys/amd64/acpica/acpi_machdep.cWed Jan 12 19:54:19 2011
(r217326)
@@ -68,7 +68,7 @@ acpi_machdep_init(device_t dev)
if (intr_model != ACPI_INTR_PIC)
acpi_SetIntrModel(intr_model);
 
-   SYSCTL_ADD_UINT(sc-acpi_sysctl_ctx,
+   SYSCTL_ADD_INT(sc-acpi_sysctl_ctx,
SYSCTL_CHILDREN(sc-acpi_sysctl_tree), OID_AUTO,
reset_video, CTLFLAG_RW, acpi_reset_video, 0,
Call the VESA reset BIOS vector on the resume path);

Modified: head/sys/ddb/db_capture.c
==
--- head/sys/ddb/db_capture.c   Wed Jan 12 19:54:14 2011(r217325)
+++ head/sys/ddb/db_capture.c   Wed Jan 12 19:54:19 2011(r217326)
@@ -90,7 +90,7 @@ SYSCTL_UINT(_debug_ddb_capture, OID_AUTO
 db_capture_maxbufsize, 0,
 Maximum value for debug.ddb.capture.bufsize);
 
-SYSCTL_UINT(_debug_ddb_capture, OID_AUTO, inprogress, CTLFLAG_RD,
+SYSCTL_INT(_debug_ddb_capture, OID_AUTO, inprogress, CTLFLAG_RD,
 db_capture_inprogress, 0, DDB output capture in progress);
 
 /*

Modified: head/sys/kern/kern_clocksource.c
==
--- head/sys/kern/kern_clocksource.cWed Jan 12 19:54:14 2011
(r217325)
+++ head/sys/kern/kern_clocksource.cWed Jan 12 19:54:19 2011
(r217326)
@@ -114,7 +114,7 @@ SYSCTL_INT(_kern_eventtimer, OID_AUTO, s
 
 static u_int   idletick = 0;   /* Idle mode allowed. */
 TUNABLE_INT(kern.eventtimer.idletick, idletick);
-SYSCTL_INT(_kern_eventtimer, OID_AUTO, idletick, CTLFLAG_RW, idletick,
+SYSCTL_UINT(_kern_eventtimer, OID_AUTO, idletick, CTLFLAG_RW, idletick,
 0, Run periodic events when idle);
 
 static int periodic = 0;   /* Periodic or one-shot mode. */

Modified: head/sys/kern/kern_et.c
==
--- head/sys/kern/kern_et.c Wed Jan 12 19:54:14 2011(r217325)
+++ head/sys/kern/kern_et.c Wed Jan 12 19:54:19 2011(r217326)
@@ -65,10 +65,10 @@ et_register(struct eventtimer *et)
et-et_sysctl = SYSCTL_ADD_NODE(NULL,
SYSCTL_STATIC_CHILDREN(_kern_eventtimer_et), OID_AUTO, et-et_name,
CTLFLAG_RW, 0, event timer description);
-   SYSCTL_ADD_UINT(NULL, SYSCTL_CHILDREN(et-et_sysctl), OID_AUTO,
+   SYSCTL_ADD_INT(NULL, SYSCTL_CHILDREN(et-et_sysctl), OID_AUTO,
flags, CTLFLAG_RD, (et-et_flags), 0,
Event timer capabilities);
-   SYSCTL_ADD_QUAD(NULL, SYSCTL_CHILDREN(et-et_sysctl), OID_AUTO,
+   SYSCTL_ADD_UQUAD(NULL, SYSCTL_CHILDREN(et-et_sysctl), OID_AUTO,
frequency, CTLFLAG_RD, (et-et_frequency),
Event timer base frequency);
SYSCTL_ADD_INT(NULL, SYSCTL_CHILDREN(et-et_sysctl), OID_AUTO,

Modified: head/sys/kern/kern_mib.c
==
--- head/sys/kern/kern_mib.cWed Jan 12 19:54:14 2011(r217325)
+++ head/sys/kern/kern_mib.cWed Jan 12 19:54:19 2011(r217326)
@@ -203,7 +203,7 @@ sysctl_hw_usermem(SYSCTL_HANDLER_ARGS)
 SYSCTL_PROC(_hw, HW_USERMEM, usermem, CTLTYPE_ULONG | CTLFLAG_RD,
0, 0, sysctl_hw_usermem, LU, );
 
-SYSCTL_ULONG(_hw, OID_AUTO, availpages, CTLFLAG_RD, physmem, 0, );
+SYSCTL_LONG(_hw, OID_AUTO, availpages, CTLFLAG_RD, physmem, 0, );
 
 u_long pagesizes[MAXPAGESIZES] = { PAGE_SIZE };
 

Modified: head/sys/kern/kern_sx.c
==
--- head/sys/kern/kern_sx.c Wed Jan 12 19:54:14 2011(r217325)
+++ head/sys/kern/kern_sx.c Wed Jan 12 19:54:19 2011(r217326)
@@ -137,8 +137,8 @@ struct lock_class lock_class_sx = {
 static u_int asx_retries = 10;
 static u_int asx_loops = 1;
 SYSCTL_NODE(_debug, OID_AUTO, sx, CTLFLAG_RD, NULL, sxlock debugging);
-SYSCTL_INT(_debug_sx, OID_AUTO, retries, CTLFLAG_RW, asx_retries, 0, );
-SYSCTL_INT(_debug_sx, OID_AUTO, loops, CTLFLAG_RW, asx_loops, 0, );
+SYSCTL_UINT(_debug_sx, OID_AUTO, retries, CTLFLAG_RW, asx_retries, 0, );

svn commit: r217318 - in head/sys/dev: e1000 ixgbe

2011-01-12 Thread Matthew D Fleming
Author: mdf
Date: Wed Jan 12 19:53:23 2011
New Revision: 217318
URL: http://svn.freebsd.org/changeset/base/217318

Log:
  sysctl(9) cleanup checkpoint: amd64 GENERIC builds cleanly.
  
  Commit the Intel drivers.

Modified:
  head/sys/dev/e1000/if_em.c
  head/sys/dev/e1000/if_igb.c
  head/sys/dev/e1000/if_lem.c
  head/sys/dev/ixgbe/ixgbe.c

Modified: head/sys/dev/e1000/if_em.c
==
--- head/sys/dev/e1000/if_em.c  Wed Jan 12 19:28:52 2011(r217317)
+++ head/sys/dev/e1000/if_em.c  Wed Jan 12 19:53:23 2011(r217318)
@@ -5059,8 +5059,8 @@ em_add_hw_stats(struct adapter *adapter)
char namebuf[QUEUE_NAME_LEN];

/* Driver Statistics */
-   SYSCTL_ADD_UINT(ctx, child, OID_AUTO, link_irq, 
-   CTLFLAG_RD, adapter-link_irq, 0,
+   SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, link_irq,
+   CTLFLAG_RD, adapter-link_irq,
Link MSIX IRQ Handled);
SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, mbuf_alloc_fail, 
 CTLFLAG_RD, adapter-mbuf_alloc_failed,
@@ -5136,147 +5136,147 @@ em_add_hw_stats(struct adapter *adapter)
CTLFLAG_RD, NULL, Statistics);
stat_list = SYSCTL_CHILDREN(stat_node);
 
-   SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, excess_coll, 
+   SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, excess_coll,
CTLFLAG_RD, stats-ecol,
Excessive collisions);
-   SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, single_coll, 
+   SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, single_coll,
CTLFLAG_RD, stats-scc,
Single collisions);
-   SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, multiple_coll, 
+   SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, multiple_coll,
CTLFLAG_RD, stats-mcc,
Multiple collisions);
-   SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, late_coll, 
+   SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, late_coll,
CTLFLAG_RD, stats-latecol,
Late collisions);
-   SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, collision_count, 
+   SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, collision_count,
CTLFLAG_RD, stats-colc,
Collision Count);
-   SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, symbol_errors,
+   SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, symbol_errors,
CTLFLAG_RD, adapter-stats.symerrs,
Symbol Errors);
-   SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, sequence_errors,
+   SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, sequence_errors,
CTLFLAG_RD, adapter-stats.sec,
Sequence Errors);
-   SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, defer_count,
+   SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, defer_count,
CTLFLAG_RD, adapter-stats.dc,
Defer Count);
-   SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, missed_packets,
+   SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, missed_packets,
CTLFLAG_RD, adapter-stats.mpc,
Missed Packets);
-   SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, recv_no_buff,
+   SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, recv_no_buff,
CTLFLAG_RD, adapter-stats.rnbc,
Receive No Buffers);
-   SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, recv_undersize,
+   SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, recv_undersize,
CTLFLAG_RD, adapter-stats.ruc,
Receive Undersize);
-   SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, recv_fragmented,
+   SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, recv_fragmented,
CTLFLAG_RD, adapter-stats.rfc,
Fragmented Packets Received );
-   SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, recv_oversize,
+   SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, recv_oversize,
CTLFLAG_RD, adapter-stats.roc,
Oversized Packets Received);
-   SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, recv_jabber,
+   SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, recv_jabber,
CTLFLAG_RD, adapter-stats.rjc,
Recevied Jabber);
-   SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, recv_errs,
+   SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, recv_errs,
CTLFLAG_RD, adapter-stats.rxerrc,
Receive Errors);
-   SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, crc_errs,
+   SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, crc_errs,
CTLFLAG_RD, adapter-stats.crcerrs,
CRC errors);
-   SYSCTL_ADD_QUAD(ctx, 

svn commit: r217321 - in head/sys/dev/cxgb: . ulp/iw_cxgb

2011-01-12 Thread Matthew D Fleming
Author: mdf
Date: Wed Jan 12 19:53:44 2011
New Revision: 217321
URL: http://svn.freebsd.org/changeset/base/217321

Log:
  sysctl(9) cleanup checkpoint: amd64 GENERIC builds cleanly.
  
  Commit the cxgb driver piece.

Modified:
  head/sys/dev/cxgb/cxgb_main.c
  head/sys/dev/cxgb/cxgb_sge.c
  head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c

Modified: head/sys/dev/cxgb/cxgb_main.c
==
--- head/sys/dev/cxgb/cxgb_main.c   Wed Jan 12 19:53:39 2011
(r217320)
+++ head/sys/dev/cxgb/cxgb_main.c   Wed Jan 12 19:53:44 2011
(r217321)
@@ -195,7 +195,7 @@ static int msi_allowed = 2;
 
 TUNABLE_INT(hw.cxgb.msi_allowed, msi_allowed);
 SYSCTL_NODE(_hw, OID_AUTO, cxgb, CTLFLAG_RD, 0, CXGB driver parameters);
-SYSCTL_UINT(_hw_cxgb, OID_AUTO, msi_allowed, CTLFLAG_RDTUN, msi_allowed, 0,
+SYSCTL_INT(_hw_cxgb, OID_AUTO, msi_allowed, CTLFLAG_RDTUN, msi_allowed, 0,
 MSI-X, MSI, INTx selector);
 
 /*
@@ -204,7 +204,7 @@ SYSCTL_UINT(_hw_cxgb, OID_AUTO, msi_allo
  */
 static int ofld_disable = 0;
 TUNABLE_INT(hw.cxgb.ofld_disable, ofld_disable);
-SYSCTL_UINT(_hw_cxgb, OID_AUTO, ofld_disable, CTLFLAG_RDTUN, ofld_disable, 0,
+SYSCTL_INT(_hw_cxgb, OID_AUTO, ofld_disable, CTLFLAG_RDTUN, ofld_disable, 0,
 disable ULP offload);
 
 /*
@@ -213,7 +213,7 @@ SYSCTL_UINT(_hw_cxgb, OID_AUTO, ofld_dis
  */
 static int multiq = 1;
 TUNABLE_INT(hw.cxgb.multiq, multiq);
-SYSCTL_UINT(_hw_cxgb, OID_AUTO, multiq, CTLFLAG_RDTUN, multiq, 0,
+SYSCTL_INT(_hw_cxgb, OID_AUTO, multiq, CTLFLAG_RDTUN, multiq, 0,
 use min(ncpus/ports, 8) queue-sets per port);
 
 /*
@@ -223,7 +223,7 @@ SYSCTL_UINT(_hw_cxgb, OID_AUTO, multiq, 
  */
 static int force_fw_update = 0;
 TUNABLE_INT(hw.cxgb.force_fw_update, force_fw_update);
-SYSCTL_UINT(_hw_cxgb, OID_AUTO, force_fw_update, CTLFLAG_RDTUN, 
force_fw_update, 0,
+SYSCTL_INT(_hw_cxgb, OID_AUTO, force_fw_update, CTLFLAG_RDTUN, 
force_fw_update, 0,
 update firmware even if up to date);
 
 int cxgb_use_16k_clusters = -1;
@@ -236,7 +236,7 @@ SYSCTL_INT(_hw_cxgb, OID_AUTO, use_16k_c
  */
 int cxgb_snd_queue_len = IFQ_MAXLEN;
 TUNABLE_INT(hw.cxgb.snd_queue_len, cxgb_snd_queue_len);
-SYSCTL_UINT(_hw_cxgb, OID_AUTO, snd_queue_len, CTLFLAG_RDTUN,
+SYSCTL_INT(_hw_cxgb, OID_AUTO, snd_queue_len, CTLFLAG_RDTUN,
 cxgb_snd_queue_len, 0, send queue size );
 
 static int nfilters = -1;

Modified: head/sys/dev/cxgb/cxgb_sge.c
==
--- head/sys/dev/cxgb/cxgb_sge.cWed Jan 12 19:53:39 2011
(r217320)
+++ head/sys/dev/cxgb/cxgb_sge.cWed Jan 12 19:53:44 2011
(r217321)
@@ -79,12 +79,12 @@ int multiq_tx_enable = 1;
 extern struct sysctl_oid_list sysctl__hw_cxgb_children;
 int cxgb_txq_buf_ring_size = TX_ETH_Q_SIZE;
 TUNABLE_INT(hw.cxgb.txq_mr_size, cxgb_txq_buf_ring_size);
-SYSCTL_UINT(_hw_cxgb, OID_AUTO, txq_mr_size, CTLFLAG_RDTUN, 
cxgb_txq_buf_ring_size, 0,
+SYSCTL_INT(_hw_cxgb, OID_AUTO, txq_mr_size, CTLFLAG_RDTUN, 
cxgb_txq_buf_ring_size, 0,
 size of per-queue mbuf ring);
 
 static int cxgb_tx_coalesce_force = 0;
 TUNABLE_INT(hw.cxgb.tx_coalesce_force, cxgb_tx_coalesce_force);
-SYSCTL_UINT(_hw_cxgb, OID_AUTO, tx_coalesce_force, CTLFLAG_RW,
+SYSCTL_INT(_hw_cxgb, OID_AUTO, tx_coalesce_force, CTLFLAG_RW,
 cxgb_tx_coalesce_force, 0,
 coalesce small packets into a single work request regardless of ring 
state);
 
@@ -100,17 +100,17 @@ SYSCTL_UINT(_hw_cxgb, OID_AUTO, tx_coale
 static int cxgb_tx_coalesce_enable_start = COALESCE_START_DEFAULT;
 TUNABLE_INT(hw.cxgb.tx_coalesce_enable_start,
 cxgb_tx_coalesce_enable_start);
-SYSCTL_UINT(_hw_cxgb, OID_AUTO, tx_coalesce_enable_start, CTLFLAG_RW,
+SYSCTL_INT(_hw_cxgb, OID_AUTO, tx_coalesce_enable_start, CTLFLAG_RW,
 cxgb_tx_coalesce_enable_start, 0,
 coalesce enable threshold);
 static int cxgb_tx_coalesce_enable_stop = COALESCE_STOP_DEFAULT;
 TUNABLE_INT(hw.cxgb.tx_coalesce_enable_stop, cxgb_tx_coalesce_enable_stop);
-SYSCTL_UINT(_hw_cxgb, OID_AUTO, tx_coalesce_enable_stop, CTLFLAG_RW,
+SYSCTL_INT(_hw_cxgb, OID_AUTO, tx_coalesce_enable_stop, CTLFLAG_RW,
 cxgb_tx_coalesce_enable_stop, 0,
 coalesce disable threshold);
 static int cxgb_tx_reclaim_threshold = TX_RECLAIM_DEFAULT;
 TUNABLE_INT(hw.cxgb.tx_reclaim_threshold, cxgb_tx_reclaim_threshold);
-SYSCTL_UINT(_hw_cxgb, OID_AUTO, tx_reclaim_threshold, CTLFLAG_RW,
+SYSCTL_INT(_hw_cxgb, OID_AUTO, tx_reclaim_threshold, CTLFLAG_RW,
 cxgb_tx_reclaim_threshold, 0,
 tx cleaning minimum threshold);
 
@@ -3493,7 +3493,7 @@ t3_add_attach_sysctls(adapter_t *sc)
firmware_version,
CTLFLAG_RD, sc-fw_version,
0, firmware version);
-   SYSCTL_ADD_INT(ctx, children, OID_AUTO, 
+   SYSCTL_ADD_UINT(ctx, children, OID_AUTO,
hw_revision,
CTLFLAG_RD, sc-params.rev,
0, chip model);
@@ -3505,14 +3505,14 @@ t3_add_attach_sysctls(adapter_t *sc)
  

svn commit: r217322 - in head/sys: net net80211 netinet netinet/cc netinet/ipfw

2011-01-12 Thread Matthew D Fleming
Author: mdf
Date: Wed Jan 12 19:53:50 2011
New Revision: 217322
URL: http://svn.freebsd.org/changeset/base/217322

Log:
  sysctl(9) cleanup checkpoint: amd64 GENERIC builds cleanly.
  
  Commit the net* piece.

Modified:
  head/sys/net/if.c
  head/sys/net/netisr.c
  head/sys/net/route.c
  head/sys/net80211/ieee80211_amrr.c
  head/sys/net80211/ieee80211_freebsd.c
  head/sys/netinet/cc/cc_htcp.c
  head/sys/netinet/ipfw/ip_dn_io.c
  head/sys/netinet/ipfw/ip_fw_dynamic.c
  head/sys/netinet/tcp_hostcache.c
  head/sys/netinet/tcp_subr.c
  head/sys/netinet/tcp_syncache.c

Modified: head/sys/net/if.c
==
--- head/sys/net/if.c   Wed Jan 12 19:53:44 2011(r217321)
+++ head/sys/net/if.c   Wed Jan 12 19:53:50 2011(r217322)
@@ -100,7 +100,7 @@ SYSCTL_NODE(_net, PF_LINK, link, CTLFLAG
 SYSCTL_NODE(_net_link, 0, generic, CTLFLAG_RW, 0, Generic link-management);
 
 TUNABLE_INT(net.link.ifqmaxlen, ifqmaxlen);
-SYSCTL_UINT(_net_link, OID_AUTO, ifqmaxlen, CTLFLAG_RDTUN,
+SYSCTL_INT(_net_link, OID_AUTO, ifqmaxlen, CTLFLAG_RDTUN,
 ifqmaxlen, 0, max send queue size);
 
 /* Log link state change events */

Modified: head/sys/net/netisr.c
==
--- head/sys/net/netisr.c   Wed Jan 12 19:53:44 2011(r217321)
+++ head/sys/net/netisr.c   Wed Jan 12 19:53:50 2011(r217322)
@@ -179,7 +179,7 @@ SYSCTL_INT(_net_isr, OID_AUTO, bindthrea
 #defineNETISR_DEFAULT_MAXQLIMIT10240
 static u_int   netisr_maxqlimit = NETISR_DEFAULT_MAXQLIMIT;
 TUNABLE_INT(net.isr.maxqlimit, netisr_maxqlimit);
-SYSCTL_INT(_net_isr, OID_AUTO, maxqlimit, CTLFLAG_RDTUN,
+SYSCTL_UINT(_net_isr, OID_AUTO, maxqlimit, CTLFLAG_RDTUN,
 netisr_maxqlimit, 0,
 Maximum netisr per-protocol, per-CPU queue depth.);
 
@@ -191,7 +191,7 @@ SYSCTL_INT(_net_isr, OID_AUTO, maxqlimit
 #defineNETISR_DEFAULT_DEFAULTQLIMIT256
 static u_int   netisr_defaultqlimit = NETISR_DEFAULT_DEFAULTQLIMIT;
 TUNABLE_INT(net.isr.defaultqlimit, netisr_defaultqlimit);
-SYSCTL_INT(_net_isr, OID_AUTO, defaultqlimit, CTLFLAG_RDTUN,
+SYSCTL_UINT(_net_isr, OID_AUTO, defaultqlimit, CTLFLAG_RDTUN,
 netisr_defaultqlimit, 0,
 Default netisr per-protocol, per-CPU queue limit if not set by protocol);
 
@@ -201,7 +201,7 @@ SYSCTL_INT(_net_isr, OID_AUTO, defaultql
  * required for crashdump analysis, as it sizes netisr_proto[].
  */
 static u_int   netisr_maxprot = NETISR_MAXPROT;
-SYSCTL_INT(_net_isr, OID_AUTO, maxprot, CTLFLAG_RD,
+SYSCTL_UINT(_net_isr, OID_AUTO, maxprot, CTLFLAG_RD,
 netisr_maxprot, 0,
 Compile-time limit on the number of protocols supported by netisr.);
 
@@ -228,7 +228,7 @@ static u_int 
nws_array[MAXCPU];
  * CPUs once fully started.
  */
 static u_intnws_count;
-SYSCTL_INT(_net_isr, OID_AUTO, numthreads, CTLFLAG_RD,
+SYSCTL_UINT(_net_isr, OID_AUTO, numthreads, CTLFLAG_RD,
 nws_count, 0, Number of extant netisr threads.);
 
 /*

Modified: head/sys/net/route.c
==
--- head/sys/net/route.cWed Jan 12 19:53:44 2011(r217321)
+++ head/sys/net/route.cWed Jan 12 19:53:50 2011(r217322)
@@ -68,7 +68,7 @@
 #include vm/uma.h
 
 u_int rt_numfibs = RT_NUMFIBS;
-SYSCTL_INT(_net, OID_AUTO, fibs, CTLFLAG_RD, rt_numfibs, 0, );
+SYSCTL_UINT(_net, OID_AUTO, fibs, CTLFLAG_RD, rt_numfibs, 0, );
 /*
  * Allow the boot code to allow LESS than RT_MAXFIBS to be used.
  * We can't do more because storage is statically allocated for now.
@@ -84,7 +84,7 @@ TUNABLE_INT(net.fibs, rt_numfibs);
  * a more fine grained solution.. that will come.
  */
 u_int rt_add_addr_allfibs = 1;
-SYSCTL_INT(_net, OID_AUTO, add_addr_allfibs, CTLFLAG_RW,
+SYSCTL_UINT(_net, OID_AUTO, add_addr_allfibs, CTLFLAG_RW,
 rt_add_addr_allfibs, 0, );
 TUNABLE_INT(net.add_addr_allfibs, rt_add_addr_allfibs);
 

Modified: head/sys/net80211/ieee80211_amrr.c
==
--- head/sys/net80211/ieee80211_amrr.c  Wed Jan 12 19:53:44 2011
(r217321)
+++ head/sys/net80211/ieee80211_amrr.c  Wed Jan 12 19:53:50 2011
(r217322)
@@ -308,10 +308,10 @@ amrr_sysctlattach(struct ieee80211vap *v
amrr_rate_interval, CTLTYPE_INT | CTLFLAG_RW, vap,
0, amrr_sysctl_interval, I, amrr operation interval (ms));
/* XXX bounds check values */
-   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
+   SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
amrr_max_sucess_threshold, CTLFLAG_RW,
amrr-amrr_max_success_threshold, 0, );
-   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
+   SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
amrr_min_sucess_threshold, CTLFLAG_RW,

svn commit: r217323 - in head/sys/dev: acpi_support ae alc ale ath bce bge bwi bwn ed iscsi/initiator iwi mps mpt nfe pccbb sound/pcm ste txp usb/input

2011-01-12 Thread Matthew D Fleming
Author: mdf
Date: Wed Jan 12 19:53:56 2011
New Revision: 217323
URL: http://svn.freebsd.org/changeset/base/217323

Log:
  sysctl(9) cleanup checkpoint: amd64 GENERIC builds cleanly.
  
  Commit the rest of the devices.

Modified:
  head/sys/dev/acpi_support/acpi_ibm.c
  head/sys/dev/ae/if_ae.c
  head/sys/dev/alc/if_alc.c
  head/sys/dev/ale/if_ale.c
  head/sys/dev/ath/if_ath.c
  head/sys/dev/bce/if_bce.c
  head/sys/dev/bge/if_bge.c
  head/sys/dev/bwi/if_bwi.c
  head/sys/dev/bwn/if_bwn.c
  head/sys/dev/ed/if_ed.c
  head/sys/dev/iscsi/initiator/iscsi.c
  head/sys/dev/iwi/if_iwi.c
  head/sys/dev/mps/mps.c
  head/sys/dev/mpt/mpt.c
  head/sys/dev/mpt/mpt_raid.c
  head/sys/dev/nfe/if_nfe.c
  head/sys/dev/pccbb/pccbb.c
  head/sys/dev/sound/pcm/sound.c
  head/sys/dev/ste/if_ste.c
  head/sys/dev/txp/if_txp.c
  head/sys/dev/usb/input/atp.c

Modified: head/sys/dev/acpi_support/acpi_ibm.c
==
--- head/sys/dev/acpi_support/acpi_ibm.cWed Jan 12 19:53:50 2011
(r217322)
+++ head/sys/dev/acpi_support/acpi_ibm.cWed Jan 12 19:53:56 2011
(r217323)
@@ -367,7 +367,7 @@ acpi_ibm_attach(device_t dev)
IBM_NAME_EVENTS_MASK_GET, sc-events_initialmask));
 
if (sc-events_mask_supported) {
-   SYSCTL_ADD_INT(sc-sysctl_ctx,
+   SYSCTL_ADD_UINT(sc-sysctl_ctx,
SYSCTL_CHILDREN(sc-sysctl_tree), OID_AUTO,
initialmask, CTLFLAG_RD,
sc-events_initialmask, 0, Initial eventmask);
@@ -377,7 +377,7 @@ acpi_ibm_attach(device_t dev)
IBM_NAME_EVENTS_AVAILMASK, sc-events_availmask)))
sc-events_availmask = 0x;
 
-   SYSCTL_ADD_INT(sc-sysctl_ctx,
+   SYSCTL_ADD_UINT(sc-sysctl_ctx,
SYSCTL_CHILDREN(sc-sysctl_tree), OID_AUTO,
availmask, CTLFLAG_RD,
sc-events_availmask, 0, Mask of supported events);

Modified: head/sys/dev/ae/if_ae.c
==
--- head/sys/dev/ae/if_ae.c Wed Jan 12 19:53:50 2011(r217322)
+++ head/sys/dev/ae/if_ae.c Wed Jan 12 19:53:56 2011(r217323)
@@ -207,43 +207,6 @@ TUNABLE_INT(hw.ae.msi_disable, msi_di
 #defineAE_TXD_VLAN(vtag) \
(((vtag)  4) | (((vtag)  13)  0x07) | (((vtag)  9)  0x08))
 
-/*
- * ae statistics.
- */
-#defineSTATS_ENTRY(node, desc, field) \
-{ node, desc, offsetof(struct ae_stats, field) }
-struct {
-   const char  *node;
-   const char  *desc;
-   intptr_toffset;
-} ae_stats_tx[] = {
-   STATS_ENTRY(bcast, broadcast frames, tx_bcast),
-   STATS_ENTRY(mcast, multicast frames, tx_mcast),
-   STATS_ENTRY(pause, PAUSE frames, tx_pause),
-   STATS_ENTRY(control, control frames, tx_ctrl),
-   STATS_ENTRY(defers, deferrals occuried, tx_defer),
-   STATS_ENTRY(exc_defers, excessive deferrals occuried, tx_excdefer),
-   STATS_ENTRY(singlecols, single collisions occuried, tx_singlecol),
-   STATS_ENTRY(multicols, multiple collisions occuried, tx_multicol),
-   STATS_ENTRY(latecols, late collisions occuried, tx_latecol),
-   STATS_ENTRY(aborts, transmit aborts due collisions, tx_abortcol),
-   STATS_ENTRY(underruns, Tx FIFO underruns, tx_underrun)
-}, ae_stats_rx[] = {
-   STATS_ENTRY(bcast, broadcast frames, rx_bcast),
-   STATS_ENTRY(mcast, multicast frames, rx_mcast),
-   STATS_ENTRY(pause, PAUSE frames, rx_pause),
-   STATS_ENTRY(control, control frames, rx_ctrl),
-   STATS_ENTRY(crc_errors, frames with CRC errors, rx_crcerr),
-   STATS_ENTRY(code_errors, frames with invalid opcode, rx_codeerr),
-   STATS_ENTRY(runt, runt frames, rx_runt),
-   STATS_ENTRY(frag, fragmented frames, rx_frag),
-   STATS_ENTRY(align_errors, frames with alignment errors, rx_align),
-   STATS_ENTRY(truncated, frames truncated due to Rx FIFO inderrun,
-   rx_trunc)
-};
-#defineAE_STATS_RX_LEN (sizeof(ae_stats_rx) / sizeof(*ae_stats_rx))
-#defineAE_STATS_TX_LEN (sizeof(ae_stats_tx) / sizeof(*ae_stats_tx))
-
 static int
 ae_probe(device_t dev)
 {
@@ -433,13 +396,15 @@ fail:
return (error);
 }
 
+#defineAE_SYSCTL(stx, parent, name, desc, ptr) \
+   SYSCTL_ADD_UINT(ctx, parent, OID_AUTO, name, CTLFLAG_RD, ptr, 0, desc)
+
 static void
 ae_init_tunables(ae_softc_t *sc)
 {
struct sysctl_ctx_list *ctx;
struct sysctl_oid *root, *stats, *stats_rx, *stats_tx;
struct ae_stats *ae_stats;
-   unsigned int i;
 
KASSERT(sc != NULL, ([ae, %d]: sc is NULL, __LINE__));
ae_stats = sc-stats;
@@ -454,20 +419,54 @@ ae_init_tunables(ae_softc_t *sc)
 */
stats_rx = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(stats), OID_AUTO, rx,
CTLFLAG_RD, NULL, Rx MAC statistics);
-   for (i = 0; i  

svn commit: r217324 - head/sys/geom/sched

2011-01-12 Thread Matthew D Fleming
Author: mdf
Date: Wed Jan 12 19:54:07 2011
New Revision: 217324
URL: http://svn.freebsd.org/changeset/base/217324

Log:
  sysctl(9) cleanup checkpoint: amd64 GENERIC builds cleanly.
  
  Commit the geom piece.

Modified:
  head/sys/geom/sched/g_sched.c
  head/sys/geom/sched/gs_rr.c

Modified: head/sys/geom/sched/g_sched.c
==
--- head/sys/geom/sched/g_sched.c   Wed Jan 12 19:53:56 2011
(r217323)
+++ head/sys/geom/sched/g_sched.c   Wed Jan 12 19:54:07 2011
(r217324)
@@ -189,10 +189,10 @@ SYSCTL_DECL(_kern_geom);
 SYSCTL_NODE(_kern_geom, OID_AUTO, sched, CTLFLAG_RW, 0,
 GEOM_SCHED stuff);
 
-SYSCTL_INT(_kern_geom_sched, OID_AUTO, in_flight_wb, CTLFLAG_RD,
+SYSCTL_UINT(_kern_geom_sched, OID_AUTO, in_flight_wb, CTLFLAG_RD,
 me.gs_write_bytes_in_flight, 0, Write bytes in flight);
 
-SYSCTL_INT(_kern_geom_sched, OID_AUTO, in_flight_b, CTLFLAG_RD,
+SYSCTL_UINT(_kern_geom_sched, OID_AUTO, in_flight_b, CTLFLAG_RD,
 me.gs_bytes_in_flight, 0, Bytes in flight);
 
 SYSCTL_UINT(_kern_geom_sched, OID_AUTO, in_flight_w, CTLFLAG_RD,

Modified: head/sys/geom/sched/gs_rr.c
==
--- head/sys/geom/sched/gs_rr.c Wed Jan 12 19:53:56 2011(r217323)
+++ head/sys/geom/sched/gs_rr.c Wed Jan 12 19:54:07 2011(r217324)
@@ -198,25 +198,25 @@ struct g_rr_params *gs_rr_me = me;
 SYSCTL_DECL(_kern_geom_sched);
 SYSCTL_NODE(_kern_geom_sched, OID_AUTO, rr, CTLFLAG_RW, 0,
 GEOM_SCHED ROUND ROBIN stuff);
-SYSCTL_UINT(_kern_geom_sched_rr, OID_AUTO, units, CTLFLAG_RD,
+SYSCTL_INT(_kern_geom_sched_rr, OID_AUTO, units, CTLFLAG_RD,
 me.units, 0, Scheduler instances);
-SYSCTL_UINT(_kern_geom_sched_rr, OID_AUTO, queues, CTLFLAG_RD,
+SYSCTL_INT(_kern_geom_sched_rr, OID_AUTO, queues, CTLFLAG_RD,
 me.queues, 0, Total rr queues);
-SYSCTL_UINT(_kern_geom_sched_rr, OID_AUTO, wait_ms, CTLFLAG_RW,
+SYSCTL_INT(_kern_geom_sched_rr, OID_AUTO, wait_ms, CTLFLAG_RW,
 me.wait_ms.x_cur, 0, Wait time milliseconds);
-SYSCTL_UINT(_kern_geom_sched_rr, OID_AUTO, quantum_ms, CTLFLAG_RW,
+SYSCTL_INT(_kern_geom_sched_rr, OID_AUTO, quantum_ms, CTLFLAG_RW,
 me.quantum_ms.x_cur, 0, Quantum size milliseconds);
-SYSCTL_UINT(_kern_geom_sched_rr, OID_AUTO, bypass, CTLFLAG_RW,
+SYSCTL_INT(_kern_geom_sched_rr, OID_AUTO, bypass, CTLFLAG_RW,
 me.bypass, 0, Bypass scheduler);
-SYSCTL_UINT(_kern_geom_sched_rr, OID_AUTO, w_anticipate, CTLFLAG_RW,
+SYSCTL_INT(_kern_geom_sched_rr, OID_AUTO, w_anticipate, CTLFLAG_RW,
 me.w_anticipate, 0, Do anticipation on writes);
-SYSCTL_UINT(_kern_geom_sched_rr, OID_AUTO, quantum_kb, CTLFLAG_RW,
+SYSCTL_INT(_kern_geom_sched_rr, OID_AUTO, quantum_kb, CTLFLAG_RW,
 me.quantum_kb.x_cur, 0, Quantum size Kbytes);
-SYSCTL_UINT(_kern_geom_sched_rr, OID_AUTO, queue_depth, CTLFLAG_RW,
+SYSCTL_INT(_kern_geom_sched_rr, OID_AUTO, queue_depth, CTLFLAG_RW,
 me.queue_depth.x_cur, 0, Maximum simultaneous requests);
-SYSCTL_UINT(_kern_geom_sched_rr, OID_AUTO, wait_hit, CTLFLAG_RW,
+SYSCTL_INT(_kern_geom_sched_rr, OID_AUTO, wait_hit, CTLFLAG_RW,
 me.wait_hit, 0, Hits in anticipation);
-SYSCTL_UINT(_kern_geom_sched_rr, OID_AUTO, wait_miss, CTLFLAG_RW,
+SYSCTL_INT(_kern_geom_sched_rr, OID_AUTO, wait_miss, CTLFLAG_RW,
 me.wait_miss, 0, Misses in anticipation);
 
 #ifdef DEBUG_QUEUES
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r217325 - in head/sys/security: mac mac_seeotheruids

2011-01-12 Thread Matthew D Fleming
Author: mdf
Date: Wed Jan 12 19:54:14 2011
New Revision: 217325
URL: http://svn.freebsd.org/changeset/base/217325

Log:
  sysctl(9) cleanup checkpoint: amd64 GENERIC builds cleanly.
  
  Commit the security directory.

Modified:
  head/sys/security/mac/mac_framework.c
  head/sys/security/mac_seeotheruids/mac_seeotheruids.c

Modified: head/sys/security/mac/mac_framework.c
==
--- head/sys/security/mac/mac_framework.c   Wed Jan 12 19:54:07 2011
(r217324)
+++ head/sys/security/mac/mac_framework.c   Wed Jan 12 19:54:14 2011
(r217325)
@@ -151,7 +151,7 @@ static int  mac_late = 0;
  * for an object type at run-time.
  */
 uint64_t   mac_labeled;
-SYSCTL_QUAD(_security_mac, OID_AUTO, labeled, CTLFLAG_RD, mac_labeled, 0,
+SYSCTL_UQUAD(_security_mac, OID_AUTO, labeled, CTLFLAG_RD, mac_labeled, 0,
 Mask of object types being labeled);
 
 MALLOC_DEFINE(M_MACTEMP, mactemp, MAC temporary label storage);

Modified: head/sys/security/mac_seeotheruids/mac_seeotheruids.c
==
--- head/sys/security/mac_seeotheruids/mac_seeotheruids.c   Wed Jan 12 
19:54:07 2011(r217324)
+++ head/sys/security/mac_seeotheruids/mac_seeotheruids.c   Wed Jan 12 
19:54:14 2011(r217325)
@@ -98,7 +98,7 @@ SYSCTL_INT(_security_mac_seeotheruids, O
 with a specific gid as their real primary group id or group set);
 
 static gid_t   specificgid = 0;
-SYSCTL_INT(_security_mac_seeotheruids, OID_AUTO, specificgid, CTLFLAG_RW,
+SYSCTL_UINT(_security_mac_seeotheruids, OID_AUTO, specificgid, CTLFLAG_RW,
 specificgid, 0, Specific gid to be exempt from seeotheruids policy);
 
 static int
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r217328 - head/sys/sys

2011-01-12 Thread Matthew D Fleming
Author: mdf
Date: Wed Jan 12 20:38:55 2011
New Revision: 217328
URL: http://svn.freebsd.org/changeset/base/217328

Log:
  Fix a typo.  XLONG should allow pointers to unsigned and signed long.
  
  Submitted by: bf1783 AT gmail DOT com

Modified:
  head/sys/sys/sysctl.h

Modified: head/sys/sys/sysctl.h
==
--- head/sys/sys/sysctl.h   Wed Jan 12 20:27:14 2011(r217327)
+++ head/sys/sys/sysctl.h   Wed Jan 12 20:38:55 2011(r217328)
@@ -242,7 +242,7 @@ SYSCTL_ALLOWED_TYPES(UINT, unsigned int 
 SYSCTL_ALLOWED_TYPES(XINT, unsigned int *a; int *b; );
 SYSCTL_ALLOWED_TYPES(LONG, long *a; );
 SYSCTL_ALLOWED_TYPES(ULONG, unsigned long *a; );
-SYSCTL_ALLOWED_TYPES(XLONG, unsigned long *a; long b; );
+SYSCTL_ALLOWED_TYPES(XLONG, unsigned long *a; long *b; );
 SYSCTL_ALLOWED_TYPES(INT64, int64_t *a; long long *b; );
 SYSCTL_ALLOWED_TYPES(UINT64, uint64_t *a; unsigned long long *b; );
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r217330 - head/sys/x86/x86

2011-01-12 Thread Matthew D Fleming
Author: mdf
Date: Wed Jan 12 21:08:49 2011
New Revision: 217330
URL: http://svn.freebsd.org/changeset/base/217330

Log:
  Fix a brain fart.  Since this file is shared between i386 and amd64, a
  bus_size_t may be 32 or 64 bits.  Change the bounce_zone alignment field
  to explicitly be 32 bits, as I can't really imagine a DMA device that
  needs anything close to 2GB alignment of data.

Modified:
  head/sys/x86/x86/busdma_machdep.c

Modified: head/sys/x86/x86/busdma_machdep.c
==
--- head/sys/x86/x86/busdma_machdep.c   Wed Jan 12 20:44:11 2011
(r217329)
+++ head/sys/x86/x86/busdma_machdep.c   Wed Jan 12 21:08:49 2011
(r217330)
@@ -100,7 +100,7 @@ struct bounce_zone {
int total_bounced;
int total_deferred;
int map_count;
-   bus_size_t  alignment;
+   uint32_talignment;
bus_addr_t  lowaddr;
charzoneid[8];
charlowaddrid[20];
@@ -1060,9 +1060,9 @@ alloc_bounce_zone(bus_dma_tag_t dmat)
SYSCTL_ADD_STRING(busdma_sysctl_tree(bz),
SYSCTL_CHILDREN(busdma_sysctl_tree_top(bz)), OID_AUTO,
lowaddr, CTLFLAG_RD, bz-lowaddrid, 0, );
-   SYSCTL_ADD_UQUAD(busdma_sysctl_tree(bz),
+   SYSCTL_ADD_UINT(busdma_sysctl_tree(bz),
SYSCTL_CHILDREN(busdma_sysctl_tree_top(bz)), OID_AUTO,
-   alignment, CTLFLAG_RD, bz-alignment, );
+   alignment, CTLFLAG_RD, bz-alignment, 0, );
 
return (0);
 }
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r217332 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2011-01-12 Thread Matthew D Fleming
Author: mdf
Date: Wed Jan 12 23:06:38 2011
New Revision: 217332
URL: http://svn.freebsd.org/changeset/base/217332

Log:
  Revert cddl changes for sysctl(9) until I understand why this isn't
  building on universe.

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_zfetch.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/txg.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c   Wed Jan 12 
22:24:07 2011(r217331)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c   Wed Jan 12 
23:06:38 2011(r217332)
@@ -188,9 +188,9 @@ TUNABLE_QUAD(vfs.zfs.arc_min, zfs_arc
 TUNABLE_QUAD(vfs.zfs.arc_meta_limit, zfs_arc_meta_limit);
 TUNABLE_INT(vfs.zfs.mdcomp_disable, zfs_mdcomp_disable);
 SYSCTL_DECL(_vfs_zfs);
-SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, arc_max, CTLFLAG_RDTUN, zfs_arc_max, 0,
+SYSCTL_QUAD(_vfs_zfs, OID_AUTO, arc_max, CTLFLAG_RDTUN, zfs_arc_max, 0,
 Maximum ARC size);
-SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, arc_min, CTLFLAG_RDTUN, zfs_arc_min, 0,
+SYSCTL_QUAD(_vfs_zfs, OID_AUTO, arc_min, CTLFLAG_RDTUN, zfs_arc_min, 0,
 Minimum ARC size);
 SYSCTL_INT(_vfs_zfs, OID_AUTO, mdcomp_disable, CTLFLAG_RDTUN,
 zfs_mdcomp_disable, 0, Disable metadata compression);
@@ -466,9 +466,9 @@ static uint64_t arc_loaned_bytes;
 static uint64_tarc_meta_used;
 static uint64_tarc_meta_limit;
 static uint64_tarc_meta_max = 0;
-SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, arc_meta_used, CTLFLAG_RDTUN,
+SYSCTL_QUAD(_vfs_zfs, OID_AUTO, arc_meta_used, CTLFLAG_RDTUN,
 arc_meta_used, 0, ARC metadata used);
-SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, arc_meta_limit, CTLFLAG_RDTUN,
+SYSCTL_QUAD(_vfs_zfs, OID_AUTO, arc_meta_limit, CTLFLAG_RDTUN,
 arc_meta_limit, 0, ARC metadata limit);
 
 typedef struct l2arc_buf_hdr l2arc_buf_hdr_t;
@@ -638,15 +638,15 @@ boolean_t l2arc_noprefetch = B_FALSE; /
 boolean_t l2arc_feed_again = B_TRUE;   /* turbo warmup */
 boolean_t l2arc_norw = B_TRUE; /* no reads during writes */
 
-SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_write_max, CTLFLAG_RW,
+SYSCTL_QUAD(_vfs_zfs, OID_AUTO, l2arc_write_max, CTLFLAG_RW,
 l2arc_write_max, 0, max write size);
-SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_write_boost, CTLFLAG_RW,
+SYSCTL_QUAD(_vfs_zfs, OID_AUTO, l2arc_write_boost, CTLFLAG_RW,
 l2arc_write_boost, 0, extra write during warmup);
-SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_headroom, CTLFLAG_RW,
+SYSCTL_QUAD(_vfs_zfs, OID_AUTO, l2arc_headroom, CTLFLAG_RW,
 l2arc_headroom, 0, number of dev writes);
-SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_feed_secs, CTLFLAG_RW,
+SYSCTL_QUAD(_vfs_zfs, OID_AUTO, l2arc_feed_secs, CTLFLAG_RW,
 l2arc_feed_secs, 0, interval seconds);
-SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_feed_min_ms, CTLFLAG_RW,
+SYSCTL_QUAD(_vfs_zfs, OID_AUTO, l2arc_feed_min_ms, CTLFLAG_RW,
 l2arc_feed_min_ms, 0, min interval milliseconds);
 
 SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_noprefetch, CTLFLAG_RW,
@@ -656,46 +656,46 @@ SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_fee
 SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_norw, CTLFLAG_RW,
 l2arc_norw, 0, no reads during writes);
 
-SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, anon_size, CTLFLAG_RD,
+SYSCTL_QUAD(_vfs_zfs, OID_AUTO, anon_size, CTLFLAG_RD,
 ARC_anon.arcs_size, 0, size of anonymous state);
-SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, anon_metadata_lsize, CTLFLAG_RD,
+SYSCTL_QUAD(_vfs_zfs, OID_AUTO, anon_metadata_lsize, CTLFLAG_RD,
 ARC_anon.arcs_lsize[ARC_BUFC_METADATA], 0, size of anonymous state);
-SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, anon_data_lsize, CTLFLAG_RD,
+SYSCTL_QUAD(_vfs_zfs, OID_AUTO, anon_data_lsize, CTLFLAG_RD,
 ARC_anon.arcs_lsize[ARC_BUFC_DATA], 0, size of anonymous state);
 
-SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_size, CTLFLAG_RD,
+SYSCTL_QUAD(_vfs_zfs, OID_AUTO, mru_size, CTLFLAG_RD,
 ARC_mru.arcs_size, 0, size of mru state);
-SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_metadata_lsize, CTLFLAG_RD,
+SYSCTL_QUAD(_vfs_zfs, OID_AUTO, mru_metadata_lsize, CTLFLAG_RD,
 ARC_mru.arcs_lsize[ARC_BUFC_METADATA], 0, size of metadata in mru 
state);
-SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_data_lsize, CTLFLAG_RD,
+SYSCTL_QUAD(_vfs_zfs, OID_AUTO, mru_data_lsize, CTLFLAG_RD,
 ARC_mru.arcs_lsize[ARC_BUFC_DATA], 0, size of data in mru state);
 
-SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_ghost_size, CTLFLAG_RD,
+SYSCTL_QUAD(_vfs_zfs, OID_AUTO, mru_ghost_size, CTLFLAG_RD,
 ARC_mru_ghost.arcs_size, 0, size of mru ghost state);
-SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_ghost_metadata_lsize, CTLFLAG_RD,
+SYSCTL_QUAD(_vfs_zfs, OID_AUTO, mru_ghost_metadata_lsize, CTLFLAG_RD,
 ARC_mru_ghost.arcs_lsize[ARC_BUFC_METADATA], 0,
 size of metadata in mru ghost state);
-SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_ghost_data_lsize, CTLFLAG_RD,

svn commit: r217337 - head/sys/x86/x86

2011-01-12 Thread Matthew D Fleming
Author: mdf
Date: Thu Jan 13 00:52:57 2011
New Revision: 217337
URL: http://svn.freebsd.org/changeset/base/217337

Log:
  Revert to using bus_size_t for the bounce_zone's alignment member.
  
  Reuqested by: jhb

Modified:
  head/sys/x86/x86/busdma_machdep.c

Modified: head/sys/x86/x86/busdma_machdep.c
==
--- head/sys/x86/x86/busdma_machdep.c   Wed Jan 12 23:46:12 2011
(r217336)
+++ head/sys/x86/x86/busdma_machdep.c   Thu Jan 13 00:52:57 2011
(r217337)
@@ -100,7 +100,7 @@ struct bounce_zone {
int total_bounced;
int total_deferred;
int map_count;
-   uint32_talignment;
+   bus_size_t  alignment;
bus_addr_t  lowaddr;
charzoneid[8];
charlowaddrid[20];
@@ -993,6 +993,13 @@ busdma_sysctl_tree_top(struct bounce_zon
return (bz-sysctl_tree_top);
 }
 
+#if defined(__amd64__) || defined(PAE)
+#defineSYSCTL_ADD_BUS_SIZE_T   SYSCTL_ADD_UQUAD
+#else
+#defineSYSCTL_ADD_BUS_SIZE_T(ctx, parent, nbr, name, flag, ptr, desc)  
\
+   SYSCTL_ADD_UINT(ctx, parent, nbr, name, flag, ptr, 0, desc)
+#endif
+
 static int
 alloc_bounce_zone(bus_dma_tag_t dmat)
 {
@@ -1060,9 +1067,9 @@ alloc_bounce_zone(bus_dma_tag_t dmat)
SYSCTL_ADD_STRING(busdma_sysctl_tree(bz),
SYSCTL_CHILDREN(busdma_sysctl_tree_top(bz)), OID_AUTO,
lowaddr, CTLFLAG_RD, bz-lowaddrid, 0, );
-   SYSCTL_ADD_UINT(busdma_sysctl_tree(bz),
+   SYSCTL_ADD_BUS_SIZE_T(busdma_sysctl_tree(bz),
SYSCTL_CHILDREN(busdma_sysctl_tree_top(bz)), OID_AUTO,
-   alignment, CTLFLAG_RD, bz-alignment, 0, );
+   alignment, CTLFLAG_RD, bz-alignment, );
 
return (0);
 }
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r217109 - head/sys/geom/part

2011-01-07 Thread Matthew D Fleming
Author: mdf
Date: Fri Jan  7 16:46:20 2011
New Revision: 217109
URL: http://svn.freebsd.org/changeset/base/217109

Log:
  Fix a memory overflow where the input length to g_gpt_utf8_to_utf16()
  was specified incorrectly, causing the bzero to run past the end of a
  malloc(9)'d object.
  
  Submitted by: Eric Youngblut  eyoungblut AT isilon DOT com 
  MFC after:3 days

Modified:
  head/sys/geom/part/g_part_gpt.c

Modified: head/sys/geom/part/g_part_gpt.c
==
--- head/sys/geom/part/g_part_gpt.c Fri Jan  7 16:13:12 2011
(r217108)
+++ head/sys/geom/part/g_part_gpt.c Fri Jan  7 16:46:20 2011
(r217109)
@@ -425,7 +425,8 @@ g_part_gpt_add(struct g_part_table *base
}
if (gpp-gpp_parms  G_PART_PARM_LABEL)
g_gpt_utf8_to_utf16(gpp-gpp_label, entry-ent.ent_name,
-   sizeof(entry-ent.ent_name));
+   sizeof(entry-ent.ent_name) /
+   sizeof(entry-ent.ent_name[0]));
return (0);
 }
 
@@ -588,7 +589,8 @@ g_part_gpt_modify(struct g_part_table *b
}
if (gpp-gpp_parms  G_PART_PARM_LABEL)
g_gpt_utf8_to_utf16(gpp-gpp_label, entry-ent.ent_name,
-   sizeof(entry-ent.ent_name));
+   sizeof(entry-ent.ent_name) /
+   sizeof(entry-ent.ent_name[0]));
return (0);
 }
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r216616 - in head/sys: kern sys

2010-12-21 Thread Matthew D Fleming
Author: mdf
Date: Tue Dec 21 16:29:58 2010
New Revision: 216616
URL: http://svn.freebsd.org/changeset/base/216616

Log:
  Move the fail_point_entry definition from fail.h to kern_fail.c, which
  allows putting the enumeration constants of fail point types with the
  text string that matches them.
  
  MFC after:1 week

Modified:
  head/sys/kern/kern_fail.c
  head/sys/sys/fail.h

Modified: head/sys/kern/kern_fail.c
==
--- head/sys/kern/kern_fail.c   Tue Dec 21 13:45:29 2010(r216615)
+++ head/sys/kern/kern_fail.c   Tue Dec 21 16:29:58 2010(r216616)
@@ -76,6 +76,43 @@ MTX_SYSINIT(g_fp_mtx, g_fp_mtx, fail p
 #define FP_LOCK()  mtx_lock(g_fp_mtx)
 #define FP_UNLOCK()mtx_unlock(g_fp_mtx)
 
+/**
+ * Failpoint types.
+ * Don't change these without changing fail_type_strings in fail.c.
+ * @ingroup failpoint_private
+ */
+enum fail_point_t {
+   FAIL_POINT_OFF, /** don't fail */
+   FAIL_POINT_PANIC,   /** panic */
+   FAIL_POINT_RETURN,  /** return an errorcode */
+   FAIL_POINT_BREAK,   /** break into the debugger */
+   FAIL_POINT_PRINT,   /** print a message */
+   FAIL_POINT_SLEEP,   /** sleep for some msecs */
+   FAIL_POINT_INVALID, /** placeholder */
+};
+
+static const char *fail_type_strings[] = {
+   off,
+   panic,
+   return,
+   break,
+   print,
+   sleep,
+};
+
+/**
+ * Internal structure tracking a single term of a complete failpoint.
+ * @ingroup failpoint_private
+ */
+struct fail_point_entry {
+   enum fail_point_t fe_type;  /** type of entry */
+   int fe_arg; /** argument to type (e.g. return 
value) */
+   int fe_prob;/** likelihood of firing in millionths 
*/
+   int fe_count;   /** number of times to fire, 0 means 
always */
+
+   TAILQ_ENTRY(fail_point_entry) fe_entries; /** next entry in fail point 
*/
+};
+
 static inline void
 fail_point_sleep(struct fail_point *fp, struct fail_point_entry *ent,
 int msecs, enum fail_point_return_code *pret)
@@ -102,15 +139,6 @@ enum {
PROB_DIGITS = 6,/* number of zero's in above number */
 };
 
-static const char *fail_type_strings[] = {
-   off,
-   panic,
-   return,
-   break,
-   print,
-   sleep,
-};
-
 static char *parse_fail_point(struct fail_point_entries *, char *);
 static char *parse_term(struct fail_point_entries *, char *);
 static char *parse_number(int *out_units, int *out_decimal, char *);

Modified: head/sys/sys/fail.h
==
--- head/sys/sys/fail.h Tue Dec 21 13:45:29 2010(r216615)
+++ head/sys/sys/fail.h Tue Dec 21 16:29:58 2010(r216616)
@@ -39,22 +39,6 @@
 #include sys/queue.h
 #include sys/sysctl.h
 
-
-/**
- * Failpoint types.
- * Don't change these without changing fail_type_strings in fail.c.
- * @ingroup failpoint_private
- */
-enum fail_point_t {
-   FAIL_POINT_OFF, /** don't fail */
-   FAIL_POINT_PANIC,   /** panic */
-   FAIL_POINT_RETURN,  /** return an errorcode */
-   FAIL_POINT_BREAK,   /** break into the debugger */
-   FAIL_POINT_PRINT,   /** print a message */
-   FAIL_POINT_SLEEP,   /** sleep for some msecs */
-   FAIL_POINT_INVALID, /** placeholder */
-};
-
 /**
  * Failpoint return codes, used internally.
  * @ingroup failpoint_private
@@ -65,6 +49,7 @@ enum fail_point_return_code {
FAIL_POINT_RC_QUEUED,   /** sleep_fn will be called */
 };
 
+struct fail_point_entry;
 TAILQ_HEAD(fail_point_entries, fail_point_entry);
 /**
  * Internal failpoint structure, tracking all the current details of the
@@ -84,18 +69,7 @@ struct fail_point {
 
 #defineFAIL_POINT_DYNAMIC_NAME 0x01/** Must free name on destroy 
*/
 
-/**
- * Internal structure tracking a single term of a complete failpoint.
- * @ingroup failpoint_private
- */
-struct fail_point_entry {
-   enum fail_point_t fe_type;  /** type of entry */
-   int fe_arg; /** argument to type (e.g. return 
value) */
-   int fe_prob;/** likelihood of firing in millionths 
*/
-   int fe_count;   /** number of times to fire, 0 means 
always */
-
-   TAILQ_ENTRY(fail_point_entry) fe_entries; /** next entry in fail point 
*/
-};
+__BEGIN_DECLS
 
 /* Private failpoint eval function -- use fail_point_eval() instead. */
 enum fail_point_return_code fail_point_eval_nontrivial(struct fail_point *,
@@ -152,6 +126,8 @@ fail_point_eval(struct fail_point *fp, i
return (fail_point_eval_nontrivial(fp, ret));
 }
 
+__END_DECLS
+
 /* Declare a fail_point and its sysctl in a function. */
 #define _FAIL_POINT_NAME(name) _fail_point_##name
 #define _STRINGIFY_HELPER(x) #x
@@ -233,7 +209,7 @@ fail_point_eval(struct fail_point *fp, 

svn commit: r216620 - in head/sys: kern sys

2010-12-21 Thread Matthew D Fleming
Author: mdf
Date: Tue Dec 21 18:23:03 2010
New Revision: 216620
URL: http://svn.freebsd.org/changeset/base/216620

Log:
  Initialize fp_location for explicitly managed fail points, and push
  the parentheses around the location for simple fail points into the
  location string.  This makes the print on fail point set more
  consistent between the two versions.
  
  Also fix up fail.h a little for style(9): only use one of sys/param.h
  and sys/types.h, and use the existing __XSTRING() macro instead of
  rolling our own.  Also fix up a few tabs on changed and nearby lines.
  
  Lastly, since KFAIL_POINT_{BEGIN,END} are not meant for use outside
  this file, just eliminate the macros entirely.
  
  MFC after: 1 week

Modified:
  head/sys/kern/kern_fail.c
  head/sys/sys/fail.h

Modified: head/sys/kern/kern_fail.c
==
--- head/sys/kern/kern_fail.c   Tue Dec 21 17:24:32 2010(r216619)
+++ head/sys/kern/kern_fail.c   Tue Dec 21 18:23:03 2010(r216620)
@@ -177,6 +177,7 @@ fail_point_init(struct fail_point *fp, c
va_end(ap);
}
fp-fp_name = name;
+   fp-fp_location = ;
fp-fp_flags |= FAIL_POINT_DYNAMIC_NAME;
fp-fp_sleep_fn = NULL;
fp-fp_sleep_arg = NULL;
@@ -372,10 +373,10 @@ fail_point_set(struct fail_point *fp, ch
  end:
 #ifdef IWARNING
if (error)
-   IWARNING(Failed to set %s (%s) to %s,
+   IWARNING(Failed to set %s %s to %s,
fp-fp_name, fp-fp_location, buf);
else
-   INOTICE(Set %s (%s) to %s,
+   INOTICE(Set %s %s to %s,
fp-fp_name, fp-fp_location, buf);
 #endif /* IWARNING */
 

Modified: head/sys/sys/fail.h
==
--- head/sys/sys/fail.h Tue Dec 21 17:24:32 2010(r216619)
+++ head/sys/sys/fail.h Tue Dec 21 18:23:03 2010(r216620)
@@ -32,10 +32,9 @@
 #ifndef _SYS_FAIL_H_
 #define _SYS_FAIL_H_
 
-#include sys/types.h
-
-#include sys/linker_set.h
 #include sys/param.h
+#include sys/cdefs.h
+#include sys/linker_set.h
 #include sys/queue.h
 #include sys/sysctl.h
 
@@ -129,10 +128,8 @@ fail_point_eval(struct fail_point *fp, i
 __END_DECLS
 
 /* Declare a fail_point and its sysctl in a function. */
-#define _FAIL_POINT_NAME(name) _fail_point_##name
-#define _STRINGIFY_HELPER(x) #x
-#define _STRINGIFY(x) _STRINGIFY_HELPER(x)
-#define _FAIL_POINT_LOCATION() __FILE__ : _STRINGIFY(__LINE__)
+#define_FAIL_POINT_NAME(name)  _fail_point_##name
+#define_FAIL_POINT_LOCATION()  ( __FILE__ : __XSTRING(__LINE__) )
 
 /**
  * Instantiate a failpoint which returns value from the function when 
triggered.
@@ -178,53 +175,43 @@ __END_DECLS
 /**
  * Instantiate a failpoint which runs arbitrary code when triggered.
  * @param parent The parent sysctl under which to locate the sysctl
- * @param name   The name of the failpoint in the sysctl tree (and 
printouts)
+ * @param name   The name of the failpoint in the sysctl tree
+ *  (and printouts)
  * @param code   The arbitrary code to run when triggered.  Can reference
- *   RETURN_VALUE if desired to extract the specified user
- *   return-value when triggered
+ *   RETURN_VALUE if desired to extract the specified
+ *   user return-value when triggered.  Note that this is
+ *   implemented with a do-while loop so be careful of
+ *   break and continue statements.
  */
 #define KFAIL_POINT_CODE(parent, name, code)   \
-   KFAIL_POINT_START(parent, name) {   \
+do {   \
+   int RETURN_VALUE;   \
+   static struct fail_point _FAIL_POINT_NAME(name) = { \
+   #name,  \
+   _FAIL_POINT_LOCATION(), \
+   TAILQ_HEAD_INITIALIZER(_FAIL_POINT_NAME(name).fp_entries), \
+   0,  \
+   NULL, NULL, \
+   };  \
+   SYSCTL_OID(parent, OID_AUTO, name,  \
+   CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE,   \
+   _FAIL_POINT_NAME(name), 0, fail_point_sysctl,  \
+   A, );   \
+   \
+   if (__predict_false(\
+   fail_point_eval(_FAIL_POINT_NAME(name), RETURN_VALUE))) { \
+ 

svn commit: r216058 - head/sys/kern

2010-11-29 Thread Matthew D Fleming
Author: mdf
Date: Mon Nov 29 18:17:53 2010
New Revision: 216058
URL: http://svn.freebsd.org/changeset/base/216058

Log:
  Use the SYSCTL_CHILDREN macro in kern_sysctl.c to help de-obfuscate the
  code.
  
  MFC after:3 days

Modified:
  head/sys/kern/kern_sysctl.c

Modified: head/sys/kern/kern_sysctl.c
==
--- head/sys/kern/kern_sysctl.c Mon Nov 29 15:08:18 2010(r216057)
+++ head/sys/kern/kern_sysctl.c Mon Nov 29 18:17:53 2010(r216058)
@@ -676,7 +676,7 @@ sysctl_sysctl_name(SYSCTL_HANDLER_ARGS)
if (oid-oid_handler)
break;
 
-   lsp2 = (struct sysctl_oid_list *)oid-oid_arg1;
+   lsp2 = SYSCTL_CHILDREN(oid);
break;
}
lsp = lsp2;
@@ -707,7 +707,7 @@ sysctl_sysctl_next_ls(struct sysctl_oid_
if (oidp-oid_handler) 
/* We really should call the handler here...*/
return (0);
-   lsp = (struct sysctl_oid_list *)oidp-oid_arg1;
+   lsp = SYSCTL_CHILDREN(oidp);
if (!sysctl_sysctl_next_ls(lsp, 0, 0, next+1, 
len, level+1, oidpp))
return (0);
@@ -722,7 +722,7 @@ sysctl_sysctl_next_ls(struct sysctl_oid_
return (0);
if (oidp-oid_handler)
return (0);
-   lsp = (struct sysctl_oid_list *)oidp-oid_arg1;
+   lsp = SYSCTL_CHILDREN(oidp);
if (!sysctl_sysctl_next_ls(lsp, name+1, namelen-1, 
next+1, len, level+1, oidpp))
return (0);
@@ -734,7 +734,7 @@ sysctl_sysctl_next_ls(struct sysctl_oid_
if (oidp-oid_handler)
continue;
 
-   lsp = (struct sysctl_oid_list *)oidp-oid_arg1;
+   lsp = SYSCTL_CHILDREN(oidp);
if (!sysctl_sysctl_next_ls(lsp, name+1, namelen-1, next+1, 
len, level+1, oidpp))
return (0);
@@ -812,7 +812,7 @@ name2oid(char *name, int *oid, int *len,
if (oidp-oid_handler)
break;
 
-   lsp = (struct sysctl_oid_list *)oidp-oid_arg1;
+   lsp = SYSCTL_CHILDREN(oidp);
oidp = SLIST_FIRST(lsp);
name = p+1;
for (p = name; *p  *p != '.'; p++) 
@@ -1322,8 +1322,7 @@ sysctl_find_oid(int *name, u_int namelen
*nindx = indx;
return (0);
}
-   oid = SLIST_FIRST(
-   (struct sysctl_oid_list *)oid-oid_arg1);
+   oid = SLIST_FIRST(SYSCTL_CHILDREN(oid));
} else if (indx == namelen) {
*noid = oid;
if (nindx != NULL)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r215011 - in head: share/man/man9 sys/kern sys/sys

2010-11-08 Thread Matthew D Fleming
Author: mdf
Date: Mon Nov  8 20:56:31 2010
New Revision: 215011
URL: http://svn.freebsd.org/changeset/base/215011

Log:
  Add a taskqueue_cancel(9) to cancel a pending task without waiting for
  it to run as taskqueue_drain(9) does.
  
  Requested by: hselasky
  Original code:jeff
  Reviewed by:  jhb
  MFC after:2 weeks

Modified:
  head/share/man/man9/Makefile
  head/share/man/man9/taskqueue.9
  head/sys/kern/subr_taskqueue.c
  head/sys/sys/taskqueue.h

Modified: head/share/man/man9/Makefile
==
--- head/share/man/man9/MakefileMon Nov  8 20:44:11 2010
(r215010)
+++ head/share/man/man9/MakefileMon Nov  8 20:56:31 2010
(r215011)
@@ -1212,6 +1212,7 @@ MLINKS+=sysctl_ctx_init.9 sysctl_ctx_ent
sysctl_ctx_init.9 sysctl_ctx_entry_find.9 \
sysctl_ctx_init.9 sysctl_ctx_free.9
 MLINKS+=taskqueue.9 TASK_INIT.9 \
+   taskqueue.9 taskqueue_cancel.9 \
taskqueue.9 taskqueue_create.9 \
taskqueue.9 taskqueue_create_fast.9 \
taskqueue.9 TASKQUEUE_DECLARE.9 \

Modified: head/share/man/man9/taskqueue.9
==
--- head/share/man/man9/taskqueue.9 Mon Nov  8 20:44:11 2010
(r215010)
+++ head/share/man/man9/taskqueue.9 Mon Nov  8 20:56:31 2010
(r215011)
@@ -63,6 +63,8 @@ struct task {
 .Fn taskqueue_enqueue struct taskqueue *queue struct task *task
 .Ft int
 .Fn taskqueue_enqueue_fast struct taskqueue *queue struct task *task
+.Ft int
+.Fn taskqueue_cancel struct taskqueue *queue struct task *task u_int 
*pendp
 .Ft void
 .Fn taskqueue_drain struct taskqueue *queue struct task *task
 .Ft int
@@ -162,6 +164,31 @@ is called on the task pointer passed to
 .Fn taskqueue_enqueue .
 .Pp
 The
+.Fn taskqueue_cancel
+function is used to cancel a task.
+The
+.Va ta_pending
+count is cleared, and the old value returned in the reference
+parameter
+.Fa pendp ,
+if it is non- Dv NULL .
+If the task is currently running,
+.Dv EBUSY
+is returned, otherwise 0.
+To implement a blocking
+.Fn taskqueue_cancel
+that waits for a running task to finish, it could look like:
+.Bd -literal -offset indent
+while (taskqueue_cancel(tq, task, NULL) != 0)
+   taskqueue_drain(tq, task);
+.Ed
+.Pp
+Note that, as with
+.Fn taskqueue_drain ,
+the caller is responsible for ensuring that the task is not re-enqueued
+after being canceled.
+.Pp
+The
 .Fn taskqueue_drain
 function is used to wait for the task to finish.
 There is no guarantee that the task will not be

Modified: head/sys/kern/subr_taskqueue.c
==
--- head/sys/kern/subr_taskqueue.c  Mon Nov  8 20:44:11 2010
(r215010)
+++ head/sys/kern/subr_taskqueue.c  Mon Nov  8 20:56:31 2010
(r215011)
@@ -275,6 +275,24 @@ task_is_running(struct taskqueue *queue,
return (0);
 }
 
+int
+taskqueue_cancel(struct taskqueue *queue, struct task *task, u_int *pendp)
+{
+   u_int pending;
+   int error;
+
+   TQ_LOCK(queue);
+   if ((pending = task-ta_pending)  0)
+   STAILQ_REMOVE(queue-tq_queue, task, task, ta_link);
+   task-ta_pending = 0;
+   error = task_is_running(queue, task) ? EBUSY : 0;
+   TQ_UNLOCK(queue);
+
+   if (pendp != NULL)
+   *pendp = pending;
+   return (error);
+}
+
 void
 taskqueue_drain(struct taskqueue *queue, struct task *task)
 {

Modified: head/sys/sys/taskqueue.h
==
--- head/sys/sys/taskqueue.hMon Nov  8 20:44:11 2010(r215010)
+++ head/sys/sys/taskqueue.hMon Nov  8 20:56:31 2010(r215011)
@@ -54,6 +54,8 @@ struct taskqueue *taskqueue_create(const
 inttaskqueue_start_threads(struct taskqueue **tqp, int count, int pri,
const char *name, ...) __printflike(4, 5);
 inttaskqueue_enqueue(struct taskqueue *queue, struct task *task);
+inttaskqueue_cancel(struct taskqueue *queue, struct task *task,
+   u_int *pendp);
 void   taskqueue_drain(struct taskqueue *queue, struct task *task);
 void   taskqueue_free(struct taskqueue *queue);
 void   taskqueue_run(struct taskqueue *queue);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r214062 - in head: share/man/man9 sys/vm

2010-10-19 Thread Matthew D Fleming
Author: mdf
Date: Tue Oct 19 16:06:00 2010
New Revision: 214062
URL: http://svn.freebsd.org/changeset/base/214062

Log:
  uma_zfree(zone, NULL) should do nothing, to match free(9).
  
  Noticed by:   Ron Steinke rsteinke at isilon dot com
  MFC after:3 days

Modified:
  head/share/man/man9/zone.9
  head/sys/vm/uma_core.c

Modified: head/share/man/man9/zone.9
==
--- head/share/man/man9/zone.9  Tue Oct 19 15:26:08 2010(r214061)
+++ head/share/man/man9/zone.9  Tue Oct 19 16:06:00 2010(r214062)
@@ -153,6 +153,13 @@ Items are released back to the zone from
 calling
 .Fn uma_zfree
 with a pointer to the zone and a pointer to the item.
+If
+.Fa item
+is
+.Dv NULL ,
+then
+.Fn uma_zfree
+does nothing.
 .Pp
 The variations
 .Fn uma_zalloc_arg

Modified: head/sys/vm/uma_core.c
==
--- head/sys/vm/uma_core.c  Tue Oct 19 15:26:08 2010(r214061)
+++ head/sys/vm/uma_core.c  Tue Oct 19 16:06:00 2010(r214062)
@@ -2517,6 +2517,10 @@ uma_zfree_arg(uma_zone_t zone, void *ite
CTR2(KTR_UMA, uma_zfree_arg thread %x zone %s, curthread,
zone-uz_name);
 
+/* uma_zfree(..., NULL) does nothing, to match free(9). */
+if (item == NULL)
+return;
+
if (zone-uz_dtor)
zone-uz_dtor(item, zone-uz_size, udata);
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r213898 - in head/sys: dev/mps modules/mps

2010-10-15 Thread Matthew D Fleming
Author: mdf
Date: Fri Oct 15 15:24:59 2010
New Revision: 213898
URL: http://svn.freebsd.org/changeset/base/213898

Log:
  Currently only opt_compat.h is included by the mps(4) driver. Also
  enable /dev/mps0, which was missing from my previous patches enabling
  f/w upload and download.
  
  opt_compat.h issue noticed by scottl.

Modified:
  head/sys/dev/mps/mps.c
  head/sys/modules/mps/Makefile

Modified: head/sys/dev/mps/mps.c
==
--- head/sys/dev/mps/mps.c  Fri Oct 15 15:23:34 2010(r213897)
+++ head/sys/dev/mps/mps.c  Fri Oct 15 15:24:59 2010(r213898)
@@ -924,7 +924,10 @@ mps_attach(struct mps_softc *sc)
/* Attach the subsystems so they can prepare their event masks. */
/* XXX Should be dynamic so that IM/IR and user modules can attach */
if (((error = mps_attach_log(sc)) != 0) ||
-   ((error = mps_attach_sas(sc)) != 0)) {
+   ((error = mps_attach_sas(sc)) != 0) ||
+   ((error = mps_attach_user(sc)) != 0)) {
+   mps_printf(sc, %s failed to attach all subsystems: error %d\n,
+   __func__, error);
mps_free(sc);
return (error);
}

Modified: head/sys/modules/mps/Makefile
==
--- head/sys/modules/mps/Makefile   Fri Oct 15 15:23:34 2010
(r213897)
+++ head/sys/modules/mps/Makefile   Fri Oct 15 15:24:59 2010
(r213898)
@@ -4,7 +4,7 @@
 
 KMOD=  mps
 SRCS=  mps_pci.c mps.c mps_sas.c mps_table.c mps_user.c
-SRCS+= opt_mps.h opt_cam.h
+SRCS+= opt_compat.h
 SRCS+= device_if.h bus_if.h pci_if.h
 
 #CFLAGS += -DMPS_DEBUG
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r213839 - head/sys/dev/mps

2010-10-14 Thread Matthew D Fleming
Author: mdf
Date: Thu Oct 14 16:44:05 2010
New Revision: 213839
URL: http://svn.freebsd.org/changeset/base/213839

Log:
  Re-work the internals of adding items to the driver's scatter-gather
  list.  Use the new internals to simplify adding transaction context
  elements, and in future diffs, more complicated SGLs.

Modified:
  head/sys/dev/mps/mps.c
  head/sys/dev/mps/mps_user.c
  head/sys/dev/mps/mpsvar.h

Modified: head/sys/dev/mps/mps.c
==
--- head/sys/dev/mps/mps.c  Thu Oct 14 15:42:32 2010(r213838)
+++ head/sys/dev/mps/mps.c  Thu Oct 14 16:44:05 2010(r213839)
@@ -380,7 +380,7 @@ mps_request_sync(struct mps_softc *sc, v
return (0);
 }
 
-static void
+void
 mps_enqueue_request(struct mps_softc *sc, struct mps_command *cm)
 {
 
@@ -1374,33 +1374,88 @@ mps_deregister_events(struct mps_softc *
return (mps_update_events(sc, NULL, NULL));
 }
 
-static void
-mps_data_cb(void *arg, bus_dma_segment_t *segs, int nsegs, int error)
+/*
+ * Add a chain element as the next SGE for the specified command.
+ * Reset cm_sge and cm_sgesize to indicate all the available space.
+ */
+static int
+mps_add_chain(struct mps_command *cm)
 {
-   MPI2_SGE_SIMPLE64 *sge;
MPI2_SGE_CHAIN32 *sgc;
-   struct mps_softc *sc;
-   struct mps_command *cm;
struct mps_chain *chain;
-   u_int i, segsleft, sglspace, dir, flags, sflags;
+   int space;
 
-   cm = (struct mps_command *)arg;
-   sc = cm-cm_sc;
+   if (cm-cm_sglsize  MPS_SGC_SIZE)
+   panic(MPS: Need SGE Error Code\n);
 
-segsleft = nsegs;
-sglspace = cm-cm_sglsize;
-sge = (MPI2_SGE_SIMPLE64 *)cm-cm_sge-MpiSimple;
+   chain = mps_alloc_chain(cm-cm_sc);
+   if (chain == NULL)
+   return (ENOBUFS);
+
+   space = (int)cm-cm_sc-facts-IOCRequestFrameSize * 4;
 
/*
-* Set up DMA direction flags.  Note no support for
-* bi-directional transactions.
+* Note: a double-linked list is used to make it easier to
+* walk for debugging.
 */
-sflags = MPI2_SGE_FLAGS_ADDRESS_SIZE;
-if (cm-cm_flags  MPS_CM_FLAGS_DATAOUT) {
-sflags |= MPI2_SGE_FLAGS_DIRECTION;
-   dir = BUS_DMASYNC_PREWRITE;
-   } else
-   dir = BUS_DMASYNC_PREREAD;
+   TAILQ_INSERT_TAIL(cm-cm_chain_list, chain, chain_link);
+
+   sgc = (MPI2_SGE_CHAIN32 *)cm-cm_sge-MpiChain;
+   sgc-Length = space;
+   sgc-NextChainOffset = 0;
+   sgc-Flags = MPI2_SGE_FLAGS_CHAIN_ELEMENT;
+   sgc-Address = chain-chain_busaddr;
+
+   cm-cm_sge = (MPI2_SGE_IO_UNION *)chain-chain-MpiSimple;
+   cm-cm_sglsize = space;
+   return (0);
+}
+
+/*
+ * Add one scatter-gather element (chain, simple, transaction context)
+ * to the scatter-gather list for a command.  Maintain cm_sglsize and
+ * cm_sge as the remaining size and pointer to the next SGE to fill
+ * in, respectively.
+ */
+int
+mps_push_sge(struct mps_command *cm, void *sgep, size_t len, int segsleft)
+{
+   MPI2_SGE_TRANSACTION_UNION *tc = sgep;
+   MPI2_SGE_SIMPLE64 *sge = sgep;
+   int error, type;
+
+   type = (tc-Flags  MPI2_SGE_FLAGS_ELEMENT_MASK);
+
+#ifdef INVARIANTS
+   switch (type) {
+   case MPI2_SGE_FLAGS_TRANSACTION_ELEMENT: {
+   if (len != tc-DetailsLength + 4)
+   panic(TC %p length %u or %zu?, tc,
+   tc-DetailsLength + 4, len);
+   }
+   break;
+   case MPI2_SGE_FLAGS_CHAIN_ELEMENT:
+   /* Driver only uses 32-bit chain elements */
+   if (len != MPS_SGC_SIZE)
+   panic(CHAIN %p length %u or %zu?, sgep,
+   MPS_SGC_SIZE, len);
+   break;
+   case MPI2_SGE_FLAGS_SIMPLE_ELEMENT:
+   /* Driver only uses 64-bit SGE simple elements */
+   sge = sgep;
+   if (len != MPS_SGE64_SIZE)
+   panic(SGE simple %p length %u or %zu?, sge,
+   MPS_SGE64_SIZE, len);
+   if (((sge-FlagsLength  MPI2_SGE_FLAGS_SHIFT) 
+   MPI2_SGE_FLAGS_ADDRESS_SIZE) == 0)
+   panic(SGE simple %p flags %02x not marked 64-bit?,
+   sge, sge-FlagsLength  MPI2_SGE_FLAGS_SHIFT);
+
+   break;
+   default:
+   panic(Unexpected SGE %p, flags %02x, tc, tc-Flags);
+   }
+#endif
 
/*
 * case 1: 1 more segment, enough room for it
@@ -1408,70 +1463,128 @@ mps_data_cb(void *arg, bus_dma_segment_t
 * case 3: =2 more segments, only enough room for 1 and a chain
 * case 4: =1 more segment, enough room for only a chain
 * case 5: =1 more segment, no room for anything (error)
-*/
+ */
 
-   for (i = 0; i  nsegs; i++) {
+   /*
+* 

svn commit: r213882 - head/sys/dev/mps

2010-10-14 Thread Matthew D Fleming
Author: mdf
Date: Thu Oct 14 23:26:08 2010
New Revision: 213882
URL: http://svn.freebsd.org/changeset/base/213882

Log:
  Fixes to mps_user_command():
   - fix the leak of command struct on error
   - simplify the cleanup logic
   - EINPROGRESS is not a fatal error
   - buggy comment and error message
  
  Reviewed by:   ken

Modified:
  head/sys/dev/mps/mps_user.c

Modified: head/sys/dev/mps/mps_user.c
==
--- head/sys/dev/mps/mps_user.c Thu Oct 14 22:45:14 2010(r213881)
+++ head/sys/dev/mps/mps_user.c Thu Oct 14 23:26:08 2010(r213882)
@@ -579,7 +579,7 @@ mps_user_command(struct mps_softc *sc, s
MPI2_REQUEST_HEADER *hdr;   
MPI2_DEFAULT_REPLY *rpl;
void *buf = NULL;
-   struct mps_command *cm;
+   struct mps_command *cm = NULL;
int err = 0;
int sz;
 
@@ -631,11 +631,12 @@ mps_user_command(struct mps_softc *sc, s
mps_lock(sc);
err = mps_map_command(sc, cm);
 
-   if (err != 0) {
-   mps_printf(sc, mps_user_command: request timed out\n);
+   if (err != 0  err != EINPROGRESS) {
+   mps_printf(sc, %s: invalid request: error %d\n,
+   __func__, err);
goto Ret;
}
-   msleep(cm, sc-mps_mtx, 0, mpsuser, 0); /* 30 seconds */
+   msleep(cm, sc-mps_mtx, 0, mpsuser, 0);
 
rpl = (MPI2_DEFAULT_REPLY *)cm-cm_reply;
sz = rpl-MsgLength * 4;
@@ -652,22 +653,14 @@ mps_user_command(struct mps_softc *sc, s
copyout(rpl, cmd-rpl, sz);
if (buf != NULL)
copyout(buf, cmd-buf, cmd-len);
-   mps_lock(sc);
-
mps_dprint(sc, MPS_INFO, mps_user_command: reply size %d\n, sz );
 
-   mps_free_command(sc, cm);
-Ret:
-   mps_unlock(sc);
-   if (buf != NULL)
-   free(buf, M_MPSUSER);
-   return (err);
-
 RetFreeUnlocked:
mps_lock(sc);
-   mps_free_command(sc, cm);
+   if (cm != NULL)
+   mps_free_command(sc, cm);
+Ret:
mps_unlock(sc);
-
if (buf != NULL)
free(buf, M_MPSUSER);
return (err);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r213813 - in head: share/man/man9 sys/kern sys/sys

2010-10-13 Thread Matthew D Fleming
Author: mdf
Date: Wed Oct 13 22:59:04 2010
New Revision: 213813
URL: http://svn.freebsd.org/changeset/base/213813

Log:
  Use a safer mechanism for determining if a task is currently running,
  that does not rely on the lifetime of pointers being the same. This also
  restores the task KBI.
  
  Suggested by: jhb
  MFC after:1 month

Modified:
  head/share/man/man9/taskqueue.9
  head/sys/kern/subr_taskqueue.c
  head/sys/sys/_task.h
  head/sys/sys/taskqueue.h

Modified: head/share/man/man9/taskqueue.9
==
--- head/share/man/man9/taskqueue.9 Wed Oct 13 22:29:48 2010
(r213812)
+++ head/share/man/man9/taskqueue.9 Wed Oct 13 22:59:04 2010
(r213813)
@@ -68,7 +68,7 @@ struct task {
 .Ft int
 .Fn taskqueue_member struct taskqueue *queue struct thread *td
 .Ft void
-.Fn taskqueue_run struct taskqueue *queue struct task **tpp
+.Fn taskqueue_run struct taskqueue *queue
 .Fn TASK_INIT struct task *task int priority task_fn_t *func void 
*context
 .Fn TASKQUEUE_DECLARE name
 .Fn TASKQUEUE_DEFINE name taskqueue_enqueue_fn enqueue void *context 
init
@@ -185,13 +185,6 @@ The
 function will run all pending tasks in the specified
 .Fa queue .
 Normally this function is only used internally.
-The
-.Fa tpp
-argument is a pointer to a
-.Vt struct task *
-that is used to record the currently running task.
-The lifetime of this pointer must match that of the
-.Fa queue .
 .Pp
 A convenience macro,
 .Fn TASK_INIT task priority func context

Modified: head/sys/kern/subr_taskqueue.c
==
--- head/sys/kern/subr_taskqueue.c  Wed Oct 13 22:29:48 2010
(r213812)
+++ head/sys/kern/subr_taskqueue.c  Wed Oct 13 22:59:04 2010
(r213813)
@@ -46,12 +46,17 @@ static MALLOC_DEFINE(M_TASKQUEUE, taskq
 static void*taskqueue_giant_ih;
 static void*taskqueue_ih;
 
+struct taskqueue_busy {
+   struct task *tb_running;
+   TAILQ_ENTRY(taskqueue_busy) tb_link;
+};
+
 struct taskqueue {
STAILQ_HEAD(, task) tq_queue;
const char  *tq_name;
taskqueue_enqueue_fntq_enqueue;
void*tq_context;
-   struct task *tq_running;
+   TAILQ_HEAD(, taskqueue_busy) tq_active;
struct mtx  tq_mutex;
struct thread   **tq_threads;
int tq_tcount;
@@ -102,6 +107,7 @@ _taskqueue_create(const char *name, int 
return NULL;
 
STAILQ_INIT(queue-tq_queue);
+   TAILQ_INIT(queue-tq_active);
queue-tq_name = name;
queue-tq_enqueue = enqueue;
queue-tq_context = context;
@@ -140,6 +146,7 @@ taskqueue_free(struct taskqueue *queue)
TQ_LOCK(queue);
queue-tq_flags = ~TQ_FLAGS_ACTIVE;
taskqueue_terminate(queue-tq_threads, queue);
+   KASSERT(TAILQ_EMPTY(queue-tq_active), (Tasks still running?));
mtx_destroy(queue-tq_mutex);
free(queue-tq_threads, M_TASKQUEUE);
free(queue, M_TASKQUEUE);
@@ -214,13 +221,17 @@ taskqueue_unblock(struct taskqueue *queu
TQ_UNLOCK(queue);
 }
 
-void
-taskqueue_run(struct taskqueue *queue, struct task **tpp)
+static void
+taskqueue_run_locked(struct taskqueue *queue)
 {
+   struct taskqueue_busy tb;
struct task *task;
int pending;
 
mtx_assert(queue-tq_mutex, MA_OWNED);
+   tb.tb_running = NULL;
+   TAILQ_INSERT_TAIL(queue-tq_active, tb, tb_link);
+
while (STAILQ_FIRST(queue-tq_queue)) {
/*
 * Carefully remove the first task from the queue and
@@ -230,16 +241,38 @@ taskqueue_run(struct taskqueue *queue, s
STAILQ_REMOVE_HEAD(queue-tq_queue, ta_link);
pending = task-ta_pending;
task-ta_pending = 0;
-   task-ta_running = tpp;
-   *tpp = task;
+   tb.tb_running = task;
TQ_UNLOCK(queue);
 
task-ta_func(task-ta_context, pending);
 
TQ_LOCK(queue);
-   *tpp = NULL;
+   tb.tb_running = NULL;
wakeup(task);
}
+   TAILQ_REMOVE(queue-tq_active, tb, tb_link);
+}
+
+void
+taskqueue_run(struct taskqueue *queue)
+{
+
+   TQ_LOCK(queue);
+   taskqueue_run_locked(queue);
+   TQ_UNLOCK(queue);
+}
+
+static int
+task_is_running(struct taskqueue *queue, struct task *task)
+{
+   struct taskqueue_busy *tb;
+
+   mtx_assert(queue-tq_mutex, MA_OWNED);
+   TAILQ_FOREACH(tb, queue-tq_active, tb_link) {
+   if (tb-tb_running == task)
+   return (1);
+   }
+   return (0);
 }
 
 void
@@ -250,10 +283,8 @@ taskqueue_drain(struct taskqueue *queue,
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, __func__);
 
TQ_LOCK(queue);
-   while (task-ta_pending != 0 ||
-   

svn commit: r213739 - in head: share/man/man9 sys/kern sys/sys

2010-10-12 Thread Matthew D Fleming
Author: mdf
Date: Tue Oct 12 18:36:03 2010
New Revision: 213739
URL: http://svn.freebsd.org/changeset/base/213739

Log:
  Re-expose and briefly document taskqueue_run(9).  The function is used
  in at least one 3rd party driver.
  
  Requested by: jhb

Modified:
  head/share/man/man9/taskqueue.9
  head/sys/kern/subr_taskqueue.c
  head/sys/sys/taskqueue.h

Modified: head/share/man/man9/taskqueue.9
==
--- head/share/man/man9/taskqueue.9 Tue Oct 12 18:20:38 2010
(r213738)
+++ head/share/man/man9/taskqueue.9 Tue Oct 12 18:36:03 2010
(r213739)
@@ -67,6 +67,8 @@ struct task {
 .Fn taskqueue_drain struct taskqueue *queue struct task *task
 .Ft int
 .Fn taskqueue_member struct taskqueue *queue struct thread *td
+.Ft void
+.Fn taskqueue_run struct taskqueue *queue struct task **tpp
 .Fn TASK_INIT struct task *task int priority task_fn_t *func void 
*context
 .Fn TASKQUEUE_DECLARE name
 .Fn TASKQUEUE_DEFINE name taskqueue_enqueue_fn enqueue void *context 
init
@@ -178,6 +180,19 @@ and
 .No 0
 otherwise.
 .Pp
+The
+.Fn taskqueue_run
+function will run all pending tasks in the specified
+.Fa queue .
+Normally this function is only used internally.
+The
+.Fa tpp
+argument is a pointer to a
+.Vt struct task *
+that is used to record the currently running task.
+The lifetime of this pointer must match that of the
+.Fa queue .
+.Pp
 A convenience macro,
 .Fn TASK_INIT task priority func context
 is provided to initialise a

Modified: head/sys/kern/subr_taskqueue.c
==
--- head/sys/kern/subr_taskqueue.c  Tue Oct 12 18:20:38 2010
(r213738)
+++ head/sys/kern/subr_taskqueue.c  Tue Oct 12 18:36:03 2010
(r213739)
@@ -63,8 +63,6 @@ struct taskqueue {
 #defineTQ_FLAGS_BLOCKED(1  1)
 #defineTQ_FLAGS_PENDING(1  2)
 
-static void taskqueue_run(struct taskqueue *, struct task **);
-
 static __inline void
 TQ_LOCK(struct taskqueue *tq)
 {
@@ -216,7 +214,7 @@ taskqueue_unblock(struct taskqueue *queu
TQ_UNLOCK(queue);
 }
 
-static void
+void
 taskqueue_run(struct taskqueue *queue, struct task **tpp)
 {
struct task *task;

Modified: head/sys/sys/taskqueue.h
==
--- head/sys/sys/taskqueue.hTue Oct 12 18:20:38 2010(r213738)
+++ head/sys/sys/taskqueue.hTue Oct 12 18:36:03 2010(r213739)
@@ -56,6 +56,7 @@ int   taskqueue_start_threads(struct taskq
 inttaskqueue_enqueue(struct taskqueue *queue, struct task *task);
 void   taskqueue_drain(struct taskqueue *queue, struct task *task);
 void   taskqueue_free(struct taskqueue *queue);
+void   taskqueue_run(struct taskqueue *queue, struct task **tpp);
 void   taskqueue_block(struct taskqueue *queue);
 void   taskqueue_unblock(struct taskqueue *queue);
 inttaskqueue_member(struct taskqueue *queue, struct thread *td);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r213743 - head/sys/dev/mps

2010-10-12 Thread Matthew D Fleming
Author: mdf
Date: Tue Oct 12 19:24:29 2010
New Revision: 213743
URL: http://svn.freebsd.org/changeset/base/213743

Log:
  Always set cm_complete_data before calling mps_config_complete().
  
  Reviewed by:  ken

Modified:
  head/sys/dev/mps/mps.c

Modified: head/sys/dev/mps/mps.c
==
--- head/sys/dev/mps/mps.c  Tue Oct 12 19:22:03 2010(r213742)
+++ head/sys/dev/mps/mps.c  Tue Oct 12 19:24:29 2010(r213743)
@@ -1562,9 +1562,9 @@ mps_read_config_page(struct mps_softc *s
cm-cm_flags = MPS_CM_FLAGS_SGE_SIMPLE | MPS_CM_FLAGS_DATAIN;
cm-cm_desc.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE;
 
+   cm-cm_complete_data = params;
if (params-callback != NULL) {
cm-cm_complete = mps_config_complete;
-   cm-cm_complete_data = params;
return (mps_map_command(sc, cm));
} else {
cm-cm_complete = NULL;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r213702 - head/sys/dev/mps

2010-10-11 Thread Matthew D Fleming
Author: mdf
Date: Mon Oct 11 21:26:24 2010
New Revision: 213702
URL: http://svn.freebsd.org/changeset/base/213702

Log:
  Fix up the COMPAT_FREEBSD32 ioctl logic for mps(4).
  
  Reviewed by:  ken

Modified:
  head/sys/dev/mps/mps_ioctl.h
  head/sys/dev/mps/mps_user.c

Modified: head/sys/dev/mps/mps_ioctl.h
==
--- head/sys/dev/mps/mps_ioctl.hMon Oct 11 21:23:07 2010
(r213701)
+++ head/sys/dev/mps/mps_ioctl.hMon Oct 11 21:26:24 2010
(r213702)
@@ -103,44 +103,4 @@ struct mps_usr_command {
 #defineMPSIO_RAID_ACTION   _IOWR('M', 205, struct mps_raid_action)
 #defineMPSIO_MPS_COMMAND   _IOWR('M', 210, struct mps_usr_command)
 
-#if defined(__amd64__)
-struct mps_cfg_page_req32 {
-   MPI2_CONFIG_PAGE_HEADER header;
-   uint32_t page_address;
-   uint32_t buf;
-   int len;
-   uint16_t ioc_status;
-};
-
-struct mps_ext_cfg_page_req32 {
-   MPI2_CONFIG_EXTENDED_PAGE_HEADER header;
-   uint32_t page_address;
-   uint32_t buf;
-   int len;
-   uint16_t ioc_status;
-};
-
-struct mps_raid_action32 {
-   uint8_t action;
-   uint8_t volume_bus;
-   uint8_t volume_id;
-   uint8_t phys_disk_num;
-   uint32_t action_data_word;
-   uint32_t buf;
-   int len;
-   uint32_t volume_status;
-   uint32_t action_data[4];
-   uint16_t action_status;
-   uint16_t ioc_status;
-   uint8_t write;
-};
-
-#defineMPSIO_READ_CFG_HEADER32 _IOWR('M', 100, struct 
mps_cfg_page_req32)
-#defineMPSIO_READ_CFG_PAGE32   _IOWR('M', 101, struct 
mps_cfg_page_req32)
-#defineMPSIO_READ_EXT_CFG_HEADER32 _IOWR('M', 102, struct 
mps_ext_cfg_page_req32)
-#defineMPSIO_READ_EXT_CFG_PAGE32 _IOWR('M', 103, struct 
mps_ext_cfg_page_req32)
-#defineMPSIO_WRITE_CFG_PAGE32  _IOWR('M', 104, struct 
mps_cfg_page_req32)
-#defineMPSIO_RAID_ACTION32 _IOWR('M', 105, struct 
mps_raid_action32)
-#endif
-
 #endif /* !_MPS_IOCTL_H_ */

Modified: head/sys/dev/mps/mps_user.c
==
--- head/sys/dev/mps/mps_user.c Mon Oct 11 21:23:07 2010(r213701)
+++ head/sys/dev/mps/mps_user.c Mon Oct 11 21:26:24 2010(r213702)
@@ -33,6 +33,8 @@
 #include sys/cdefs.h
 __FBSDID($FreeBSD$);
 
+#include opt_compat.h
+
 #include sys/types.h
 #include sys/param.h
 #include sys/systm.h
@@ -47,6 +49,8 @@ __FBSDID($FreeBSD$);
 #include sys/sysctl.h
 #include sys/ioccom.h
 #include sys/endian.h
+#include sys/proc.h
+#include sys/sysent.h
 
 #include machine/bus.h
 #include machine/resource.h
@@ -64,14 +68,14 @@ __FBSDID($FreeBSD$);
 
 static d_open_tmps_open;
 static d_close_t   mps_close;
-static d_ioctl_t   mps_ioctl;
+static d_ioctl_t   mps_ioctl_devsw;
 
 static struct cdevsw mps_cdevsw = {
.d_version =D_VERSION,
.d_flags =  0,
.d_open =   mps_open,
.d_close =  mps_close,
-   .d_ioctl =  mps_ioctl,
+   .d_ioctl =  mps_ioctl_devsw,
.d_name =   mps,
 };
 
@@ -424,25 +428,14 @@ Ret:
return err;
 }  
 
-#ifdef __amd64__
-#definePTRIN(p)((void *)(uintptr_t)(p))
-#define PTROUT(v)  ((u_int32_t)(uintptr_t)(v))
-#endif
-
 static int
-mps_ioctl(struct cdev *dev, u_long cmd, caddr_t arg, int flag,
+mps_ioctl(struct cdev *dev, u_long cmd, void *arg, int flag,
 struct thread *td)
 {
struct mps_softc *sc;
struct mps_cfg_page_req *page_req;
struct mps_ext_cfg_page_req *ext_page_req;
void *mps_page;
-#ifdef __amd64__
-   struct mps_cfg_page_req32 *page_req32;
-   struct mps_cfg_page_req page_req_swab;
-   struct mps_ext_cfg_page_req32 *ext_page_req32;
-   struct mps_ext_cfg_page_req ext_page_req_swab;
-#endif
int error;
 
mps_page = NULL;
@@ -450,47 +443,12 @@ mps_ioctl(struct cdev *dev, u_long cmd, 
page_req = (void *)arg;
ext_page_req = (void *)arg;
 
-#ifdef __amd64__
-   /* Convert 32-bit structs to native ones. */
-   page_req32 = (void *)arg;
-   ext_page_req32 = (void *)arg;
-   switch (cmd) {
-   case MPSIO_READ_CFG_HEADER32:
-   case MPSIO_READ_CFG_PAGE32:
-   case MPSIO_WRITE_CFG_PAGE32:
-   page_req = page_req_swab;
-   page_req-header = page_req32-header;
-   page_req-page_address = page_req32-page_address;
-   page_req-buf = PTRIN(page_req32-buf);
-   page_req-len = page_req32-len;
-   page_req-ioc_status = page_req32-ioc_status;
-   break;
-   case MPSIO_READ_EXT_CFG_HEADER32:
-   case MPSIO_READ_EXT_CFG_PAGE32:
-   ext_page_req = ext_page_req_swab;
-   ext_page_req-header = ext_page_req32-header;
-   ext_page_req-page_address = 

svn commit: r213704 - head/sys/dev/mps

2010-10-11 Thread Matthew D Fleming
Author: mdf
Date: Mon Oct 11 21:38:31 2010
New Revision: 213704
URL: http://svn.freebsd.org/changeset/base/213704

Log:
  Fix a memory leak and locking inconsistency in mps(4) ioctl handling.
  Check copyin(9) for error and sanity check the length before copyin.
  
  Reviewed by:  ken

Modified:
  head/sys/dev/mps/mps_user.c

Modified: head/sys/dev/mps/mps_user.c
==
--- head/sys/dev/mps/mps_user.c Mon Oct 11 21:34:35 2010(r213703)
+++ head/sys/dev/mps/mps_user.c Mon Oct 11 21:38:31 2010(r213704)
@@ -343,7 +343,7 @@ mps_user_command(struct mps_softc *sc, s
MPI2_REQUEST_HEADER *hdr;   
MPI2_DEFAULT_REPLY *rpl;
MPI2_SGE_IO_UNION *sgl; 
-   void *buf;
+   void *buf = NULL;
struct mps_command *cm;
int err = 0;
int sz;
@@ -363,7 +363,13 @@ mps_user_command(struct mps_softc *sc, s
mps_dprint(sc, MPS_INFO, mps_user_command: req %p %d  rpl %p %d\n,
cmd-req, cmd-req_len, cmd-rpl, cmd-rpl_len );
 
-   copyin(cmd-req, hdr, cmd-req_len);
+   if (cmd-req_len  (int)sc-facts-IOCRequestFrameSize * 4) {
+   err = EINVAL;
+   goto RetFreeUnlocked;
+   }
+   err = copyin(cmd-req, hdr, cmd-req_len);
+   if (err != 0)
+   goto RetFreeUnlocked;
 
mps_dprint(sc, MPS_INFO, mps_user_command: Function %02X  
MsgFlags %02X\n, hdr-Function, hdr-MsgFlags );
@@ -372,7 +378,7 @@ mps_user_command(struct mps_softc *sc, s
if (err != 0) {
mps_printf(sc, mps_user_command: unsupported function 0x%X\n,
hdr-Function );
-   goto RetFree;
+   goto RetFreeUnlocked;
}
 
if (cmd-len  0) {
@@ -380,7 +386,6 @@ mps_user_command(struct mps_softc *sc, s
cm-cm_data = buf;
cm-cm_length = cmd-len;
} else {
-   buf = NULL;
cm-cm_data = NULL;
cm-cm_length = 0;
}
@@ -412,20 +417,27 @@ mps_user_command(struct mps_softc *sc, s
 
mps_unlock(sc);
copyout(rpl, cmd-rpl, sz);
-   if (buf != NULL) {
+   if (buf != NULL)
copyout(buf, cmd-buf, cmd-len);
-   free(buf, M_MPSUSER);
-   }
mps_lock(sc);
 
mps_dprint(sc, MPS_INFO, mps_user_command: reply size %d\n, sz );
 
-RetFree:  
mps_free_command(sc, cm);
-
 Ret:
mps_unlock(sc);
-   return err;
+   if (buf != NULL)
+   free(buf, M_MPSUSER);
+   return (err);
+
+RetFreeUnlocked:
+   mps_lock(sc);
+   mps_free_command(sc, cm);
+   mps_unlock(sc);
+
+   if (buf != NULL)
+   free(buf, M_MPSUSER);
+   return (err);
 }  
 
 static int
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r213707 - head/sys/dev/mps

2010-10-11 Thread Matthew D Fleming
Author: mdf
Date: Mon Oct 11 22:44:05 2010
New Revision: 213707
URL: http://svn.freebsd.org/changeset/base/213707

Log:
  Add function prototypes for static functions.
  
  Requested by: ken

Modified:
  head/sys/dev/mps/mps_user.c

Modified: head/sys/dev/mps/mps_user.c
==
--- head/sys/dev/mps/mps_user.c Mon Oct 11 22:41:01 2010(r213706)
+++ head/sys/dev/mps/mps_user.c Mon Oct 11 22:44:05 2010(r213707)
@@ -79,6 +79,19 @@ static struct cdevsw mps_cdevsw = {
.d_name =   mps,
 };
 
+static int mps_user_read_cfg_header(struct mps_softc *,
+   struct mps_cfg_page_req *);
+static int mps_user_read_cfg_page(struct mps_softc *,
+ struct mps_cfg_page_req *, void *);
+static int mps_user_read_extcfg_header(struct mps_softc *,
+struct mps_ext_cfg_page_req *);
+static int mps_user_read_extcfg_page(struct mps_softc *,
+struct mps_ext_cfg_page_req *, void *);
+static int mps_user_write_cfg_page(struct mps_softc *,
+  struct mps_cfg_page_req *, void *);
+static int mps_user_verify_request(MPI2_REQUEST_HEADER *, MPI2_SGE_IO_UNION 
**);
+static int mps_user_command(struct mps_softc *, struct mps_usr_command *);
+
 static MALLOC_DEFINE(M_MPSUSER, mps_user, Buffers for mps(4) ioctls);
 
 int
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r212926 - head/sys/cam/scsi

2010-09-20 Thread Matthew D Fleming
Author: mdf
Date: Mon Sep 20 19:42:14 2010
New Revision: 212926
URL: http://svn.freebsd.org/changeset/base/212926

Log:
  Use destroy_dev_sched(9) instead of destroy_dev(9) in passcleanup() as
  it is indirectly a d_close method.
  
  Prompted by:  kib
  Reviewed by:  mav
  MFC after:2 weeks

Modified:
  head/sys/cam/scsi/scsi_pass.c

Modified: head/sys/cam/scsi/scsi_pass.c
==
--- head/sys/cam/scsi/scsi_pass.c   Mon Sep 20 19:36:53 2010
(r212925)
+++ head/sys/cam/scsi/scsi_pass.c   Mon Sep 20 19:42:14 2010
(r212926)
@@ -169,7 +169,11 @@ passcleanup(struct cam_periph *periph)
xpt_print(periph-path, removing device entry\n);
devstat_remove_entry(softc-device_stats);
cam_periph_unlock(periph);
-   destroy_dev(softc-dev);
+   /*
+* passcleanup() is indirectly a d_close method via passclose,
+* so using destroy_dev(9) directly can result in deadlock.
+*/
+   destroy_dev_sched(softc-dev);
cam_periph_lock(periph);
free(softc, M_DEVBUF);
 }
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r212931 - head/sys/vm

2010-09-20 Thread Matthew D Fleming
Author: mdf
Date: Mon Sep 20 20:41:59 2010
New Revision: 212931
URL: http://svn.freebsd.org/changeset/base/212931

Log:
  Replace an XXX comment with the appropriate code.
  
  Submitted by: alc

Modified:
  head/sys/vm/vm_kern.c

Modified: head/sys/vm/vm_kern.c
==
--- head/sys/vm/vm_kern.c   Mon Sep 20 19:59:08 2010(r212930)
+++ head/sys/vm/vm_kern.c   Mon Sep 20 20:41:59 2010(r212931)
@@ -354,11 +354,7 @@ kmem_back(vm_map_t map, vm_offset_t addr
vm_page_t m;
int pflags;
 
-   /*
-* XXX the map must be locked for write on entry, but there's
-* no easy way to assert that.
-*/
-
+   KASSERT(vm_map_locked(map), (kmem_back: map %p is not locked, map));
offset = addr - VM_MIN_KERNEL_ADDRESS;
vm_object_reference(kmem_object);
vm_map_insert(map, kmem_object, offset, addr, addr + size,
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r212750 - in head/sys: dev/cxgb kern sys vm

2010-09-16 Thread Matthew D Fleming
Author: mdf
Date: Thu Sep 16 16:13:12 2010
New Revision: 212750
URL: http://svn.freebsd.org/changeset/base/212750

Log:
  Re-add r212370 now that the LOR in powerpc64 has been resolved:
  
  Add a drain function for struct sysctl_req, and use it for a variety
  of handlers, some of which had to do awkward things to get a large
  enough SBUF_FIXEDLEN buffer.
  
  Note that some sysctl handlers were explicitly outputting a trailing
  NUL byte.  This behaviour was preserved, though it should not be
  necessary.
  
  Reviewed by:phk (original patch)

Modified:
  head/sys/dev/cxgb/cxgb_sge.c
  head/sys/kern/kern_malloc.c
  head/sys/kern/kern_sysctl.c
  head/sys/kern/subr_lock.c
  head/sys/kern/subr_sbuf.c
  head/sys/kern/subr_sleepqueue.c
  head/sys/kern/subr_witness.c
  head/sys/sys/sysctl.h
  head/sys/vm/uma_core.c
  head/sys/vm/vm_phys.c
  head/sys/vm/vm_reserv.c

Modified: head/sys/dev/cxgb/cxgb_sge.c
==
--- head/sys/dev/cxgb/cxgb_sge.cThu Sep 16 16:03:12 2010
(r212749)
+++ head/sys/dev/cxgb/cxgb_sge.cThu Sep 16 16:13:12 2010
(r212750)
@@ -3227,7 +3227,6 @@ t3_dump_rspq(SYSCTL_HANDLER_ARGS)
struct sge_rspq *rspq;
struct sge_qset *qs;
int i, err, dump_end, idx;
-   static int multiplier = 1;
struct sbuf *sb;
struct rsp_desc *rspd;
uint32_t data[4];
@@ -3252,8 +3251,8 @@ t3_dump_rspq(SYSCTL_HANDLER_ARGS)
err = t3_sge_read_rspq(qs-port-adapter, rspq-cntxt_id, data);
if (err)
return (err);
-retry_sbufops:
-   sb = sbuf_new(NULL, NULL, QDUMP_SBUF_SIZE*multiplier, SBUF_FIXEDLEN);
+
+   sb = sbuf_new_for_sysctl(NULL, NULL, QDUMP_SBUF_SIZE, req);
 
sbuf_printf(sb,  \n index=%u size=%u MSI-X/RspQ=%u intr enable=%u intr 
armed=%u\n,
(data[0]  0x), data[0]  16, ((data[2]  20)  0x3f),
@@ -3276,13 +3275,11 @@ retry_sbufops:
rspd-rss_hdr.rss_hash_val, be32toh(rspd-flags),
be32toh(rspd-len_cq), rspd-intr_gen);
}
-   if (sbuf_error(sb) != 0) {
-   sbuf_delete(sb);
-   multiplier++;
-   goto retry_sbufops;
-   }
-   sbuf_finish(sb);
-   err = SYSCTL_OUT(req, sbuf_data(sb), sbuf_len(sb) + 1);
+
+   err = sbuf_finish(sb);
+   /* Output a trailing NUL. */
+   if (err == 0)
+   err = SYSCTL_OUT(req, , 1);
sbuf_delete(sb);
return (err);
 }  
@@ -3293,7 +3290,6 @@ t3_dump_txq_eth(SYSCTL_HANDLER_ARGS)
struct sge_txq *txq;
struct sge_qset *qs;
int i, j, err, dump_end;
-   static int multiplier = 1;
struct sbuf *sb;
struct tx_desc *txd;
uint32_t *WR, wr_hi, wr_lo, gen;
@@ -3321,9 +3317,7 @@ t3_dump_txq_eth(SYSCTL_HANDLER_ARGS)
if (err)
return (err);

-   
-retry_sbufops:
-   sb = sbuf_new(NULL, NULL, QDUMP_SBUF_SIZE*multiplier, SBUF_FIXEDLEN);
+   sb = sbuf_new_for_sysctl(NULL, NULL, QDUMP_SBUF_SIZE, req);
 
sbuf_printf(sb,  \n credits=%u GTS=%u index=%u size=%u rspq#=%u 
cmdq#=%u\n,
(data[0]  0x7fff), ((data[0]  15)  1), (data[0]  16), 
@@ -3350,13 +3344,10 @@ retry_sbufops:
WR[j], WR[j + 1], WR[j + 2], WR[j + 3]);
 
}
-   if (sbuf_error(sb) != 0) {
-   sbuf_delete(sb);
-   multiplier++;
-   goto retry_sbufops;
-   }
-   sbuf_finish(sb);
-   err = SYSCTL_OUT(req, sbuf_data(sb), sbuf_len(sb) + 1);
+   err = sbuf_finish(sb);
+   /* Output a trailing NUL. */
+   if (err == 0)
+   err = SYSCTL_OUT(req, , 1);
sbuf_delete(sb);
return (err);
 }
@@ -3367,7 +3358,6 @@ t3_dump_txq_ctrl(SYSCTL_HANDLER_ARGS)
struct sge_txq *txq;
struct sge_qset *qs;
int i, j, err, dump_end;
-   static int multiplier = 1;
struct sbuf *sb;
struct tx_desc *txd;
uint32_t *WR, wr_hi, wr_lo, gen;
@@ -3391,8 +3381,7 @@ t3_dump_txq_ctrl(SYSCTL_HANDLER_ARGS)
return (EINVAL);
}
 
-retry_sbufops:
-   sb = sbuf_new(NULL, NULL, QDUMP_SBUF_SIZE*multiplier, SBUF_FIXEDLEN);
+   sb = sbuf_new_for_sysctl(NULL, NULL, QDUMP_SBUF_SIZE, req);
sbuf_printf(sb,  qid=%d start=%d - end=%d\n, qs-idx,
txq-txq_dump_start,
(txq-txq_dump_start + txq-txq_dump_count)  255);
@@ -3412,13 +3401,10 @@ retry_sbufops:
WR[j], WR[j + 1], WR[j + 2], WR[j + 3]);
 
}
-   if (sbuf_error(sb) != 0) {
-   sbuf_delete(sb);
-   multiplier++;
-   goto retry_sbufops;
-   }
-   sbuf_finish(sb);
-   err = SYSCTL_OUT(req, sbuf_data(sb), sbuf_len(sb) + 1);
+   err = sbuf_finish(sb);
+   /* Output a trailing NUL. */
+   if (err == 0)
+   err = SYSCTL_OUT(req, , 1);

svn commit: r212572 - in head/sys: dev/cxgb kern sys vm

2010-09-13 Thread Matthew D Fleming
Author: mdf
Date: Mon Sep 13 18:48:23 2010
New Revision: 212572
URL: http://svn.freebsd.org/changeset/base/212572

Log:
  Revert r212370, as it causes a LOR on powerpc.  powerpc does a few
  unexpected things in copyout(9) and so wiring the user buffer is not
  sufficient to perform a copyout(9) while holding a random mutex.
  
  Requested by: nwhitehorn

Modified:
  head/sys/dev/cxgb/cxgb_sge.c
  head/sys/kern/kern_malloc.c
  head/sys/kern/kern_sysctl.c
  head/sys/kern/subr_lock.c
  head/sys/kern/subr_sbuf.c
  head/sys/kern/subr_sleepqueue.c
  head/sys/kern/subr_witness.c
  head/sys/sys/sysctl.h
  head/sys/vm/uma_core.c
  head/sys/vm/vm_phys.c
  head/sys/vm/vm_reserv.c

Modified: head/sys/dev/cxgb/cxgb_sge.c
==
--- head/sys/dev/cxgb/cxgb_sge.cMon Sep 13 18:32:49 2010
(r212571)
+++ head/sys/dev/cxgb/cxgb_sge.cMon Sep 13 18:48:23 2010
(r212572)
@@ -3227,6 +3227,7 @@ t3_dump_rspq(SYSCTL_HANDLER_ARGS)
struct sge_rspq *rspq;
struct sge_qset *qs;
int i, err, dump_end, idx;
+   static int multiplier = 1;
struct sbuf *sb;
struct rsp_desc *rspd;
uint32_t data[4];
@@ -3251,8 +3252,8 @@ t3_dump_rspq(SYSCTL_HANDLER_ARGS)
err = t3_sge_read_rspq(qs-port-adapter, rspq-cntxt_id, data);
if (err)
return (err);
-
-   sb = sbuf_new_for_sysctl(NULL, NULL, QDUMP_SBUF_SIZE, req);
+retry_sbufops:
+   sb = sbuf_new(NULL, NULL, QDUMP_SBUF_SIZE*multiplier, SBUF_FIXEDLEN);
 
sbuf_printf(sb,  \n index=%u size=%u MSI-X/RspQ=%u intr enable=%u intr 
armed=%u\n,
(data[0]  0x), data[0]  16, ((data[2]  20)  0x3f),
@@ -3275,11 +3276,13 @@ t3_dump_rspq(SYSCTL_HANDLER_ARGS)
rspd-rss_hdr.rss_hash_val, be32toh(rspd-flags),
be32toh(rspd-len_cq), rspd-intr_gen);
}
-
-   err = sbuf_finish(sb);
-   /* Output a trailing NUL. */
-   if (err == 0)
-   err = SYSCTL_OUT(req, , 1);
+   if (sbuf_error(sb) != 0) {
+   sbuf_delete(sb);
+   multiplier++;
+   goto retry_sbufops;
+   }
+   sbuf_finish(sb);
+   err = SYSCTL_OUT(req, sbuf_data(sb), sbuf_len(sb) + 1);
sbuf_delete(sb);
return (err);
 }  
@@ -3290,6 +3293,7 @@ t3_dump_txq_eth(SYSCTL_HANDLER_ARGS)
struct sge_txq *txq;
struct sge_qset *qs;
int i, j, err, dump_end;
+   static int multiplier = 1;
struct sbuf *sb;
struct tx_desc *txd;
uint32_t *WR, wr_hi, wr_lo, gen;
@@ -3317,7 +3321,9 @@ t3_dump_txq_eth(SYSCTL_HANDLER_ARGS)
if (err)
return (err);

-   sb = sbuf_new_for_sysctl(NULL, NULL, QDUMP_SBUF_SIZE, req);
+   
+retry_sbufops:
+   sb = sbuf_new(NULL, NULL, QDUMP_SBUF_SIZE*multiplier, SBUF_FIXEDLEN);
 
sbuf_printf(sb,  \n credits=%u GTS=%u index=%u size=%u rspq#=%u 
cmdq#=%u\n,
(data[0]  0x7fff), ((data[0]  15)  1), (data[0]  16), 
@@ -3344,10 +3350,13 @@ t3_dump_txq_eth(SYSCTL_HANDLER_ARGS)
WR[j], WR[j + 1], WR[j + 2], WR[j + 3]);
 
}
-   err = sbuf_finish(sb);
-   /* Output a trailing NUL. */
-   if (err == 0)
-   err = SYSCTL_OUT(req, , 1);
+   if (sbuf_error(sb) != 0) {
+   sbuf_delete(sb);
+   multiplier++;
+   goto retry_sbufops;
+   }
+   sbuf_finish(sb);
+   err = SYSCTL_OUT(req, sbuf_data(sb), sbuf_len(sb) + 1);
sbuf_delete(sb);
return (err);
 }
@@ -3358,6 +3367,7 @@ t3_dump_txq_ctrl(SYSCTL_HANDLER_ARGS)
struct sge_txq *txq;
struct sge_qset *qs;
int i, j, err, dump_end;
+   static int multiplier = 1;
struct sbuf *sb;
struct tx_desc *txd;
uint32_t *WR, wr_hi, wr_lo, gen;
@@ -3381,7 +3391,8 @@ t3_dump_txq_ctrl(SYSCTL_HANDLER_ARGS)
return (EINVAL);
}
 
-   sb = sbuf_new_for_sysctl(NULL, NULL, QDUMP_SBUF_SIZE, req);
+retry_sbufops:
+   sb = sbuf_new(NULL, NULL, QDUMP_SBUF_SIZE*multiplier, SBUF_FIXEDLEN);
sbuf_printf(sb,  qid=%d start=%d - end=%d\n, qs-idx,
txq-txq_dump_start,
(txq-txq_dump_start + txq-txq_dump_count)  255);
@@ -3401,10 +3412,13 @@ t3_dump_txq_ctrl(SYSCTL_HANDLER_ARGS)
WR[j], WR[j + 1], WR[j + 2], WR[j + 3]);
 
}
-   err = sbuf_finish(sb);
-   /* Output a trailing NUL. */
-   if (err == 0)
-   err = SYSCTL_OUT(req, , 1);
+   if (sbuf_error(sb) != 0) {
+   sbuf_delete(sb);
+   multiplier++;
+   goto retry_sbufops;
+   }
+   sbuf_finish(sb);
+   err = SYSCTL_OUT(req, sbuf_data(sb), sbuf_len(sb) + 1);
sbuf_delete(sb);
return (err);
 }

Modified: head/sys/kern/kern_malloc.c

svn commit: r212425 - in head: share/man/man9 sys/cddl/contrib/opensolaris/uts/common/fs/zfs sys/compat/linux sys/kern sys/net sys/security/audit sys/sys

2010-09-10 Thread Matthew D Fleming
Author: mdf
Date: Fri Sep 10 16:42:16 2010
New Revision: 212425
URL: http://svn.freebsd.org/changeset/base/212425

Log:
  Replace sbuf_overflowed() with sbuf_error(), which returns any error
  code associated with overflow or with the drain function.  While this
  function is not expected to be used often, it produces more information
  in the form of an errno that sbuf_overflowed() did.

Modified:
  head/share/man/man9/Makefile
  head/share/man/man9/sbuf.9
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_fm.c
  head/sys/compat/linux/linux_ioctl.c
  head/sys/kern/kern_sig.c
  head/sys/kern/subr_sbuf.c
  head/sys/net/if.c
  head/sys/security/audit/audit_bsm_klib.c
  head/sys/sys/sbuf.h

Modified: head/share/man/man9/Makefile
==
--- head/share/man/man9/MakefileFri Sep 10 16:27:09 2010
(r212424)
+++ head/share/man/man9/MakefileFri Sep 10 16:42:16 2010
(r212425)
@@ -1025,10 +1025,10 @@ MLINKS+=sbuf.9 sbuf_bcat.9 \
sbuf.9 sbuf_data.9 \
sbuf.9 sbuf_delete.9 \
sbuf.9 sbuf_done.9 \
+   sbuf.9 sbuf_error.9 \
sbuf.9 sbuf_finish.9 \
sbuf.9 sbuf_len.9 \
sbuf.9 sbuf_new.9 \
-   sbuf.9 sbuf_overflowed.9 \
sbuf.9 sbuf_printf.9 \
sbuf.9 sbuf_putc.9 \
sbuf.9 sbuf_set_drain.9 \

Modified: head/share/man/man9/sbuf.9
==
--- head/share/man/man9/sbuf.9  Fri Sep 10 16:27:09 2010(r212424)
+++ head/share/man/man9/sbuf.9  Fri Sep 10 16:42:16 2010(r212425)
@@ -45,7 +45,7 @@
 .Nm sbuf_putc ,
 .Nm sbuf_set_drain ,
 .Nm sbuf_trim ,
-.Nm sbuf_overflowed ,
+.Nm sbuf_error ,
 .Nm sbuf_finish ,
 .Nm sbuf_data ,
 .Nm sbuf_len ,
@@ -88,7 +88,7 @@
 .Ft int
 .Fn sbuf_trim struct sbuf *s
 .Ft int
-.Fn sbuf_overflowed struct sbuf *s
+.Fn sbuf_error struct sbuf *s
 .Ft int
 .Fn sbuf_finish struct sbuf *s
 .Ft char *
@@ -332,10 +332,15 @@ function removes trailing whitespace fro
 .Fa sbuf .
 .Pp
 The
-.Fn sbuf_overflowed
-function returns a non-zero value if the
+.Fn sbuf_error
+function returns any error value that the
+.Fa sbuf
+may have accumulated, either from the drain function, or ENOMEM if the
 .Fa sbuf
 overflowed.
+This function is generally not needed and instead the error code from
+.Fn sbuf_finish
+is the preferred way to discover whether an sbuf had an error.
 .Pp
 The
 .Fn sbuf_finish
@@ -437,9 +442,9 @@ functions
 all return \-1 if the buffer overflowed, and zero otherwise.
 .Pp
 The
-.Fn sbuf_overflowed
-function
-returns a non-zero value if the buffer overflowed, and zero otherwise.
+.Fn sbuf_error
+function returns a non-zero value if the buffer has an overflow or
+drain error, and zero otherwise.
 .Pp
 The
 .Fn sbuf_data

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_fm.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_fm.cFri Sep 
10 16:27:09 2010(r212424)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_fm.cFri Sep 
10 16:42:16 2010(r212425)
@@ -101,6 +101,7 @@ zfs_ereport_post(const char *subclass, s
char buf[1024];
struct sbuf sb;
struct timespec ts;
+   int error;
 
/*
 * If we are doing a spa_tryimport(), ignore errors.
@@ -315,9 +316,9 @@ zfs_ereport_post(const char *subclass, s
}
mutex_exit(spa-spa_errlist_lock);
 
-   sbuf_finish(sb);
+   error = sbuf_finish(sb);
devctl_notify(ZFS, spa-spa_name, subclass, sbuf_data(sb));
-   if (sbuf_overflowed(sb))
+   if (error != 0)
printf(ZFS WARNING: sbuf overflowed\n);
sbuf_delete(sb);
 #endif
@@ -331,6 +332,7 @@ zfs_post_common(spa_t *spa, vdev_t *vd, 
char class[64];
struct sbuf sb;
struct timespec ts;
+   int error;
 
nanotime(ts);
 
@@ -346,10 +348,10 @@ zfs_post_common(spa_t *spa, vdev_t *vd, 
if (vd)
sbuf_printf(sb,  %s=%ju, FM_EREPORT_PAYLOAD_ZFS_VDEV_GUID,
vd-vdev_guid);
-   sbuf_finish(sb);
+   error = sbuf_finish(sb);
ZFS_LOG(1, %s, sbuf_data(sb));
devctl_notify(ZFS, spa-spa_name, class, sbuf_data(sb));
-   if (sbuf_overflowed(sb))
+   if (error != 0)
printf(ZFS WARNING: sbuf overflowed\n);
sbuf_delete(sb);
 #endif

Modified: head/sys/compat/linux/linux_ioctl.c
==
--- head/sys/compat/linux/linux_ioctl.c Fri Sep 10 16:27:09 2010
(r212424)
+++ head/sys/compat/linux/linux_ioctl.c Fri Sep 10 16:42:16 2010
(r212425)
@@ -2220,7 +2220,7 @@ again:
addrs++;
}
 
-   if (!sbuf_overflowed(sb))
+   if (sbuf_error(sb) == 0)
  

svn commit: r212435 - head

2010-09-10 Thread Matthew D Fleming
Author: mdf
Date: Fri Sep 10 20:42:41 2010
New Revision: 212435
URL: http://svn.freebsd.org/changeset/base/212435

Log:
  Mark the sbuf_overflowed(9) manpage as obsolete since it has been
  renamed.
  
  Noticed by:   jhb

Modified:
  head/ObsoleteFiles.inc

Modified: head/ObsoleteFiles.inc
==
--- head/ObsoleteFiles.inc  Fri Sep 10 20:20:28 2010(r212434)
+++ head/ObsoleteFiles.inc  Fri Sep 10 20:42:41 2010(r212435)
@@ -14,6 +14,8 @@
 # The file is partitioned: OLD_FILES first, then OLD_LIBS and OLD_DIRS last.
 #
 
+# 20100910: renamed sbuf_overflowed to sbuf_error
+OLD_FILES+=usr/share/man/man9/sbuf_overflowed.9.gz
 # 20100815: retired last traces of chooseproc(9)
 OLD_FILES+=usr/share/man/man9/chooseproc.9.gz
 # 20100806: removal of unused libcompat routines
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r212364 - head/share/man/man9

2010-09-09 Thread Matthew D Fleming
Author: mdf
Date: Thu Sep  9 16:27:02 2010
New Revision: 212364
URL: http://svn.freebsd.org/changeset/base/212364

Log:
  Fix small errors in the sbuf(9) man page.

Modified:
  head/share/man/man9/sbuf.9

Modified: head/share/man/man9/sbuf.9
==
--- head/share/man/man9/sbuf.9  Thu Sep  9 16:06:55 2010(r212363)
+++ head/share/man/man9/sbuf.9  Thu Sep  9 16:27:02 2010(r212364)
@@ -98,7 +98,7 @@
 The
 .Nm
 family of functions allows one to safely allocate, construct and
-release bounded null-terminated strings in kernel space.
+release bounded NUL-terminated strings in kernel space.
 Instead of arrays of characters, these functions operate on structures
 called
 .Fa sbufs ,
@@ -289,7 +289,7 @@ overflowed.
 .Pp
 The
 .Fn sbuf_finish
-function null-terminates the
+function NUL-terminates the
 .Fa sbuf
 and marks it as finished, which means that it may no longer be
 modified using
@@ -298,7 +298,10 @@ modified using
 .Fn sbuf_cpy ,
 .Fn sbuf_printf
 or
-.Fn sbuf_putc .
+.Fn sbuf_putc ,
+until
+.Fn sbuf_clear
+is used to reset the sbuf.
 .Pp
 The
 .Fn sbuf_data
@@ -309,7 +312,9 @@ functions return the actual string and i
 only works on a finished
 .Fa sbuf .
 .Fn sbuf_done
-returns non-zero if the sbuf is finished.
+returns non-zero if the
+.Fa sbuf
+is finished.
 .Sh NOTES
 If an operation caused an
 .Fa sbuf
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r212365 - head/sys/kern

2010-09-09 Thread Matthew D Fleming
Author: mdf
Date: Thu Sep  9 16:51:52 2010
New Revision: 212365
URL: http://svn.freebsd.org/changeset/base/212365

Log:
  Refactor sbuf code so that most uses of sbuf_extend() are in a new
  sbuf_put_byte().  This makes it easier to add drain functionality when a
  buffer would overflow as there are fewer code points.
  
  Reviewed by:  phk

Modified:
  head/sys/kern/subr_sbuf.c

Modified: head/sys/kern/subr_sbuf.c
==
--- head/sys/kern/subr_sbuf.c   Thu Sep  9 16:27:02 2010(r212364)
+++ head/sys/kern/subr_sbuf.c   Thu Sep  9 16:51:52 2010(r212365)
@@ -272,27 +272,59 @@ sbuf_setpos(struct sbuf *s, int pos)
 }
 
 /*
+ * Append a byte to an sbuf.  This is the core function for appending
+ * to an sbuf and is the main place that deals with extending the
+ * buffer and marking overflow.
+ */
+static void
+sbuf_put_byte(int c, struct sbuf *s)
+{
+
+   assert_sbuf_integrity(s);
+   assert_sbuf_state(s, 0);
+
+   if (SBUF_HASOVERFLOWED(s))
+   return;
+   if (SBUF_FREESPACE(s) = 0) {
+   if (sbuf_extend(s, 1)  0) {
+   SBUF_SETFLAG(s, SBUF_OVERFLOWED);
+   return;
+   }
+   }
+   s-s_buf[s-s_len++] = c;
+}
+
+/*
+ * Append a non-NUL character to an sbuf.  This prototype signature is
+ * suitable for use with kvprintf(9).
+ */
+static void
+sbuf_putc_func(int c, void *arg)
+{
+
+   if (c != '\0')
+   sbuf_put_byte(c, arg);
+}
+
+/*
  * Append a byte string to an sbuf.
  */
 int
 sbuf_bcat(struct sbuf *s, const void *buf, size_t len)
 {
const char *str = buf;
+   const char *end = str + len;
 
assert_sbuf_integrity(s);
assert_sbuf_state(s, 0);
 
if (SBUF_HASOVERFLOWED(s))
return (-1);
-   for (; len; len--) {
-   if (!SBUF_HASROOM(s)  sbuf_extend(s, len)  0)
-   break;
-   s-s_buf[s-s_len++] = *str++;
-   }
-   if (len  0) {
-   SBUF_SETFLAG(s, SBUF_OVERFLOWED);
-   return (-1);
-   }
+   for (; str  end; str++) {
+   sbuf_put_byte(*str, s);
+   if (SBUF_HASOVERFLOWED(s))
+   return (-1);
+   }
return (0);
 }
 
@@ -352,13 +384,9 @@ sbuf_cat(struct sbuf *s, const char *str
return (-1);
 
while (*str != '\0') {
-   if (!SBUF_HASROOM(s)  sbuf_extend(s, strlen(str))  0)
-   break;
-   s-s_buf[s-s_len++] = *str++;
-   }
-   if (*str != '\0') {
-   SBUF_SETFLAG(s, SBUF_OVERFLOWED);
-   return (-1);
+   sbuf_put_byte(*str, s);
+   if (SBUF_HASOVERFLOWED(s))
+   return (-1);
}
return (0);
 }
@@ -417,6 +445,23 @@ sbuf_cpy(struct sbuf *s, const char *str
 /*
  * Format the given argument list and append the resulting string to an sbuf.
  */
+#ifdef _KERNEL
+int
+sbuf_vprintf(struct sbuf *s, const char *fmt, va_list ap)
+{
+
+   assert_sbuf_integrity(s);
+   assert_sbuf_state(s, 0);
+
+   KASSERT(fmt != NULL,
+   (%s called with a NULL format string, __func__));
+
+   (void)kvprintf(fmt, sbuf_putc_func, s, 10, ap);
+   if (SBUF_HASOVERFLOWED(s))
+   return (-1);
+   return (0);
+}
+#else /* !_KERNEL */
 int
 sbuf_vprintf(struct sbuf *s, const char *fmt, va_list ap)
 {
@@ -432,6 +477,12 @@ sbuf_vprintf(struct sbuf *s, const char 
if (SBUF_HASOVERFLOWED(s))
return (-1);
 
+   /*
+* For the moment, there is no way to get vsnprintf(3) to hand
+* back a character at a time, to push everything into
+* sbuf_putc_func() as was done for the kernel.
+*/
+
do {
va_copy(ap_copy, ap);
len = vsnprintf(s-s_buf[s-s_len], SBUF_FREESPACE(s) + 1,
@@ -462,6 +513,7 @@ sbuf_vprintf(struct sbuf *s, const char 
return (-1);
return (0);
 }
+#endif /* _KERNEL */
 
 /*
  * Format the given arguments and append the resulting string to an sbuf.
@@ -485,17 +537,9 @@ int
 sbuf_putc(struct sbuf *s, int c)
 {
 
-   assert_sbuf_integrity(s);
-   assert_sbuf_state(s, 0);
-
+   sbuf_putc_func(c, s);
if (SBUF_HASOVERFLOWED(s))
return (-1);
-   if (!SBUF_HASROOM(s)  sbuf_extend(s, 1)  0) {
-   SBUF_SETFLAG(s, SBUF_OVERFLOWED);
-   return (-1);
-   }
-   if (c != '\0')
-   s-s_buf[s-s_len++] = c;
return (0);
 }
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r212367 - in head: share/man/man9 sys/kern sys/sys

2010-09-09 Thread Matthew D Fleming
Author: mdf
Date: Thu Sep  9 17:49:18 2010
New Revision: 212367
URL: http://svn.freebsd.org/changeset/base/212367

Log:
  Add drain functionality to sbufs.  The drain is a function that is
  called when the sbuf internal buffer is filled.  For kernel sbufs with a
  drain, the internal buffer will never be expanded.  For userland sbufs
  with a drain, the internal buffer may still be expanded by
  sbuf_[v]printf(3).
  
  Sbufs now have three basic uses:
  1) static string manipulation.  Overflow is marked.
  2) dynamic string manipulation.  Overflow triggers string growth.
  3) drained string manipulation.  Overflow triggers draining.
  
  In all cases the manipulation is 'safe' in that overflow is detected and
  managed.
  
  Reviewed by:  phk (the previous version)

Modified:
  head/share/man/man9/Makefile
  head/share/man/man9/sbuf.9
  head/sys/kern/subr_sbuf.c
  head/sys/sys/sbuf.h

Modified: head/share/man/man9/Makefile
==
--- head/share/man/man9/MakefileThu Sep  9 17:45:48 2010
(r212366)
+++ head/share/man/man9/MakefileThu Sep  9 17:49:18 2010
(r212367)
@@ -1031,6 +1031,7 @@ MLINKS+=sbuf.9 sbuf_bcat.9 \
sbuf.9 sbuf_overflowed.9 \
sbuf.9 sbuf_printf.9 \
sbuf.9 sbuf_putc.9 \
+   sbuf.9 sbuf_set_drain.9 \
sbuf.9 sbuf_setpos.9 \
sbuf.9 sbuf_trim.9 \
sbuf.9 sbuf_vprintf.9

Modified: head/share/man/man9/sbuf.9
==
--- head/share/man/man9/sbuf.9  Thu Sep  9 17:45:48 2010(r212366)
+++ head/share/man/man9/sbuf.9  Thu Sep  9 17:49:18 2010(r212367)
@@ -43,6 +43,7 @@
 .Nm sbuf_printf ,
 .Nm sbuf_vprintf ,
 .Nm sbuf_putc ,
+.Nm sbuf_set_drain ,
 .Nm sbuf_trim ,
 .Nm sbuf_overflowed ,
 .Nm sbuf_finish ,
@@ -54,6 +55,8 @@
 .Sh SYNOPSIS
 .In sys/types.h
 .In sys/sbuf.h
+.Ft typedef\ int ( sbuf_drain_func ) ( void\ *arg, const\ char\ *data, int\ 
len ) ;
+.Pp
 .Ft struct sbuf *
 .Fn sbuf_new struct sbuf *s char *buf int length int flags
 .Ft struct sbuf *
@@ -80,11 +83,13 @@
 .Fn sbuf_vprintf struct sbuf *s const char *fmt va_list ap
 .Ft int
 .Fn sbuf_putc struct sbuf *s int c
+.Ft void
+.Fn sbuf_set_drain struct sbuf *s sbuf_drain_func *func void *arg
 .Ft int
 .Fn sbuf_trim struct sbuf *s
 .Ft int
 .Fn sbuf_overflowed struct sbuf *s
-.Ft void
+.Ft int
 .Fn sbuf_finish struct sbuf *s
 .Ft char *
 .Fn sbuf_data struct sbuf *s
@@ -224,6 +229,51 @@ to the
 at the current position.
 .Pp
 The
+.Fn sbuf_set_drain
+function sets a drain function
+.Fa func
+for the
+.Fa sbuf ,
+and records a pointer
+.Fa arg
+to be passed to the drain on callback.
+The drain function cannot be changed while
+.Fa sbuf_len
+is non-zero.
+.Pp
+The registered drain function
+.Vt sbuf_drain_func
+will be called with the argument
+.Fa arg
+provided to
+.Fn sbuf_set_drain ,
+a pointer
+.Fa data
+to a byte string that is the contents of the sbuf, and the length
+.Fa len
+of the data.
+If the drain function exists, it will be called when the sbuf internal
+buffer is full, or on behalf of
+.Fn sbuf_finish .
+The drain function may drain some or all of the data, but must drain
+at least 1 byte.
+The return value from the drain function, if positive, indicates how
+many bytes were drained.
+If negative, the return value indicates the negative error code which
+will be returned from this or a later call to
+.Fn sbuf_finish .
+The returned drained length cannot be zero.
+To do unbuffered draining, initialize the sbuf with a two-byte buffer.
+The drain will be called for every byte added to the sbuf.
+The
+.Fn sbuf_bcopyin ,
+.Fn sbuf_copyin ,
+.Fn sbuf_trim ,
+and
+.Fn sbuf_data
+functions cannot be used on an sbuf with a drain.
+.Pp
+The
 .Fn sbuf_copyin
 function copies a NUL-terminated string from the specified userland
 address into the
@@ -289,10 +339,17 @@ overflowed.
 .Pp
 The
 .Fn sbuf_finish
-function NUL-terminates the
+function will call the attached drain function if one exists until all
+the data in the
 .Fa sbuf
-and marks it as finished, which means that it may no longer be
-modified using
+is flushed.
+If there is no attached drain,
+.Fn sbuf_finish
+NUL-terminates the
+.Fa sbuf .
+In either case it marks the
+.Fa sbuf
+as finished, which means that it may no longer be modified using
 .Fn sbuf_setpos ,
 .Fn sbuf_cat ,
 .Fn sbuf_cpy ,
@@ -305,12 +362,21 @@ is used to reset the sbuf.
 .Pp
 The
 .Fn sbuf_data
-and
-.Fn sbuf_len
-functions return the actual string and its length, respectively;
+function returns the actual string;
 .Fn sbuf_data
 only works on a finished
 .Fa sbuf .
+The
+.Fn sbuf_len function returns the length of the string.
+For an
+.Fa sbuf
+with an attached drain,
+.Fn sbuf_len
+returns the length of the un-drained data.
+.Fn sbuf_done
+returns non-zero if the
+.Fa sbuf
+is finished.
 .Fn sbuf_done
 returns non-zero if the
 .Fa sbuf
@@ -329,6 +395,22 @@ size of its storage 

svn commit: r212381 - head/sys/sys

2010-09-09 Thread Matthew D Fleming
Author: mdf
Date: Thu Sep  9 21:01:41 2010
New Revision: 212381
URL: http://svn.freebsd.org/changeset/base/212381

Log:
  Bump __FreeBSD_version for sbuf ABI change.

Modified:
  head/sys/sys/param.h

Modified: head/sys/sys/param.h
==
--- head/sys/sys/param.hThu Sep  9 20:51:23 2010(r212380)
+++ head/sys/sys/param.hThu Sep  9 21:01:41 2010(r212381)
@@ -58,7 +58,7 @@
  * in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 900019   /* Master, propagated to newvers */
+#define __FreeBSD_version 900020   /* Master, propagated to newvers */
 
 #ifndef LOCORE
 #include sys/types.h
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r212180 - head/sys/kern

2010-09-03 Thread Matthew D Fleming
Author: mdf
Date: Fri Sep  3 16:09:17 2010
New Revision: 212180
URL: http://svn.freebsd.org/changeset/base/212180

Log:
  Use math rather than iteration when the desired sbuf size is larger than
  SBUF_MAXEXTENDSIZE.

Modified:
  head/sys/kern/subr_sbuf.c

Modified: head/sys/kern/subr_sbuf.c
==
--- head/sys/kern/subr_sbuf.c   Fri Sep  3 15:34:28 2010(r212179)
+++ head/sys/kern/subr_sbuf.c   Fri Sep  3 16:09:17 2010(r212180)
@@ -116,18 +116,22 @@ _assert_sbuf_state(const char *fun, stru
 
 #endif /* _KERNEL  INVARIANTS */
 
+CTASSERT(powerof2(SBUF_MAXEXTENDSIZE));
+CTASSERT(powerof2(SBUF_MAXEXTENDINCR));
+
 static int
 sbuf_extendsize(int size)
 {
int newsize;
 
-   newsize = SBUF_MINEXTENDSIZE;
-   while (newsize  size) {
-   if (newsize  (int)SBUF_MAXEXTENDSIZE)
+   if (size  (int)SBUF_MAXEXTENDSIZE) {
+   newsize = SBUF_MINEXTENDSIZE;
+   while (newsize  size)
newsize *= 2;
-   else
-   newsize += SBUF_MAXEXTENDINCR;
+   } else {
+   newsize = roundup2(size, SBUF_MAXEXTENDINCR);
}
+   KASSERT(newsize  size, (%s: %d  %d\n, __func__, newsize, size));
return (newsize);
 }
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r212181 - head/sys/kern

2010-09-03 Thread Matthew D Fleming
Author: mdf
Date: Fri Sep  3 16:12:39 2010
New Revision: 212181
URL: http://svn.freebsd.org/changeset/base/212181

Log:
  Fix brain fart when converting an if statement into a KASSERT.

Modified:
  head/sys/kern/subr_sbuf.c

Modified: head/sys/kern/subr_sbuf.c
==
--- head/sys/kern/subr_sbuf.c   Fri Sep  3 16:09:17 2010(r212180)
+++ head/sys/kern/subr_sbuf.c   Fri Sep  3 16:12:39 2010(r212181)
@@ -131,7 +131,7 @@ sbuf_extendsize(int size)
} else {
newsize = roundup2(size, SBUF_MAXEXTENDINCR);
}
-   KASSERT(newsize  size, (%s: %d  %d\n, __func__, newsize, size));
+   KASSERT(newsize = size, (%s: %d  %d\n, __func__, newsize, size));
return (newsize);
 }
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r212182 - head/sys/kern

2010-09-03 Thread Matthew D Fleming
Author: mdf
Date: Fri Sep  3 17:23:26 2010
New Revision: 212182
URL: http://svn.freebsd.org/changeset/base/212182

Log:
  Fix user-space libsbuf build.  Why isn't CTASSERT available to
  user-space?

Modified:
  head/sys/kern/subr_sbuf.c

Modified: head/sys/kern/subr_sbuf.c
==
--- head/sys/kern/subr_sbuf.c   Fri Sep  3 16:12:39 2010(r212181)
+++ head/sys/kern/subr_sbuf.c   Fri Sep  3 17:23:26 2010(r212182)
@@ -116,8 +116,10 @@ _assert_sbuf_state(const char *fun, stru
 
 #endif /* _KERNEL  INVARIANTS */
 
+#ifdef _KERNEL
 CTASSERT(powerof2(SBUF_MAXEXTENDSIZE));
 CTASSERT(powerof2(SBUF_MAXEXTENDINCR));
+#endif
 
 static int
 sbuf_extendsize(int size)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r212184 - head/sys/kern

2010-09-03 Thread Matthew D Fleming
Author: mdf
Date: Fri Sep  3 17:42:17 2010
New Revision: 212184
URL: http://svn.freebsd.org/changeset/base/212184

Log:
  Use a better #if guard.
  
  Suggested by pluknet pluknet at gmail dot com.

Modified:
  head/sys/kern/subr_sbuf.c

Modified: head/sys/kern/subr_sbuf.c
==
--- head/sys/kern/subr_sbuf.c   Fri Sep  3 17:42:12 2010(r212183)
+++ head/sys/kern/subr_sbuf.c   Fri Sep  3 17:42:17 2010(r212184)
@@ -115,7 +115,7 @@ _assert_sbuf_state(const char *fun, stru
 
 #endif /* _KERNEL  INVARIANTS */
 
-#ifdef _KERNEL
+#ifdef CTASSERT
 CTASSERT(powerof2(SBUF_MAXEXTENDSIZE));
 CTASSERT(powerof2(SBUF_MAXEXTENDINCR));
 #endif
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r212183 - head/sys/kern

2010-09-03 Thread Matthew D Fleming
Author: mdf
Date: Fri Sep  3 17:42:12 2010
New Revision: 212183
URL: http://svn.freebsd.org/changeset/base/212183

Log:
  Style(9) fixes and eliminate the use of min().

Modified:
  head/sys/kern/subr_sbuf.c

Modified: head/sys/kern/subr_sbuf.c
==
--- head/sys/kern/subr_sbuf.c   Fri Sep  3 17:23:26 2010(r212182)
+++ head/sys/kern/subr_sbuf.c   Fri Sep  3 17:42:12 2010(r212183)
@@ -56,7 +56,6 @@ static MALLOC_DEFINE(M_SBUF, sbuf, st
 #defineKASSERT(e, m)
 #defineSBMALLOC(size)  malloc(size)
 #defineSBFREE(buf) free(buf)
-#definemin(x,y)MIN(x,y)
 #endif /* _KERNEL */
 
 /*
@@ -190,11 +189,11 @@ sbuf_new(struct sbuf *s, char *buf, int 
s-s_flags = flags;
}
s-s_size = length;
-   if (buf) {
+   if (buf != NULL) {
s-s_buf = buf;
return (s);
}
-   if (flags  SBUF_AUTOEXTEND)
+   if ((flags  SBUF_AUTOEXTEND) != 0)
s-s_size = sbuf_extendsize(s-s_size);
s-s_buf = SBMALLOC(s-s_size);
if (s-s_buf == NULL) {
@@ -290,7 +289,7 @@ sbuf_bcat(struct sbuf *s, const void *bu
break;
s-s_buf[s-s_len++] = *str++;
}
-   if (len) {
+   if (len  0) {
SBUF_SETFLAG(s, SBUF_OVERFLOWED);
return (-1);
}
@@ -314,7 +313,8 @@ sbuf_bcopyin(struct sbuf *s, const void 
return (0);
if (len  SBUF_FREESPACE(s)) {
sbuf_extend(s, len - SBUF_FREESPACE(s));
-   len = min(len, SBUF_FREESPACE(s));
+   if (SBUF_FREESPACE(s)  len)
+   len = SBUF_FREESPACE(s);
}
if (copyin(uaddr, s-s_buf + s-s_len, len) != 0)
return (-1);
@@ -351,12 +351,12 @@ sbuf_cat(struct sbuf *s, const char *str
if (SBUF_HASOVERFLOWED(s))
return (-1);
 
-   while (*str) {
+   while (*str != '\0') {
if (!SBUF_HASROOM(s)  sbuf_extend(s, strlen(str))  0)
break;
s-s_buf[s-s_len++] = *str++;
}
-   if (*str) {
+   if (*str != '\0') {
SBUF_SETFLAG(s, SBUF_OVERFLOWED);
return (-1);
}
@@ -382,7 +382,8 @@ sbuf_copyin(struct sbuf *s, const void *
len = SBUF_FREESPACE(s);/* XXX return 0? */
if (len  SBUF_FREESPACE(s)) {
sbuf_extend(s, len);
-   len = min(len, SBUF_FREESPACE(s));
+   if (SBUF_FREESPACE(s)  len)
+   len = SBUF_FREESPACE(s);
}
switch (copyinstr(uaddr, s-s_buf + s-s_len, len + 1, done)) {
case ENAMETOOLONG:
@@ -446,9 +447,11 @@ sbuf_vprintf(struct sbuf *s, const char 
 * terminating nul.
 *
 * vsnprintf() returns the amount that would have been copied,
-* given sufficient space, hence the min() calculation below.
+* given sufficient space, so don't over-increment s_len.
 */
-   s-s_len += min(len, SBUF_FREESPACE(s));
+   if (SBUF_FREESPACE(s)  len)
+   len = SBUF_FREESPACE(s);
+   s-s_len += len;
if (!SBUF_HASROOM(s)  !SBUF_CANEXTEND(s))
SBUF_SETFLAG(s, SBUF_OVERFLOWED);
 
@@ -492,7 +495,7 @@ sbuf_putc(struct sbuf *s, int c)
return (-1);
}
if (c != '\0')
-   s-s_buf[s-s_len++] = c;
+   s-s_buf[s-s_len++] = c;
return (0);
 }
 
@@ -509,7 +512,7 @@ sbuf_trim(struct sbuf *s)
if (SBUF_HASOVERFLOWED(s))
return (-1);
 
-   while (s-s_len  isspace(s-s_buf[s-s_len-1]))
+   while (s-s_len  0  isspace(s-s_buf[s-s_len-1]))
--s-s_len;
 
return (0);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r212153 - head/sys/kern

2010-09-02 Thread Matthew D Fleming
Author: mdf
Date: Thu Sep  2 16:23:05 2010
New Revision: 212153
URL: http://svn.freebsd.org/changeset/base/212153

Log:
  Fix UP build.
  
  MFC after:2 weeks

Modified:
  head/sys/kern/sched_ule.c

Modified: head/sys/kern/sched_ule.c
==
--- head/sys/kern/sched_ule.c   Thu Sep  2 16:11:12 2010(r212152)
+++ head/sys/kern/sched_ule.c   Thu Sep  2 16:23:05 2010(r212153)
@@ -1797,8 +1797,10 @@ sched_switch(struct thread *td, struct t
srqflag = (flags  SW_PREEMPT) ?
SRQ_OURSELF|SRQ_YIELDING|SRQ_PREEMPTED :
SRQ_OURSELF|SRQ_YIELDING;
+#ifdef SMP
if (THREAD_CAN_MIGRATE(td)  !THREAD_CAN_SCHED(td, ts-ts_cpu))
ts-ts_cpu = sched_pickcpu(td, 0);
+#endif
if (ts-ts_cpu == cpuid)
tdq_runq_add(tdq, td, srqflag);
else {
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r212115 - head/sys/kern

2010-09-01 Thread Matthew D Fleming
Author: mdf
Date: Wed Sep  1 20:32:47 2010
New Revision: 212115
URL: http://svn.freebsd.org/changeset/base/212115

Log:
  Fix a bug with sched_affinity() where it checks td_pinned of another
  thread in a racy manner, which can lead to attempting to migrate a
  thread that is pinned to a CPU.  Instead, have sched_switch() determine
  which CPU a thread should run on if the current one is not allowed.
  
  KASSERT in sched_bind() that the thread is not yet pinned to a CPU.
  
  KASSERT in sched_switch() that only migratable threads or those moving
  due to a sched_bind() are changing CPUs.
  
  sched_affinity code came from j...@.
  
  MFC after:2 weeks

Modified:
  head/sys/kern/sched_ule.c

Modified: head/sys/kern/sched_ule.c
==
--- head/sys/kern/sched_ule.c   Wed Sep  1 20:25:36 2010(r212114)
+++ head/sys/kern/sched_ule.c   Wed Sep  1 20:32:47 2010(r212115)
@@ -1797,10 +1797,16 @@ sched_switch(struct thread *td, struct t
srqflag = (flags  SW_PREEMPT) ?
SRQ_OURSELF|SRQ_YIELDING|SRQ_PREEMPTED :
SRQ_OURSELF|SRQ_YIELDING;
+   if (THREAD_CAN_MIGRATE(td)  !THREAD_CAN_SCHED(td, ts-ts_cpu))
+   ts-ts_cpu = sched_pickcpu(td, 0);
if (ts-ts_cpu == cpuid)
tdq_runq_add(tdq, td, srqflag);
-   else
+   else {
+   KASSERT(THREAD_CAN_MIGRATE(td) ||
+   (ts-ts_flags  TSF_BOUND) != 0,
+   (Thread %p shouldn't migrate, td));
mtx = sched_switch_migrate(tdq, td, srqflag);
+   }
} else {
/* This thread must be going to sleep. */
TDQ_LOCK(tdq);
@@ -2383,7 +2389,6 @@ sched_affinity(struct thread *td)
 {
 #ifdef SMP
struct td_sched *ts;
-   int cpu;
 
THREAD_LOCK_ASSERT(td, MA_OWNED);
ts = td-td_sched;
@@ -2397,17 +2402,13 @@ sched_affinity(struct thread *td)
if (!TD_IS_RUNNING(td))
return;
td-td_flags |= TDF_NEEDRESCHED;
-   if (!THREAD_CAN_MIGRATE(td))
-   return;
/*
-* Assign the new cpu and force a switch before returning to
-* userspace.  If the target thread is not running locally send
-* an ipi to force the issue.
+* Force a switch before returning to userspace.  If the
+* target thread is not running locally send an ipi to force
+* the issue.
 */
-   cpu = ts-ts_cpu;
-   ts-ts_cpu = sched_pickcpu(td, 0);
-   if (cpu != PCPU_GET(cpuid))
-   ipi_cpu(cpu, IPI_PREEMPT);
+   if (td != curthread)
+   ipi_cpu(ts-ts_cpu, IPI_PREEMPT);
 #endif
 }
 
@@ -2424,6 +2425,7 @@ sched_bind(struct thread *td, int cpu)
ts = td-td_sched;
if (ts-ts_flags  TSF_BOUND)
sched_unbind(td);
+   KASSERT(THREAD_CAN_MIGRATE(td), (%p must be migratable, td));
ts-ts_flags |= TSF_BOUND;
sched_pin();
if (PCPU_GET(cpuid) == cpu)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r212058 - in head/sys: kern vm

2010-08-31 Thread Matthew D Fleming
Author: mdf
Date: Tue Aug 31 16:57:58 2010
New Revision: 212058
URL: http://svn.freebsd.org/changeset/base/212058

Log:
  The realloc case for memguard(9) will copy too many bytes when
  reallocating to a smaller-sized allocation.  Fix this issue.
  
  Noticed by: alc
  Reviewed by:alc
  Approved by:zml (mentor)
  MFC after:  3 weeks

Modified:
  head/sys/kern/kern_malloc.c
  head/sys/vm/memguard.c
  head/sys/vm/memguard.h

Modified: head/sys/kern/kern_malloc.c
==
--- head/sys/kern/kern_malloc.c Tue Aug 31 15:58:15 2010(r212057)
+++ head/sys/kern/kern_malloc.c Tue Aug 31 16:57:58 2010(r212058)
@@ -566,11 +566,8 @@ realloc(void *addr, unsigned long size, 
 */
 
 #ifdef DEBUG_MEMGUARD
-   if (is_memguard_addr(addr)) {
-   slab = NULL;
-   alloc = size;
-   goto remalloc;
-   }
+   if (is_memguard_addr(addr))
+   return (memguard_realloc(addr, size, mtp, flags));
 #endif
 
 #ifdef DEBUG_REDZONE
@@ -595,10 +592,6 @@ realloc(void *addr, unsigned long size, 
return (addr);
 #endif /* !DEBUG_REDZONE */
 
-#ifdef DEBUG_MEMGUARD
-remalloc:
-#endif
-
/* Allocate a new, bigger (or smaller) block */
if ((newaddr = malloc(size, mtp, flags)) == NULL)
return (NULL);

Modified: head/sys/vm/memguard.c
==
--- head/sys/vm/memguard.c  Tue Aug 31 15:58:15 2010(r212057)
+++ head/sys/vm/memguard.c  Tue Aug 31 16:57:58 2010(r212058)
@@ -399,6 +399,31 @@ memguard_free(void *ptr)
vm_map_unlock(memguard_map);
 }
 
+/*
+ * Re-allocate an allocation that was originally guarded.
+ */
+void *
+memguard_realloc(void *addr, unsigned long size, struct malloc_type *mtp,
+int flags)
+{
+   void *newaddr;
+   u_long old_size;
+
+   /*
+* Allocate the new block.  Force the allocation to be guarded
+* as the original may have been guarded through random
+* chance, and that should be preserved.
+*/
+   if ((newaddr = memguard_alloc(size, flags)) == NULL)
+   return (NULL);
+
+   /* Copy over original contents. */
+   old_size = *v2sizep(trunc_page((uintptr_t)addr));
+   bcopy(addr, newaddr, min(size, old_size));
+   memguard_free(addr);
+   return (newaddr);
+}
+
 int
 memguard_cmp(struct malloc_type *mtp, unsigned long size)
 {

Modified: head/sys/vm/memguard.h
==
--- head/sys/vm/memguard.h  Tue Aug 31 15:58:15 2010(r212057)
+++ head/sys/vm/memguard.h  Tue Aug 31 16:57:58 2010(r212058)
@@ -38,6 +38,7 @@ struct vm_map;
 unsigned long  memguard_fudge(unsigned long, unsigned long);
 void   memguard_init(struct vm_map *);
 void   *memguard_alloc(unsigned long, int);
+void   *memguard_realloc(void *, unsigned long, struct malloc_type *, int);
 void   memguard_free(void *);
 intmemguard_cmp(struct malloc_type *, unsigned long);
 intis_memguard_addr(void *);
@@ -45,6 +46,7 @@ int   is_memguard_addr(void *);
 #definememguard_fudge(size, xxx)   (size)
 #definememguard_init(map)  do { } while (0)
 #definememguard_alloc(size, flags) NULL
+#definememguard_realloc(a, s, mtp, f)  NULL
 #definememguard_free(addr) do { } while (0)
 #definememguard_cmp(mtp, size) 0
 #defineis_memguard_addr(addr)  0
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r212063 - head/sys/vm

2010-08-31 Thread Matthew D Fleming
Author: mdf
Date: Tue Aug 31 17:43:47 2010
New Revision: 212063
URL: http://svn.freebsd.org/changeset/base/212063

Log:
  Have memguard(9) crash with an easier-to-debug message on double-free.
  
  Reviewed by:zml
  MFC after:  3 weeks

Modified:
  head/sys/vm/memguard.c

Modified: head/sys/vm/memguard.c
==
--- head/sys/vm/memguard.c  Tue Aug 31 17:38:20 2010(r212062)
+++ head/sys/vm/memguard.c  Tue Aug 31 17:43:47 2010(r212063)
@@ -247,9 +247,13 @@ SYSINIT(memguard, SI_SUB_KLD, SI_ORDER_A
 static u_long *
 v2sizep(vm_offset_t va)
 {
+   vm_paddr_t pa;
struct vm_page *p;
 
-   p = PHYS_TO_VM_PAGE(pmap_kextract(va));
+   pa = pmap_kextract(va);
+   if (pa == 0)
+   panic(MemGuard detected double-free of %p, (void *)va);
+   p = PHYS_TO_VM_PAGE(pa);
KASSERT(p-wire_count != 0  p-queue == PQ_NONE,
(MEMGUARD: Expected wired page %p in vtomgfifo!, p));
return ((u_long *)p-pageq.tqe_next);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r210663 - head/sys/powerpc/conf

2010-07-30 Thread Matthew D Fleming
Author: mdf
Date: Fri Jul 30 20:25:04 2010
New Revision: 210663
URL: http://svn.freebsd.org/changeset/base/210663

Log:
  Add MALLOC_DEBUG_MAXZONES=8 to powerpc64 GENERIC configuration file.
  
  Requested by:nwhitehorn
  Approved by: zml (mentor)

Modified:
  head/sys/powerpc/conf/GENERIC64

Modified: head/sys/powerpc/conf/GENERIC64
==
--- head/sys/powerpc/conf/GENERIC64 Fri Jul 30 20:20:14 2010
(r210662)
+++ head/sys/powerpc/conf/GENERIC64 Fri Jul 30 20:25:04 2010
(r210663)
@@ -73,6 +73,7 @@ options   INVARIANTS  #Enable calls of ex
 optionsINVARIANT_SUPPORT   #Extra sanity checks of internal 
structures, required by INVARIANTS
 optionsWITNESS #Enable checks to detect deadlocks and 
cycles
 optionsWITNESS_SKIPSPIN#Don't run witness on spinlocks for 
speed
+optionsMALLOC_DEBUG_MAXZONES=8 # Separate malloc(9) zones
 
 # To make an SMP kernel, the next line is needed
 #options   SMP # Symmetric MultiProcessor Kernel
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r210564 - in head/sys: amd64/conf conf i386/conf ia64/conf kern pc98/conf powerpc/conf sparc64/conf sun4v/conf sys

2010-07-28 Thread Matthew D Fleming
Author: mdf
Date: Wed Jul 28 15:36:12 2010
New Revision: 210564
URL: http://svn.freebsd.org/changeset/base/210564

Log:
  Add MALLOC_DEBUG_MAXZONES debug malloc(9) option to use multiple uma
  zones for each malloc bucket size.  The purpose is to isolate
  different malloc types into hash classes, so that any buffer overruns
  or use-after-free will usually only affect memory from malloc types in
  that hash class.  This is purely a debugging tool; by varying the hash
  function and tracking which hash class was corrupted, the intersection
  of the hash classes from each instance will point to a single malloc
  type that is being misused.  At this point inspection or memguard(9)
  can be used to catch the offending code.
  
  Add MALLOC_DEBUG_MAXZONES=8 to -current GENERIC configuration files.
  The suggestion to have this on by default came from Kostik Belousov on
  -arch.
  
  This code is based on work by Ron Steinke at Isilon Systems.
  
  Reviewed by:-arch (mostly silence)
  Reviewed by:zml
  Approved by:zml (mentor)

Modified:
  head/sys/amd64/conf/GENERIC
  head/sys/conf/NOTES
  head/sys/conf/options
  head/sys/i386/conf/GENERIC
  head/sys/ia64/conf/GENERIC
  head/sys/kern/kern_malloc.c
  head/sys/pc98/conf/GENERIC
  head/sys/powerpc/conf/GENERIC
  head/sys/sparc64/conf/GENERIC
  head/sys/sun4v/conf/GENERIC
  head/sys/sys/malloc.h

Modified: head/sys/amd64/conf/GENERIC
==
--- head/sys/amd64/conf/GENERIC Wed Jul 28 15:29:18 2010(r210563)
+++ head/sys/amd64/conf/GENERIC Wed Jul 28 15:36:12 2010(r210564)
@@ -76,6 +76,7 @@ options   INVARIANTS  # Enable calls of e
 optionsINVARIANT_SUPPORT   # Extra sanity checks of internal 
structures, required by INVARIANTS
 optionsWITNESS # Enable checks to detect deadlocks and 
cycles
 optionsWITNESS_SKIPSPIN# Don't run witness on spinlocks for 
speed
+optionsMALLOC_DEBUG_MAXZONES=8 # Separate malloc(9) zones
 
 # Make an SMP-capable kernel by default
 optionsSMP # Symmetric MultiProcessor Kernel

Modified: head/sys/conf/NOTES
==
--- head/sys/conf/NOTES Wed Jul 28 15:29:18 2010(r210563)
+++ head/sys/conf/NOTES Wed Jul 28 15:36:12 2010(r210564)
@@ -385,6 +385,20 @@ optionsSYSCTL_DEBUG
 optionsNO_SYSCTL_DESCR
 
 #
+# MALLOC_DEBUG_MAXZONES enables multiple uma zones for malloc(9)
+# allocations that are smaller than a page.  The purpose is to isolate
+# different malloc types into hash classes, so that any buffer
+# overruns or use-after-free will usually only affect memory from
+# malloc types in that hash class.  This is purely a debugging tool;
+# by varying the hash function and tracking which hash class was
+# corrupted, the intersection of the hash classes from each instance
+# will point to a single malloc type that is being misused.  At this
+# point inspection or memguard(9) can be used to catch the offending
+# code.
+#
+optionsMALLOC_DEBUG_MAXZONES=8
+
+#
 # DEBUG_MEMGUARD builds and enables memguard(9), a replacement allocator
 # for the kernel used to detect modify-after-free scenarios.  See the
 # memguard(9) man page for more information on usage.

Modified: head/sys/conf/options
==
--- head/sys/conf/options   Wed Jul 28 15:29:18 2010(r210563)
+++ head/sys/conf/options   Wed Jul 28 15:36:12 2010(r210564)
@@ -586,6 +586,7 @@ VM_LEVEL_0_ORDERopt_vm.h
 NO_SWAPPINGopt_vm.h
 MALLOC_MAKE_FAILURES   opt_vm.h
 MALLOC_PROFILE opt_vm.h
+MALLOC_DEBUG_MAXZONES  opt_vm.h
 
 # The MemGuard replacement allocator used for tamper-after-free detection
 DEBUG_MEMGUARD opt_vm.h

Modified: head/sys/i386/conf/GENERIC
==
--- head/sys/i386/conf/GENERIC  Wed Jul 28 15:29:18 2010(r210563)
+++ head/sys/i386/conf/GENERIC  Wed Jul 28 15:36:12 2010(r210564)
@@ -76,6 +76,7 @@ options   INVARIANTS  # Enable calls of e
 optionsINVARIANT_SUPPORT   # Extra sanity checks of internal 
structures, required by INVARIANTS
 optionsWITNESS # Enable checks to detect deadlocks and 
cycles
 optionsWITNESS_SKIPSPIN# Don't run witness on spinlocks for 
speed
+optionsMALLOC_DEBUG_MAXZONES=8 # Separate malloc(9) zones
 
 # To make an SMP kernel, the next two lines are needed
 optionsSMP # Symmetric MultiProcessor Kernel

Modified: head/sys/ia64/conf/GENERIC
==
--- head/sys/ia64/conf/GENERIC  Wed Jul 28 15:29:18 2010(r210563)
+++ head/sys/ia64/conf/GENERIC  Wed Jul 28 

svn commit: r210565 - head/sys/sys

2010-07-28 Thread Matthew D Fleming
Author: mdf
Date: Wed Jul 28 15:47:32 2010
New Revision: 210565
URL: http://svn.freebsd.org/changeset/base/210565

Log:
  Bump __FreeBSD_version for multizone malloc(9).
  
  Approved by:zml (mentor)

Modified:
  head/sys/sys/param.h

Modified: head/sys/sys/param.h
==
--- head/sys/sys/param.hWed Jul 28 15:36:12 2010(r210564)
+++ head/sys/sys/param.hWed Jul 28 15:47:32 2010(r210565)
@@ -58,7 +58,7 @@
  * in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 900015   /* Master, propagated to newvers */
+#define __FreeBSD_version 900016   /* Master, propagated to newvers */
 
 #ifndef LOCORE
 #include sys/types.h
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r210569 - head/sys/dev/e1000

2010-07-28 Thread Matthew D Fleming
Author: mdf
Date: Wed Jul 28 16:24:06 2010
New Revision: 210569
URL: http://svn.freebsd.org/changeset/base/210569

Log:
  Fix clang warning on empty statement.
  
  Reviewed by:rdivacky, zml
  Approved by:zml (mentor)

Modified:
  head/sys/dev/e1000/e1000_osdep.h

Modified: head/sys/dev/e1000/e1000_osdep.h
==
--- head/sys/dev/e1000/e1000_osdep.hWed Jul 28 16:11:22 2010
(r210568)
+++ head/sys/dev/e1000/e1000_osdep.hWed Jul 28 16:24:06 2010
(r210569)
@@ -65,11 +65,11 @@
 
 #define MSGOUT(S, A, B) printf(S \n, A, B)
 #define DEBUGFUNC(F)DEBUGOUT(F);
-   #define DEBUGOUT(S)
-   #define DEBUGOUT1(S,A)
-   #define DEBUGOUT2(S,A,B)
-   #define DEBUGOUT3(S,A,B,C)
-   #define DEBUGOUT7(S,A,B,C,D,E,F,G)
+#define DEBUGOUT(S)do {} while (0)
+#define DEBUGOUT1(S,A) do {} while (0)
+#define DEBUGOUT2(S,A,B)   do {} while (0)
+#define DEBUGOUT3(S,A,B,C) do {} while (0)
+#define DEBUGOUT7(S,A,B,C,D,E,F,G) do {} while (0)
 
 #define STATIC static
 #define FALSE  0
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


  1   2   >