CVS commit: src/sys/kern

2017-03-30 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Mar 31 05:44:05 UTC 2017

Modified Files:
src/sys/kern: uipc_mbuf.c

Log Message:
 Remove extra 0x in m_print().


To generate a diff of this commit:
cvs rdiff -u -r1.171 -r1.172 src/sys/kern/uipc_mbuf.c

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

Modified files:

Index: src/sys/kern/uipc_mbuf.c
diff -u src/sys/kern/uipc_mbuf.c:1.171 src/sys/kern/uipc_mbuf.c:1.172
--- src/sys/kern/uipc_mbuf.c:1.171	Tue Mar 14 09:03:08 2017
+++ src/sys/kern/uipc_mbuf.c	Fri Mar 31 05:44:05 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_mbuf.c,v 1.171 2017/03/14 09:03:08 ozaki-r Exp $	*/
+/*	$NetBSD: uipc_mbuf.c,v 1.172 2017/03/31 05:44:05 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2001 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.171 2017/03/14 09:03:08 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.172 2017/03/31 05:44:05 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mbuftrace.h"
@@ -1759,7 +1759,7 @@ nextchain:
 	(int)M_READONLY(m));
 	if ((m->m_flags & M_PKTHDR) != 0) {
 		snprintb(buf, sizeof(buf), M_CSUM_BITS, m->m_pkthdr.csum_flags);
-		(*pr)("  pktlen=%d, rcvif=%p, csum_flags=0x%s, csum_data=0x%"
+		(*pr)("  pktlen=%d, rcvif=%p, csum_flags=%s, csum_data=0x%"
 		PRIx32 ", segsz=%u\n",
 		m->m_pkthdr.len, m_get_rcvif_NOMPSAFE(m),
 		buf, m->m_pkthdr.csum_data, m->m_pkthdr.segsz);



CVS commit: src/sys

2017-03-30 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Thu Mar 30 23:13:54 UTC 2017

Modified Files:
src/sys/netinet: in_l2tp.c
src/sys/netinet6: in6_l2tp.c

Log Message:
remove duplicated validation. That is already done in l2tp_lookup_session_ref().

pointed out by s-yamaguchi@IIJ, thanks.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/netinet/in_l2tp.c
cvs rdiff -u -r1.1 -r1.2 src/sys/netinet6/in6_l2tp.c

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

Modified files:

Index: src/sys/netinet/in_l2tp.c
diff -u src/sys/netinet/in_l2tp.c:1.1 src/sys/netinet/in_l2tp.c:1.2
--- src/sys/netinet/in_l2tp.c:1.1	Thu Feb 16 08:23:35 2017
+++ src/sys/netinet/in_l2tp.c	Thu Mar 30 23:13:54 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: in_l2tp.c,v 1.1 2017/02/16 08:23:35 knakahara Exp $	*/
+/*	$NetBSD: in_l2tp.c,v 1.2 2017/03/30 23:13:54 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: in_l2tp.c,v 1.1 2017/02/16 08:23:35 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in_l2tp.c,v 1.2 2017/03/30 23:13:54 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_l2tp.h"
@@ -315,11 +315,6 @@ in_l2tp_input(struct mbuf *m, int off, i
 		goto out;
 	}
 
-	if (sess_id != var->lv_my_sess_id) {
-		m_freem(m);
-		goto out;
-	}
-
 	m_adj(m, off + sizeof(uint32_t));
 
 	if (var->lv_use_cookie == L2TP_COOKIE_ON) {

Index: src/sys/netinet6/in6_l2tp.c
diff -u src/sys/netinet6/in6_l2tp.c:1.1 src/sys/netinet6/in6_l2tp.c:1.2
--- src/sys/netinet6/in6_l2tp.c:1.1	Thu Feb 16 08:23:36 2017
+++ src/sys/netinet6/in6_l2tp.c	Thu Mar 30 23:13:54 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: in6_l2tp.c,v 1.1 2017/02/16 08:23:36 knakahara Exp $	*/
+/*	$NetBSD: in6_l2tp.c,v 1.2 2017/03/30 23:13:54 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: in6_l2tp.c,v 1.1 2017/02/16 08:23:36 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_l2tp.c,v 1.2 2017/03/30 23:13:54 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_l2tp.h"
@@ -309,12 +309,6 @@ in6_l2tp_input(struct mbuf **mp, int *of
 		m_freem(m);
 		goto out;
 	}
-
-	if (sess_id != var->lv_my_sess_id) {
-		m_freem(m);
-		goto out;
-	}
-
 	m_adj(m, off + sizeof(uint32_t));
 
 	if (var->lv_use_cookie == L2TP_COOKIE_ON) {



CVS commit: src/share/misc

2017-03-30 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Thu Mar 30 22:33:18 UTC 2017

Modified Files:
src/share/misc: bsd-family-tree

Log Message:
Sync with r316082 from FreeBSD


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/share/misc/bsd-family-tree

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

Modified files:

Index: src/share/misc/bsd-family-tree
diff -u src/share/misc/bsd-family-tree:1.58 src/share/misc/bsd-family-tree:1.59
--- src/share/misc/bsd-family-tree:1.58	Thu Sep 29 15:10:37 2016
+++ src/share/misc/bsd-family-tree	Thu Mar 30 22:33:18 2017
@@ -176,7 +176,7 @@ FreeBSD 4.0  |  |  |  |  | NetBSD 1.
  ||  | |  \
 FreeBSD 5.0   |  | |   |
  ||  | |   |
-FreeBSD 5.1   |  | | DragonFly 1.0
+FreeBSD 5.1   |  | |DragonFly 1.0
  |  \ |  | |   |
  |   - Mac OS X  | |   |
  |   10.3| |   |
@@ -187,7 +187,7 @@ FreeBSD 5.2   |  |  
  *---FreeBSD 5.3  |  | |   |
  |   ||  | OpenBSD 3.6 |
  |   ||   NetBSD 2.0   |   |
- |   ||  | |  ||DragonFly 1.2.0
+ |   ||  | |  ||   DragonFly 1.2.0
  |   | Mac OS X  | | NetBSD 2.0.2  |   |
  |   |   10.4| |  ||   |
  |   FreeBSD 5.4  |  | |  ||   |
@@ -200,50 +200,50 @@ FreeBSD 5.2   |  |  
  | | ||  | NetBSD 2.1  |   |
  | | ||  | |   |
  | | ||   NetBSD 3.0   |   |
- | | ||  | |  ||DragonFly 1.4.0
+ | | ||  | |  ||   DragonFly 1.4.0
  | | ||  | |  |OpenBSD 3.9 |
  |  FreeBSD  ||  | |  ||   |
  |6.1||  | |  ||   |
  | |  FreeBSD 5.5 |  | |  ||   |
- | |  |  | | NetBSD 3.0.1  |DragonFly 1.6.0
+ | |  |  | | NetBSD 3.0.1  |   DragonFly 1.6.0
  | |  |  | |  ||   |
  | |  |  | |  |OpenBSD 4.0 |
  | |  |  | | NetBSD 3.0.2  |   |
  | |  |  | NetBSD 3.1  |   |
  | FreeBSD 6.2|  | |   |
- | |  |  | |DragonFly 1.8.0
+ | |  |  | |   DragonFly 1.8.0
  | |  |  | OpenBSD 4.1 |
- | |  |  | |DragonFly 1.10.0
+ | |  |  | |   DragonFly 1.10.0
  | |   Mac OS X  | |   |
  | | 10.5| |   |
  | |  |  | OpenBSD 4.2 |
  | |  |   NetBSD 4.0   |   |
  | FreeBSD 6.3|  |||   |
  |\   |  |||   |
- *--FreeBSD|  |  |||DragonFly 1.12.0
+ *--FreeBSD|  |  |||   DragonFly 1.12.0
  |7.0  |  |  |||   |
  | |   |  |  ||OpenBSD 4.3 |
- | |   |  |  | NetBSD  |DragonFly 2.0.0
+ | |   |  |  | NetBSD  |   DragonFly 2.0.0
  | |FreeBSD   |  |  4.0.1  OpenBSD 4.4 |
  | |  6.4 |  | |   |
  | |  |  | |   |
  |  FreeBSD 7.1   |  | |   |
- | |  |  | |DragonFly 2.2.0
+ | |  |  | 

CVS commit: src/tests/kernel/arch/x86

2017-03-30 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Thu Mar 30 20:24:35 UTC 2017

Modified Files:
src/tests/kernel/arch/x86: t_ptrace_wait.c

Log Message:
Remove deuplicated code in dbregs_dr[01234]_dont_inherit_lwp

Currently remove tests for dbregs_dr[67]_dont_inherit_lwp.

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/kernel/arch/x86/t_ptrace_wait.c

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

Modified files:

Index: src/tests/kernel/arch/x86/t_ptrace_wait.c
diff -u src/tests/kernel/arch/x86/t_ptrace_wait.c:1.5 src/tests/kernel/arch/x86/t_ptrace_wait.c:1.6
--- src/tests/kernel/arch/x86/t_ptrace_wait.c:1.5	Thu Mar 30 02:17:38 2017
+++ src/tests/kernel/arch/x86/t_ptrace_wait.c	Thu Mar 30 20:24:35 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.5 2017/03/30 02:17:38 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.6 2017/03/30 20:24:35 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.5 2017/03/30 02:17:38 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.6 2017/03/30 20:24:35 kamil Exp $");
 
 #include 
 #include 
@@ -1622,17 +1622,8 @@ lwp_main_func(void *arg)
 	_lwp_exit();
 }
 
-#if defined(HAVE_DBREGS)
-ATF_TC(dbregs_dr0_dont_inherit_lwp);
-ATF_TC_HEAD(dbregs_dr0_dont_inherit_lwp, tc)
-{
-	atf_tc_set_md_var(tc, "descr",
-	"Verify that 1 LWP creation is intercepted by ptrace(2) with "
-	"EVENT_MASK set to PTRACE_LWP_CREATE and Debug Register 0 from "
-	"the forker thread is not inherited");
-}
-
-ATF_TC_BODY(dbregs_dr0_dont_inherit_lwp, tc)
+static void
+dbregs_dont_inherit_lwp(int reg)
 {
 	const int exitval = 5;
 	const int sigval = SIGSTOP;
@@ -1698,9 +1689,9 @@ ATF_TC_BODY(dbregs_dr0_dont_inherit_lwp,
 	for (i = 0; i < __arraycount(r1.dr); i++)
 		printf("r1[%zu]=%" PRIxREGISTER "\n", i, r1.dr[i]);
 
-	r1.dr[0] = (long)(intptr_t)check_happy;
-	printf("Set DR0 (r1.dr[0]) to new value %" PRIxREGISTER "\n",
-	r1.dr[0]);
+	r1.dr[reg] = (long)(intptr_t)check_happy;
+	printf("Set DR%d (r1.dr[%d]) to new value %" PRIxREGISTER "\n",
+	reg, reg, r1.dr[0]);
 
 	printf("New state of the debug registers (r1):\n");
 	for (i = 0; i < __arraycount(r1.dr); i++)
@@ -1750,9 +1741,21 @@ ATF_TC_BODY(dbregs_dr0_dont_inherit_lwp,
 	TWAIT_FNAME);
 	TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, , 0));
 }
-#endif
 
-#if defined(HAVE_DBREGS)
+ATF_TC(dbregs_dr0_dont_inherit_lwp);
+ATF_TC_HEAD(dbregs_dr0_dont_inherit_lwp, tc)
+{
+	atf_tc_set_md_var(tc, "descr",
+	"Verify that 1 LWP creation is intercepted by ptrace(2) with "
+	"EVENT_MASK set to PTRACE_LWP_CREATE and Debug Register 0 from "
+	"the forker thread is not inherited");
+}
+
+ATF_TC_BODY(dbregs_dr0_dont_inherit_lwp, tc)
+{
+	dbregs_dont_inherit_lwp(0);
+}
+
 ATF_TC(dbregs_dr1_dont_inherit_lwp);
 ATF_TC_HEAD(dbregs_dr1_dont_inherit_lwp, tc)
 {
@@ -1764,125 +1767,9 @@ ATF_TC_HEAD(dbregs_dr1_dont_inherit_lwp,
 
 ATF_TC_BODY(dbregs_dr1_dont_inherit_lwp, tc)
 {
-	const int exitval = 5;
-	const int sigval = SIGSTOP;
-	pid_t child, wpid;
-#if defined(TWAIT_HAVE_STATUS)
-	int status;
-#endif
-	ptrace_state_t state;
-	const int slen = sizeof(state);
-	ptrace_event_t event;
-	const int elen = sizeof(event);
-	ucontext_t uc;
-	lwpid_t lid;
-	static const size_t ssize = 16*1024;
-	void *stack;
-	size_t i;
-	struct dbreg r1;
-	struct dbreg r2;
-
-	printf("Before forking process PID=%d\n", getpid());
-	ATF_REQUIRE((child = fork()) != -1);
-	if (child == 0) {
-		printf("Before calling PT_TRACE_ME from child %d\n", getpid());
-		FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
-
-		printf("Before raising %s from child\n", strsignal(sigval));
-		FORKEE_ASSERT(raise(sigval) == 0);
-
-		printf("Before allocating memory for stack in child\n");
-		FORKEE_ASSERT((stack = malloc(ssize)) != NULL);
-
-		printf("Before making context for new lwp in child\n");
-		_lwp_makecontext(, lwp_main_func, NULL, NULL, stack, ssize);
-
-		printf("Before creating new in child\n");
-		FORKEE_ASSERT(_lwp_create(, 0, ) == 0);
-
-		printf("Before waiting for lwp %d to exit\n", lid);
-		FORKEE_ASSERT(_lwp_wait(lid, NULL) == 0);
-
-		printf("Before verifying that reported %d and running lid %d "
-		"are the same\n", lid, the_lwp_id);
-		FORKEE_ASSERT_EQ(lid, the_lwp_id);
-
-		printf("Before exiting of the child process\n");
-		_exit(exitval);
-	}
-	printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
-
-	printf("Before calling %s() for the child\n", TWAIT_FNAME);
-	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
-
-	validate_status_stopped(status, sigval);
-
-	printf("Set empty EVENT_MASK for the child %d\n", child);
-	event.pe_set_event = PTRACE_LWP_CREATE;
-	ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, , elen) != -1);
-
-	printf("Call GETDBREGS for the child process (r1)\n");
-	

CVS commit: src/sys/miscfs/procfs

2017-03-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Mar 30 20:21:00 UTC 2017

Modified Files:
src/sys/miscfs/procfs: procfs_auxv.c

Log Message:
remove comment.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/miscfs/procfs/procfs_auxv.c

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

Modified files:

Index: src/sys/miscfs/procfs/procfs_auxv.c
diff -u src/sys/miscfs/procfs/procfs_auxv.c:1.1 src/sys/miscfs/procfs/procfs_auxv.c:1.2
--- src/sys/miscfs/procfs/procfs_auxv.c:1.1	Thu Mar 30 16:16:29 2017
+++ src/sys/miscfs/procfs/procfs_auxv.c	Thu Mar 30 16:21:00 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_auxv.c,v 1.1 2017/03/30 20:16:29 christos Exp $	*/
+/*	$NetBSD: procfs_auxv.c,v 1.2 2017/03/30 20:21:00 christos Exp $	*/
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_auxv.c,v 1.1 2017/03/30 20:16:29 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_auxv.c,v 1.2 2017/03/30 20:21:00 christos Exp $");
 
 #include 
 #include 
@@ -52,11 +52,6 @@ procfs_doauxv(struct lwp *curl, struct p
 	if ((error = proc_getauxv(p, , )) != 0)
 		return error;
 
-	/*
-	 * We support reading from an offset, because linux does.
-	 * The map could have changed between the two reads, and
-	 * that could result in junk, but typically it does not.
-	 */
 	if (uio->uio_offset < bufsize)
 		error = uiomove((char *)buffer + uio->uio_offset,
 		bufsize - uio->uio_offset, uio);



CVS commit: src/sys

2017-03-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Mar 30 20:17:11 UTC 2017

Modified Files:
src/sys/kern: core_elf32.c kern_proc.c
src/sys/sys: proc.h

Log Message:
factor out getauxv code.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/kern/core_elf32.c
cvs rdiff -u -r1.205 -r1.206 src/sys/kern/kern_proc.c
cvs rdiff -u -r1.339 -r1.340 src/sys/sys/proc.h

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

Modified files:

Index: src/sys/kern/core_elf32.c
diff -u src/sys/kern/core_elf32.c:1.53 src/sys/kern/core_elf32.c:1.54
--- src/sys/kern/core_elf32.c:1.53	Wed Mar 29 18:48:03 2017
+++ src/sys/kern/core_elf32.c	Thu Mar 30 16:17:11 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: core_elf32.c,v 1.53 2017/03/29 22:48:03 kamil Exp $	*/
+/*	$NetBSD: core_elf32.c,v 1.54 2017/03/30 20:17:11 christos Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: core_elf32.c,v 1.53 2017/03/29 22:48:03 kamil Exp $");
+__KERNEL_RCSID(1, "$NetBSD: core_elf32.c,v 1.54 2017/03/30 20:17:11 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_coredump.h"
@@ -403,30 +403,18 @@ coredump_note_procinfo(struct lwp *l, st
 static int
 coredump_note_auxv(struct lwp *l, struct note_state *ns)
 {
-	struct ps_strings pss;
 	int error;
-	struct proc *p = l->l_proc;
-	void *uauxv, *kauxv;
+	size_t len;
+	void *kauxv;
 
-	if ((error = copyin_psstrings(p, )) != 0)
+	if ((error = proc_getauxv(l->l_proc, , )) != 0)
 		return error;
 
-	if (pss.ps_envstr == NULL)
-		return EIO;
-
-	size_t ptrsz = PROC_PTRSZ(p);
-	uauxv = (void *)((char *)pss.ps_envstr + (pss.ps_nenvstr + 1) * ptrsz);
-	size_t len = p->p_execsw->es_arglen;
-
-	kauxv = kmem_alloc(len, KM_SLEEP);
-	error = copyin_proc(p, uauxv, kauxv, len);
-	if (error == 0) {
-		ELFNAMEEND(coredump_savenote)(ns, ELF_NOTE_NETBSD_CORE_AUXV,
-		ELF_NOTE_NETBSD_CORE_NAME, kauxv, len);
-	}
+	ELFNAMEEND(coredump_savenote)(ns, ELF_NOTE_NETBSD_CORE_AUXV,
+	ELF_NOTE_NETBSD_CORE_NAME, kauxv, len);
 	
 	kmem_free(kauxv, len);
-	return error;
+	return 0;
 }
 
 static int

Index: src/sys/kern/kern_proc.c
diff -u src/sys/kern/kern_proc.c:1.205 src/sys/kern/kern_proc.c:1.206
--- src/sys/kern/kern_proc.c:1.205	Sat Jan 28 11:43:59 2017
+++ src/sys/kern/kern_proc.c	Thu Mar 30 16:17:11 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_proc.c,v 1.205 2017/01/28 16:43:59 christos Exp $	*/
+/*	$NetBSD: kern_proc.c,v 1.206 2017/03/30 20:17:11 christos Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.205 2017/01/28 16:43:59 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.206 2017/03/30 20:17:11 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_kstack.h"
@@ -2470,3 +2470,34 @@ out:
 	return 0;
 #endif
 }
+
+int
+proc_getauxv(struct proc *p, void **buf, size_t *len)
+{
+	struct ps_strings pss;
+	int error;
+	void *uauxv, *kauxv;
+
+	if ((error = copyin_psstrings(p, )) != 0)
+		return error;
+
+	if (pss.ps_envstr == NULL)
+		return EIO;
+
+	size_t ptrsz = PROC_PTRSZ(p);
+	uauxv = (void *)((char *)pss.ps_envstr + (pss.ps_nenvstr + 1) * ptrsz);
+	size_t size = p->p_execsw->es_arglen;
+
+	kauxv = kmem_alloc(size, KM_SLEEP);
+
+	error = copyin_proc(p, uauxv, kauxv, size);
+	if (error) {
+		kmem_free(kauxv, size);
+		return error;
+	}
+
+	*buf = kauxv;
+	*len = size;
+
+	return 0;
+}

Index: src/sys/sys/proc.h
diff -u src/sys/sys/proc.h:1.339 src/sys/sys/proc.h:1.340
--- src/sys/sys/proc.h:1.339	Fri Mar 24 13:40:44 2017
+++ src/sys/sys/proc.h	Thu Mar 30 16:17:11 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: proc.h,v 1.339 2017/03/24 17:40:44 christos Exp $	*/
+/*	$NetBSD: proc.h,v 1.340 2017/03/30 20:17:11 christos Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -543,6 +543,7 @@ int	proc_uidmatch(kauth_cred_t, kauth_cr
 int	proc_vmspace_getref(struct proc *, struct vmspace **);
 void	proc_crmod_leave(kauth_cred_t, kauth_cred_t, bool);
 void	proc_crmod_enter(void);
+int	proc_getauxv(struct proc *, void **, size_t *);
 
 int	proc_specific_key_create(specificdata_key_t *, specificdata_dtor_t);
 void	proc_specific_key_delete(specificdata_key_t);



CVS commit: src/sys/modules/procfs

2017-03-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Mar 30 20:16:42 UTC 2017

Modified Files:
src/sys/modules/procfs: Makefile

Log Message:
Add auxv


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/modules/procfs/Makefile

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

Modified files:

Index: src/sys/modules/procfs/Makefile
diff -u src/sys/modules/procfs/Makefile:1.2 src/sys/modules/procfs/Makefile:1.3
--- src/sys/modules/procfs/Makefile:1.2	Thu Jul  8 16:32:12 2010
+++ src/sys/modules/procfs/Makefile	Thu Mar 30 16:16:42 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.2 2010/07/08 20:32:12 rmind Exp $
+#	$NetBSD: Makefile,v 1.3 2017/03/30 20:16:42 christos Exp $
 
 .include "../Makefile.inc"
 
@@ -13,6 +13,6 @@ KMOD=	procfs
 SRCS=	procfs_ctl.c procfs_note.c procfs_status.c procfs_subr.c \
 	procfs_vfsops.c procfs_vnops.c procfs_cmdline.c procfs_linux.c \
 	procfs_machdep.c procfs_map.c procfs_regs.c procfs_fpregs.c \
-	procfs_mem.c procfs_fd.c
+	procfs_mem.c procfs_fd.c procfs_auxv.c
 
 .include 



CVS commit: src/sys/miscfs/procfs

2017-03-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Mar 30 20:16:29 UTC 2017

Modified Files:
src/sys/miscfs/procfs: files.procfs procfs.h procfs_subr.c
procfs_vfsops.c procfs_vnops.c
Added Files:
src/sys/miscfs/procfs: procfs_auxv.c

Log Message:
add an auxv node.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/miscfs/procfs/files.procfs
cvs rdiff -u -r1.70 -r1.71 src/sys/miscfs/procfs/procfs.h
cvs rdiff -u -r0 -r1.1 src/sys/miscfs/procfs/procfs_auxv.c
cvs rdiff -u -r1.106 -r1.107 src/sys/miscfs/procfs/procfs_subr.c
cvs rdiff -u -r1.96 -r1.97 src/sys/miscfs/procfs/procfs_vfsops.c
cvs rdiff -u -r1.194 -r1.195 src/sys/miscfs/procfs/procfs_vnops.c

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

Modified files:

Index: src/sys/miscfs/procfs/files.procfs
diff -u src/sys/miscfs/procfs/files.procfs:1.10 src/sys/miscfs/procfs/files.procfs:1.11
--- src/sys/miscfs/procfs/files.procfs:1.10	Tue Nov  1 20:12:00 2016
+++ src/sys/miscfs/procfs/files.procfs	Thu Mar 30 16:16:29 2017
@@ -1,8 +1,9 @@
-#	$NetBSD: files.procfs,v 1.10 2016/11/02 00:12:00 pgoyette Exp $
+#	$NetBSD: files.procfs,v 1.11 2017/03/30 20:16:29 christos Exp $
 
 deffs	PROCFS:	PTRACE_HOOKS
 
 define	procfs: vfs
+file	miscfs/procfs/procfs_auxv.c	procfs
 file	miscfs/procfs/procfs_cmdline.c	procfs
 file	miscfs/procfs/procfs_ctl.c	procfs
 file	miscfs/procfs/procfs_fd.c	procfs

Index: src/sys/miscfs/procfs/procfs.h
diff -u src/sys/miscfs/procfs/procfs.h:1.70 src/sys/miscfs/procfs/procfs.h:1.71
--- src/sys/miscfs/procfs/procfs.h:1.70	Sun Jul 27 12:47:26 2014
+++ src/sys/miscfs/procfs/procfs.h	Thu Mar 30 16:16:29 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs.h,v 1.70 2014/07/27 16:47:26 hannken Exp $	*/
+/*	$NetBSD: procfs.h,v 1.71 2017/03/30 20:16:29 christos Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -110,6 +110,7 @@ typedef enum {
 	PFSstatm,	/* process memory info (if -o linux) */
 	PFSversion,	/* kernel version (if -o linux) */
 	PFStask,	/* task subdirector (if -o linux) */
+	PFSauxv,	/* ELF Auxiliary Vector */
 #ifdef __HAVE_PROCFS_MACHDEP
 	PROCFS_MACHDEP_NODE_TYPES
 #endif
@@ -192,6 +193,7 @@ const vfs_namemap_t *vfs_findname(const 
 
 int procfs_proc_lock(int, struct proc **, int);
 void procfs_proc_unlock(struct proc *);
+struct mount;
 int procfs_allocvp(struct mount *, struct vnode **, pid_t, pfstype, int);
 int procfs_donote(struct lwp *, struct proc *, struct pfsnode *,
 struct uio *);
@@ -233,11 +235,14 @@ int procfs_doemul(struct lwp *, struct p
 struct uio *);
 int procfs_doversion(struct lwp *, struct proc *, struct pfsnode *,
 struct uio *);
+int procfs_doauxv(struct lwp *, struct proc *, struct pfsnode *,
+struct uio *);
 
 void procfs_revoke_vnodes(struct proc *, void *);
 int procfs_getfp(struct pfsnode *, struct proc *, struct file **);
 
 /* functions to check whether or not files should be displayed */
+int procfs_validauxv(struct lwp *, struct mount *);
 int procfs_validfile(struct lwp *, struct mount *);
 int procfs_validfpregs(struct lwp *, struct mount *);
 int procfs_validregs(struct lwp *, struct mount *);

Index: src/sys/miscfs/procfs/procfs_subr.c
diff -u src/sys/miscfs/procfs/procfs_subr.c:1.106 src/sys/miscfs/procfs/procfs_subr.c:1.107
--- src/sys/miscfs/procfs/procfs_subr.c:1.106	Mon Nov 10 13:46:34 2014
+++ src/sys/miscfs/procfs/procfs_subr.c	Thu Mar 30 16:16:29 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_subr.c,v 1.106 2014/11/10 18:46:34 maxv Exp $	*/
+/*	$NetBSD: procfs_subr.c,v 1.107 2017/03/30 20:16:29 christos Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -102,7 +102,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.106 2014/11/10 18:46:34 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.107 2017/03/30 20:16:29 christos Exp $");
 
 #include 
 #include 
@@ -272,6 +272,10 @@ procfs_rw(void *v)
 		error = procfs_doversion(curl, p, pfs, uio);
 		break;
 
+	case PFSauxv:
+		error = procfs_doauxv(curl, p, pfs, uio);
+		break;
+
 #ifdef __HAVE_PROCFS_MACHDEP
 	PROCFS_MACHDEP_NODETYPE_CASES
 		error = procfs_machdep_rw(curl, l, pfs, uio);

Index: src/sys/miscfs/procfs/procfs_vfsops.c
diff -u src/sys/miscfs/procfs/procfs_vfsops.c:1.96 src/sys/miscfs/procfs/procfs_vfsops.c:1.97
--- src/sys/miscfs/procfs/procfs_vfsops.c:1.96	Fri Feb 17 03:31:25 2017
+++ src/sys/miscfs/procfs/procfs_vfsops.c	Thu Mar 30 16:16:29 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_vfsops.c,v 1.96 2017/02/17 08:31:25 hannken Exp $	*/
+/*	$NetBSD: procfs_vfsops.c,v 1.97 2017/03/30 20:16:29 christos Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_vfsops.c,v 1.96 2017/02/17 08:31:25 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_vfsops.c,v 1.97 2017/03/30 20:16:29 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -386,20 +386,25 @@ procfs_loadvnode(struct mount 

CVS commit: src/lib/libutil

2017-03-30 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Thu Mar 30 20:00:21 UTC 2017

Modified Files:
src/lib/libutil: util.3

Log Message:
Use Sy to highlight the table header.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/lib/libutil/util.3

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

Modified files:

Index: src/lib/libutil/util.3
diff -u src/lib/libutil/util.3:1.25 src/lib/libutil/util.3:1.26
--- src/lib/libutil/util.3:1.25	Thu Mar 30 19:56:36 2017
+++ src/lib/libutil/util.3	Thu Mar 30 20:00:21 2017
@@ -1,4 +1,4 @@
-.\" $NetBSD: util.3,v 1.25 2017/03/30 19:56:36 abhinav Exp $
+.\" $NetBSD: util.3,v 1.26 2017/03/30 20:00:21 abhinav Exp $
 .\"
 .\" Copyright (c) 2001 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -57,7 +57,7 @@ library and the associated functions are
 directory.
 .Sh LIST OF FUNCTIONS
 .Bl -column ".Xr sockaddr_snprintf 3" -compact
-.It Sy Name	Description
+.It Sy Name Ta Sy Description
 .It Xr disklabel_dkcksum 3 Ta compute the checksum for a disklabel
 .It Xr disklabel_scan 3 Ta scan a buffer for a valid disklabel
 .It Xr efun 3 Ta error checked utility functions



CVS commit: src/lib/libutil

2017-03-30 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Thu Mar 30 19:56:36 UTC 2017

Modified Files:
src/lib/libutil: util.3

Log Message:
Add missing functions


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/lib/libutil/util.3

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

Modified files:

Index: src/lib/libutil/util.3
diff -u src/lib/libutil/util.3:1.24 src/lib/libutil/util.3:1.25
--- src/lib/libutil/util.3:1.24	Mon Aug 29 12:39:50 2011
+++ src/lib/libutil/util.3	Thu Mar 30 19:56:36 2017
@@ -1,4 +1,4 @@
-.\" $NetBSD: util.3,v 1.24 2011/08/29 12:39:50 jruoho Exp $
+.\" $NetBSD: util.3,v 1.25 2017/03/30 19:56:36 abhinav Exp $
 .\"
 .\" Copyright (c) 2001 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd August 29, 2011
+.Dd March 31, 2017
 .Dt UTIL 3
 .Os
 .Sh NAME
@@ -60,12 +60,20 @@ directory.
 .It Sy Name	Description
 .It Xr disklabel_dkcksum 3 Ta compute the checksum for a disklabel
 .It Xr disklabel_scan 3 Ta scan a buffer for a valid disklabel
+.It Xr efun 3 Ta error checked utility functions
 .It Xr forkpty 3 Ta tty utility function
 .It Xr getbootfile 3 Ta get the name of the booted kernel file
+.It Xr getbyteorder 3 Ta get the current byte order
+.It Xr getdiskrawname 3 Ta get the the block/character device name for a disk
+.It Xr getfsspecname 3 Ta get the underlying wedge name from a label
+.It Xr getfstypename 3 Ta convert a partition file system type integer to a wedge
+partition type name
 .It Xr getlabeloffset 3 Ta get the sector number and offset of the disklabel
 .It Xr getlabelsector 3 Ta get the sector number and offset of the disklabel
 .It Xr getmaxpartitions 3 Ta get the maximum number of partitions allowed per disk
+.It Xr getmntopts 3 Ta scan mount options
 .It Xr getrawpartition 3 Ta get the system ``raw'' partition
+.It Xr kinfo_getvmmap 3 Ta get per-process memory map information
 .It Xr login 3 Ta login utility function
 .It Xr login_cap 3 Ta query login.conf database about a user class
 .It Xr login_close 3 Ta query login.conf database about a user class
@@ -85,6 +93,7 @@ directory.
 .It Xr openpty 3 Ta tty utility function
 .It Xr pidfile 3 Ta write a daemon pid file
 .It Xr pidlock 3 Ta locks based on files containing PIDs
+.It Xr proc_compare 3 Ta compare two processes' interactivity
 .It Xr pw_abort 3 Ta passwd file update function
 .It Xr pw_copy 3 Ta utility function for interactive passwd file updates
 .It Xr pw_edit 3 Ta utility function for interactive passwd file updates
@@ -97,6 +106,7 @@ directory.
 .It Xr pw_prompt 3 Ta utility function for interactive passwd file updates
 .It Xr pw_scan 3 Ta utility function for interactive passwd file updates
 .It Xr pw_setprefix 3 Ta passwd file update function
+.It Xr raise_default_signal 3 Ta raise the default signal handler
 .It Xr secure_path 3 Ta determine if a file appears to be ``secure''
 .It Xr setclasscontext 3 Ta query login.conf database about a user class
 .It Xr setusercontext 3 Ta query login.conf database about a user class



CVS commit: src/lib/libutil

2017-03-30 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Thu Mar 30 19:41:41 UTC 2017

Modified Files:
src/lib/libutil: getmntopts.3

Log Message:
Add getmntoptstr, getmntoptnum, and freemntopts to the NAME section
Fix couple of sentences

getmntoptstr, getmntoptnum, and freemntopts need to be linked to the 
getmntopts(3)
man page as well. Will do in a later commit after doing a relase build test.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/lib/libutil/getmntopts.3

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

Modified files:

Index: src/lib/libutil/getmntopts.3
diff -u src/lib/libutil/getmntopts.3:1.12 src/lib/libutil/getmntopts.3:1.13
--- src/lib/libutil/getmntopts.3:1.12	Tue Aug 24 12:05:01 2010
+++ src/lib/libutil/getmntopts.3	Thu Mar 30 19:41:41 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: getmntopts.3,v 1.12 2010/08/24 12:05:01 christos Exp $
+.\"	$NetBSD: getmntopts.3,v 1.13 2017/03/30 19:41:41 abhinav Exp $
 .\"
 .\" Copyright (c) 1994
 .\"	The Regents of the University of California.  All rights reserved.
@@ -33,7 +33,10 @@
 .Dt GETMNTOPTS 3
 .Os
 .Sh NAME
-.Nm getmntopts
+.Nm getmntopts ,
+.Nm getmntoptstr ,
+.Nm getmntoptnum ,
+.Nm freemntopts
 .Nd scan mount options
 .Sh LIBRARY
 .Lb libutil
@@ -181,7 +184,7 @@ returns
 .Pp
 The
 .Fn getmntoptnum
-returns the long value of the named option, if such a value was set in the
+function returns the long value of the named option, if such a value was set in the
 option string.
 If the value was not set, or could not be converted from a string to a
 long, then if the external integer value
@@ -197,7 +200,7 @@ returns \-1.
 .Pp
 The
 .Fn freemntopts
-frees the storage used by
+function frees the storage used by
 .Fn getmntopts .
 .Sh RETURN VALUES
 .Fn getmntopts



CVS commit: src/lib/libutil

2017-03-30 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Thu Mar 30 19:23:06 UTC 2017

Modified Files:
src/lib/libutil: getdiskrawname.3

Log Message:
Add getdiskcookedname to the NAME section
Fix couple of typos.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libutil/getdiskrawname.3

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

Modified files:

Index: src/lib/libutil/getdiskrawname.3
diff -u src/lib/libutil/getdiskrawname.3:1.2 src/lib/libutil/getdiskrawname.3:1.3
--- src/lib/libutil/getdiskrawname.3:1.2	Sun Apr  8 16:06:23 2012
+++ src/lib/libutil/getdiskrawname.3	Thu Mar 30 19:23:06 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: getdiskrawname.3,v 1.2 2012/04/08 16:06:23 wiz Exp $
+.\"	$NetBSD: getdiskrawname.3,v 1.3 2017/03/30 19:23:06 abhinav Exp $
 .\"
 .\" Copyright (c) 2012 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -32,7 +32,8 @@
 .Dt GETDISKRAWNAME 3
 .Os
 .Sh NAME
-.Nm getdiskrawname
+.Nm getdiskrawname ,
+.Nm getdiskcookedname
 .Nd get the the block/character device name for a disk
 .Sh LIBRARY
 .Lb libutil
@@ -47,13 +48,13 @@ The
 .Fn getdiskrawname
 function converts the
 .Fa name
-argument thar contains a path to a disk block device node to the
+argument that contains a path to a disk block device node to the
 path that contains the corresponding character device node.
 The
 .Fn getdiskcookedname
 function converts the
 .Fa name
-argument thar contains a path to a disk character device node to the
+argument that contains a path to a disk character device node to the
 path that contains the corresponding block device node.
 .Sh RETURN VALUES
 On success the absolute pathname of the underlying device node is returned.



CVS commit: src/lib/libc/sys

2017-03-30 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Thu Mar 30 18:54:26 UTC 2017

Modified Files:
src/lib/libc/sys: unlink.2

Log Message:
Remov comma from the last Nm entry
Use Xr instead of Fn to refer rmdir(2)
Fix couple of sentences


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/lib/libc/sys/unlink.2

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

Modified files:

Index: src/lib/libc/sys/unlink.2
diff -u src/lib/libc/sys/unlink.2:1.28 src/lib/libc/sys/unlink.2:1.29
--- src/lib/libc/sys/unlink.2:1.28	Sun Jul 28 13:53:04 2013
+++ src/lib/libc/sys/unlink.2	Thu Mar 30 18:54:26 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: unlink.2,v 1.28 2013/07/28 13:53:04 njoly Exp $
+.\"	$NetBSD: unlink.2,v 1.29 2017/03/30 18:54:26 abhinav Exp $
 .\"
 .\" Copyright (c) 1980, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -34,7 +34,7 @@
 .Os
 .Sh NAME
 .Nm unlink ,
-.Nm unlinkat ,
+.Nm unlinkat
 .Nd remove directory entry
 .Sh LIBRARY
 .Lb libc
@@ -89,7 +89,7 @@ in order to specify the current director
 .Pp
 .Fn unlinkat
 will remove directories just like
-.Fn rmdir
+.Xr rmdir 2 ,
 provided
 .Dv AT_REMOVEDIR
 is set in
@@ -101,7 +101,7 @@ The
 .Fn unlink
 and
 .Fn unlinkat
-succeeds unless:
+functions succeed unless:
 .Bl -tag -width Er
 .It Bq Er EACCES
 Search permission is denied for a component of the path prefix, or



CVS commit: src/share/dict

2017-03-30 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Thu Mar 30 18:38:19 UTC 2017

Modified Files:
src/share/dict: web2

Log Message:
Add `preexist'


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/share/dict/web2

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

Modified files:

Index: src/share/dict/web2
diff -u src/share/dict/web2:1.25 src/share/dict/web2:1.26
--- src/share/dict/web2:1.25	Fri Mar 24 10:22:23 2017
+++ src/share/dict/web2	Thu Mar 30 18:38:19 2017
@@ -153053,6 +153053,7 @@ predynamite
 predynastic
 preen
 preener
+preexist
 preeze
 prefab
 prefabricate



CVS commit: src/sys/arch/hpcarm/conf

2017-03-30 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Thu Mar 30 17:40:09 UTC 2017

Modified Files:
src/sys/arch/hpcarm/conf: JORNADA720

Log Message:
Set the relevant options to build a kernel with the necessary components to
support DTrace on the Jornada 710/720 devices.
- Modular
- Built with DTrace hooks and full symbol table


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/sys/arch/hpcarm/conf/JORNADA720

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

Modified files:

Index: src/sys/arch/hpcarm/conf/JORNADA720
diff -u src/sys/arch/hpcarm/conf/JORNADA720:1.98 src/sys/arch/hpcarm/conf/JORNADA720:1.99
--- src/sys/arch/hpcarm/conf/JORNADA720:1.98	Wed Mar 22 22:37:41 2017
+++ src/sys/arch/hpcarm/conf/JORNADA720	Thu Mar 30 17:40:09 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: JORNADA720,v 1.98 2017/03/22 22:37:41 sevan Exp $
+#	$NetBSD: JORNADA720,v 1.99 2017/03/30 17:40:09 sevan Exp $
 #
 #	JORNADA -- Windows-CE based jornada 720
 #
@@ -7,7 +7,7 @@ include	"arch/hpcarm/conf/std.sa11x0"
 
 #options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.98 $"
+#ident 		"GENERIC-$Revision: 1.99 $"
 
 # estimated number of users
 maxusers	32
@@ -115,9 +115,11 @@ options 	NFS_BOOT_DHCP
 #options 	DIAGNOSTIC	# internal consistency checks
 #options 	DEBUG		# expensive debugging checks/support
 #options 	PMAP_DEBUG	# Enable pmap_debug_level code
+options 	KDTRACE_HOOKS	# kernel DTrace hooks
+options 	MODULAR		# DTrace is a module (load via modules.conf)
 options 	DDB		# in-kernel debugger
 #options 	DDB_HISTORY_SIZE=100	# Enable history editing in DDB
-#makeoptions	DEBUG="-g"	# compile full symbol table
+makeoptions	DEBUG="-g"	# compile full symbol table
 
 config		netbsd	root on ? type ?
 #options 	COMCONSOLE=0,CONADDR=0x3f8,CONUNIT=0



CVS commit: src/sys/arch/evbarm/conf

2017-03-30 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Thu Mar 30 17:17:41 UTC 2017

Modified Files:
src/sys/arch/evbarm/conf: BEAGLEBONE

Log Message:
While KDTRACE_HOOKS is enabled by default in GENERIC.common, the BEAGLEBONE
config does not make use of this config file yet.
Revert previous change (r1.39).


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/evbarm/conf/BEAGLEBONE

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

Modified files:

Index: src/sys/arch/evbarm/conf/BEAGLEBONE
diff -u src/sys/arch/evbarm/conf/BEAGLEBONE:1.39 src/sys/arch/evbarm/conf/BEAGLEBONE:1.40
--- src/sys/arch/evbarm/conf/BEAGLEBONE:1.39	Wed Mar 22 22:53:06 2017
+++ src/sys/arch/evbarm/conf/BEAGLEBONE	Thu Mar 30 17:17:41 2017
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: BEAGLEBONE,v 1.39 2017/03/22 22:53:06 sevan Exp $
+#	$NetBSD: BEAGLEBONE,v 1.40 2017/03/30 17:17:41 sevan Exp $
 #
 #	BEAGLEBONE -- TI AM335x board Kernel
 #
@@ -134,6 +134,7 @@ options 	KTRACE		# system call tracing, 
 #options 	PERFCTRS	# performance counters
 options 	DIAGNOSTIC	# internal consistency checks
 options 	DEBUG
+options 	KDTRACE_HOOKS	# kernel DTrace hooks
 options 	MODULAR 	# DTrace is a module (load via modules.conf)
 #options 	PMAP_DEBUG	# Enable pmap_debug_level code
 #options 	IPKDB		# remote kernel debugging



CVS commit: src/sys/dev

2017-03-30 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Thu Mar 30 16:50:33 UTC 2017

Modified Files:
src/sys/dev: ccd.c

Log Message:
support DIOCGCACHE - result is intersection of flags returned by underlying
devices; devices can't be added or removed, so the feature flags remain
static

add support for DIOCGSTRATEGY while here, mainly to make dkctl(8) output neater


To generate a diff of this commit:
cvs rdiff -u -r1.169 -r1.170 src/sys/dev/ccd.c

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

Modified files:

Index: src/sys/dev/ccd.c
diff -u src/sys/dev/ccd.c:1.169 src/sys/dev/ccd.c:1.170
--- src/sys/dev/ccd.c:1.169	Sun Mar  5 23:07:12 2017
+++ src/sys/dev/ccd.c	Thu Mar 30 16:50:32 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ccd.c,v 1.169 2017/03/05 23:07:12 mlelstv Exp $	*/
+/*	$NetBSD: ccd.c,v 1.170 2017/03/30 16:50:32 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 1999, 2007, 2009 The NetBSD Foundation, Inc.
@@ -88,7 +88,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.169 2017/03/05 23:07:12 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.170 2017/03/30 16:50:32 jdolecek Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -1182,6 +1182,8 @@ ccdioctl(dev_t dev, u_long cmd, void *da
 	switch (cmd) {
 	case CCDIOCCLR:
 	case DIOCGDINFO:
+	case DIOCGSTRATEGY:
+	case DIOCGCACHE:
 	case DIOCCACHESYNC:
 	case DIOCAWEDGE:
 	case DIOCDWEDGE:
@@ -1393,6 +1395,50 @@ ccdioctl(dev_t dev, u_long cmd, void *da
 		/* Don't break, otherwise cs is read again. */
 		return 0;
 
+	case DIOCGSTRATEGY:
+	{
+		struct disk_strategy *dks = (void *)data;
+
+		mutex_enter(cs->sc_iolock);
+		if (cs->sc_bufq != NULL)
+			strlcpy(dks->dks_name,
+			bufq_getstrategyname(cs->sc_bufq),
+			sizeof(dks->dks_name));
+		else
+			error = EINVAL;
+		mutex_exit(cs->sc_iolock);
+		dks->dks_paramlen = 0;
+		break;
+	}
+
+	case DIOCGCACHE:
+	{
+		int dkcache = 0;
+
+		/*
+		 * We pass this call down to all components and report
+		 * intersection of the flags returned by the components.
+		 * If any errors out, we return error. CCD components
+		 * can not change unless the device is unconfigured, so
+		 * device feature flags will remain static. RCE/WCE can change
+		 * of course, if set directly on underlying device.
+		 */
+		for (error = 0, i = 0; i < cs->sc_nccdisks; i++) {
+			error = VOP_IOCTL(cs->sc_cinfo[i].ci_vp, cmd, ,
+  flag, uc);
+			if (error)
+break;
+
+			if (i == 0)
+dkcache = j;
+			else
+dkcache &= j;
+		}
+
+		*((int *)data) = dkcache;
+		break;
+	}
+
 	case DIOCCACHESYNC:
 		/*
 		 * We pass this call down to all components and report



CVS commit: src/sys

2017-03-30 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Mar 30 09:16:53 UTC 2017

Modified Files:
src/sys/kern: vfs_vnode.c
src/sys/miscfs/genfs: genfs_vnops.c layer_extern.h layer_vfsops.c
layer_vnops.c
src/sys/miscfs/nullfs: null_vnops.c
src/sys/miscfs/overlay: overlay_vnops.c
src/sys/miscfs/umapfs: umap_vnops.c
src/sys/sys: param.h vnode.h vnode_impl.h

Log Message:
Locking a layer vnode is racy as it may become reclaimed before
calling the operation on the lower vnode.

Replace vi_lock with a rw_obj and change layered file systems
to share the lock with the lower vnode.

Layered file systems now use genfs_lock()/_unlock/_islocked().

Welcome to 7.99.67


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sys/kern/vfs_vnode.c
cvs rdiff -u -r1.193 -r1.194 src/sys/miscfs/genfs/genfs_vnops.c
cvs rdiff -u -r1.38 -r1.39 src/sys/miscfs/genfs/layer_extern.h
cvs rdiff -u -r1.47 -r1.48 src/sys/miscfs/genfs/layer_vfsops.c
cvs rdiff -u -r1.60 -r1.61 src/sys/miscfs/genfs/layer_vnops.c
cvs rdiff -u -r1.40 -r1.41 src/sys/miscfs/nullfs/null_vnops.c
cvs rdiff -u -r1.22 -r1.23 src/sys/miscfs/overlay/overlay_vnops.c
cvs rdiff -u -r1.58 -r1.59 src/sys/miscfs/umapfs/umap_vnops.c
cvs rdiff -u -r1.533 -r1.534 src/sys/sys/param.h
cvs rdiff -u -r1.274 -r1.275 src/sys/sys/vnode.h
cvs rdiff -u -r1.12 -r1.13 src/sys/sys/vnode_impl.h

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

Modified files:

Index: src/sys/kern/vfs_vnode.c
diff -u src/sys/kern/vfs_vnode.c:1.80 src/sys/kern/vfs_vnode.c:1.81
--- src/sys/kern/vfs_vnode.c:1.80	Thu Mar 30 09:15:51 2017
+++ src/sys/kern/vfs_vnode.c	Thu Mar 30 09:16:52 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_vnode.c,v 1.80 2017/03/30 09:15:51 hannken Exp $	*/
+/*	$NetBSD: vfs_vnode.c,v 1.81 2017/03/30 09:16:52 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -156,7 +156,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.80 2017/03/30 09:15:51 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.81 2017/03/30 09:16:52 hannken Exp $");
 
 #include 
 #include 
@@ -416,6 +416,21 @@ vnis_marker(vnode_t *vp)
 }
 
 /*
+ * Set vnode to share another vnodes lock.
+ */
+void
+vshare_lock(vnode_t *vp, vnode_t *src_vp)
+{
+	vnode_impl_t *vip = VNODE_TO_VIMPL(vp);
+	vnode_impl_t *src_vip = VNODE_TO_VIMPL(src_vp);
+	krwlock_t *oldlock = vip->vi_lock;
+
+	rw_obj_hold(src_vip->vi_lock);
+	vip->vi_lock = src_vip->vi_lock;
+	rw_obj_free(oldlock);
+}
+
+/*
  * Return the lru list this node should be on.
  */
 static vnodelst_t *
@@ -1066,7 +1081,7 @@ vcache_alloc(void)
 	vip = pool_cache_get(vcache_pool, PR_WAITOK);
 	memset(vip, 0, sizeof(*vip));
 
-	rw_init(>vi_lock);
+	vip->vi_lock = rw_obj_alloc();
 	/* SLIST_INIT(>vi_hash); */
 	/* LIST_INIT(>vi_nclist); */
 	/* LIST_INIT(>vi_dnclist); */
@@ -1128,7 +1143,7 @@ vcache_free(vnode_impl_t *vip)
 	if (vp->v_type == VBLK || vp->v_type == VCHR)
 		spec_node_destroy(vp);
 
-	rw_destroy(>vi_lock);
+	rw_obj_free(vip->vi_lock);
 	uvm_obj_destroy(>v_uobj, true);
 	cv_destroy(>v_cv);
 	pool_cache_put(vcache_pool, vip);

Index: src/sys/miscfs/genfs/genfs_vnops.c
diff -u src/sys/miscfs/genfs/genfs_vnops.c:1.193 src/sys/miscfs/genfs/genfs_vnops.c:1.194
--- src/sys/miscfs/genfs/genfs_vnops.c:1.193	Wed Jan 11 09:08:59 2017
+++ src/sys/miscfs/genfs/genfs_vnops.c	Thu Mar 30 09:16:52 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_vnops.c,v 1.193 2017/01/11 09:08:59 hannken Exp $	*/
+/*	$NetBSD: genfs_vnops.c,v 1.194 2017/03/30 09:16:52 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.193 2017/01/11 09:08:59 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.194 2017/03/30 09:16:52 hannken Exp $");
 
 #include 
 #include 
@@ -295,7 +295,7 @@ genfs_deadlock(void *v)
 
 	op = (ISSET(flags, LK_EXCLUSIVE) ? RW_WRITER : RW_READER);
 	if (ISSET(flags, LK_NOWAIT)) {
-		if (! rw_tryenter(>vi_lock, op))
+		if (! rw_tryenter(vip->vi_lock, op))
 			return EBUSY;
 		if (mutex_tryenter(vp->v_interlock)) {
 			error = vdead_check(vp, VDEAD_NOWAIT);
@@ -305,25 +305,25 @@ genfs_deadlock(void *v)
 		} else
 			error = EBUSY;
 		if (error)
-			rw_exit(>vi_lock);
+			rw_exit(vip->vi_lock);
 		return error;
 	}
 
-	rw_enter(>vi_lock, op);
+	rw_enter(vip->vi_lock, op);
 	mutex_enter(vp->v_interlock);
 	error = vdead_check(vp, VDEAD_NOWAIT);
 	if (error == EBUSY) {
-		rw_exit(>vi_lock);
+		rw_exit(vip->vi_lock);
 		error = vdead_check(vp, 0);
 		KASSERT(error == ENOENT);
 		mutex_exit(vp->v_interlock);
-		rw_enter(>vi_lock, op);
+		rw_enter(vip->vi_lock, op);
 		mutex_enter(vp->v_interlock);
 	}
 	KASSERT(error == ENOENT);
 	mutex_exit(vp->v_interlock);
 	if (! ISSET(flags, LK_RETRY)) {
-		rw_exit(>vi_lock);
+		rw_exit(vip->vi_lock);
 		return ENOENT;
 	}
 	return 0;
@@ -341,7 +341,7 @@ 

CVS commit: src/sys/kern

2017-03-30 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Mar 30 09:15:51 UTC 2017

Modified Files:
src/sys/kern: vfs_vnode.c

Log Message:
Change the operations vector before changing the mount.

Vnode operations enter the mount before using the vector.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/kern/vfs_vnode.c

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

Modified files:

Index: src/sys/kern/vfs_vnode.c
diff -u src/sys/kern/vfs_vnode.c:1.79 src/sys/kern/vfs_vnode.c:1.80
--- src/sys/kern/vfs_vnode.c:1.79	Thu Mar 30 09:14:59 2017
+++ src/sys/kern/vfs_vnode.c	Thu Mar 30 09:15:51 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_vnode.c,v 1.79 2017/03/30 09:14:59 hannken Exp $	*/
+/*	$NetBSD: vfs_vnode.c,v 1.80 2017/03/30 09:15:51 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -156,7 +156,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.79 2017/03/30 09:14:59 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.80 2017/03/30 09:15:51 hannken Exp $");
 
 #include 
 #include 
@@ -1556,11 +1556,6 @@ vcache_reclaim(vnode_t *vp)
 	/* Purge name cache. */
 	cache_purge(vp);
 
-	/* Move to dead mount. */
-	vp->v_vflag &= ~VV_ROOT;
-	atomic_inc_uint(_rootmount->mnt_refcnt);
-	vfs_insmntque(vp, dead_rootmount);
-
 	/* Remove from vnode cache. */
 	hash = vcache_hash(>vi_key);
 	mutex_enter(_lock);
@@ -1578,9 +1573,19 @@ vcache_reclaim(vnode_t *vp)
 	VSTATE_CHANGE(vp, VS_RECLAIMING, VS_RECLAIMED);
 	vp->v_tag = VT_NON;
 	KNOTE(>v_klist, NOTE_REVOKE);
+	mutex_exit(vp->v_interlock);
 
-	fstrans_done(mp);
+	/*
+	 * Move to dead mount.  Must be after changing the operations
+	 * vector as vnode operations enter the mount before using the
+	 * operations vector.  See sys/kern/vnode_if.c.
+	 */
+	vp->v_vflag &= ~VV_ROOT;
+	atomic_inc_uint(_rootmount->mnt_refcnt);
+	vfs_insmntque(vp, dead_rootmount);
 
+	mutex_enter(vp->v_interlock);
+	fstrans_done(mp);
 	KASSERT((vp->v_iflag & VI_ONWORKLST) == 0);
 }
 



CVS commit: src/sys/kern

2017-03-30 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Mar 30 09:14:59 UTC 2017

Modified Files:
src/sys/kern: vfs_vnode.c

Log Message:
Change vrelel() to defer the test for a reclaimed vnode until
we hold both the interlock and the vnode lock.

Add a common operation to deallocate a vnode in state LOADING.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sys/kern/vfs_vnode.c

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

Modified files:

Index: src/sys/kern/vfs_vnode.c
diff -u src/sys/kern/vfs_vnode.c:1.78 src/sys/kern/vfs_vnode.c:1.79
--- src/sys/kern/vfs_vnode.c:1.78	Thu Mar 30 09:14:08 2017
+++ src/sys/kern/vfs_vnode.c	Thu Mar 30 09:14:59 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_vnode.c,v 1.78 2017/03/30 09:14:08 hannken Exp $	*/
+/*	$NetBSD: vfs_vnode.c,v 1.79 2017/03/30 09:14:59 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -156,7 +156,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.78 2017/03/30 09:14:08 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.79 2017/03/30 09:14:59 hannken Exp $");
 
 #include 
 #include 
@@ -212,6 +212,7 @@ static pool_cache_t	vcache_pool;
 static void		lru_requeue(vnode_t *, vnodelst_t *);
 static vnodelst_t *	lru_which(vnode_t *);
 static vnode_impl_t *	vcache_alloc(void);
+static void		vcache_dealloc(vnode_impl_t *);
 static void		vcache_free(vnode_impl_t *);
 static void		vcache_init(void);
 static void		vcache_reinit(void);
@@ -662,6 +663,8 @@ vtryrele(vnode_t *vp)
 static void
 vrelel(vnode_t *vp, int flags)
 {
+	const bool async = ((flags & VRELEL_ASYNC_RELE) != 0);
+	const bool force = ((flags & VRELEL_FORCE_RELE) != 0);
 	bool recycle, defer;
 	int error;
 
@@ -692,62 +695,48 @@ vrelel(vnode_t *vp, int flags)
 #endif
 
 	/*
-	 * If not clean, deactivate the vnode, but preserve
-	 * our reference across the call to VOP_INACTIVE().
+	 * First try to get the vnode locked for VOP_INACTIVE().
+	 * Defer vnode release to vdrain_thread if caller requests
+	 * it explicitly, is the pagedaemon or the lock failed.
 	 */
-	if (VSTATE_GET(vp) != VS_RECLAIMED) {
-		recycle = false;
-
+	if ((curlwp == uvm.pagedaemon_lwp) || async) {
+		defer = true;
+	} else {
+		mutex_exit(vp->v_interlock);
+		error = vn_lock(vp,
+		LK_EXCLUSIVE | LK_RETRY | (force ? 0 : LK_NOWAIT));
+		defer = (error != 0);
+		mutex_enter(vp->v_interlock);
+	}
+	KASSERT(mutex_owned(vp->v_interlock));
+	KASSERT(! (force && defer));
+	if (defer) {
 		/*
-		 * XXX This ugly block can be largely eliminated if
-		 * locking is pushed down into the file systems.
-		 *
-		 * Defer vnode release to vdrain_thread if caller
-		 * requests it explicitly or is the pagedaemon.
+		 * Defer reclaim to the kthread; it's not safe to
+		 * clean it here.  We donate it our last reference.
 		 */
-		if ((curlwp == uvm.pagedaemon_lwp) ||
-		(flags & VRELEL_ASYNC_RELE) != 0) {
-			defer = true;
-		} else if ((flags & VRELEL_FORCE_RELE) != 0) {
-			/*
-			 * We have to try harder.
-			 */
-			mutex_exit(vp->v_interlock);
-			error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
-			KASSERTMSG((error == 0), "vn_lock failed: %d", error);
-			mutex_enter(vp->v_interlock);
-			defer = false;
-		} else {
-			/* If we can't acquire the lock, then defer. */
-			mutex_exit(vp->v_interlock);
-			error = vn_lock(vp,
-			LK_EXCLUSIVE | LK_RETRY | LK_NOWAIT);
-			defer = (error != 0);
-			mutex_enter(vp->v_interlock);
-		}
-
-		KASSERT(mutex_owned(vp->v_interlock));
-		KASSERT(! ((flags & VRELEL_FORCE_RELE) != 0 && defer));
+		lru_requeue(vp, _vrele_list);
+		mutex_exit(vp->v_interlock);
+		return;
+	}
 
-		if (defer) {
-			/*
-			 * Defer reclaim to the kthread; it's not safe to
-			 * clean it here.  We donate it our last reference.
-			 */
-			lru_requeue(vp, _vrele_list);
-			mutex_exit(vp->v_interlock);
-			return;
-		}
+	/*
+	 * If the node got another reference while we
+	 * released the interlock, don't try to inactivate it yet.
+	 */
+	if (__predict_false(vtryrele(vp))) {
+		VOP_UNLOCK(vp);
+		mutex_exit(vp->v_interlock);
+		return;
+	}
 
-		/*
-		 * If the node got another reference while we
-		 * released the interlock, don't try to inactivate it yet.
-		 */
-		if (__predict_false(vtryrele(vp))) {
-			VOP_UNLOCK(vp);
-			mutex_exit(vp->v_interlock);
-			return;
-		}
+	/*
+	 * If not clean, deactivate the vnode, but preserve
+	 * our reference across the call to VOP_INACTIVE().
+	 */
+	if (VSTATE_GET(vp) == VS_RECLAIMED) {
+		VOP_UNLOCK(vp);
+	} else {
 		VSTATE_CHANGE(vp, VS_ACTIVE, VS_BLOCKED);
 		mutex_exit(vp->v_interlock);
 
@@ -759,6 +748,7 @@ vrelel(vnode_t *vp, int flags)
 		 *
 		 * Note that VOP_INACTIVE() will drop the vnode lock.
 		 */
+		recycle = false;
 		VOP_INACTIVE(vp, );
 		if (recycle) {
 			/* vcache_reclaim() below will drop the lock. */
@@ -1097,6 +1087,26 @@ vcache_alloc(void)
 }
 
 /*
+ * Deallocate a vcache node in state VS_LOADING.
+ 

CVS commit: src/sys/kern

2017-03-30 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Mar 30 09:14:08 UTC 2017

Modified Files:
src/sys/kern: vfs_vnode.c

Log Message:
Add flag VRELEL_FORCE_RELE to vrelel() to force release and
use it from vdrain_vrele() and vrele_flush() to prevent a
possible live lock from vrele_flush().


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sys/kern/vfs_vnode.c

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

Modified files:

Index: src/sys/kern/vfs_vnode.c
diff -u src/sys/kern/vfs_vnode.c:1.77 src/sys/kern/vfs_vnode.c:1.78
--- src/sys/kern/vfs_vnode.c:1.77	Thu Mar 30 09:12:21 2017
+++ src/sys/kern/vfs_vnode.c	Thu Mar 30 09:14:08 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_vnode.c,v 1.77 2017/03/30 09:12:21 hannken Exp $	*/
+/*	$NetBSD: vfs_vnode.c,v 1.78 2017/03/30 09:14:08 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -156,7 +156,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.77 2017/03/30 09:12:21 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.78 2017/03/30 09:14:08 hannken Exp $");
 
 #include 
 #include 
@@ -184,6 +184,7 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,
 
 /* Flags to vrelel. */
 #define	VRELEL_ASYNC_RELE	0x0001	/* Always defer to vrele thread. */
+#define	VRELEL_FORCE_RELE	0x0002	/* Must always succeed. */
 
 u_int			numvnodes		__cacheline_aligned;
 
@@ -482,7 +483,8 @@ vrele_flush(struct mount *mp)
 		TAILQ_INSERT_TAIL(vip->vi_lrulisthd, vip, vi_lrulist);
 		mutex_exit(_lock);
 
-		vrele(VIMPL_TO_VNODE(vip));
+		mutex_enter(VIMPL_TO_VNODE(vip)->v_interlock);
+		vrelel(VIMPL_TO_VNODE(vip), VRELEL_FORCE_RELE);
 
 		mutex_enter(_lock);
 	}
@@ -523,8 +525,10 @@ vdrain_remove(vnode_t *vp)
 	mutex_exit(_lock);
 
 	if (vcache_vget(vp) == 0) {
-		if (!vrecycle(vp))
-			vrele(vp);
+		if (!vrecycle(vp)) {
+			mutex_enter(vp->v_interlock);
+			vrelel(vp, VRELEL_FORCE_RELE);
+		}
 	}
 	fstrans_done(mp);
 
@@ -561,7 +565,7 @@ vdrain_vrele(vnode_t *vp)
 	mutex_exit(_lock);
 
 	mutex_enter(vp->v_interlock);
-	vrelel(vp, 0);
+	vrelel(vp, VRELEL_FORCE_RELE);
 	fstrans_done(mp);
 
 	mutex_enter(_lock);
@@ -704,7 +708,7 @@ vrelel(vnode_t *vp, int flags)
 		if ((curlwp == uvm.pagedaemon_lwp) ||
 		(flags & VRELEL_ASYNC_RELE) != 0) {
 			defer = true;
-		} else if (curlwp == vdrain_lwp) {
+		} else if ((flags & VRELEL_FORCE_RELE) != 0) {
 			/*
 			 * We have to try harder.
 			 */
@@ -723,7 +727,7 @@ vrelel(vnode_t *vp, int flags)
 		}
 
 		KASSERT(mutex_owned(vp->v_interlock));
-		KASSERT(! (curlwp == vdrain_lwp && defer));
+		KASSERT(! ((flags & VRELEL_FORCE_RELE) != 0 && defer));
 
 		if (defer) {
 			/*



CVS commit: src/sys/kern

2017-03-30 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Mar 30 09:13:37 UTC 2017

Modified Files:
src/sys/kern: vfs_vnops.c

Log Message:
Lock the vnode before changing its writecount.


To generate a diff of this commit:
cvs rdiff -u -r1.194 -r1.195 src/sys/kern/vfs_vnops.c

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

Modified files:

Index: src/sys/kern/vfs_vnops.c
diff -u src/sys/kern/vfs_vnops.c:1.194 src/sys/kern/vfs_vnops.c:1.195
--- src/sys/kern/vfs_vnops.c:1.194	Wed Mar  1 10:43:37 2017
+++ src/sys/kern/vfs_vnops.c	Thu Mar 30 09:13:37 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_vnops.c,v 1.194 2017/03/01 10:43:37 hannken Exp $	*/
+/*	$NetBSD: vfs_vnops.c,v 1.195 2017/03/30 09:13:37 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.194 2017/03/01 10:43:37 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.195 2017/03/30 09:13:37 hannken Exp $");
 
 #include "veriexec.h"
 
@@ -376,13 +376,13 @@ vn_close(struct vnode *vp, int flags, ka
 {
 	int error;
 
+	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
 	if (flags & FWRITE) {
 		mutex_enter(vp->v_interlock);
 		KASSERT(vp->v_writecount > 0);
 		vp->v_writecount--;
 		mutex_exit(vp->v_interlock);
 	}
-	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
 	error = VOP_CLOSE(vp, flags, cred);
 	vput(vp);
 	return (error);



CVS commit: src/sys

2017-03-30 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Mar 30 09:13:01 UTC 2017

Modified Files:
src/sys/kern: vfs_mount.c vfs_trans.c
src/sys/miscfs/nullfs: null_vfsops.c
src/sys/miscfs/overlay: overlay_vfsops.c
src/sys/miscfs/umapfs: umap_vfsops.c

Log Message:
Change _fstrans_start() to allocate per lwp info for layered file
systems to get a reference on the mount.

Set mnt_lower on successfull mount only.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/kern/vfs_mount.c
cvs rdiff -u -r1.39 -r1.40 src/sys/kern/vfs_trans.c
cvs rdiff -u -r1.92 -r1.93 src/sys/miscfs/nullfs/null_vfsops.c
cvs rdiff -u -r1.65 -r1.66 src/sys/miscfs/overlay/overlay_vfsops.c
cvs rdiff -u -r1.97 -r1.98 src/sys/miscfs/umapfs/umap_vfsops.c

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

Modified files:

Index: src/sys/kern/vfs_mount.c
diff -u src/sys/kern/vfs_mount.c:1.50 src/sys/kern/vfs_mount.c:1.51
--- src/sys/kern/vfs_mount.c:1.50	Mon Mar  6 10:11:21 2017
+++ src/sys/kern/vfs_mount.c	Thu Mar 30 09:13:01 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_mount.c,v 1.50 2017/03/06 10:11:21 hannken Exp $	*/
+/*	$NetBSD: vfs_mount.c,v 1.51 2017/03/30 09:13:01 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.50 2017/03/06 10:11:21 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.51 2017/03/30 09:13:01 hannken Exp $");
 
 #include 
 #include 
@@ -711,6 +711,12 @@ mount_domount(struct lwp *l, vnode_t **v
 		return ENOMEM;
 	}
 
+	if ((error = fstrans_mount(mp)) != 0) {
+		vfs_unbusy(mp, false, NULL);
+		vfs_destroy(mp);
+		return error;
+	}
+
 	mp->mnt_stat.f_owner = kauth_cred_geteuid(l->l_cred);
 
 	/*
@@ -728,12 +734,6 @@ mount_domount(struct lwp *l, vnode_t **v
 	if (error != 0)
 		goto err_unmounted;
 
-	if (mp->mnt_lower == NULL) {
-		error = fstrans_mount(mp);
-		if (error)
-			goto err_mounted;
-	}
-
 	/*
 	 * Validate and prepare the mount point.
 	 */

Index: src/sys/kern/vfs_trans.c
diff -u src/sys/kern/vfs_trans.c:1.39 src/sys/kern/vfs_trans.c:1.40
--- src/sys/kern/vfs_trans.c:1.39	Mon Mar  6 10:11:21 2017
+++ src/sys/kern/vfs_trans.c	Thu Mar 30 09:13:01 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_trans.c,v 1.39 2017/03/06 10:11:21 hannken Exp $	*/
+/*	$NetBSD: vfs_trans.c,v 1.40 2017/03/30 09:13:01 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.39 2017/03/06 10:11:21 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.40 2017/03/30 09:13:01 hannken Exp $");
 
 /*
  * File system transaction operations.
@@ -329,15 +329,26 @@ int
 _fstrans_start(struct mount *mp, enum fstrans_lock_type lock_type, int wait)
 {
 	int s;
+	struct mount *lmp;
 	struct fstrans_lwp_info *fli;
 	struct fstrans_mount_info *fmi;
 
-	if ((mp = fstrans_normalize_mount(mp)) == NULL)
+	if ((lmp = fstrans_normalize_mount(mp)) == NULL)
 		return 0;
 
 	ASSERT_SLEEPABLE();
 
-	if ((fli = fstrans_get_lwp_info(mp, true)) == NULL)
+	/*
+	 * Allocate per lwp info for layered file systems to
+	 * get a reference to the mount.  No need to increment
+	 * the reference counter here.
+	 */
+	for (lmp = mp; lmp->mnt_lower; lmp = lmp->mnt_lower) {
+		fli = fstrans_get_lwp_info(lmp, true);
+		KASSERT(fli != NULL);
+	}
+
+	if ((fli = fstrans_get_lwp_info(lmp, true)) == NULL)
 		return 0;
 
 	if (fli->fli_trans_cnt > 0) {
@@ -348,7 +359,7 @@ _fstrans_start(struct mount *mp, enum fs
 	}
 
 	s = pserialize_read_enter();
-	fmi = mp->mnt_transinfo;
+	fmi = lmp->mnt_transinfo;
 	if (__predict_true(grant_lock(fmi->fmi_state, lock_type))) {
 		fli->fli_trans_cnt = 1;
 		fli->fli_lock_type = lock_type;
@@ -383,9 +394,8 @@ fstrans_done(struct mount *mp)
 
 	if ((mp = fstrans_normalize_mount(mp)) == NULL)
 		return;
-	if ((fli = fstrans_get_lwp_info(mp, true)) == NULL)
-		return;
-
+	fli = fstrans_get_lwp_info(mp, false);
+	KASSERT(fli != NULL);
 	KASSERT(fli->fli_trans_cnt > 0);
 
 	if (fli->fli_trans_cnt > 1) {

Index: src/sys/miscfs/nullfs/null_vfsops.c
diff -u src/sys/miscfs/nullfs/null_vfsops.c:1.92 src/sys/miscfs/nullfs/null_vfsops.c:1.93
--- src/sys/miscfs/nullfs/null_vfsops.c:1.92	Mon Mar  6 10:10:07 2017
+++ src/sys/miscfs/nullfs/null_vfsops.c	Thu Mar 30 09:13:01 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: null_vfsops.c,v 1.92 2017/03/06 10:10:07 hannken Exp $	*/
+/*	$NetBSD: null_vfsops.c,v 1.93 2017/03/30 09:13:01 hannken Exp $	*/
 
 /*
  * Copyright (c) 1999 National Aeronautics & Space Administration
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: null_vfsops.c,v 1.92 2017/03/06 10:10:07 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: null_vfsops.c,v 1.93 2017/03/30 09:13:01 hannken Exp $");
 
 #include 
 #include 
@@ -170,13 +170,15 @@ nullfs_mount(struct mount *mp, const cha
 	vn_lock(vp, LK_EXCLUSIVE | 

CVS commit: src/sys

2017-03-30 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Mar 30 09:12:22 UTC 2017

Modified Files:
src/sys/kern: vfs_vnode.c
src/sys/miscfs/genfs: genfs_io.c genfs_vfsops.c

Log Message:
Change last users of FSTRANS_LAZY to FSTRANS_SHARED and change
genfs_suspendctl() to move from FSTRANS_NORMAL to FSTRANS_SUSPENDED
and vice versa.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/kern/vfs_vnode.c
cvs rdiff -u -r1.65 -r1.66 src/sys/miscfs/genfs/genfs_io.c
cvs rdiff -u -r1.4 -r1.5 src/sys/miscfs/genfs/genfs_vfsops.c

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

Modified files:

Index: src/sys/kern/vfs_vnode.c
diff -u src/sys/kern/vfs_vnode.c:1.76 src/sys/kern/vfs_vnode.c:1.77
--- src/sys/kern/vfs_vnode.c:1.76	Mon Mar  6 10:07:52 2017
+++ src/sys/kern/vfs_vnode.c	Thu Mar 30 09:12:21 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_vnode.c,v 1.76 2017/03/06 10:07:52 hannken Exp $	*/
+/*	$NetBSD: vfs_vnode.c,v 1.77 2017/03/30 09:12:21 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -156,7 +156,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.76 2017/03/06 10:07:52 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.77 2017/03/30 09:12:21 hannken Exp $");
 
 #include 
 #include 
@@ -543,7 +543,7 @@ vdrain_vrele(vnode_t *vp)
 	KASSERT(mutex_owned(_lock));
 
 	mp = vp->v_mount;
-	if (fstrans_start_nowait(mp, FSTRANS_LAZY) != 0)
+	if (fstrans_start_nowait(mp, FSTRANS_SHARED) != 0)
 		return;
 
 	/*
@@ -1518,7 +1518,7 @@ vcache_reclaim(vnode_t *vp)
 	vip->vi_key.vk_key = temp_key;
 	mutex_exit(_lock);
 
-	fstrans_start(mp, FSTRANS_LAZY);
+	fstrans_start(mp, FSTRANS_SHARED);
 
 	/*
 	 * Clean out any cached data associated with the vnode.

Index: src/sys/miscfs/genfs/genfs_io.c
diff -u src/sys/miscfs/genfs/genfs_io.c:1.65 src/sys/miscfs/genfs/genfs_io.c:1.66
--- src/sys/miscfs/genfs/genfs_io.c:1.65	Thu Mar  9 10:10:02 2017
+++ src/sys/miscfs/genfs/genfs_io.c	Thu Mar 30 09:12:21 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_io.c,v 1.65 2017/03/09 10:10:02 hannken Exp $	*/
+/*	$NetBSD: genfs_io.c,v 1.66 2017/03/30 09:12:21 hannken Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.65 2017/03/09 10:10:02 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.66 2017/03/30 09:12:21 hannken Exp $");
 
 #include 
 #include 
@@ -890,7 +890,7 @@ retry:
 		if (pagedaemon) {
 			/* Pagedaemon must not sleep here. */
 			trans_mp = vp->v_mount;
-			error = fstrans_start_nowait(trans_mp, FSTRANS_LAZY);
+			error = fstrans_start_nowait(trans_mp, FSTRANS_SHARED);
 			if (error) {
 mutex_exit(slock);
 return error;
@@ -903,7 +903,7 @@ retry:
 			 */
 			mutex_exit(slock);
 			trans_mp = vp->v_mount;
-			fstrans_start(trans_mp, FSTRANS_LAZY);
+			fstrans_start(trans_mp, FSTRANS_SHARED);
 			if (vp->v_mount != trans_mp) {
 fstrans_done(trans_mp);
 trans_mp = NULL;

Index: src/sys/miscfs/genfs/genfs_vfsops.c
diff -u src/sys/miscfs/genfs/genfs_vfsops.c:1.4 src/sys/miscfs/genfs/genfs_vfsops.c:1.5
--- src/sys/miscfs/genfs/genfs_vfsops.c:1.4	Fri Feb 17 08:31:25 2017
+++ src/sys/miscfs/genfs/genfs_vfsops.c	Thu Mar 30 09:12:21 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_vfsops.c,v 1.4 2017/02/17 08:31:25 hannken Exp $	*/
+/*	$NetBSD: genfs_vfsops.c,v 1.5 2017/03/30 09:12:21 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_vfsops.c,v 1.4 2017/02/17 08:31:25 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_vfsops.c,v 1.5 2017/03/30 09:12:21 hannken Exp $");
 
 #include 
 #include 
@@ -75,26 +75,18 @@ genfs_renamelock_exit(struct mount *mp)
 int
 genfs_suspendctl(struct mount *mp, int cmd)
 {
-	int error;
-	int error2 __diagused;
+	int error __diagused;
 
 	if ((mp->mnt_iflag & IMNT_HAS_TRANS) == 0)
 		return EOPNOTSUPP;
 
 	switch (cmd) {
 	case SUSPEND_SUSPEND:
-		if ((error = fstrans_setstate(mp, FSTRANS_SUSPENDING)) != 0)
-			return error;
-		if ((error = fstrans_setstate(mp, FSTRANS_SUSPENDED)) != 0) {
-			error2 = fstrans_setstate(mp, FSTRANS_NORMAL);
-			KASSERT(error2 == 0);
-			return error;
-		}
-		return 0;
+		return fstrans_setstate(mp, FSTRANS_SUSPENDED);
 
 	case SUSPEND_RESUME:
-		error2 = fstrans_setstate(mp, FSTRANS_NORMAL);
-		KASSERT(error2 == 0);
+		error = fstrans_setstate(mp, FSTRANS_NORMAL);
+		KASSERT(error == 0);
 		return 0;
 
 	default:



CVS commit: src/sys/ufs/ufs

2017-03-30 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Mar 30 09:11:45 UTC 2017

Modified Files:
src/sys/ufs/ufs: ufs_lookup.c

Log Message:
Remove now redundant calls to fstrans_start()/fstrans_done().


To generate a diff of this commit:
cvs rdiff -u -r1.145 -r1.146 src/sys/ufs/ufs/ufs_lookup.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_lookup.c
diff -u src/sys/ufs/ufs/ufs_lookup.c:1.145 src/sys/ufs/ufs/ufs_lookup.c:1.146
--- src/sys/ufs/ufs/ufs_lookup.c:1.145	Fri Apr 29 02:38:19 2016
+++ src/sys/ufs/ufs/ufs_lookup.c	Thu Mar 30 09:11:45 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_lookup.c,v 1.145 2016/04/29 02:38:19 christos Exp $	*/
+/*	$NetBSD: ufs_lookup.c,v 1.146 2017/03/30 09:11:45 hannken Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.145 2016/04/29 02:38:19 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.146 2017/03/30 09:11:45 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ffs.h"
@@ -54,7 +54,6 @@ __KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
@@ -376,8 +375,6 @@ ufs_lookup(void *v)
 		cnp->cn_flags |= ISWHITEOUT;
 	}
 
-	fstrans_start(vdp->v_mount, FSTRANS_SHARED);
-
 	/*
 	 * Suppress search for slots unless creating
 	 * file and at end of pathname, in which case
@@ -695,7 +692,6 @@ found:
 	error = 0;
 
 out:
-	fstrans_done(vdp->v_mount);
 	return error;
 }
 



CVS commit: src/sys/miscfs/genfs

2017-03-30 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Mar 30 09:11:12 UTC 2017

Modified Files:
src/sys/miscfs/genfs: genfs_rename.c

Log Message:
Remove now redundant calls to fstrans_start()/fstrans_done().


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/miscfs/genfs/genfs_rename.c

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

Modified files:

Index: src/sys/miscfs/genfs/genfs_rename.c
diff -u src/sys/miscfs/genfs/genfs_rename.c:1.2 src/sys/miscfs/genfs/genfs_rename.c:1.3
--- src/sys/miscfs/genfs/genfs_rename.c:1.2	Thu Feb  6 10:57:12 2014
+++ src/sys/miscfs/genfs/genfs_rename.c	Thu Mar 30 09:11:12 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_rename.c,v 1.2 2014/02/06 10:57:12 hannken Exp $	*/
+/*	$NetBSD: genfs_rename.c,v 1.3 2017/03/30 09:11:12 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_rename.c,v 1.2 2014/02/06 10:57:12 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_rename.c,v 1.3 2017/03/30 09:11:12 hannken Exp $");
 
 #include 
 #include 
@@ -45,7 +45,6 @@ __KERNEL_RCSID(0, "$NetBSD: genfs_rename
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include 
@@ -177,7 +176,6 @@ genfs_insane_rename(void *v,
 	struct componentname *fcnp = ap->a_fcnp;
 	struct vnode *tdvp = ap->a_tdvp;
 	struct vnode *tvp = ap->a_tvp;
-	struct mount *mp = fdvp->v_mount;
 	struct componentname *tcnp = ap->a_tcnp;
 	kauth_cred_t cred;
 	int error;
@@ -196,8 +194,6 @@ genfs_insane_rename(void *v,
 	KASSERT(fdvp->v_type == VDIR);
 	KASSERT(tdvp->v_type == VDIR);
 
-	fstrans_start(mp, FSTRANS_SHARED);
-
 	cred = fcnp->cn_cred;
 
 	/*
@@ -232,8 +228,6 @@ genfs_insane_rename(void *v,
 	vrele(fdvp);
 	vrele(tdvp);
 
-	fstrans_done(mp);
-
 	return error;
 }
 



CVS commit: src/sys/ufs/chfs

2017-03-30 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Mar 30 09:10:47 UTC 2017

Modified Files:
src/sys/ufs/chfs: chfs_vnops.c

Log Message:
Remove now redundant calls to fstrans_start()/fstrans_done().


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/ufs/chfs/chfs_vnops.c

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

Modified files:

Index: src/sys/ufs/chfs/chfs_vnops.c
diff -u src/sys/ufs/chfs/chfs_vnops.c:1.29 src/sys/ufs/chfs/chfs_vnops.c:1.30
--- src/sys/ufs/chfs/chfs_vnops.c:1.29	Sat Aug 20 12:37:09 2016
+++ src/sys/ufs/chfs/chfs_vnops.c	Thu Mar 30 09:10:46 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: chfs_vnops.c,v 1.29 2016/08/20 12:37:09 hannken Exp $	*/
+/*	$NetBSD: chfs_vnops.c,v 1.30 2017/03/30 09:10:46 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2010 Department of Software Engineering,
@@ -43,7 +43,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include "chfs.h"
@@ -653,8 +652,6 @@ chfs_read(void *v)
 	if (uio->uio_resid == 0)
 		return (0);
 
-	fstrans_start(vp->v_mount, FSTRANS_SHARED);
-
 	if (uio->uio_offset >= ip->size)
 		goto out;
 
@@ -737,7 +734,6 @@ out:
 		ip->iflag |= IN_ACCESS;
 		if ((ap->a_ioflag & IO_SYNC) == IO_SYNC) {
 			if (error) {
-fstrans_done(vp->v_mount);
 return error;
 			}
 			error = chfs_update(vp, NULL, NULL, UPDATE_WAIT);
@@ -745,7 +741,6 @@ out:
 	}
 
 	dbg("[END]\n");
-	fstrans_done(vp->v_mount);
 
 	return (error);
 }
@@ -833,8 +828,6 @@ chfs_write(void *v)
 	if (uio->uio_resid == 0)
 		return (0);
 
-	fstrans_start(vp->v_mount, FSTRANS_SHARED);
-
 	flags = ioflag & IO_SYNC ? B_SYNC : 0;
 	async = vp->v_mount->mnt_flag & MNT_ASYNC;
 	origoff = uio->uio_offset;
@@ -1003,7 +996,6 @@ out:
 
 
 	KASSERT(vp->v_size == ip->size);
-	fstrans_done(vp->v_mount);
 
 	mutex_enter(>chm_lock_mountfields);
 	error = chfs_write_flash_vnode(chmp, ip, ALLOC_NORMAL);



CVS commit: src/sys/ufs/lfs

2017-03-30 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Mar 30 09:10:08 UTC 2017

Modified Files:
src/sys/ufs/lfs: lfs_pages.c lfs_vnops.c ulfs_bmap.c ulfs_inode.c
ulfs_lookup.c ulfs_quota2.c ulfs_readwrite.c ulfs_vnops.c

Log Message:
Remove now redundant calls to fstrans_start()/fstrans_done().

Add fstrans_start()/fstrans_done() to lfs_putpages().


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/ufs/lfs/lfs_pages.c
cvs rdiff -u -r1.306 -r1.307 src/sys/ufs/lfs/lfs_vnops.c
cvs rdiff -u -r1.8 -r1.9 src/sys/ufs/lfs/ulfs_bmap.c
cvs rdiff -u -r1.16 -r1.17 src/sys/ufs/lfs/ulfs_inode.c
cvs rdiff -u -r1.39 -r1.40 src/sys/ufs/lfs/ulfs_lookup.c
cvs rdiff -u -r1.29 -r1.30 src/sys/ufs/lfs/ulfs_quota2.c
cvs rdiff -u -r1.22 -r1.23 src/sys/ufs/lfs/ulfs_readwrite.c
cvs rdiff -u -r1.45 -r1.46 src/sys/ufs/lfs/ulfs_vnops.c

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

Modified files:

Index: src/sys/ufs/lfs/lfs_pages.c
diff -u src/sys/ufs/lfs/lfs_pages.c:1.9 src/sys/ufs/lfs/lfs_pages.c:1.10
--- src/sys/ufs/lfs/lfs_pages.c:1.9	Tue Oct  4 16:46:20 2016
+++ src/sys/ufs/lfs/lfs_pages.c	Thu Mar 30 09:10:08 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_pages.c,v 1.9 2016/10/04 16:46:20 christos Exp $	*/
+/*	$NetBSD: lfs_pages.c,v 1.10 2017/03/30 09:10:08 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_pages.c,v 1.9 2016/10/04 16:46:20 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_pages.c,v 1.10 2017/03/30 09:10:08 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -466,6 +466,7 @@ lfs_putpages(void *v)
 	bool seglocked, sync, pagedaemon, reclaim;
 	struct vm_page *pg, *busypg;
 	UVMHIST_FUNC("lfs_putpages"); UVMHIST_CALLED(ubchist);
+	struct mount *trans_mp;
 	int oreclaim = 0;
 	int donewriting = 0;
 #ifdef DEBUG
@@ -478,6 +479,7 @@ lfs_putpages(void *v)
 	sync = (ap->a_flags & PGO_SYNCIO) != 0;
 	reclaim = (ap->a_flags & PGO_RECLAIM) != 0;
 	pagedaemon = (curlwp == uvm.pagedaemon_lwp);
+	trans_mp = NULL;
 
 	KASSERT(mutex_owned(vp->v_interlock));
 
@@ -487,6 +489,7 @@ lfs_putpages(void *v)
 		return 0;
 	}
 
+retry:
 	/*
 	 * If there are no pages, don't do anything.
 	 */
@@ -497,6 +500,8 @@ lfs_putpages(void *v)
 			vp->v_iflag &= ~VI_WRMAPDIRTY;
 			vn_syncer_remove_from_worklist(vp);
 		}
+		if (trans_mp)
+			fstrans_done(trans_mp);
 		mutex_exit(vp->v_interlock);
 		
 		/* Remove us from paging queue, if we were on it */
@@ -587,6 +592,33 @@ lfs_putpages(void *v)
 		return r;
 	}
 
+	if (trans_mp /* && (ap->a_flags & PGO_CLEANIT) != 0 */) {
+		if (pagedaemon) {
+			/* Pagedaemon must not sleep here. */
+			trans_mp = vp->v_mount;
+			error = fstrans_start_nowait(trans_mp, FSTRANS_SHARED);
+			if (error) {
+mutex_exit(vp->v_interlock);
+return error;
+			}
+		} else {
+			/*
+			 * Cannot use vdeadcheck() here as this operation
+			 * usually gets used from VOP_RECLAIM().  Test for
+			 * change of v_mount instead and retry on change.
+			 */
+			mutex_exit(vp->v_interlock);
+			trans_mp = vp->v_mount;
+			fstrans_start(trans_mp, FSTRANS_SHARED);
+			if (vp->v_mount != trans_mp) {
+fstrans_done(trans_mp);
+trans_mp = NULL;
+			}
+		}
+		mutex_enter(vp->v_interlock);
+		goto retry;
+	}
+
 	/* Set PGO_BUSYFAIL to avoid deadlocks */
 	ap->a_flags |= PGO_BUSYFAIL;
 
@@ -607,7 +639,8 @@ lfs_putpages(void *v)
 		if (r < 0) {
 			/* Pages are busy with another process */
 			mutex_exit(vp->v_interlock);
-			return EDEADLK;
+			error = EDEADLK;
+			goto out;
 		}
 		if (r > 0) /* Some pages are dirty */
 			break;
@@ -624,7 +657,8 @@ lfs_putpages(void *v)
 		ip->i_lfs_iflags &= ~LFSI_NO_GOP_WRITE;
 		if (r != EDEADLK) {
 			KASSERT(!mutex_owned(vp->v_interlock));
- 			return r;
+ 			error = r;
+			goto out;
 		}
 
 		/* One of the pages was busy.  Start over. */
@@ -662,7 +696,8 @@ lfs_putpages(void *v)
 		mutex_exit(_lock);
 		preempt();
 		KASSERT(!mutex_owned(vp->v_interlock));
-		return EWOULDBLOCK;
+		error = EWOULDBLOCK;
+		goto out;
 	}
 
 	/*
@@ -724,7 +759,7 @@ lfs_putpages(void *v)
 		error = lfs_seglock(fs, SEGM_PROT | (sync ? SEGM_SYNC : 0));
 		if (error != 0) {
 			KASSERT(!mutex_owned(vp->v_interlock));
- 			return error;
+ 			goto out;
 		}
 		mutex_enter(vp->v_interlock);
 		lfs_acquire_finfo(fs, ip->i_number, ip->i_gen);
@@ -851,7 +886,7 @@ lfs_putpages(void *v)
 	 */
 	if (seglocked) {
 		KASSERT(!mutex_owned(vp->v_interlock));
-		return error;
+		goto out;
 	}
 
 	/* Clean up FIP and send it to disk. */
@@ -892,6 +927,10 @@ lfs_putpages(void *v)
 		}
 		mutex_exit(vp->v_interlock);
 	}
+
+out:;
+	if (trans_mp)
+		fstrans_done(trans_mp);
 	KASSERT(!mutex_owned(vp->v_interlock));
 	return error;
 }

Index: src/sys/ufs/lfs/lfs_vnops.c
diff -u src/sys/ufs/lfs/lfs_vnops.c:1.306 src/sys/ufs/lfs/lfs_vnops.c:1.307
--- 

CVS commit: src/sys/fs/tmpfs

2017-03-30 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Mar 30 09:09:26 UTC 2017

Modified Files:
src/sys/fs/tmpfs: tmpfs_vnops.c

Log Message:
Protect tmpfs_getpages() against reclaiming vnodes.


To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 src/sys/fs/tmpfs/tmpfs_vnops.c

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

Modified files:

Index: src/sys/fs/tmpfs/tmpfs_vnops.c
diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.129 src/sys/fs/tmpfs/tmpfs_vnops.c:1.130
--- src/sys/fs/tmpfs/tmpfs_vnops.c:1.129	Wed Jan 11 12:12:32 2017
+++ src/sys/fs/tmpfs/tmpfs_vnops.c	Thu Mar 30 09:09:26 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: tmpfs_vnops.c,v 1.129 2017/01/11 12:12:32 joerg Exp $	*/
+/*	$NetBSD: tmpfs_vnops.c,v 1.130 2017/03/30 09:09:26 hannken Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.129 2017/01/11 12:12:32 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.130 2017/03/30 09:09:26 hannken Exp $");
 
 #include 
 #include 
@@ -1165,9 +1165,6 @@ tmpfs_getpages(void *v)
 	KASSERT(vp->v_type == VREG);
 	KASSERT(mutex_owned(vp->v_interlock));
 
-	node = VP_TO_TMPFS_NODE(vp);
-	uobj = node->tn_spec.tn_reg.tn_aobj;
-
 	/*
 	 * Currently, PGO_PASTEOF is not supported.
 	 */
@@ -1184,6 +1181,12 @@ tmpfs_getpages(void *v)
 	if ((flags & PGO_LOCKED) != 0)
 		return EBUSY;
 
+	if (vdead_check(vp, VDEAD_NOWAIT) != 0)
+		return ENOENT;
+
+	node = VP_TO_TMPFS_NODE(vp);
+	uobj = node->tn_spec.tn_reg.tn_aobj;
+
 	if ((flags & PGO_NOTIMESTAMP) == 0) {
 		u_int tflags = 0;
 



CVS commit: src/sys/dev/pci

2017-03-30 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Mar 30 08:44:34 UTC 2017

Modified Files:
src/sys/dev/pci: pci_subr.c

Log Message:
 Fix a bug that SR-IOV's system page size was doubled. ffs()'s bit are
numbered starting from 1.


To generate a diff of this commit:
cvs rdiff -u -r1.170 -r1.171 src/sys/dev/pci/pci_subr.c

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

Modified files:

Index: src/sys/dev/pci/pci_subr.c
diff -u src/sys/dev/pci/pci_subr.c:1.170 src/sys/dev/pci/pci_subr.c:1.171
--- src/sys/dev/pci/pci_subr.c:1.170	Tue Mar 28 10:30:27 2017
+++ src/sys/dev/pci/pci_subr.c	Thu Mar 30 08:44:33 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_subr.c,v 1.170 2017/03/28 10:30:27 msaitoh Exp $	*/
+/*	$NetBSD: pci_subr.c,v 1.171 2017/03/30 08:44:33 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1997 Zubin D. Dittia.  All rights reserved.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.170 2017/03/28 10:30:27 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.171 2017/03/30 08:44:33 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pci.h"
@@ -3097,11 +3097,14 @@ pci_conf_print_sriov_cap(const pcireg_t 
 	printf("System Page Sizes register: 0x%08x\n", reg);
 	printf("  Page Size: ");
 	if (reg != 0) {
+		int bitpos = ffs(reg) -1;
+
+		/* Assume only one bit is set. */
 #ifdef _KERNEL
-		format_bytes(buf, sizeof(buf), 1LL << (ffs(reg) + 12));
+		format_bytes(buf, sizeof(buf), 1LL << (bitpos + 12));
 #else
-		humanize_number(buf, sizeof(buf), 1LL << (ffs(reg) + 12), "B",
-		HN_AUTOSCALE, 0);
+		humanize_number(buf, sizeof(buf), 1LL << (bitpos + 12),
+		"B", HN_AUTOSCALE, 0);
 #endif
 		printf("%s", buf);
 	} else {



CVS commit: src/sys/arch/mips/cavium

2017-03-30 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Mar 30 08:43:40 UTC 2017

Modified Files:
src/sys/arch/mips/cavium: octeon_intr.c

Log Message:
Indentation


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/mips/cavium/octeon_intr.c

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

Modified files:

Index: src/sys/arch/mips/cavium/octeon_intr.c
diff -u src/sys/arch/mips/cavium/octeon_intr.c:1.9 src/sys/arch/mips/cavium/octeon_intr.c:1.10
--- src/sys/arch/mips/cavium/octeon_intr.c:1.9	Mon Nov 28 04:18:08 2016
+++ src/sys/arch/mips/cavium/octeon_intr.c	Thu Mar 30 08:43:40 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: octeon_intr.c,v 1.9 2016/11/28 04:18:08 mrg Exp $	*/
+/*	$NetBSD: octeon_intr.c,v 1.10 2017/03/30 08:43:40 skrll Exp $	*/
 /*
  * Copyright 2001, 2002 Wasabi Systems, Inc.
  * All rights reserved.
@@ -45,7 +45,7 @@
 #define __INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: octeon_intr.c,v 1.9 2016/11/28 04:18:08 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: octeon_intr.c,v 1.10 2017/03/30 08:43:40 skrll Exp $");
 
 #include 
 #include 
@@ -333,9 +333,10 @@ octeon_intr_init(struct cpu_info *ci)
 #endif
 
 	if (ci->ci_dev)
-	aprint_verbose_dev(ci->ci_dev,
-	"enabling intr masks %#"PRIx64"/%#"PRIx64"/%#"PRIx64"\n",
-	cpu->cpu_int0_enable0, cpu->cpu_int1_enable0, cpu->cpu_int2_enable0);
+		aprint_verbose_dev(ci->ci_dev,
+		"enabling intr masks %#"PRIx64"/%#"PRIx64"/%#"PRIx64"\n",
+		cpu->cpu_int0_enable0, cpu->cpu_int1_enable0,
+		cpu->cpu_int2_enable0);
 
 	mips3_sd(cpu->cpu_int0_en0, cpu->cpu_int0_enable0);
 	mips3_sd(cpu->cpu_int1_en0, cpu->cpu_int1_enable0);



CVS commit: src/doc

2017-03-30 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Mar 30 06:50:53 UTC 2017

Modified Files:
src/doc: TODO.smpnet

Log Message:
Write about bpf's statistic counters


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/doc/TODO.smpnet

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

Modified files:

Index: src/doc/TODO.smpnet
diff -u src/doc/TODO.smpnet:1.10 src/doc/TODO.smpnet:1.11
--- src/doc/TODO.smpnet:1.10	Thu Mar 30 04:37:58 2017
+++ src/doc/TODO.smpnet	Thu Mar 30 06:50:53 2017
@@ -1,4 +1,4 @@
-$NetBSD: TODO.smpnet,v 1.10 2017/03/30 04:37:58 ozaki-r Exp $
+$NetBSD: TODO.smpnet,v 1.11 2017/03/30 06:50:53 ozaki-r Exp $
 
 MP-safe components
 ==
@@ -140,4 +140,8 @@ fstat(1) shows information of bpf instan
 obtained via kvm(3). bpf_d#_bd_next, bpf_d#_bd_filter and bpf_d#_bd_list
 member variables are obsolete but remain. ifnet#if_xname is also accessed
 via struct bpf_if and obsolete ifnet#if_list is required to remain to not change
-the offset of ifnet#if_xname.
+the offset of ifnet#if_xname. The statistic counters (bpf#bd_rcount,
+bpf#bd_dcount and bpf#bd_ccount) are also victims of this restriction; for
+scalability the statistic counters should be per-CPU and we should stop using
+atomic operations for them however we have to remain the counters and atomic
+operations.



CVS commit: src/sys/net

2017-03-30 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Thu Mar 30 06:42:05 UTC 2017

Modified Files:
src/sys/net: if_l2tp.c

Log Message:
KNF. pointed out by s-yamaguchi@IIJ


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/net/if_l2tp.c

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

Modified files:

Index: src/sys/net/if_l2tp.c
diff -u src/sys/net/if_l2tp.c:1.1 src/sys/net/if_l2tp.c:1.2
--- src/sys/net/if_l2tp.c:1.1	Thu Feb 16 08:23:35 2017
+++ src/sys/net/if_l2tp.c	Thu Mar 30 06:42:05 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_l2tp.c,v 1.1 2017/02/16 08:23:35 knakahara Exp $	*/
+/*	$NetBSD: if_l2tp.c,v 1.2 2017/03/30 06:42:05 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_l2tp.c,v 1.1 2017/02/16 08:23:35 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_l2tp.c,v 1.2 2017/03/30 06:42:05 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -993,7 +993,8 @@ l2tp_delete_tunnel(struct ifnet *ifp)
 	kmem_free(ovar, sizeof(*ovar));
 }
 
-static int id_hash_func(uint32_t id)
+static int
+id_hash_func(uint32_t id)
 {
 	uint32_t hash;