CVS commit: src/sys/dev

2019-05-26 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun May 26 10:22:07 UTC 2019

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

Log Message:
Take "sc_lock" after calling disk_ioctl() to make GPT partitioning work.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sys/dev/md.c

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



CVS commit: src/sys/dev

2019-05-26 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun May 26 10:22:07 UTC 2019

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

Log Message:
Take "sc_lock" after calling disk_ioctl() to make GPT partitioning work.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sys/dev/md.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/md.c
diff -u src/sys/dev/md.c:1.80 src/sys/dev/md.c:1.81
--- src/sys/dev/md.c:1.80	Sat Mar  3 19:26:12 2018
+++ src/sys/dev/md.c	Sun May 26 10:22:07 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: md.c,v 1.80 2018/03/03 19:26:12 christos Exp $	*/
+/*	$NetBSD: md.c,v 1.81 2019/05/26 10:22:07 hannken Exp $	*/
 
 /*
  * Copyright (c) 1995 Gordon W. Ross, Leo Weppelman.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.80 2018/03/03 19:26:12 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.81 2019/05/26 10:22:07 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_md.h"
@@ -479,21 +479,19 @@ mdioctl(dev_t dev, u_long cmd, void *dat
 	if ((sc = device_lookup_private(&md_cd, MD_UNIT(dev))) == NULL)
 		return ENXIO;
 
-	mutex_enter(&sc->sc_lock);
 	if (sc->sc_type != MD_UNCONFIGURED) {
 		error = disk_ioctl(&sc->sc_dkdev, dev, cmd, data, flag, l); 
 		if (error != EPASSTHROUGH) {
-			mutex_exit(&sc->sc_lock);
-			return 0;
+			return error;
 		}
 	}
 
 	/* If this is not the raw partition, punt! */
 	if (DISKPART(dev) != RAW_PART) {
-		mutex_exit(&sc->sc_lock);
 		return ENOTTY;
 	}
 
+	mutex_enter(&sc->sc_lock);
 	umd = (struct md_conf *)data;
 	error = EINVAL;
 	switch (cmd) {



CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs

2019-05-26 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun May 26 10:22:59 UTC 2019

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: vdev_disk.c

Log Message:
upport wedges as vdevs, use DIOCGWEDGEINFO before DIOCGPARTINFO.

PR kern/54219 zpool create pool dk5 causes kernel panic


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c

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



CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs

2019-05-26 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun May 26 10:22:59 UTC 2019

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: vdev_disk.c

Log Message:
upport wedges as vdevs, use DIOCGWEDGEINFO before DIOCGPARTINFO.

PR kern/54219 zpool create pool dk5 causes kernel panic


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c

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

Modified files:

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c:1.8 src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c:1.9
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c:1.8	Mon Sep  3 16:29:22 2018
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c	Sun May 26 10:22:59 2019
@@ -34,6 +34,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -146,6 +147,8 @@ vdev_disk_open(vdev_t *vd, uint64_t *psi
 	spa_t *spa = vd->vdev_spa;
 	vdev_disk_t *dvd;
 	vnode_t *vp;
+	struct dkwedge_info dkw;
+	struct disk *pdk;
 	int error, cmd;
 	struct partinfo pinfo;
 
@@ -235,9 +238,20 @@ vdev_disk_open(vdev_t *vd, uint64_t *psi
 skip_open:
 	/*
 	 * Determine the actual size of the device.
-	 * XXXNETBSD wedges.
+	 * Try wedge info first as it supports larger disks.
 	 */
-	error = VOP_IOCTL(vp, DIOCGPARTINFO, &pinfo, FREAD|FWRITE, kcred);
+	error = VOP_IOCTL(vp, DIOCGWEDGEINFO, &dkw, FREAD, NOCRED);
+	if (error == 0) {
+		pdk = disk_find(dkw.dkw_parent);
+		if (pdk) {
+			pinfo.pi_secsize = (1 << pdk->dk_byteshift);
+			pinfo.pi_size = dkw.dkw_size;
+			pinfo.pi_offset = dkw.dkw_offset;
+		} else	
+			error = ENODEV;
+	}
+	if (error)
+		error = VOP_IOCTL(vp, DIOCGPARTINFO, &pinfo, FREAD, kcred);
 	if (error != 0) {
 		vd->vdev_stat.vs_aux = VDEV_AUX_OPEN_FAILED;
 		return (SET_ERROR(error));



CVS commit: src/distrib/sets/lists/tests

2019-05-26 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun May 26 20:01:07 UTC 2019

Modified Files:
src/distrib/sets/lists/tests: mi

Log Message:
Add entries for the recent tests/lib/libcurses commit.


To generate a diff of this commit:
cvs rdiff -u -r1.812 -r1.813 src/distrib/sets/lists/tests/mi

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



CVS commit: src/distrib/sets/lists/tests

2019-05-26 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun May 26 20:01:07 UTC 2019

Modified Files:
src/distrib/sets/lists/tests: mi

Log Message:
Add entries for the recent tests/lib/libcurses commit.


To generate a diff of this commit:
cvs rdiff -u -r1.812 -r1.813 src/distrib/sets/lists/tests/mi

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.812 src/distrib/sets/lists/tests/mi:1.813
--- src/distrib/sets/lists/tests/mi:1.812	Fri Apr 26 08:52:16 2019
+++ src/distrib/sets/lists/tests/mi	Sun May 26 20:01:07 2019
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.812 2019/04/26 08:52:16 maya Exp $
+# $NetBSD: mi,v 1.813 2019/05/26 20:01:07 hannken Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -2911,8 +2911,11 @@
 ./usr/tests/lib/libcurses/Atffile		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libcurses/Kyuafile		tests-lib-tests		compattestfile,atf,kyua
 ./usr/tests/lib/libcurses/check_files			tests-lib-tests	compattestfile,atf
+./usr/tests/lib/libcurses/check_files/add_wch1.chk	tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libcurses/check_files/add_wch2.chk	tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libcurses/check_files/addch.chk		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libcurses/check_files/addchstr.chk	tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libcurses/check_files/addchstr2.chk	tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libcurses/check_files/addstr.chk	tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libcurses/check_files/attributes.chk	tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libcurses/check_files/background1.chk	tests-lib-tests		compattestfile,atf
@@ -2921,6 +2924,7 @@
 ./usr/tests/lib/libcurses/check_files/background4.chk	tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libcurses/check_files/background5.chk	tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libcurses/check_files/bell.chk		tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libcurses/check_files/bkgdset1.chk	tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libcurses/check_files/box_standout.chk	tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libcurses/check_files/chgat1.chk	tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libcurses/check_files/chgat2.chk	tests-lib-tests		compattestfile,atf
@@ -2959,9 +2963,72 @@
 ./usr/tests/lib/libcurses/check_files/curs_set2.chk	tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libcurses/check_files/curs_set3.chk	tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libcurses/check_files/curses_start.chk	tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libcurses/check_files/delay_output.chk	tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libcurses/check_files/delch1.chk	tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libcurses/check_files/delch2.chk	tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libcurses/check_files/delch3.chk	tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libcurses/check_files/delch4.chk	tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libcurses/check_files/delch5.chk	tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libcurses/check_files/deleteln1.chk	tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libcurses/check_files/deleteln2.chk	tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libcurses/check_files/deleteln3.chk	tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libcurses/check_files/deleteln4.chk	tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libcurses/check_files/deleteln5.chk	tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libcurses/check_files/deleteln6.chk	tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libcurses/check_files/delwin1.chk	tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libcurses/check_files/delwin2.chk	tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libcurses/check_files/derwin1.chk	tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libcurses/check_files/derwin2.chk	tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libcurses/check_files/doupdate.chk	tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libcurses/check_files/dupwin1.chk	tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libcurses/check_files/dupwin2.chk	tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libcurses/check_files/fill.chk		tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libcurses/check_files/fill_screen_numbers.chk	tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libcurses/check_files/fill_window_numbers.chk	tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libcurses/check_files/flash.chk	tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libcurses/check_files/hline.chk	tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libcurses/check_files/home.chk		tests-lib-tests		compattestfile,atf
+./

CVS commit: src/sys/uvm

2021-08-23 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Aug 23 13:08:18 UTC 2021

Modified Files:
src/sys/uvm: uvm_swap.c

Log Message:
Return immediately from uvm_swap_shutdown() if there are
no (more) swap devices configured.


To generate a diff of this commit:
cvs rdiff -u -r1.205 -r1.206 src/sys/uvm/uvm_swap.c

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



CVS commit: src/sys/uvm

2021-08-23 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Aug 23 13:08:18 UTC 2021

Modified Files:
src/sys/uvm: uvm_swap.c

Log Message:
Return immediately from uvm_swap_shutdown() if there are
no (more) swap devices configured.


To generate a diff of this commit:
cvs rdiff -u -r1.205 -r1.206 src/sys/uvm/uvm_swap.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/uvm/uvm_swap.c
diff -u src/sys/uvm/uvm_swap.c:1.205 src/sys/uvm/uvm_swap.c:1.206
--- src/sys/uvm/uvm_swap.c:1.205	Thu Jun  3 20:18:06 2021
+++ src/sys/uvm/uvm_swap.c	Mon Aug 23 13:08:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_swap.c,v 1.205 2021/06/03 20:18:06 riastradh Exp $	*/
+/*	$NetBSD: uvm_swap.c,v 1.206 2021/08/23 13:08:18 hannken Exp $	*/
 
 /*
  * Copyright (c) 1995, 1996, 1997, 2009 Matthew R. Green
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v 1.205 2021/06/03 20:18:06 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v 1.206 2021/08/23 13:08:18 hannken Exp $");
 
 #include "opt_uvmhist.h"
 #include "opt_compat_netbsd.h"
@@ -1149,7 +1149,7 @@ uvm_swap_shutdown(struct lwp *l)
 	struct vnode *vp;
 	int error;
 
-	if (!uvm_swap_init_done)
+	if (!uvm_swap_init_done || uvmexp.nswapdev == 0)
 		return;
 	printf("turning off swap...");
 	rw_enter(&swap_syscall_lock, RW_WRITER);



CVS commit: src/sys/kern

2021-10-02 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Oct  2 07:35:41 UTC 2021

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

Log Message:
Fix a deadlock where one thread writes to a pipe, has more data
and no space in the pipe and waits on "pipe_wcv" while the reader
is closing the pipe and waits on "pipe_draincv".

Swap the test for "PIPE_EOF" and the "cv_wait_sig()" in "pipe_write()".

PR bin/56422 "zgrep -l sometimes hangs"


To generate a diff of this commit:
cvs rdiff -u -r1.156 -r1.157 src/sys/kern/sys_pipe.c

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



CVS commit: src/sys/kern

2021-10-02 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Oct  2 07:35:41 UTC 2021

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

Log Message:
Fix a deadlock where one thread writes to a pipe, has more data
and no space in the pipe and waits on "pipe_wcv" while the reader
is closing the pipe and waits on "pipe_draincv".

Swap the test for "PIPE_EOF" and the "cv_wait_sig()" in "pipe_write()".

PR bin/56422 "zgrep -l sometimes hangs"


To generate a diff of this commit:
cvs rdiff -u -r1.156 -r1.157 src/sys/kern/sys_pipe.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/sys_pipe.c
diff -u src/sys/kern/sys_pipe.c:1.156 src/sys/kern/sys_pipe.c:1.157
--- src/sys/kern/sys_pipe.c:1.156	Mon Sep 27 00:51:10 2021
+++ src/sys/kern/sys_pipe.c	Sat Oct  2 07:35:40 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_pipe.c,v 1.156 2021/09/27 00:51:10 thorpej Exp $	*/
+/*	$NetBSD: sys_pipe.c,v 1.157 2021/10/02 07:35:40 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2003, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.156 2021/09/27 00:51:10 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.157 2021/10/02 07:35:40 hannken Exp $");
 
 #include 
 #include 
@@ -694,11 +694,6 @@ pipe_write(file_t *fp, off_t *offset, st
 break;
 			}
 
-			pipeunlock(wpipe);
-			error = cv_wait_sig(&wpipe->pipe_wcv, lock);
-			(void)pipelock(wpipe, false);
-			if (error != 0)
-break;
 			/*
 			 * If read side wants to go away, we just issue a signal
 			 * to ourselves.
@@ -707,6 +702,12 @@ pipe_write(file_t *fp, off_t *offset, st
 error = EPIPE;
 break;
 			}
+
+			pipeunlock(wpipe);
+			error = cv_wait_sig(&wpipe->pipe_wcv, lock);
+			(void)pipelock(wpipe, false);
+			if (error != 0)
+break;
 			wakeup_state = wpipe->pipe_state;
 		}
 	}



CVS commit: src/sys/dev/pci

2021-10-18 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Oct 18 08:15:00 UTC 2021

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

Log Message:
Use a local static variable to hold "pktq_rps_hash_default"
like the other devices do.

Kernel ALL/amd64 compiles again.

OK: Kengo NAKAHARA 


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/pci/xmm7360.c

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



CVS commit: src/sys/dev/pci

2021-10-18 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Oct 18 08:15:00 UTC 2021

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

Log Message:
Use a local static variable to hold "pktq_rps_hash_default"
like the other devices do.

Kernel ALL/amd64 compiles again.

OK: Kengo NAKAHARA 


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/pci/xmm7360.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/xmm7360.c
diff -u src/sys/dev/pci/xmm7360.c:1.12 src/sys/dev/pci/xmm7360.c:1.13
--- src/sys/dev/pci/xmm7360.c:1.12	Mon Oct 11 05:13:10 2021
+++ src/sys/dev/pci/xmm7360.c	Mon Oct 18 08:15:00 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: xmm7360.c,v 1.12 2021/10/11 05:13:10 knakahara Exp $	*/
+/*	$NetBSD: xmm7360.c,v 1.13 2021/10/18 08:15:00 hannken Exp $	*/
 
 /*
  * Device driver for Intel XMM7360 LTE modems, eg. Fibocom L850-GL.
@@ -75,7 +75,7 @@ MODULE_DEVICE_TABLE(pci, xmm7360_ids);
 #include "opt_gateway.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xmm7360.c,v 1.12 2021/10/11 05:13:10 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xmm7360.c,v 1.13 2021/10/18 08:15:00 hannken Exp $");
 #endif
 
 #include 
@@ -294,6 +294,7 @@ typedef struct kmutex spinlock_t;
 		tsleep(xmm, 0, "wwancsl", msec * hz / 1000);	\
 	} while (0)
 
+static pktq_rps_hash_func_t xmm7360_pktq_rps_hash_p;
 static void *dma_alloc_coherent(struct device *, size_t, dma_addr_t *, int);
 static void dma_free_coherent(struct device *, size_t, volatile void *, dma_addr_t);
 
@@ -3110,7 +3111,7 @@ wwan_if_input(struct ifnet *ifp, struct 
 	/* No errors.  Receive the packet. */
 	m_set_rcvif(m, ifp);
 
-	const uint32_t h = pktq_rps_hash(&pktq_rps_hash_default, m);
+	const uint32_t h = pktq_rps_hash(&xmm7360_pktq_rps_hash_p, m);
 	if (__predict_false(!pktq_enqueue(pktq, m, h))) {
 		m_freem(m);
 	}
@@ -3257,6 +3258,8 @@ wwan_attach(struct device *parent, struc
 	printf("\n");
 
 #ifdef __NetBSD__
+	xmm7360_pktq_rps_hash_p = pktq_rps_hash_default;
+
 	if (pmf_device_register(self, wwan_pmf_suspend, NULL))
 		pmf_class_network_register(self, ifp);
 	else



CVS commit: src

2021-10-23 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Oct 23 07:38:33 UTC 2021

Modified Files:
src/sys/fs/msdosfs: denode.h msdosfs_lookup.c msdosfs_vnops.c
src/usr.sbin/makefs/msdos: msdosfs_vnops.c

Log Message:
Factor out the lookup results from struct denode.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/fs/msdosfs/denode.h
cvs rdiff -u -r1.37 -r1.38 src/sys/fs/msdosfs/msdosfs_lookup.c
cvs rdiff -u -r1.107 -r1.108 src/sys/fs/msdosfs/msdosfs_vnops.c
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/makefs/msdos/msdosfs_vnops.c

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



CVS commit: src

2021-10-23 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Oct 23 07:38:33 UTC 2021

Modified Files:
src/sys/fs/msdosfs: denode.h msdosfs_lookup.c msdosfs_vnops.c
src/usr.sbin/makefs/msdos: msdosfs_vnops.c

Log Message:
Factor out the lookup results from struct denode.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/fs/msdosfs/denode.h
cvs rdiff -u -r1.37 -r1.38 src/sys/fs/msdosfs/msdosfs_lookup.c
cvs rdiff -u -r1.107 -r1.108 src/sys/fs/msdosfs/msdosfs_vnops.c
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/makefs/msdos/msdosfs_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/msdosfs/denode.h
diff -u src/sys/fs/msdosfs/denode.h:1.26 src/sys/fs/msdosfs/denode.h:1.27
--- src/sys/fs/msdosfs/denode.h:1.26	Sun Jul 18 23:57:14 2021
+++ src/sys/fs/msdosfs/denode.h	Sat Oct 23 07:38:33 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: denode.h,v 1.26 2021/07/18 23:57:14 dholland Exp $	*/
+/*	$NetBSD: denode.h,v 1.27 2021/10/23 07:38:33 hannken Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -147,7 +147,14 @@ struct fatcache {
 		(dep)->de_fc[FC_NEXTTOLASTFC].fc_frcn = (dep)->de_fc[FC_LASTFC].fc_frcn; \
 		(dep)->de_fc[FC_NEXTTOLASTFC].fc_fsrcn = (dep)->de_fc[FC_LASTFC].fc_fsrcn; \
 	} while (0)
-	 
+
+/*
+ * Auxiliary results from an msdosfs_lookup operation
+ */
+struct msdosfs_lookup_results {
+	u_long mlr_fndoffset;	/* offset of found dir entry */
+	int mlr_fndcnt;		/* number of slots before de_fndoffset */
+};
 
 /*
  * This is the in memory variant of a dos directory entry.  It is usually
@@ -168,8 +175,7 @@ struct denode {
 #define de_dirclust de_key.dk_dirclust
 #define de_diroffset de_key.dk_diroffset
 #define de_dirgen de_key.dk_dirgen
-	u_long de_fndoffset;	/* offset of found dir entry */
-	int de_fndcnt;		/* number of slots before de_fndoffset */
+	struct msdosfs_lookup_results de_crap;	/* results from lookup */
 	long de_refcnt;		/* reference count */
 	struct msdosfsmount *de_pmp;	/* addr of our mount struct */
 	struct lockf *de_lockf;	/* byte level lock list */
@@ -302,6 +308,7 @@ struct kauth_cred;
 int msdosfs_update(struct vnode *, const struct timespec *,
 	const struct timespec *, int);
 int createde(struct denode *, struct denode *,
+		const struct msdosfs_lookup_results *,
 		struct denode **, struct componentname *);
 int deextend(struct denode *, u_long, struct kauth_cred *);
 #ifdef MAKEFS
@@ -316,7 +323,8 @@ int dosdirempty(struct denode *);
 int readde(struct denode *, struct buf **, struct direntry **);
 int readep(struct msdosfsmount *, u_long, u_long,
 		struct buf **, struct direntry **);
-int removede(struct denode *, struct denode *);
+int removede(struct denode *, struct denode *,
+		const struct msdosfs_lookup_results *);
 int uniqdosname(struct denode *, struct componentname *, u_char *);
 int findwin95(struct denode *);
 int msdosfs_gop_alloc(struct vnode *, off_t, off_t, int, struct kauth_cred *);

Index: src/sys/fs/msdosfs/msdosfs_lookup.c
diff -u src/sys/fs/msdosfs/msdosfs_lookup.c:1.37 src/sys/fs/msdosfs/msdosfs_lookup.c:1.38
--- src/sys/fs/msdosfs/msdosfs_lookup.c:1.37	Sat Jul 24 21:31:38 2021
+++ src/sys/fs/msdosfs/msdosfs_lookup.c	Sat Oct 23 07:38:33 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_lookup.c,v 1.37 2021/07/24 21:31:38 andvar Exp $	*/
+/*	$NetBSD: msdosfs_lookup.c,v 1.38 2021/10/23 07:38:33 hannken Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -52,7 +52,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_lookup.c,v 1.37 2021/07/24 21:31:38 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_lookup.c,v 1.38 2021/10/23 07:38:33 hannken Exp $");
 
 #include 
 
@@ -320,21 +320,21 @@ msdosfs_lookup(void *v)
  * entry came from for whoever did
  * this lookup.
  */
-dp->de_fndoffset = diroff;
+dp->de_crap.mlr_fndoffset = diroff;
 if (chksum_ok && nameiop == RENAME) {
 	/*
 	 * Target had correct long name
 	 * directory entries, reuse them
 	 * as needed.
 	 */
-	dp->de_fndcnt = wincnt - 1;
+	dp->de_crap.mlr_fndcnt = wincnt - 1;
 } else {
 	/*
 	 * Long name directory entries
 	 * not present or corrupt, can only
 	 * reuse dos directory entry.
 	 */
-	dp->de_fndcnt = 0;
+	dp->de_crap.mlr_fndcnt = 0;
 }
 
 goto found;
@@ -389,8 +389,8 @@ notfound:
 		 * Return an indication of where the new directory
 		 * entry should be put.
 		 */
-		dp->de_fndoffset = slotoffset;
-		dp->de_fndcnt = wincnt - 1;
+		dp->de_crap.mlr_fndoffset = slotoffset;
+		dp->de_crap.mlr_fndcnt = wincnt - 1;
 
 		/*
 		 * We return with the directory locked, so that
@@ -552,7 +552,9 @@ foundroot:
  * cnp  - componentname needed for Win95 long filenames
  */
 int
-createde(struct denode *dep, struct denode *ddep, struct denode **depp, struct componentname *cnp)
+createde(struct denode *dep, stru

CVS commit: src/sys

2021-10-23 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Oct 23 07:41:38 UTC 2021

Modified Files:
src/sys/fs/msdosfs: files.msdosfs msdosfs_lookup.c msdosfs_vnops.c
src/sys/modules/msdos: Makefile
src/sys/rump/fs/lib/libmsdos: Makefile
Added Files:
src/sys/fs/msdosfs: msdosfs_rename.c

Log Message:
Move msdosfs_rename() and doscheckpath() to new file msdosfs_rename.c.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/fs/msdosfs/files.msdosfs
cvs rdiff -u -r1.38 -r1.39 src/sys/fs/msdosfs/msdosfs_lookup.c
cvs rdiff -u -r0 -r1.1 src/sys/fs/msdosfs/msdosfs_rename.c
cvs rdiff -u -r1.108 -r1.109 src/sys/fs/msdosfs/msdosfs_vnops.c
cvs rdiff -u -r1.3 -r1.4 src/sys/modules/msdos/Makefile
cvs rdiff -u -r1.5 -r1.6 src/sys/rump/fs/lib/libmsdos/Makefile

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



CVS commit: src/sys

2021-10-23 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Oct 23 07:41:38 UTC 2021

Modified Files:
src/sys/fs/msdosfs: files.msdosfs msdosfs_lookup.c msdosfs_vnops.c
src/sys/modules/msdos: Makefile
src/sys/rump/fs/lib/libmsdos: Makefile
Added Files:
src/sys/fs/msdosfs: msdosfs_rename.c

Log Message:
Move msdosfs_rename() and doscheckpath() to new file msdosfs_rename.c.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/fs/msdosfs/files.msdosfs
cvs rdiff -u -r1.38 -r1.39 src/sys/fs/msdosfs/msdosfs_lookup.c
cvs rdiff -u -r0 -r1.1 src/sys/fs/msdosfs/msdosfs_rename.c
cvs rdiff -u -r1.108 -r1.109 src/sys/fs/msdosfs/msdosfs_vnops.c
cvs rdiff -u -r1.3 -r1.4 src/sys/modules/msdos/Makefile
cvs rdiff -u -r1.5 -r1.6 src/sys/rump/fs/lib/libmsdos/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/fs/msdosfs/files.msdosfs
diff -u src/sys/fs/msdosfs/files.msdosfs:1.3 src/sys/fs/msdosfs/files.msdosfs:1.4
--- src/sys/fs/msdosfs/files.msdosfs:1.3	Sat Feb  6 10:40:58 2016
+++ src/sys/fs/msdosfs/files.msdosfs	Sat Oct 23 07:41:37 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: files.msdosfs,v 1.3 2016/02/06 10:40:58 mlelstv Exp $
+#	$NetBSD: files.msdosfs,v 1.4 2021/10/23 07:41:37 hannken Exp $
 
 deffs	MSDOSFS
 
@@ -7,6 +7,7 @@ file	fs/msdosfs/msdosfs_conv.c		msdosfs
 file	fs/msdosfs/msdosfs_denode.c		msdosfs
 file	fs/msdosfs/msdosfs_fat.c		msdosfs
 file	fs/msdosfs/msdosfs_lookup.c		msdosfs
+file	fs/msdosfs/msdosfs_rename.c		msdosfs
 file	fs/msdosfs/msdosfs_vfsops.c		msdosfs
 file	fs/msdosfs/msdosfs_vnops.c		msdosfs
 file	fs/msdosfs/msdosfs_unicode.c		msdosfs

Index: src/sys/fs/msdosfs/msdosfs_lookup.c
diff -u src/sys/fs/msdosfs/msdosfs_lookup.c:1.38 src/sys/fs/msdosfs/msdosfs_lookup.c:1.39
--- src/sys/fs/msdosfs/msdosfs_lookup.c:1.38	Sat Oct 23 07:38:33 2021
+++ src/sys/fs/msdosfs/msdosfs_lookup.c	Sat Oct 23 07:41:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_lookup.c,v 1.38 2021/10/23 07:38:33 hannken Exp $	*/
+/*	$NetBSD: msdosfs_lookup.c,v 1.39 2021/10/23 07:41:37 hannken Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -52,7 +52,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_lookup.c,v 1.38 2021/10/23 07:38:33 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_lookup.c,v 1.39 2021/10/23 07:41:37 hannken Exp $");
 
 #include 
 
@@ -830,116 +830,6 @@ dosdirempty(struct denode *dep)
 }
 
 /*
- * Check to see if the directory described by target is in some
- * subdirectory of source.  This prevents something like the following from
- * succeeding and leaving a bunch or files and directories orphaned. mv
- * /a/b/c /a/b/c/d/e/f Where c and f are directories.
- *
- * source - the inode for /a/b/c
- * target - the inode for /a/b/c/d/e/f
- *
- * Returns 0 if target is NOT a subdirectory of source.
- * Otherwise returns a non-zero error number.
- * The target inode is always unlocked on return.
- */
-int
-doscheckpath(struct denode *source, struct denode *target)
-{
-	u_long scn;
-	struct msdosfsmount *pmp;
-	struct direntry *ep;
-	struct denode *dep;
-	struct buf *bp = NULL;
-	int error = 0;
-
-	dep = target;
-	if ((target->de_Attributes & ATTR_DIRECTORY) == 0 ||
-	(source->de_Attributes & ATTR_DIRECTORY) == 0) {
-		error = ENOTDIR;
-		goto out;
-	}
-	if (dep->de_StartCluster == source->de_StartCluster) {
-		error = EEXIST;
-		goto out;
-	}
-	if (dep->de_StartCluster == MSDOSFSROOT)
-		goto out;
-	pmp = dep->de_pmp;
-#ifdef	DIAGNOSTIC
-	if (pmp != source->de_pmp)
-		panic("doscheckpath: source and target on different filesystems");
-#endif
-	if (FAT32(pmp) && dep->de_StartCluster == pmp->pm_rootdirblk)
-		goto out;
-
-	for (;;) {
-		if ((dep->de_Attributes & ATTR_DIRECTORY) == 0) {
-			error = ENOTDIR;
-			break;
-		}
-		scn = dep->de_StartCluster;
-		error = bread(pmp->pm_devvp, de_bn2kb(pmp, cntobn(pmp, scn)),
-			  pmp->pm_bpcluster, 0, &bp);
-		if (error)
-			break;
-
-		ep = (struct direntry *) bp->b_data + 1;
-		if ((ep->deAttributes & ATTR_DIRECTORY) == 0 ||
-		memcmp(ep->deName, ".. ", 11) != 0) {
-			error = ENOTDIR;
-			break;
-		}
-		scn = getushort(ep->deStartCluster);
-		if (FAT32(pmp))
-			scn |= getushort(ep->deHighClust) << 16;
-
-		if (scn == source->de_StartCluster) {
-			error = EINVAL;
-			break;
-		}
-		if (scn == MSDOSFSROOT)
-			break;
-		if (FAT32(pmp) && scn == pmp->pm_rootdirblk) {
-			/*
-			 * scn should be 0 in this case,
-			 * but we silently ignore the error.
-			 */
-			break;
-		}
-
-		vput(DETOV(dep));
-		brelse(bp, 0);
-		bp = NULL;
-#ifdef MAKEFS
-		/* NOTE: deget() clears dep on error */
-		if ((error = deget(pmp, scn, 0, &dep)) != 0)
-			break;
-#else
-		struct vnode *vp;
-
-		dep = NULL;
-		error = deget(pmp, scn, 0, &vp);
-		if (error)
-			break;
-		error = vn_lock(vp, LK_EXCLUSIVE);
-		if (error) {
-			vrele(vp);
-			break;
-		}
-		dep = VTODE(vp);
-#endif
-	}

CVS commit: src/sys/fs/msdosfs

2021-10-23 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Oct 23 07:45:03 UTC 2021

Modified Files:
src/sys/fs/msdosfs: denode.h msdosfs_rename.c

Log Message:
Convert msdosfs_rename() to use genfs_sane_rename().

Based on work by Taylor R Campbell.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/fs/msdosfs/denode.h
cvs rdiff -u -r1.1 -r1.2 src/sys/fs/msdosfs/msdosfs_rename.c

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



CVS commit: src/sys/fs/msdosfs

2021-10-23 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Oct 23 07:45:03 UTC 2021

Modified Files:
src/sys/fs/msdosfs: denode.h msdosfs_rename.c

Log Message:
Convert msdosfs_rename() to use genfs_sane_rename().

Based on work by Taylor R Campbell.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/fs/msdosfs/denode.h
cvs rdiff -u -r1.1 -r1.2 src/sys/fs/msdosfs/msdosfs_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/fs/msdosfs/denode.h
diff -u src/sys/fs/msdosfs/denode.h:1.27 src/sys/fs/msdosfs/denode.h:1.28
--- src/sys/fs/msdosfs/denode.h:1.27	Sat Oct 23 07:38:33 2021
+++ src/sys/fs/msdosfs/denode.h	Sat Oct 23 07:45:03 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: denode.h,v 1.27 2021/10/23 07:38:33 hannken Exp $	*/
+/*	$NetBSD: denode.h,v 1.28 2021/10/23 07:45:03 hannken Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -318,7 +318,6 @@ int deget(struct msdosfsmount *, u_long,
 #endif
 int detrunc(struct denode *, u_long, int, struct kauth_cred *);
 int deupdat(struct denode *, int);
-int doscheckpath(struct denode *, struct denode *);
 int dosdirempty(struct denode *);
 int readde(struct denode *, struct buf **, struct direntry **);
 int readep(struct msdosfsmount *, u_long, u_long,

Index: src/sys/fs/msdosfs/msdosfs_rename.c
diff -u src/sys/fs/msdosfs/msdosfs_rename.c:1.1 src/sys/fs/msdosfs/msdosfs_rename.c:1.2
--- src/sys/fs/msdosfs/msdosfs_rename.c:1.1	Sat Oct 23 07:41:37 2021
+++ src/sys/fs/msdosfs/msdosfs_rename.c	Sat Oct 23 07:45:03 2021
@@ -1,10 +1,11 @@
-/*	$NetBSD: msdosfs_rename.c,v 1.1 2021/10/23 07:41:37 hannken Exp $	*/
+/*	$NetBSD: msdosfs_rename.c,v 1.2 2021/10/23 07:45:03 hannken Exp $	*/
 
 /*-
- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
- * Copyright (C) 1994, 1995, 1997 TooLs GmbH.
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
- * Original code by Paul Popelka (pa...@uts.amdahl.com) (see below).
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Taylor R Campbell.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -14,60 +15,36 @@
  * 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.
- * 3. All advertising materials mentioning features or use of this software
- *must display the following acknowledgement:
- *	This product includes software developed by TooLs GmbH.
- * 4. The name of TooLs GmbH may not be used to endorse or promote products
- *derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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.
- */
-/*
- * Written by Paul Popelka (pa...@uts.amdahl.com)
- *
- * You can do anything you want with this software, just don't say you wrote
- * it, and don't remove this notice.
- *
- * This software is provided "as is".
- *
- * The author supplies this software to be publicly redistributed on the
- * understanding that the author is not responsible for the correct
- * functioning of this software in any circumstances and is not liable for
- * any damages caused by this software.
  *
- * October 1992
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
  */
 
+/*
+ * MS-DOS FS Rename
+ */
+
+#include 
+__KERNEL_

CVS commit: src/tests/fs/vfs

2021-10-23 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Oct 23 17:43:08 UTC 2021

Modified Files:
src/tests/fs/vfs: t_renamerace.c

Log Message:
After converting msdosfs_rename() to use genfs_sane_rename() the
MSDOS tests should pass.

Tested on QEMU/nvmm archs i386 and amd64.

Should resolve PR kern/43626 (directory renaming more than a little racy)


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/tests/fs/vfs/t_renamerace.c

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



CVS commit: src/tests/fs/vfs

2021-10-23 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Oct 23 17:43:08 UTC 2021

Modified Files:
src/tests/fs/vfs: t_renamerace.c

Log Message:
After converting msdosfs_rename() to use genfs_sane_rename() the
MSDOS tests should pass.

Tested on QEMU/nvmm archs i386 and amd64.

Should resolve PR kern/43626 (directory renaming more than a little racy)


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/tests/fs/vfs/t_renamerace.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/fs/vfs/t_renamerace.c
diff -u src/tests/fs/vfs/t_renamerace.c:1.41 src/tests/fs/vfs/t_renamerace.c:1.42
--- src/tests/fs/vfs/t_renamerace.c:1.41	Wed Jun 16 23:58:07 2021
+++ src/tests/fs/vfs/t_renamerace.c	Sat Oct 23 17:43:08 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_renamerace.c,v 1.41 2021/06/16 23:58:07 riastradh Exp $	*/
+/*	$NetBSD: t_renamerace.c,v 1.42 2021/10/23 17:43:08 hannken Exp $	*/
 
 /*
  * Modified for rump and atf from a program supplied
@@ -183,19 +183,6 @@ renamerace(const atf_tc_t *tc, const cha
 
 	if (FSTYPE_UDF(tc))
 		atf_tc_fail("race did not trigger this time");
-
-	if (FSTYPE_MSDOS(tc)) {
-		atf_tc_expect_fail("PR kern/43626");
-		/*
-		 * XXX: race does not trigger every time at least
-		 * on amd64/qemu.
-		 */
-		if (msdosfs_fstest_unmount(tc, mp, 0) != 0) {
-			rump_pub_vfs_mount_print(mp, 1);
-			atf_tc_fail_errno("unmount failed");
-		}
-		atf_tc_fail("race did not trigger this time");
-	}
 }
 
 static void
@@ -210,10 +197,6 @@ renamerace_dirs(const atf_tc_t *tc, cons
 	if (FSTYPE_UDF(tc))
 		atf_tc_expect_fail("PR kern/53865");
 
-	/* XXX: msdosfs also sometimes hangs */
-	if (FSTYPE_MSDOS(tc))
-		atf_tc_expect_signal(-1, "PR kern/43626");
-
 	RZ(rump_pub_lwproc_rfork(RUMP_RFCFDG));
 	RL(wrkpid = rump_sys_getpid());
 
@@ -230,13 +213,6 @@ renamerace_dirs(const atf_tc_t *tc, cons
 
 	if (FSTYPE_UDF(tc))
 		atf_tc_fail("race did not trigger this time");
-
-	/*
-	 * Doesn't always trigger when run on a slow backend
-	 * (i.e. not on tmpfs/mfs).  So do the usual kludge.
-	 */
-	if (FSTYPE_MSDOS(tc))
-		abort();
 }
 
 static void
@@ -257,10 +233,6 @@ renamerace_cycle(const atf_tc_t *tc, con
 	if (FSTYPE_UDF(tc))
 		atf_tc_expect_fail("sometimes fails with ENOSPC, PR kern/56253");
 
-	/* XXX: msdosfs also sometimes hangs */
-	if (FSTYPE_MSDOS(tc))
-		atf_tc_expect_signal(-1, "PR kern/43626");
-
 	RZ(rump_pub_lwproc_rfork(RUMP_RFCFDG));
 	RL(wrkpid = rump_sys_getpid());
 
@@ -281,13 +253,6 @@ renamerace_cycle(const atf_tc_t *tc, con
 
 	if (FSTYPE_UDF(tc))
 		atf_tc_fail("PR kern/56253 did not trigger this time");
-
-	/*
-	 * Doesn't always trigger when run on a slow backend
-	 * (i.e. not on tmpfs/mfs).  So do the usual kludge.
-	 */
-	if (FSTYPE_MSDOS(tc))
-		abort();
 }
 
 ATF_TC_FSAPPLY(renamerace, "rename(2) race with file unlinked mid-operation");



CVS commit: src/tests/fs/tmpfs

2021-10-30 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Oct 30 09:53:47 UTC 2021

Modified Files:
src/tests/fs/tmpfs: t_link.sh

Log Message:
With the recent "centralize vnode kevent handling" kevent(2) no
longer raises NOTE_LINK when removing a hard linked node.

It now behaves as FreeBSD and raises NOTE_DELETE.

Adapt the test to the new behaviour.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/fs/tmpfs/t_link.sh

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



CVS commit: src/tests/fs/tmpfs

2021-10-30 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Oct 30 09:53:47 UTC 2021

Modified Files:
src/tests/fs/tmpfs: t_link.sh

Log Message:
With the recent "centralize vnode kevent handling" kevent(2) no
longer raises NOTE_LINK when removing a hard linked node.

It now behaves as FreeBSD and raises NOTE_DELETE.

Adapt the test to the new behaviour.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/fs/tmpfs/t_link.sh

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

Modified files:

Index: src/tests/fs/tmpfs/t_link.sh
diff -u src/tests/fs/tmpfs/t_link.sh:1.5 src/tests/fs/tmpfs/t_link.sh:1.6
--- src/tests/fs/tmpfs/t_link.sh:1.5	Sun Nov  7 17:51:18 2010
+++ src/tests/fs/tmpfs/t_link.sh	Sat Oct 30 09:53:47 2021
@@ -1,4 +1,4 @@
-# $NetBSD: t_link.sh,v 1.5 2010/11/07 17:51:18 jmmv Exp $
+# $NetBSD: t_link.sh,v 1.6 2021/10/30 09:53:47 hannken Exp $
 #
 # Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -109,9 +109,7 @@ kqueue_body() {
 	kqueue_check dir NOTE_WRITE
 
 	echo 'rm dir/a' | kqueue_monitor 2 dir dir/b
-	# XXX According to the (short) kqueue(2) documentation, the following
-	# should raise a NOTE_LINK but FFS raises a NOTE_DELETE...
-	kqueue_check dir/b NOTE_LINK
+	kqueue_check dir/b NOTE_DELETE
 	kqueue_check dir NOTE_WRITE
 	atf_check -s eq:0 -o empty -e empty rm dir/b
 	atf_check -s eq:0 -o empty -e empty rmdir dir



CVS commit: src/usr.bin/telnet

2021-10-30 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Oct 30 13:43:40 UTC 2021

Modified Files:
src/usr.bin/telnet: telnet.c

Log Message:
Obvious typo ':' -> ';'.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/usr.bin/telnet/telnet.c

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



CVS commit: src/usr.bin/telnet

2021-10-30 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Oct 30 13:43:40 UTC 2021

Modified Files:
src/usr.bin/telnet: telnet.c

Log Message:
Obvious typo ':' -> ';'.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/usr.bin/telnet/telnet.c

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

Modified files:

Index: src/usr.bin/telnet/telnet.c
diff -u src/usr.bin/telnet/telnet.c:1.43 src/usr.bin/telnet/telnet.c:1.44
--- src/usr.bin/telnet/telnet.c:1.43	Sat Oct 30 11:37:18 2021
+++ src/usr.bin/telnet/telnet.c	Sat Oct 30 13:43:40 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: telnet.c,v 1.43 2021/10/30 11:37:18 nia Exp $	*/
+/*	$NetBSD: telnet.c,v 1.44 2021/10/30 13:43:40 hannken Exp $	*/
 
 /*
  * Copyright (c) 1988, 1990, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)telnet.c	8.4 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: telnet.c,v 1.43 2021/10/30 11:37:18 nia Exp $");
+__RCSID("$NetBSD: telnet.c,v 1.44 2021/10/30 13:43:40 hannken Exp $");
 #endif
 #endif /* not lint */
 
@@ -578,7 +578,7 @@ mklist(char *buf, char *name)
 	/*
 	 * Allocate an array to put the name pointers into
 	 */
-	argv = NULL:
+	argv = NULL;
 	if (reallocarr(&argv, n + 3, sizeof(char *)) != 0)
 		return(unknown);
 



CVS commit: src/tests/lib/libc/sys

2021-11-01 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Nov  1 14:33:42 UTC 2021

Modified Files:
src/tests/lib/libc/sys: Makefile t_timerfd.c

Log Message:
Test lib/libc/sys/t_timerfd often fails when run on QEMU because
QEMU misses clock interrupts.

Always check values against [ lower, upper ] bounds and use "4 * upper"
when run under QEMU.

Now becomes part of PR kern/43997 "Kernel timer discrepancies".


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/tests/lib/libc/sys/Makefile
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/sys/t_timerfd.c

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



CVS commit: src/tests/lib/libc/sys

2021-11-01 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Nov  1 14:33:42 UTC 2021

Modified Files:
src/tests/lib/libc/sys: Makefile t_timerfd.c

Log Message:
Test lib/libc/sys/t_timerfd often fails when run on QEMU because
QEMU misses clock interrupts.

Always check values against [ lower, upper ] bounds and use "4 * upper"
when run under QEMU.

Now becomes part of PR kern/43997 "Kernel timer discrepancies".


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/tests/lib/libc/sys/Makefile
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/sys/t_timerfd.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/lib/libc/sys/Makefile
diff -u src/tests/lib/libc/sys/Makefile:1.69 src/tests/lib/libc/sys/Makefile:1.70
--- src/tests/lib/libc/sys/Makefile:1.69	Sun Sep 19 15:51:28 2021
+++ src/tests/lib/libc/sys/Makefile	Mon Nov  1 14:33:41 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.69 2021/09/19 15:51:28 thorpej Exp $
+# $NetBSD: Makefile,v 1.70 2021/11/01 14:33:41 hannken Exp $
 
 MKMAN=	no
 
@@ -117,6 +117,8 @@ LDADD.t_posix_fadvise+= ${LIBRUMPBASE}
 CPPFLAGS.t_futex_ops.c		+= -I${.CURDIR}/../../../../lib
 CPPFLAGS.t_futex_robust.c	+= -I${.CURDIR}/../../../../lib
 
+CPPFLAGS.t_timerfd.c		+= -I${.CURDIR}/../gen
+
 CPPFLAGS.t_lwp_create.c		+= -D_KERNTYPES
 CPPFLAGS.t_ptrace_sigchld.c	+= -D__TEST_FENV
 CPPFLAGS.t_ptrace_wait.c	+= -D_KERNTYPES -D__TEST_FENV

Index: src/tests/lib/libc/sys/t_timerfd.c
diff -u src/tests/lib/libc/sys/t_timerfd.c:1.2 src/tests/lib/libc/sys/t_timerfd.c:1.3
--- src/tests/lib/libc/sys/t_timerfd.c:1.2	Sun Sep 19 15:51:28 2021
+++ src/tests/lib/libc/sys/t_timerfd.c	Mon Nov  1 14:33:41 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: t_timerfd.c,v 1.2 2021/09/19 15:51:28 thorpej Exp $ */
+/* $NetBSD: t_timerfd.c,v 1.3 2021/11/01 14:33:41 hannken Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
 #include 
 __COPYRIGHT("@(#) Copyright (c) 2020\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_timerfd.c,v 1.2 2021/09/19 15:51:28 thorpej Exp $");
+__RCSID("$NetBSD: t_timerfd.c,v 1.3 2021/11/01 14:33:41 hannken Exp $");
 
 #include 
 #include 
@@ -47,6 +47,8 @@ __RCSID("$NetBSD: t_timerfd.c,v 1.2 2021
 
 #include 
 
+#include "isqemu.h"
+
 struct helper_context {
 	int	fd;
 
@@ -70,6 +72,26 @@ wait_barrier(struct helper_context * con
 	return rv == 0 || rv == PTHREAD_BARRIER_SERIAL_THREAD;
 }
 
+static bool
+check_value_against_bounds(uint64_t value, uint64_t lower, uint64_t upper)
+{
+
+	/*
+	 * If running under QEMU make sure the upper bound is large
+	 * enough for the effect of kern/43997
+	 */
+	if (isQEMU()) {
+		upper *= 4;
+	}
+
+	if (value < lower || value > upper) {
+		printf("val %" PRIu64 " not in [ %" PRIu64 ", %" PRIu64 " ]\n",
+		value, lower, upper);
+	}
+
+	return value >= lower && value <= upper;
+}
+
 /*/
 
 static int
@@ -169,10 +191,10 @@ ATF_TC_BODY(timerfd_block, tc)
 	ATF_REQUIRE(timerfd_settime(fd, 0, &its, NULL) == 0);
 	ATF_REQUIRE(timerfd_read(fd, &val) == 0);
 	ATF_REQUIRE(clock_gettime(CLOCK_MONOTONIC, &now) == 0);
-	ATF_REQUIRE(val == 1);
+	ATF_REQUIRE(check_value_against_bounds(val, 1, 1));
 
 	timespecsub(&now, &then, &delta);
-	ATF_REQUIRE(delta.tv_sec == 1);
+	ATF_REQUIRE(check_value_against_bounds(delta.tv_sec, 1, 1));
 
 	(void) close(fd);
 }
@@ -203,10 +225,11 @@ ATF_TC_BODY(timerfd_repeating, tc)
 	ATF_REQUIRE(sleep(1) == 0);
 	ATF_REQUIRE(clock_gettime(CLOCK_MONOTONIC, &now) == 0);
 	ATF_REQUIRE(timerfd_read(fd, &val) == 0);
-	ATF_REQUIRE(val >= 3 && val <= 5);	/* allow some slop */
+	/* allow some slop */
+	ATF_REQUIRE(check_value_against_bounds(val, 3, 5));
 
 	timespecsub(&now, &then, &delta);
-	ATF_REQUIRE(delta.tv_sec == 1);
+	ATF_REQUIRE(check_value_against_bounds(delta.tv_sec, 1, 1));
 
 	(void) close(fd);
 }
@@ -237,10 +260,10 @@ ATF_TC_BODY(timerfd_abstime, tc)
 	ATF_REQUIRE(timerfd_settime(fd, TFD_TIMER_ABSTIME, &its, NULL) == 0);
 	ATF_REQUIRE(timerfd_read(fd, &val) == 0);
 	ATF_REQUIRE(clock_gettime(CLOCK_MONOTONIC, &now) == 0);
-	ATF_REQUIRE(val == 1);
+	ATF_REQUIRE(check_value_against_bounds(val, 1, 1));
 
 	timespecsub(&now, &then, &delta);
-	ATF_REQUIRE(delta.tv_sec == 1);
+	ATF_REQUIRE(check_value_against_bounds(delta.tv_sec, 1, 1));
 
 	(void) close(fd);
 }



CVS commit: src/external/gpl3/gcc/dist/gcc/config

2021-11-07 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun Nov  7 09:22:58 UTC 2021

Modified Files:
src/external/gpl3/gcc/dist/gcc/config: netbsd.h

Log Message:
Libtsan intercepts the pthread exported functions with
dlsym(RTLD_NEXT, func_name).  This fails for pthread_join() as it
is present both as a stub in libc and as real operation in libpthread
and the search order is "libtsan.so libc.so libpthread.so".

Force the order "libtsan.so libpthread.so libc.so" so symbols
get intercepted from libpthread first.

Ok: Matthew Green 


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/external/gpl3/gcc/dist/gcc/config/netbsd.h

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



CVS commit: src/external/gpl3/gcc/dist/gcc/config

2021-11-07 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun Nov  7 09:22:58 UTC 2021

Modified Files:
src/external/gpl3/gcc/dist/gcc/config: netbsd.h

Log Message:
Libtsan intercepts the pthread exported functions with
dlsym(RTLD_NEXT, func_name).  This fails for pthread_join() as it
is present both as a stub in libc and as real operation in libpthread
and the search order is "libtsan.so libc.so libpthread.so".

Force the order "libtsan.so libpthread.so libc.so" so symbols
get intercepted from libpthread first.

Ok: Matthew Green 


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/external/gpl3/gcc/dist/gcc/config/netbsd.h

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

Modified files:

Index: src/external/gpl3/gcc/dist/gcc/config/netbsd.h
diff -u src/external/gpl3/gcc/dist/gcc/config/netbsd.h:1.37 src/external/gpl3/gcc/dist/gcc/config/netbsd.h:1.38
--- src/external/gpl3/gcc/dist/gcc/config/netbsd.h:1.37	Mon Apr 12 00:05:54 2021
+++ src/external/gpl3/gcc/dist/gcc/config/netbsd.h	Sun Nov  7 09:22:58 2021
@@ -203,3 +203,9 @@ along with GCC; see the file COPYING3.  
   do {	\
 netbsd_patch_builtins ();		\
   } while(0)
+
+#if defined(HAVE_LD_STATIC_DYNAMIC)
+#undef LIBTSAN_EARLY_SPEC
+#define LIBTSAN_EARLY_SPEC "%{static-libtsan:" LD_STATIC_OPTION "}"	\
+  " -ltsan %{static-libtsan:" LD_DYNAMIC_OPTION "} -lpthread"
+#endif



CVS commit: src/sys/kern

2021-11-13 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Nov 13 14:52:08 UTC 2021

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

Log Message:
If lookup_fastforward() loses an intermediate searchdir, has to roll
back and retry it must use the initial searchdir from *searchdir_ret
for lookup_parsepath().


To generate a diff of this commit:
cvs rdiff -u -r1.229 -r1.230 src/sys/kern/vfs_lookup.c

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



CVS commit: src/sys/kern

2021-11-13 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Nov 13 14:52:08 UTC 2021

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

Log Message:
If lookup_fastforward() loses an intermediate searchdir, has to roll
back and retry it must use the initial searchdir from *searchdir_ret
for lookup_parsepath().


To generate a diff of this commit:
cvs rdiff -u -r1.229 -r1.230 src/sys/kern/vfs_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/kern/vfs_lookup.c
diff -u src/sys/kern/vfs_lookup.c:1.229 src/sys/kern/vfs_lookup.c:1.230
--- src/sys/kern/vfs_lookup.c:1.229	Tue Jun 29 22:39:21 2021
+++ src/sys/kern/vfs_lookup.c	Sat Nov 13 14:52:08 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_lookup.c,v 1.229 2021/06/29 22:39:21 dholland Exp $	*/
+/*	$NetBSD: vfs_lookup.c,v 1.230 2021/11/13 14:52:08 hannken Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.229 2021/06/29 22:39:21 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.230 2021/11/13 14:52:08 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_magiclinks.h"
@@ -1474,13 +1474,9 @@ lookup_fastforward(struct namei_state *s
 			}
 			cnp->cn_nameptr = oldnameptr;
 			ndp->ni_pathlen = oldpathlen;
-			if (searchdir == NULL) {
+			error = lookup_parsepath(state, *searchdir_ret);
+			if (error == 0) {
 error = EOPNOTSUPP;
-			} else {
-error = lookup_parsepath(state, searchdir);
-if (error == 0) {
-	error = EOPNOTSUPP;
-}
 			}
 		}
 	} else if (plock != NULL) {



CVS commit: src/tests/kernel/kqueue

2021-11-21 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun Nov 21 09:35:39 UTC 2021

Modified Files:
src/tests/kernel/kqueue: Makefile t_timer.c

Log Message:
Test kernel/kqueue/t_timer, subtests abstime, basic_timer and timer_units
often fail when run on QEMU because QEMU misses clock interrupts.

Always check timespec against expected "tv_sec" and use an "4 * tv_sec"
upper bound when run under QEMU.

Now becomes part of PR kern/43997 "Kernel timer discrepancies".


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/kernel/kqueue/Makefile
cvs rdiff -u -r1.3 -r1.4 src/tests/kernel/kqueue/t_timer.c

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



CVS commit: src/tests/kernel/kqueue

2021-11-21 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun Nov 21 09:35:39 UTC 2021

Modified Files:
src/tests/kernel/kqueue: Makefile t_timer.c

Log Message:
Test kernel/kqueue/t_timer, subtests abstime, basic_timer and timer_units
often fail when run on QEMU because QEMU misses clock interrupts.

Always check timespec against expected "tv_sec" and use an "4 * tv_sec"
upper bound when run under QEMU.

Now becomes part of PR kern/43997 "Kernel timer discrepancies".


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/kernel/kqueue/Makefile
cvs rdiff -u -r1.3 -r1.4 src/tests/kernel/kqueue/t_timer.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/kqueue/Makefile
diff -u src/tests/kernel/kqueue/Makefile:1.9 src/tests/kernel/kqueue/Makefile:1.10
--- src/tests/kernel/kqueue/Makefile:1.9	Sat Oct 23 18:46:26 2021
+++ src/tests/kernel/kqueue/Makefile	Sun Nov 21 09:35:39 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.9 2021/10/23 18:46:26 thorpej Exp $
+# $NetBSD: Makefile,v 1.10 2021/11/21 09:35:39 hannken Exp $
 
 WARNS?=6
 NOMAN=		# defined
@@ -24,4 +24,6 @@ TESTS_C+=	t_vnode
 
 LDADD.t_scan+=	-lpthread
 
+CPPFLAGS.t_timer.c+=	-I${.CURDIR}/../../lib/libc/gen
+
 .include 

Index: src/tests/kernel/kqueue/t_timer.c
diff -u src/tests/kernel/kqueue/t_timer.c:1.3 src/tests/kernel/kqueue/t_timer.c:1.4
--- src/tests/kernel/kqueue/t_timer.c:1.3	Fri Oct 22 13:53:20 2021
+++ src/tests/kernel/kqueue/t_timer.c	Sun Nov 21 09:35:39 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: t_timer.c,v 1.3 2021/10/22 13:53:20 thorpej Exp $ */
+/* $NetBSD: t_timer.c,v 1.4 2021/11/21 09:35:39 hannken Exp $ */
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_timer.c,v 1.3 2021/10/22 13:53:20 thorpej Exp $");
+__RCSID("$NetBSD: t_timer.c,v 1.4 2021/11/21 09:35:39 hannken Exp $");
 
 #include 
 #include 
@@ -39,6 +39,36 @@ __RCSID("$NetBSD: t_timer.c,v 1.3 2021/1
 
 #include 
 
+#include "isqemu.h"
+
+static bool
+check_timespec(struct timespec *ts, time_t seconds)
+{
+	time_t upper = seconds;
+	bool result = true;
+
+	/*
+	 * If running under QEMU make sure the upper bound is large
+	 * enough for the effect of kern/43997
+	 */
+	if (isQEMU()) {
+		upper *= 4;
+	}
+
+	if (ts->tv_sec < seconds - 1 ||
+	(ts->tv_sec == seconds - 1 && ts->tv_nsec < 5))
+		result = false;
+	else if (ts->tv_sec > upper ||
+	(ts->tv_sec == upper && ts->tv_nsec >= 5))
+		result = false;
+
+	printf("time %" PRId64 ".%09ld %sin [ %" PRId64 ".5, %" PRId64 ".5 )\n",
+		ts->tv_sec, ts->tv_nsec, (result ? "" : "not "),
+		seconds - 1, upper);
+
+	return result;
+}
+
 ATF_TC(basic_timer);
 ATF_TC_HEAD(basic_timer, tc)
 {
@@ -83,13 +113,8 @@ ATF_TC_BODY(basic_timer, tc)
 ATF_REQUIRE(clock_gettime(CLOCK_MONOTONIC,
 &ts) == 0);
 timespecsub(&ts, &ots, &ts);
-ATF_REQUIRE(ts.tv_sec ==
-	(TIME1_TOTAL_SEC - 1) ||
-ts.tv_sec == TIME1_TOTAL_SEC);
-if (ts.tv_sec == TIME1_TOTAL_SEC - 1) {
-	ATF_REQUIRE(ts.tv_nsec >=
-	9);
-}
+ATF_REQUIRE(check_timespec(&ts,
+TIME1_TOTAL_SEC));
 EV_SET(&event[0], 1, EVFILT_TIMER, EV_DELETE,
 0, 0, NULL);
 ATF_REQUIRE(kevent(kq, event, 1, NULL, 0,
@@ -106,12 +131,7 @@ ATF_TC_BODY(basic_timer, tc)
 			ATF_REQUIRE(clock_gettime(CLOCK_MONOTONIC,
 			&ts) == 0);
 			timespecsub(&ts, &ots, &ts);
-			ATF_REQUIRE(ts.tv_sec ==
-(TIME2_TOTAL_SEC - 1) ||
-			ts.tv_sec == TIME2_TOTAL_SEC);
-			if (ts.tv_sec == TIME2_TOTAL_SEC - 1) {
-ATF_REQUIRE(ts.tv_nsec >= 9);
-			}
+			ATF_REQUIRE(check_timespec(&ts, TIME2_TOTAL_SEC));
 			EV_SET(&event[0], 2, EVFILT_TIMER, EV_DELETE,
 			0, 0, NULL);
 			ATF_REQUIRE_ERRNO(ENOENT,
@@ -130,14 +150,7 @@ ATF_TC_BODY(basic_timer, tc)
 	ATF_REQUIRE(kevent(kq, NULL, 0, event, 1, &ts) == 0);
 	ATF_REQUIRE(clock_gettime(CLOCK_MONOTONIC, &ts) == 0);
 	timespecsub(&ts, &ots, &ts);
-	ATF_REQUIRE(ts.tv_sec == (TIME2_TOTAL_SEC - 1) ||
-	ts.tv_sec == TIME2_TOTAL_SEC ||
-	ts.tv_sec == (TIME2_TOTAL_SEC + 1));
-	if (ts.tv_sec == TIME2_TOTAL_SEC - 1) {
-		ATF_REQUIRE(ts.tv_nsec >= 9);
-	} else if (ts.tv_sec == TIME2_TOTAL_SEC + 1) {
-		ATF_REQUIRE(ts.tv_nsec < 5);
-	}
+	ATF_REQUIRE(check_timespec(&ts, TIME2_TOTAL_SEC));
 }
 
 ATF_TC(count_expirations);
@@ -272,9 +285,6 @@ ATF_TC_BODY(abstime, tc)
 	ATF_REQUIRE(ots.tv_sec < INTPTR_MAX - TIME1_TOTAL_SEC);
 
 	seconds = ots.tv_sec + TIME1_TOTAL_SEC;
-	if (ots.tv_nsec >= 5) {
-		seconds++;
-	}
 
 	EV_SET(&event[0], 1, EVFILT_TIMER, EV_ADD,
 	NOTE_ABSTIME | NOTE_SECONDS, seconds, NULL);
@@ -287,10 +297,7 @@ ATF_TC_BODY(abstime, tc)
 	 * We're not going for precision here; just verify that it was
 	 * delivered anywhere between 4.5-6.whatever seconds later.
 	 */
-	ATF_REQUIRE(ts.tv_sec >= 4 && ts.tv_sec <= 6);
-	if (ts.tv_sec == 4) 

CVS commit: src/tests/net

2021-11-25 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Nov 25 14:17:22 UTC 2021

Modified Files:
src/tests/net: net_common.sh
src/tests/net/mpls: t_ldp_regen.sh
src/tests/net/net: t_ipv6_lifetime.sh

Log Message:
Consistently use "drvctl -l qemufwcfg0" to check if
running under qemu in general.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/tests/net/net_common.sh
cvs rdiff -u -r1.10 -r1.11 src/tests/net/mpls/t_ldp_regen.sh
cvs rdiff -u -r1.6 -r1.7 src/tests/net/net/t_ipv6_lifetime.sh

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



CVS commit: src/tests/net

2021-11-25 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Nov 25 14:17:22 UTC 2021

Modified Files:
src/tests/net: net_common.sh
src/tests/net/mpls: t_ldp_regen.sh
src/tests/net/net: t_ipv6_lifetime.sh

Log Message:
Consistently use "drvctl -l qemufwcfg0" to check if
running under qemu in general.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/tests/net/net_common.sh
cvs rdiff -u -r1.10 -r1.11 src/tests/net/mpls/t_ldp_regen.sh
cvs rdiff -u -r1.6 -r1.7 src/tests/net/net/t_ipv6_lifetime.sh

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

Modified files:

Index: src/tests/net/net_common.sh
diff -u src/tests/net/net_common.sh:1.42 src/tests/net/net_common.sh:1.43
--- src/tests/net/net_common.sh:1.42	Fri Jul  9 05:54:11 2021
+++ src/tests/net/net_common.sh	Thu Nov 25 14:17:22 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: net_common.sh,v 1.42 2021/07/09 05:54:11 yamaguchi Exp $
+#	$NetBSD: net_common.sh,v 1.43 2021/11/25 14:17:22 hannken Exp $
 #
 # Copyright (c) 2016 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -537,7 +537,7 @@ dump()
 
 skip_if_qemu()
 {
-	if sysctl machdep.cpu_brand 2>/dev/null | grep QEMU >/dev/null 2>&1
+	if drvctl -l qemufwcfg0 >/dev/null 2>&1
 	then
 	atf_skip "unreliable under qemu, skip until PR kern/43997 fixed"
 	fi

Index: src/tests/net/mpls/t_ldp_regen.sh
diff -u src/tests/net/mpls/t_ldp_regen.sh:1.10 src/tests/net/mpls/t_ldp_regen.sh:1.11
--- src/tests/net/mpls/t_ldp_regen.sh:1.10	Wed Apr  1 01:51:02 2020
+++ src/tests/net/mpls/t_ldp_regen.sh	Thu Nov 25 14:17:22 2021
@@ -1,4 +1,4 @@
-# $NetBSD: t_ldp_regen.sh,v 1.10 2020/04/01 01:51:02 christos Exp $
+# $NetBSD: t_ldp_regen.sh,v 1.11 2021/11/25 14:17:22 hannken Exp $
 #
 # Copyright (c) 2013 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -139,7 +139,7 @@ wait_ldp_ok() {
 
 ldp_regen_body() {
 
-if sysctl machdep.cpu_brand 2>/dev/null | grep QEMU >/dev/null 2>&1
+	if drvctl -l qemufwcfg0 >/dev/null 2>&1
 	then
 	atf_skip "unreliable under qemu, skip until PR kern/43997 fixed"
 	fi

Index: src/tests/net/net/t_ipv6_lifetime.sh
diff -u src/tests/net/net/t_ipv6_lifetime.sh:1.6 src/tests/net/net/t_ipv6_lifetime.sh:1.7
--- src/tests/net/net/t_ipv6_lifetime.sh:1.6	Fri Nov 25 08:51:17 2016
+++ src/tests/net/net/t_ipv6_lifetime.sh	Thu Nov 25 14:17:22 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: t_ipv6_lifetime.sh,v 1.6 2016/11/25 08:51:17 ozaki-r Exp $
+#	$NetBSD: t_ipv6_lifetime.sh,v 1.7 2021/11/25 14:17:22 hannken Exp $
 #
 # Copyright (c) 2015 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -97,7 +97,7 @@ basic_body()
 	atf_check -s exit:0 -o match:'pltime' rump.ifconfig -L shmif0
 	atf_check -s exit:0 -o match:'vltime' rump.ifconfig -L shmif0
 
-	if sysctl machdep.cpu_brand 2>/dev/null | grep QEMU >/dev/null 2>&1
+	if drvctl -l qemufwcfg0 >/dev/null 2>&1
 	then
 		atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip delete
 		atf_skip "unreliable under qemu, skip until PR kern/43997 fixed"



CVS commit: src/sys/fs/union

2021-12-05 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun Dec  5 16:16:58 UTC 2021

Modified Files:
src/sys/fs/union: union_vnops.c

Log Message:
In union_access() copy up regular files before checking permissions.

Unionfs is meant to provide a writable layer above a read-only layer
and should not fail here just because the lower layer is mounted
read-only.


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

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



CVS commit: src/sys/fs/union

2021-12-05 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun Dec  5 16:16:58 UTC 2021

Modified Files:
src/sys/fs/union: union_vnops.c

Log Message:
In union_access() copy up regular files before checking permissions.

Unionfs is meant to provide a writable layer above a read-only layer
and should not fail here just because the lower layer is mounted
read-only.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/fs/union/union_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/union/union_vnops.c
diff -u src/sys/fs/union/union_vnops.c:1.79 src/sys/fs/union/union_vnops.c:1.80
--- src/sys/fs/union/union_vnops.c:1.79	Wed Oct 20 03:08:17 2021
+++ src/sys/fs/union/union_vnops.c	Sun Dec  5 16:16:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: union_vnops.c,v 1.79 2021/10/20 03:08:17 thorpej Exp $	*/
+/*	$NetBSD: union_vnops.c,v 1.80 2021/12/05 16:16:58 hannken Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993, 1994, 1995
@@ -72,7 +72,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: union_vnops.c,v 1.79 2021/10/20 03:08:17 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: union_vnops.c,v 1.80 2021/12/05 16:16:58 hannken Exp $");
 
 #include 
 #include 
@@ -771,6 +771,13 @@ union_access(void *v)
 		}
 	}
 
+	if (un->un_uppervp == NULLVP &&
+	(un->un_lowervp->v_type == VREG) &&
+	(ap->a_accmode & VWRITE)) {
+		error = union_copyup(un, 1, ap->a_cred, curlwp);
+		if (error)
+			return error;
+	}
 
 	if ((vp = un->un_uppervp) != NULLVP) {
 		ap->a_vp = vp;



CVS commit: src/sys/fs/union

2021-12-10 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Dec 10 09:20:38 UTC 2021

Modified Files:
src/sys/fs/union: union_vnops.c

Log Message:
Fix previous, don't copy up if the underlying node is unreadable.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sys/fs/union/union_vnops.c

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



CVS commit: src/sys/fs/union

2021-12-10 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Dec 10 09:20:38 UTC 2021

Modified Files:
src/sys/fs/union: union_vnops.c

Log Message:
Fix previous, don't copy up if the underlying node is unreadable.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sys/fs/union/union_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/union/union_vnops.c
diff -u src/sys/fs/union/union_vnops.c:1.80 src/sys/fs/union/union_vnops.c:1.81
--- src/sys/fs/union/union_vnops.c:1.80	Sun Dec  5 16:16:58 2021
+++ src/sys/fs/union/union_vnops.c	Fri Dec 10 09:20:38 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: union_vnops.c,v 1.80 2021/12/05 16:16:58 hannken Exp $	*/
+/*	$NetBSD: union_vnops.c,v 1.81 2021/12/10 09:20:38 hannken Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993, 1994, 1995
@@ -72,7 +72,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: union_vnops.c,v 1.80 2021/12/05 16:16:58 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: union_vnops.c,v 1.81 2021/12/10 09:20:38 hannken Exp $");
 
 #include 
 #include 
@@ -771,10 +771,20 @@ union_access(void *v)
 		}
 	}
 
+	/*
+	 * Copy up to prevent checking (and failing) against
+	 * underlying file system mounted read only.
+	 * Check for read access first to prevent implicit
+	 * copy of unaccessible underlying vnode.
+	 */
 	if (un->un_uppervp == NULLVP &&
 	(un->un_lowervp->v_type == VREG) &&
 	(ap->a_accmode & VWRITE)) {
-		error = union_copyup(un, 1, ap->a_cred, curlwp);
+		vn_lock(un->un_lowervp, LK_EXCLUSIVE | LK_RETRY);
+		error = VOP_ACCESS(un->un_lowervp, VREAD, ap->a_cred);
+		VOP_UNLOCK(un->un_lowervp);
+		if (error == 0)
+			error = union_copyup(un, 1, ap->a_cred, curlwp);
 		if (error)
 			return error;
 	}



CVS commit: src/sys/kern

2019-10-11 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Oct 11 08:04:52 UTC 2019

Modified Files:
src/sys/kern: vnode_if.sh vnode_if.src

Log Message:
As VOP_STRATEGY() usually calls itself on the file system holding "/dev"
it may deadlock on suspension of this file system.

Add fstrans type LAZY and use it for VOP_STRATEGY().

Adress PR kern/53624 (dom0 freeze on domU exit) is still there


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/kern/vnode_if.sh
cvs rdiff -u -r1.77 -r1.78 src/sys/kern/vnode_if.src

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/vnode_if.sh
diff -u src/sys/kern/vnode_if.sh:1.66 src/sys/kern/vnode_if.sh:1.67
--- src/sys/kern/vnode_if.sh:1.66	Sun Jun  4 08:03:26 2017
+++ src/sys/kern/vnode_if.sh	Fri Oct 11 08:04:52 2019
@@ -29,7 +29,7 @@ copyright="\
  * SUCH DAMAGE.
  */
 "
-SCRIPT_ID='$NetBSD: vnode_if.sh,v 1.66 2017/06/04 08:03:26 hannken Exp $'
+SCRIPT_ID='$NetBSD: vnode_if.sh,v 1.67 2019/10/11 08:04:52 hannken Exp $'
 
 # Script to produce VFS front-end sugar.
 #
@@ -318,7 +318,7 @@ echo '
 
 if [ -z "${rump}" ] ; then
 	echo "
-enum fst_op { FST_NO, FST_YES, FST_TRY };
+enum fst_op { FST_NO, FST_YES, FST_LAZY, FST_TRY };
 
 static inline int
 vop_pre(vnode_t *vp, struct mount **mp, bool *mpsafe, enum fst_op op)
@@ -331,7 +331,7 @@ vop_pre(vnode_t *vp, struct mount **mp, 
 		KERNEL_LOCK(1, curlwp);
 	}
 
-	if (op == FST_YES || op == FST_TRY) {
+	if (op == FST_YES || op == FST_LAZY || op == FST_TRY) {
 		for (;;) {
 			*mp = vp->v_mount;
 			if (op == FST_TRY) {
@@ -342,6 +342,8 @@ vop_pre(vnode_t *vp, struct mount **mp, 
 	}
 	return error;
 }
+			} else if (op == FST_LAZY) {
+fstrans_start_lazy(*mp);
 			} else {
 fstrans_start(*mp);
 			}
@@ -360,7 +362,7 @@ static inline void
 vop_post(vnode_t *vp, struct mount *mp, bool mpsafe, enum fst_op op)
 {
 
-	if (op == FST_YES) {
+	if (op == FST_YES || op == FST_LAZY) {
 		fstrans_done(mp);
 	}
 

Index: src/sys/kern/vnode_if.src
diff -u src/sys/kern/vnode_if.src:1.77 src/sys/kern/vnode_if.src:1.78
--- src/sys/kern/vnode_if.src:1.77	Wed Jul 12 09:31:07 2017
+++ src/sys/kern/vnode_if.src	Fri Oct 11 08:04:52 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: vnode_if.src,v 1.77 2017/07/12 09:31:07 hannken Exp $
+#	$NetBSD: vnode_if.src,v 1.78 2019/10/11 08:04:52 hannken Exp $
 #
 # Copyright (c) 1992, 1993
 #	The Regents of the University of California.  All rights reserved.
@@ -436,6 +436,7 @@ vop_bmap {
 #% strategy   vp  = = =
 #
 vop_strategy {
+	FSTRANS=LAZY
 	IN struct vnode *vp;
 	IN struct buf *bp;
 };



CVS commit: src/sys/kern

2019-10-11 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Oct 11 08:04:52 UTC 2019

Modified Files:
src/sys/kern: vnode_if.sh vnode_if.src

Log Message:
As VOP_STRATEGY() usually calls itself on the file system holding "/dev"
it may deadlock on suspension of this file system.

Add fstrans type LAZY and use it for VOP_STRATEGY().

Adress PR kern/53624 (dom0 freeze on domU exit) is still there


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/kern/vnode_if.sh
cvs rdiff -u -r1.77 -r1.78 src/sys/kern/vnode_if.src

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



CVS commit: src/sys/kern

2019-10-11 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Oct 11 08:05:19 UTC 2019

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

Log Message:
Regen.


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/sys/kern/vnode_if.c

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



CVS commit: src/sys/kern

2019-10-11 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Oct 11 08:05:19 UTC 2019

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

Log Message:
Regen.


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/sys/kern/vnode_if.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/vnode_if.c
diff -u src/sys/kern/vnode_if.c:1.107 src/sys/kern/vnode_if.c:1.108
--- src/sys/kern/vnode_if.c:1.107	Wed Jul 12 09:31:59 2017
+++ src/sys/kern/vnode_if.c	Fri Oct 11 08:05:19 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: vnode_if.c,v 1.107 2017/07/12 09:31:59 hannken Exp $	*/
+/*	$NetBSD: vnode_if.c,v 1.108 2019/10/11 08:05:19 hannken Exp $	*/
 
 /*
  * Warning: DO NOT EDIT! This file is automatically generated!
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vnode_if.c,v 1.107 2017/07/12 09:31:59 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vnode_if.c,v 1.108 2019/10/11 08:05:19 hannken Exp $");
 
 #include 
 #include 
@@ -49,7 +49,7 @@ __KERNEL_RCSID(0, "$NetBSD: vnode_if.c,v
 #include 
 #include 
 
-enum fst_op { FST_NO, FST_YES, FST_TRY };
+enum fst_op { FST_NO, FST_YES, FST_LAZY, FST_TRY };
 
 static inline int
 vop_pre(vnode_t *vp, struct mount **mp, bool *mpsafe, enum fst_op op)
@@ -62,7 +62,7 @@ vop_pre(vnode_t *vp, struct mount **mp, 
 		KERNEL_LOCK(1, curlwp);
 	}
 
-	if (op == FST_YES || op == FST_TRY) {
+	if (op == FST_YES || op == FST_LAZY || op == FST_TRY) {
 		for (;;) {
 			*mp = vp->v_mount;
 			if (op == FST_TRY) {
@@ -73,6 +73,8 @@ vop_pre(vnode_t *vp, struct mount **mp, 
 	}
 	return error;
 }
+			} else if (op == FST_LAZY) {
+fstrans_start_lazy(*mp);
 			} else {
 fstrans_start(*mp);
 			}
@@ -91,7 +93,7 @@ static inline void
 vop_post(vnode_t *vp, struct mount *mp, bool mpsafe, enum fst_op op)
 {
 
-	if (op == FST_YES) {
+	if (op == FST_YES || op == FST_LAZY) {
 		fstrans_done(mp);
 	}
 
@@ -1378,11 +1380,11 @@ VOP_STRATEGY(struct vnode *vp,
 	a.a_desc = VDESC(vop_strategy);
 	a.a_vp = vp;
 	a.a_bp = bp;
-	error = vop_pre(vp, &mp, &mpsafe, FST_YES);
+	error = vop_pre(vp, &mp, &mpsafe, FST_LAZY);
 	if (error)
 		return error;
 	error = (VCALL(vp, VOFFSET(vop_strategy), &a));
-	vop_post(vp, mp, mpsafe, FST_YES);
+	vop_post(vp, mp, mpsafe, FST_LAZY);
 	return error;
 }
 



CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs

2019-10-14 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Oct 14 13:18:00 UTC 2019

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: dmu_diff.c zfs_ioctl.c
src/external/cddl/osnet/dist/uts/common/fs/zfs/sys: dmu.h

Log Message:
Change dmu_diff() back to use a "file" instead of a "vnode".
Command "zfs diff" calls it with a pipe, not a plain file.

Fixes PR kern/54541: kernel panic using "zfs diff"


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_diff.c
cvs rdiff -u -r1.20 -r1.21 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c
cvs rdiff -u -r1.3 -r1.4 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/dmu.h

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

Modified files:

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_diff.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_diff.c:1.2 src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_diff.c:1.3
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_diff.c:1.2	Mon May 28 21:05:07 2018
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_diff.c	Mon Oct 14 13:18:00 2019
@@ -43,16 +43,13 @@
 struct diffarg {
 #ifdef __FreeBSD__
 	kthread_t *da_td;
-	struct file *da_fp;		/* file to which we are reporting */
-#else
-	struct vnode *da_vp;		/* file to which we are reporting */
 #endif
+	struct file *da_fp;		/* file to which we are reporting */
 	offset_t *da_offp;
 	int da_err;			/* error that stopped diff search */
 	dmu_diff_record_t da_ddr;
 };
 
-#ifdef __FreeBSD__
 static int
 write_bytes(struct diffarg *da)
 {
@@ -66,18 +63,30 @@ write_bytes(struct diffarg *da)
 	auio.uio_resid = aiov.iov_len;
 	auio.uio_rw = UIO_WRITE;
 	auio.uio_offset = (off_t)-1;
+#ifdef __FreeBSD__
 	auio.uio_segflg = UIO_SYSSPACE;
 	auio.uio_td = da->da_td;
+#else
+	auio.uio_vmspace = vmspace_kernel();
+#endif /* __FreeBSD__ */
 #ifdef _KERNEL
+#ifdef __FreeBSD__
 	if (da->da_fp->f_type == DTYPE_VNODE)
 		bwillwrite();
 	return (fo_write(da->da_fp, &auio, da->da_td->td_ucred, 0, da->da_td));
 #else
+	int flags = 0;
+
+	if (da->da_fp->f_type == DTYPE_VNODE)
+		flags |= FOF_UPDATE_OFFSET;
+	return (*da->da_fp->f_ops->fo_write)(da->da_fp, &da->da_fp->f_offset,
+	&auio, da->da_fp->f_cred, flags);
+#endif /* __FreeBSD__ */
+#else
 	fprintf(stderr, "%s: returning EOPNOTSUPP\n", __func__);
 	return (EOPNOTSUPP);
 #endif
 }
-#endif /* __FreeBSD__ */
 
 static int
 write_record(struct diffarg *da)
@@ -89,13 +98,7 @@ write_record(struct diffarg *da)
 		return (0);
 	}
 
-#ifdef __FreeBSD__
 	da->da_err = write_bytes(da);
-#else
-	da->da_err = vn_rdwr(UIO_WRITE, da->da_vp, (caddr_t)&da->da_ddr,
-	sizeof (da->da_ddr), 0, UIO_SYSSPACE, FAPPEND,
-	RLIM64_INFINITY, CRED(), &resid);
-#endif
 	*da->da_offp += sizeof (da->da_ddr);
 	return (da->da_err);
 }
@@ -193,11 +196,7 @@ diff_cb(spa_t *spa, zilog_t *zilog, cons
 
 int
 dmu_diff(const char *tosnap_name, const char *fromsnap_name,
-#ifdef __FreeBSD__
 struct file *fp, offset_t *offp)
-#else
-struct vnode *vp, offset_t *offp)
-#endif
 {
 	struct diffarg da;
 	dsl_dataset_t *fromsnap;
@@ -242,10 +241,8 @@ dmu_diff(const char *tosnap_name, const 
 
 #ifdef __FreeBSD__
 	da.da_td = curthread;
-	da.da_fp = fp;
-#else
-	da.da_vp = vp;
 #endif
+	da.da_fp = fp;
 	da.da_offp = offp;
 	da.da_ddr.ddr_type = DDR_NONE;
 	da.da_ddr.ddr_first = da.da_ddr.ddr_last = 0;

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c:1.20 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c:1.21
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c:1.20	Wed May 22 08:46:27 2019
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c	Mon Oct 14 13:18:00 2019
@@ -5296,11 +5296,7 @@ zfs_ioc_diff(zfs_cmd_t *zc)
 
 	off = fp->f_offset;
 
-#ifdef __FreeBSD__
 	error = dmu_diff(zc->zc_name, zc->zc_value, fp, &off);
-#else
-	error = dmu_diff(zc->zc_name, zc->zc_value, fp->f_vnode, &off);
-#endif
 
 	if (off >= 0 && off <= MAXOFFSET_T)
 		fp->f_offset = off;

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/dmu.h
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/dmu.h:1.3 src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/dmu.h:1.4
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/dmu.h:1.3	Mon May 28 21:05:07 2018
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/dmu.h	Mon Oct 14 13:18:00 2019
@@ -957,13 +957,8 @@ typedef void (*dmu_traverse_cb_t)(objset
 void dmu_traverse_objset(objset_t *os, uint64_t txg_start,
 dmu_traverse_cb_t cb, void *arg);
 
-#ifdef __FreeBSD__
 int dmu_diff(const char *tosnap_name, const char *fromsnap_name,
 struct file *fp, offset_t *offp);
-#else
-int dmu_diff(const char *tosnap_name, const char *fromsnap_name,
-struct vnode *vp, offset_t *offp);
-#endif
 
 /* CRC64 table */
 #define	ZF

CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs

2019-10-14 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Oct 14 13:18:00 UTC 2019

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: dmu_diff.c zfs_ioctl.c
src/external/cddl/osnet/dist/uts/common/fs/zfs/sys: dmu.h

Log Message:
Change dmu_diff() back to use a "file" instead of a "vnode".
Command "zfs diff" calls it with a pipe, not a plain file.

Fixes PR kern/54541: kernel panic using "zfs diff"


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_diff.c
cvs rdiff -u -r1.20 -r1.21 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c
cvs rdiff -u -r1.3 -r1.4 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/dmu.h

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



CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs

2019-10-14 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Oct 15 06:58:13 UTC 2019

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: dmu_diff.c

Log Message:
Add missing "#ifdef _KERNEL" to fix the build of userland zfs libraries.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_diff.c

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

Modified files:

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_diff.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_diff.c:1.3 src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_diff.c:1.4
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_diff.c:1.3	Mon Oct 14 13:18:00 2019
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_diff.c	Tue Oct 15 06:58:12 2019
@@ -67,7 +67,9 @@ write_bytes(struct diffarg *da)
 	auio.uio_segflg = UIO_SYSSPACE;
 	auio.uio_td = da->da_td;
 #else
+#ifdef _KERNEL
 	auio.uio_vmspace = vmspace_kernel();
+#endif
 #endif /* __FreeBSD__ */
 #ifdef _KERNEL
 #ifdef __FreeBSD__



CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs

2019-10-14 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Oct 15 06:58:13 UTC 2019

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: dmu_diff.c

Log Message:
Add missing "#ifdef _KERNEL" to fix the build of userland zfs libraries.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_diff.c

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



CVS commit: src/sys/fs/ntfs

2019-10-18 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Oct 18 08:18:40 UTC 2019

Modified Files:
src/sys/fs/ntfs: ntfs_vfsops.c

Log Message:
It is not possible to call vflush() from xxx_mount().

Replace with a vnode iterator and use vrecycle().


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/sys/fs/ntfs/ntfs_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/fs/ntfs/ntfs_vfsops.c
diff -u src/sys/fs/ntfs/ntfs_vfsops.c:1.107 src/sys/fs/ntfs/ntfs_vfsops.c:1.108
--- src/sys/fs/ntfs/ntfs_vfsops.c:1.107	Mon Apr 17 08:32:00 2017
+++ src/sys/fs/ntfs/ntfs_vfsops.c	Fri Oct 18 08:18:40 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ntfs_vfsops.c,v 1.107 2017/04/17 08:32:00 hannken Exp $	*/
+/*	$NetBSD: ntfs_vfsops.c,v 1.108 2019/10/18 08:18:40 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999 Semen Ustimenko
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ntfs_vfsops.c,v 1.107 2017/04/17 08:32:00 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ntfs_vfsops.c,v 1.108 2019/10/18 08:18:40 hannken Exp $");
 
 #include 
 #include 
@@ -322,6 +322,7 @@ ntfs_mountfs(struct vnode *devvp, struct
 	dev_t dev = devvp->v_rdev;
 	int error, i;
 	struct vnode *vp;
+	struct vnode_iterator *marker;
 
 	ntmp = NULL;
 
@@ -471,9 +472,13 @@ out1:
 		if (ntmp->ntm_sysvn[i])
 			vrele(ntmp->ntm_sysvn[i]);
 
-	if (vflush(mp, NULLVP, 0)) {
-		dprintf(("ntfs_mountfs: vflush failed\n"));
+	vfs_vnode_iterator_init(mp, &marker);
+	while ((vp = vfs_vnode_iterator_next(marker, NULL, NULL))) {
+		if (vrecycle(vp))
+			continue;
+		panic("%s: cannot recycle vnode %p", __func__, vp);
 	}
+	vfs_vnode_iterator_destroy(marker);
 out:
 	spec_node_setmountedfs(devvp, NULL);
 	if (bp)



CVS commit: src/sys/fs/ntfs

2019-10-18 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Oct 18 08:18:40 UTC 2019

Modified Files:
src/sys/fs/ntfs: ntfs_vfsops.c

Log Message:
It is not possible to call vflush() from xxx_mount().

Replace with a vnode iterator and use vrecycle().


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/sys/fs/ntfs/ntfs_vfsops.c

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



CVS commit: src/sys/fs/ntfs

2019-10-18 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Oct 18 08:19:33 UTC 2019

Modified Files:
src/sys/fs/ntfs: ntfs_subr.c

Log Message:
When the MFT record size is lower than the cluster size we have
to read consecutive clusters to fill the MFT record.

Should fix PR kern/54598: mount ntfs panic


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/fs/ntfs/ntfs_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/fs/ntfs/ntfs_subr.c
diff -u src/sys/fs/ntfs/ntfs_subr.c:1.61 src/sys/fs/ntfs/ntfs_subr.c:1.62
--- src/sys/fs/ntfs/ntfs_subr.c:1.61	Sat Mar 28 19:24:05 2015
+++ src/sys/fs/ntfs/ntfs_subr.c	Fri Oct 18 08:19:33 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ntfs_subr.c,v 1.61 2015/03/28 19:24:05 maxv Exp $	*/
+/*	$NetBSD: ntfs_subr.c,v 1.62 2019/10/18 08:19:33 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999 Semen Ustimenko (sem...@freebsd.org)
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ntfs_subr.c,v 1.61 2015/03/28 19:24:05 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ntfs_subr.c,v 1.62 2019/10/18 08:19:33 hannken Exp $");
 
 #include 
 #include 
@@ -271,6 +271,8 @@ ntfs_loadntnode(struct ntfsmount *ntmp, 
 		struct buf *bp;
 		daddr_t bn;
 		off_t boff;
+		size_t resid, l;
+		char *data;
 
 		dprintf(("%s: read system node\n", __func__));
 
@@ -281,17 +283,26 @@ ntfs_loadntnode(struct ntfsmount *ntmp, 
 		boff = ntfs_cntob(ntmp->ntm_mftcn) +
 		ntfs_bntob(ntmp->ntm_bpmftrec) * ip->i_number;
 		bn = ntfs_cntobn(ntfs_btocn(boff));
-		off = ntfs_btocnoff(boff);
+		boff = ntfs_btocnoff(boff);
+		resid = ntfs_bntob(ntmp->ntm_bpmftrec);
+		data = (char *)mfrp;
+		while (resid > 0) {
+			l = MIN(resid, ntfs_cntob(1) - boff);
+
+			error = bread(ntmp->ntm_devvp, bn, ntfs_cntob(1),
+			0, &bp);
+			if (error) {
+printf("%s: BREAD FAILED\n", __func__);
+goto out;
+			}
+			memcpy(data, (char *)bp->b_data + boff, l);
+			bqrelse(bp);
 
-		error = bread(ntmp->ntm_devvp, bn, ntfs_cntob(1),
-		0, &bp);
-		if (error) {
-			printf("%s: BREAD FAILED\n", __func__);
-			goto out;
+			bn += ntfs_cntobn(1);
+			boff = 0;
+			data += l;
+			resid -= l;
 		}
-		memcpy(mfrp, (char *)bp->b_data + off,
-		ntfs_bntob(ntmp->ntm_bpmftrec));
-		bqrelse(bp);
 	} else {
 		struct vnode   *vp;
 



CVS commit: src/sys/fs/ntfs

2019-10-18 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Oct 18 08:19:33 UTC 2019

Modified Files:
src/sys/fs/ntfs: ntfs_subr.c

Log Message:
When the MFT record size is lower than the cluster size we have
to read consecutive clusters to fill the MFT record.

Should fix PR kern/54598: mount ntfs panic


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/fs/ntfs/ntfs_subr.c

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



CVS commit: src/sys/arch/x86/x86

2019-10-18 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Oct 18 14:59:22 UTC 2019

Modified Files:
src/sys/arch/x86/x86: multiboot2.c

Log Message:
Make compile with "options DEBUG".


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

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



CVS commit: src/sys/arch/x86/x86

2019-10-18 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Oct 18 14:59:22 UTC 2019

Modified Files:
src/sys/arch/x86/x86: multiboot2.c

Log Message:
Make compile with "options DEBUG".


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/x86/x86/multiboot2.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/x86/x86/multiboot2.c
diff -u src/sys/arch/x86/x86/multiboot2.c:1.1 src/sys/arch/x86/x86/multiboot2.c:1.2
--- src/sys/arch/x86/x86/multiboot2.c:1.1	Fri Oct 18 01:38:28 2019
+++ src/sys/arch/x86/x86/multiboot2.c	Fri Oct 18 14:59:22 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: multiboot2.c,v 1.1 2019/10/18 01:38:28 manu Exp $	*/
+/*	$NetBSD: multiboot2.c,v 1.2 2019/10/18 14:59:22 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: multiboot2.c,v 1.1 2019/10/18 01:38:28 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: multiboot2.c,v 1.2 2019/10/18 14:59:22 hannken Exp $");
 
 #include "opt_multiboot.h"
 
@@ -784,6 +784,9 @@ multiboot2_print_info(void)
 	char *cp;
 	uint32_t total_size;
 	uint32_t reserved;
+#ifdef DEBUG
+	int i = 0;
+#endif
 
 	if (multiboot2_enabled == false)
 		goto out;



CVS commit: src/sys/arch/i386/pci

2019-10-18 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Oct 18 15:00:15 UTC 2019

Modified Files:
src/sys/arch/i386/pci: piixpcib.c

Log Message:
Add missing include -- kernel ALL/i386 compiles.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/i386/pci/piixpcib.c

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



CVS commit: src/sys/arch/i386/pci

2019-10-18 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Oct 18 15:00:15 UTC 2019

Modified Files:
src/sys/arch/i386/pci: piixpcib.c

Log Message:
Add missing include -- kernel ALL/i386 compiles.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/i386/pci/piixpcib.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/i386/pci/piixpcib.c
diff -u src/sys/arch/i386/pci/piixpcib.c:1.23 src/sys/arch/i386/pci/piixpcib.c:1.24
--- src/sys/arch/i386/pci/piixpcib.c:1.23	Fri Oct 18 01:00:25 2019
+++ src/sys/arch/i386/pci/piixpcib.c	Fri Oct 18 15:00:15 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: piixpcib.c,v 1.23 2019/10/18 01:00:25 manu Exp $ */
+/* $NetBSD: piixpcib.c,v 1.24 2019/10/18 15:00:15 hannken Exp $ */
 
 /*-
  * Copyright (c) 2004, 2006 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: piixpcib.c,v 1.23 2019/10/18 01:00:25 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: piixpcib.c,v 1.24 2019/10/18 15:00:15 hannken Exp $");
 
 #include 
 #include 
@@ -47,6 +47,7 @@ __KERNEL_RCSID(0, "$NetBSD: piixpcib.c,v
 
 #include 
 #include 
+#include 
 
 #include 
 #include 



CVS commit: src/usr.sbin/syslogd

2019-10-24 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Oct 24 08:21:18 UTC 2019

Modified Files:
src/usr.sbin/syslogd: tls.c

Log Message:
With TLSv1.3 a client has to receive and process metadata.

Update dispatch_tls_eof() to check for metadata and
rearm on success.

Ok: christos@


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/usr.sbin/syslogd/tls.c

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



CVS commit: src/usr.sbin/syslogd

2019-10-24 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Oct 24 08:21:18 UTC 2019

Modified Files:
src/usr.sbin/syslogd: tls.c

Log Message:
With TLSv1.3 a client has to receive and process metadata.

Update dispatch_tls_eof() to check for metadata and
rearm on success.

Ok: christos@


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/usr.sbin/syslogd/tls.c

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

Modified files:

Index: src/usr.sbin/syslogd/tls.c
diff -u src/usr.sbin/syslogd/tls.c:1.16 src/usr.sbin/syslogd/tls.c:1.17
--- src/usr.sbin/syslogd/tls.c:1.16	Thu Feb  8 17:45:29 2018
+++ src/usr.sbin/syslogd/tls.c	Thu Oct 24 08:21:18 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: tls.c,v 1.16 2018/02/08 17:45:29 christos Exp $	*/
+/*	$NetBSD: tls.c,v 1.17 2019/10/24 08:21:18 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -45,7 +45,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: tls.c,v 1.16 2018/02/08 17:45:29 christos Exp $");
+__RCSID("$NetBSD: tls.c,v 1.17 2019/10/24 08:21:18 hannken Exp $");
 
 #ifndef DISABLE_TLS
 #include 
@@ -1450,7 +1450,7 @@ dispatch_socket_accept(int fd, short eve
  *
  * I do not know if libevent can tell us the difference
  * between available data and an EOF. But it does not matter
- * because there should not be any incoming data.
+ * because there should not be any incoming data beside metadata.
  * So we close the connection either because the peer closed its
  * side or because the peer broke the protocol by sending us stuff  ;-)
  */
@@ -1460,11 +1460,26 @@ dispatch_tls_eof(int fd, short event, vo
 	struct tls_conn_settings *conn_info = (struct tls_conn_settings *) arg;
 	sigset_t newmask, omask;
 	struct timeval tv;
+	int rc;
+	char buf[1];
 
 	BLOCK_SIGNALS(omask, newmask);
 	DPRINTF((D_TLS|D_EVENT|D_CALL), "dispatch_eof_tls(%d, %d, %p)\n",
 	fd, event, arg);
 	assert(conn_info->state == ST_TLS_EST);
+
+	/* First check for incoming metadata. */
+	ST_CHANGE(conn_info->state, ST_READING);
+	rc = SSL_read(conn_info->sslptr, buf, sizeof(buf));
+	ST_CHANGE(conn_info->state, ST_TLS_EST);
+	if (rc <= 0 && tls_examine_error("SSL_read()", conn_info->sslptr,
+	conn_info, rc) == TLS_RETRY_READ) {
+		/* Connection is still alive, rearm and return. */
+		EVENT_ADD(conn_info->event);
+		RESTORE_SIGNALS(omask);
+		return;
+	}
+
 	ST_CHANGE(conn_info->state, ST_EOF);
 	DEL_EVENT(conn_info->event);
 



CVS commit: src/external/cddl/osnet/dev/dtrace/amd64

2019-11-08 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Nov  8 11:06:21 UTC 2019

Modified Files:
src/external/cddl/osnet/dev/dtrace/amd64: dtrace_subr.c

Log Message:
dtrace_trap() gets called from alltraps() -> trap() with interrupts enabled
so we cannot assert for interrupts disabled here.

Should fix PR kern/54603: kernel panic when running dtruss


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 \
src/external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c

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



CVS commit: src/external/cddl/osnet/dev/dtrace/amd64

2019-11-08 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Nov  8 11:06:21 UTC 2019

Modified Files:
src/external/cddl/osnet/dev/dtrace/amd64: dtrace_subr.c

Log Message:
dtrace_trap() gets called from alltraps() -> trap() with interrupts enabled
so we cannot assert for interrupts disabled here.

Should fix PR kern/54603: kernel panic when running dtruss


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 \
src/external/cddl/osnet/dev/dtrace/amd64/dtrace_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/external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c
diff -u src/external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c:1.13 src/external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c:1.14
--- src/external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c:1.13	Fri Jul  5 08:29:18 2019
+++ src/external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c	Fri Nov  8 11:06:21 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: dtrace_subr.c,v 1.13 2019/07/05 08:29:18 hannken Exp $	*/
+/*	$NetBSD: dtrace_subr.c,v 1.14 2019/11/08 11:06:21 hannken Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -412,7 +412,11 @@ dtrace_trap(struct trapframe *frame, u_i
 	 */
 	nofault = (cpu_core[cpuid].cpuc_dtrace_flags & CPU_DTRACE_NOFAULT) != 0;
 	if (nofault) {
+#if 0
+		This assertion would always fire, we get called from
+		alltraps() -> trap() with interrupts enabled.
 		KASSERTMSG((x86_read_flags() & PSL_I) == 0, "interrupts enabled");
+#endif
 
 		/*
 		 * There are only a couple of trap types that are expected.



CVS commit: src

2019-06-04 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Jun  4 08:44:08 UTC 2019

Modified Files:
src/distrib/sets/lists/base: shl.mi
src/distrib/sets/lists/debug: shl.mi
src/include/rpc: xdr.h
src/lib/libc: shlib_version
src/lib/libc/rpc: xdr_mem.c

Log Message:
Implement xdrmem_control(), used as xdr_control(xdr, XDR_GET_BYTES_AVAIL ...
and bump libc minor number.

Final goal is to remove the unmaintained XDR implementation
at external/cddl/osnet/dist/uts/common/rpc.


To generate a diff of this commit:
cvs rdiff -u -r1.864 -r1.865 src/distrib/sets/lists/base/shl.mi
cvs rdiff -u -r1.223 -r1.224 src/distrib/sets/lists/debug/shl.mi
cvs rdiff -u -r1.30 -r1.31 src/include/rpc/xdr.h
cvs rdiff -u -r1.283 -r1.284 src/lib/libc/shlib_version
cvs rdiff -u -r1.19 -r1.20 src/lib/libc/rpc/xdr_mem.c

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

Modified files:

Index: src/distrib/sets/lists/base/shl.mi
diff -u src/distrib/sets/lists/base/shl.mi:1.864 src/distrib/sets/lists/base/shl.mi:1.865
--- src/distrib/sets/lists/base/shl.mi:1.864	Sun Apr 28 00:03:46 2019
+++ src/distrib/sets/lists/base/shl.mi	Tue Jun  4 08:44:08 2019
@@ -1,4 +1,4 @@
-# $NetBSD: shl.mi,v 1.864 2019/04/28 00:03:46 christos Exp $
+# $NetBSD: shl.mi,v 1.865 2019/06/04 08:44:08 hannken Exp $
 #
 # Note:	Don't delete entries from here - mark them as "obsolete" instead,
 #	unless otherwise stated below.
@@ -18,7 +18,7 @@
 ./lib/libblacklist.so.0.0			base-sys-shlib		dynamicroot
 ./lib/libc.so	base-sys-shlib		dynamicroot
 ./lib/libc.so.12base-sys-shlib		dynamicroot
-./lib/libc.so.12.212base-sys-shlib		dynamicroot
+./lib/libc.so.12.213base-sys-shlib		dynamicroot
 ./lib/libcrypt.sobase-sys-shlib		dynamicroot
 ./lib/libcrypt.so.1base-sys-shlib		dynamicroot
 ./lib/libcrypt.so.1.0base-sys-shlib		dynamicroot
@@ -221,7 +221,7 @@
 ./usr/lib/libc++.so.1.0base-sys-shlib		compatfile,libcxx
 ./usr/lib/libc.sobase-sys-shlib		compatfile
 ./usr/lib/libc.so.12base-sys-shlib		compatfile
-./usr/lib/libc.so.12.212			base-sys-shlib		compatfile
+./usr/lib/libc.so.12.213			base-sys-shlib		compatfile
 ./usr/lib/libcdk.sobase-obsolete		compatfile,obsolete
 ./usr/lib/libcom_err.sobase-krb5-shlib		compatfile,kerberos
 ./usr/lib/libcom_err.so.8			base-krb5-shlib		compatfile,kerberos

Index: src/distrib/sets/lists/debug/shl.mi
diff -u src/distrib/sets/lists/debug/shl.mi:1.223 src/distrib/sets/lists/debug/shl.mi:1.224
--- src/distrib/sets/lists/debug/shl.mi:1.223	Sun Apr 28 00:03:46 2019
+++ src/distrib/sets/lists/debug/shl.mi	Tue Jun  4 08:44:08 2019
@@ -1,8 +1,8 @@
-# $NetBSD: shl.mi,v 1.223 2019/04/28 00:03:46 christos Exp $
+# $NetBSD: shl.mi,v 1.224 2019/06/04 08:44:08 hannken Exp $
 ./usr/lib/libbfd_g.a		comp-c-debuglib	debuglib,compatfile,binutils
 ./usr/libdata/debug/lib		base-sys-usr	debug,dynamicroot,compatdir
 ./usr/libdata/debug/lib/libblacklist.so.0.0.debug		comp-sys-debug	debug,dynamicroot
-./usr/libdata/debug/lib/libc.so.12.212.debug			comp-sys-debug	debug,dynamicroot
+./usr/libdata/debug/lib/libc.so.12.213.debug			comp-sys-debug	debug,dynamicroot
 ./usr/libdata/debug/lib/libcrypt.so.1.0.debug			comp-sys-debug	debug,dynamicroot
 ./usr/libdata/debug/lib/libcrypto.so.12.0.debug			comp-sys-debug	debug,dynamicroot,openssl=10
 ./usr/libdata/debug/lib/libcrypto.so.14.0.debug			comp-sys-debug	debug,dynamicroot,openssl=11
@@ -71,7 +71,7 @@
 ./usr/libdata/debug/usr/lib/libbsdmalloc.so.0.0.debug		comp-sys-debug	debug,compatfile
 ./usr/libdata/debug/usr/lib/libbz2.so.1.1.debug			comp-sys-debug	debug,compatfile
 ./usr/libdata/debug/usr/lib/libc++.so.1.0.debug			comp-sys-debug	debug,compatfile,libcxx
-./usr/libdata/debug/usr/lib/libc.so.12.212.debug		comp-sys-debug	debug,compatfile
+./usr/libdata/debug/usr/lib/libc.so.12.213.debug		comp-sys-debug	debug,compatfile
 ./usr/libdata/debug/usr/lib/libcom_err.so.8.0.debug		comp-krb5-debug	debug,compatfile,kerberos
 ./usr/libdata/debug/usr/lib/libcrypt.so.1.0.debug		comp-sys-debug	debug,compatfile
 ./usr/libdata/debug/usr/lib/libcrypto.so.12.0.debug		comp-crypto-debug	debug,compatfile,openssl=10

Index: src/include/rpc/xdr.h
diff -u src/include/rpc/xdr.h:1.30 src/include/rpc/xdr.h:1.31
--- src/include/rpc/xdr.h:1.30	Wed Aug 16 08:35:48 2017
+++ src/include/rpc/xdr.h	Tue Jun  4 08:44:08 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: xdr.h,v 1.30 2017/08/16 08:35:48 christos Exp $	*/
+/*	$NetBSD: xdr.h,v 1.31 2019/06/04 08:44:08 hannken Exp $	*/
 
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -209,8 +209,8 @@ xdr_putint32(XDR *xdrs, int32_t *ip)
 		(*(xdrs)->x_ops->x_destroy)(xdrs)
 
 #define XDR_CONTROL(xdrs, req, op)			\
-	if ((xdrs)->x_ops->x_control)			\
-		(*(xdrs)->x_ops->x_control)(xdrs, req, op)
+	(((xdrs)->x_ops->x_control == NULL) ? (FALSE) : \
+		(*(xdrs)->x_ops->x_control)(xdrs, req, op))
 #define xdr_control(xdrs, req, op) XDR_CONTROL(xdrs, r

CVS commit: src

2019-06-04 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Jun  4 08:44:08 UTC 2019

Modified Files:
src/distrib/sets/lists/base: shl.mi
src/distrib/sets/lists/debug: shl.mi
src/include/rpc: xdr.h
src/lib/libc: shlib_version
src/lib/libc/rpc: xdr_mem.c

Log Message:
Implement xdrmem_control(), used as xdr_control(xdr, XDR_GET_BYTES_AVAIL ...
and bump libc minor number.

Final goal is to remove the unmaintained XDR implementation
at external/cddl/osnet/dist/uts/common/rpc.


To generate a diff of this commit:
cvs rdiff -u -r1.864 -r1.865 src/distrib/sets/lists/base/shl.mi
cvs rdiff -u -r1.223 -r1.224 src/distrib/sets/lists/debug/shl.mi
cvs rdiff -u -r1.30 -r1.31 src/include/rpc/xdr.h
cvs rdiff -u -r1.283 -r1.284 src/lib/libc/shlib_version
cvs rdiff -u -r1.19 -r1.20 src/lib/libc/rpc/xdr_mem.c

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



CVS commit: src/external/cddl/osnet

2019-06-04 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Jun  4 08:45:18 UTC 2019

Modified Files:
src/external/cddl/osnet/dist/uts/common/rpc: xdr.h
src/external/cddl/osnet/lib/libnvpair: Makefile

Log Message:
Use native XDR for libnvpair in userland.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/cddl/osnet/dist/uts/common/rpc/xdr.h
cvs rdiff -u -r1.9 -r1.10 src/external/cddl/osnet/lib/libnvpair/Makefile

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

Modified files:

Index: src/external/cddl/osnet/dist/uts/common/rpc/xdr.h
diff -u src/external/cddl/osnet/dist/uts/common/rpc/xdr.h:1.4 src/external/cddl/osnet/dist/uts/common/rpc/xdr.h:1.5
--- src/external/cddl/osnet/dist/uts/common/rpc/xdr.h:1.4	Mon May 28 21:05:07 2018
+++ src/external/cddl/osnet/dist/uts/common/rpc/xdr.h	Tue Jun  4 08:45:17 2019
@@ -34,6 +34,7 @@
  *
  */
 
+#if defined(_KERNEL) || defined(_STANDALONE)
 #ifndef _RPC_XDR_H
 #define	_RPC_XDR_H
 
@@ -646,3 +647,6 @@ extern bool_t	xdr_replymsg_hdr(XDR *, st
 #endif
 
 #endif	/* !_RPC_XDR_H */
+#else /* defined(_KERNEL) || defined(_STANDALONE) */
+#include_next 
+#endif /* defined(_KERNEL) || defined(_STANDALONE) */

Index: src/external/cddl/osnet/lib/libnvpair/Makefile
diff -u src/external/cddl/osnet/lib/libnvpair/Makefile:1.9 src/external/cddl/osnet/lib/libnvpair/Makefile:1.10
--- src/external/cddl/osnet/lib/libnvpair/Makefile:1.9	Mon May 28 21:05:09 2018
+++ src/external/cddl/osnet/lib/libnvpair/Makefile	Tue Jun  4 08:45:17 2019
@@ -1,15 +1,13 @@
-#	$NetBSD: Makefile,v 1.9 2018/05/28 21:05:09 chs Exp $
+#	$NetBSD: Makefile,v 1.10 2019/06/04 08:45:17 hannken Exp $
 
 .include 
 
 .PATH:  ${.CURDIR}/../../dist/lib/libnvpair
 .PATH:  ${.CURDIR}/../../dist/common/nvpair
-.PATH:  ${.CURDIR}/../../dist/uts/common/rpc
 
 CPPFLAGS+=	-I${OSNETDIR}/sys \
 		-I${OPENSOLARIS_USR_DISTDIR}/head \
-		-I${OPENSOLARIS_SYS_DISTDIR}/common \
-		-I${OPENSOLARIS_SYS_DISTDIR}/uts/common
+		-I${OPENSOLARIS_SYS_DISTDIR}/common
 
 CPPFLAGS+=	-Wall \
 		-Wno-unknown-pragmas \
@@ -21,9 +19,6 @@ CPPFLAGS+=	-Wall \
 LIB=	nvpair
 
 SRCS=	libnvpair.c nvpair_alloc_system.c nvpair_alloc_fixed.c nvpair.c fnvpair.c nvpair_json.c
-SRCS+=	xdr.c
-SRCS+=	xdr_array.c
-SRCS+=	xdr_mem.c
 
 .include "../../Makefile.zfs"
 .include 



CVS commit: src/external/cddl/osnet

2019-06-04 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Jun  4 08:45:18 UTC 2019

Modified Files:
src/external/cddl/osnet/dist/uts/common/rpc: xdr.h
src/external/cddl/osnet/lib/libnvpair: Makefile

Log Message:
Use native XDR for libnvpair in userland.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/cddl/osnet/dist/uts/common/rpc/xdr.h
cvs rdiff -u -r1.9 -r1.10 src/external/cddl/osnet/lib/libnvpair/Makefile

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



CVS commit: src

2019-06-04 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Jun  4 15:07:55 UTC 2019

Modified Files:
src/common/lib/libc: Makefile.inc
src/include: Makefile
src/include/rpc: Makefile
Added Files:
src/common/include/rpc: Makefile types.h xdr.h
src/common/lib/libc/rpc: xdr.c xdr_array.c xdr_mem.c
Removed Files:
src/include/rpc: types.h xdr.h
src/lib/libc/rpc: xdr.c xdr_array.c xdr_mem.c

Log Message:
Move the basic part of XDR to common/include/rpc and common/lib/libc/rpc.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/common/include/rpc/Makefile \
src/common/include/rpc/types.h src/common/include/rpc/xdr.h
cvs rdiff -u -r1.18 -r1.19 src/common/lib/libc/Makefile.inc
cvs rdiff -u -r0 -r1.1 src/common/lib/libc/rpc/xdr.c \
src/common/lib/libc/rpc/xdr_array.c src/common/lib/libc/rpc/xdr_mem.c
cvs rdiff -u -r1.145 -r1.146 src/include/Makefile
cvs rdiff -u -r1.12 -r1.13 src/include/rpc/Makefile
cvs rdiff -u -r1.15 -r0 src/include/rpc/types.h
cvs rdiff -u -r1.31 -r0 src/include/rpc/xdr.h
cvs rdiff -u -r1.34 -r0 src/lib/libc/rpc/xdr.c
cvs rdiff -u -r1.19 -r0 src/lib/libc/rpc/xdr_array.c
cvs rdiff -u -r1.20 -r0 src/lib/libc/rpc/xdr_mem.c

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



CVS commit: src

2019-06-04 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Jun  4 15:07:55 UTC 2019

Modified Files:
src/common/lib/libc: Makefile.inc
src/include: Makefile
src/include/rpc: Makefile
Added Files:
src/common/include/rpc: Makefile types.h xdr.h
src/common/lib/libc/rpc: xdr.c xdr_array.c xdr_mem.c
Removed Files:
src/include/rpc: types.h xdr.h
src/lib/libc/rpc: xdr.c xdr_array.c xdr_mem.c

Log Message:
Move the basic part of XDR to common/include/rpc and common/lib/libc/rpc.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/common/include/rpc/Makefile \
src/common/include/rpc/types.h src/common/include/rpc/xdr.h
cvs rdiff -u -r1.18 -r1.19 src/common/lib/libc/Makefile.inc
cvs rdiff -u -r0 -r1.1 src/common/lib/libc/rpc/xdr.c \
src/common/lib/libc/rpc/xdr_array.c src/common/lib/libc/rpc/xdr_mem.c
cvs rdiff -u -r1.145 -r1.146 src/include/Makefile
cvs rdiff -u -r1.12 -r1.13 src/include/rpc/Makefile
cvs rdiff -u -r1.15 -r0 src/include/rpc/types.h
cvs rdiff -u -r1.31 -r0 src/include/rpc/xdr.h
cvs rdiff -u -r1.34 -r0 src/lib/libc/rpc/xdr.c
cvs rdiff -u -r1.19 -r0 src/lib/libc/rpc/xdr_array.c
cvs rdiff -u -r1.20 -r0 src/lib/libc/rpc/xdr_mem.c

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

Modified files:

Index: src/common/lib/libc/Makefile.inc
diff -u src/common/lib/libc/Makefile.inc:1.18 src/common/lib/libc/Makefile.inc:1.19
--- src/common/lib/libc/Makefile.inc:1.18	Fri Aug  3 03:35:17 2018
+++ src/common/lib/libc/Makefile.inc	Tue Jun  4 15:07:55 2019
@@ -1,9 +1,9 @@
-# $NetBSD: Makefile.inc,v 1.18 2018/08/03 03:35:17 kamil Exp $
+# $NetBSD: Makefile.inc,v 1.19 2019/06/04 15:07:55 hannken Exp $
 
 .include 
 
 COMMON_DIR:=${.PARSEDIR}
-COMMON_CODEDIRS=atomic gen gmon inet md misc net stdlib string sys
+COMMON_CODEDIRS=atomic gen gmon inet md misc net rpc stdlib string sys
 COMMON_CODEDIRS+=hash/sha1 hash/sha2 hash/sha3 hash/rmd160 hash/murmurhash
 
 .if defined(COMMON_MACHINE_ARCH) && !empty(COMMON_MACHINE_ARCH) && \

Index: src/include/Makefile
diff -u src/include/Makefile:1.145 src/include/Makefile:1.146
--- src/include/Makefile:1.145	Wed Apr 24 10:26:08 2019
+++ src/include/Makefile	Tue Jun  4 15:07:55 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.145 2019/04/24 10:26:08 roy Exp $
+#	$NetBSD: Makefile,v 1.146 2019/06/04 15:07:55 hannken Exp $
 #	@(#)Makefile	8.2 (Berkeley) 1/4/94
 
 # Doing a make includes builds /usr/include
@@ -47,6 +47,7 @@ INCSDIR=	/usr/include
 SUBDIR=		rpc
 SUBDIR+=	../common/include/prop
 SUBDIR+=	../common/include/ppath
+SUBDIR+=	../common/include/rpc
 
 .include 
 .include 

Index: src/include/rpc/Makefile
diff -u src/include/rpc/Makefile:1.12 src/include/rpc/Makefile:1.13
--- src/include/rpc/Makefile:1.12	Sat Jan 11 13:28:43 2003
+++ src/include/rpc/Makefile	Tue Jun  4 15:07:55 2019
@@ -1,10 +1,10 @@
-#	$NetBSD: Makefile,v 1.12 2003/01/11 13:28:43 tron Exp $
+#	$NetBSD: Makefile,v 1.13 2019/06/04 15:07:55 hannken Exp $
 #
 
 INCS=	auth.h auth_unix.h clnt.h clnt_soc.h nettype.h \
 	pmap_clnt.h pmap_prot.h pmap_rmt.h raw.h rpc.h \
 	rpc_com.h rpc_msg.h rpcb_clnt.h rpcb_prot.h rpcent.h \
-	svc.h svc_auth.h svc_soc.h types.h xdr.h
+	svc.h svc_auth.h svc_soc.h
 RPC_INCS=	rpcb_prot.h
 
 INCSDIR=	/usr/include/rpc

Added files:

Index: src/common/include/rpc/Makefile
diff -u /dev/null src/common/include/rpc/Makefile:1.1
--- /dev/null	Tue Jun  4 15:07:55 2019
+++ src/common/include/rpc/Makefile	Tue Jun  4 15:07:55 2019
@@ -0,0 +1,8 @@
+#	$NetBSD: Makefile,v 1.1 2019/06/04 15:07:55 hannken Exp $
+#
+
+INCS=	types.h xdr.h
+
+INCSDIR=	/usr/include/rpc
+
+.include 
Index: src/common/include/rpc/types.h
diff -u /dev/null src/common/include/rpc/types.h:1.1
--- /dev/null	Tue Jun  4 15:07:55 2019
+++ src/common/include/rpc/types.h	Tue Jun  4 15:07:55 2019
@@ -0,0 +1,107 @@
+/*	$NetBSD: types.h,v 1.1 2019/06/04 15:07:55 hannken Exp $	*/
+
+/*
+ * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
+ * unrestricted use provided that this legend is included on all tape
+ * media and as a part of the software program in whole or part.  Users
+ * may copy or modify Sun RPC without charge, but are not authorized
+ * to license or distribute it to anyone else except as part of a product or
+ * program developed by the user.
+ * 
+ * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
+ * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
+ * 
+ * Sun RPC is provided with no support and without any obligation on the
+ * part of Sun Microsystems, Inc. to assist in its use, correction,
+ * modification or enhancement.
+ * 
+ * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
+ * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
+ * OR ANY PART THEREOF.
+ * 
+ * In no event will 

CVS commit: src/common

2019-06-05 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Jun  5 16:25:43 UTC 2019

Modified Files:
src/common/include/rpc: types.h
src/common/lib/libc/rpc: xdr.c xdr_array.c xdr_mem.c

Log Message:
Make XDR usable from kernel or module.

No user visible changes intended.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/common/include/rpc/types.h
cvs rdiff -u -r1.1 -r1.2 src/common/lib/libc/rpc/xdr.c \
src/common/lib/libc/rpc/xdr_array.c src/common/lib/libc/rpc/xdr_mem.c

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



CVS commit: src/common

2019-06-05 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Jun  5 16:25:43 UTC 2019

Modified Files:
src/common/include/rpc: types.h
src/common/lib/libc/rpc: xdr.c xdr_array.c xdr_mem.c

Log Message:
Make XDR usable from kernel or module.

No user visible changes intended.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/common/include/rpc/types.h
cvs rdiff -u -r1.1 -r1.2 src/common/lib/libc/rpc/xdr.c \
src/common/lib/libc/rpc/xdr_array.c src/common/lib/libc/rpc/xdr_mem.c

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

Modified files:

Index: src/common/include/rpc/types.h
diff -u src/common/include/rpc/types.h:1.1 src/common/include/rpc/types.h:1.2
--- src/common/include/rpc/types.h:1.1	Tue Jun  4 15:07:55 2019
+++ src/common/include/rpc/types.h	Wed Jun  5 16:25:43 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: types.h,v 1.1 2019/06/04 15:07:55 hannken Exp $	*/
+/*	$NetBSD: types.h,v 1.2 2019/06/05 16:25:43 hannken Exp $	*/
 
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -62,6 +62,19 @@ typedef   int32_t rpc_inline_t;
 #	define NULL	0
 #endif
 
+#if defined(_KERNEL) || defined(_STANDALONE)
+
+#define warn(msg,...) /**/
+
+typedef __caddr_t caddr_t;
+
+#include 
+
+#define mem_alloc(bsize)	kmem_alloc(bsize, KM_SLEEP)
+#define mem_free(ptr, bsize)	kmem_free(ptr, bsize)
+
+#else /* _KERNEL || _STANDALONE */
+
 #define mem_alloc(bsize)	calloc((size_t)1, bsize)
 #define mem_free(ptr, bsize)	free(ptr)
 
@@ -104,4 +117,6 @@ struct __rpc_sockinfo {
 	int si_alen;
 };
 
+#endif /* _KERNEL || _STANDALONE */
+
 #endif /* !_RPC_TYPES_H_ */

Index: src/common/lib/libc/rpc/xdr.c
diff -u src/common/lib/libc/rpc/xdr.c:1.1 src/common/lib/libc/rpc/xdr.c:1.2
--- src/common/lib/libc/rpc/xdr.c:1.1	Tue Jun  4 15:07:55 2019
+++ src/common/lib/libc/rpc/xdr.c	Wed Jun  5 16:25:43 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: xdr.c,v 1.1 2019/06/04 15:07:55 hannken Exp $	*/
+/*	$NetBSD: xdr.c,v 1.2 2019/06/05 16:25:43 hannken Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -37,7 +37,7 @@
 static char *sccsid = "@(#)xdr.c 1.35 87/08/12";
 static char *sccsid = "@(#)xdr.c	2.1 88/07/29 4.0 RPCSRC";
 #else
-__RCSID("$NetBSD: xdr.c,v 1.1 2019/06/04 15:07:55 hannken Exp $");
+__RCSID("$NetBSD: xdr.c,v 1.2 2019/06/05 16:25:43 hannken Exp $");
 #endif
 #endif
 
@@ -51,6 +51,14 @@ __RCSID("$NetBSD: xdr.c,v 1.1 2019/06/04
  * xdr.
  */
 
+#if defined(_KERNEL) || defined(_STANDALONE)
+
+#include 
+#include 
+#include 
+
+#else /* _KERNEL || _STANDALONE */
+
 #include "namespace.h"
 
 #include 
@@ -95,6 +103,8 @@ __weak_alias(xdr_void,_xdr_void)
 __weak_alias(xdr_wrapstring,_xdr_wrapstring)
 #endif
 
+#endif /* _KERNEL || _STANDALONE */
+
 /*
  * constants specific to the xdr "protocol"
  */
@@ -633,7 +643,7 @@ xdr_bytes(XDR *xdrs, char **cpp, u_int *
 		ret = xdr_opaque(xdrs, sp, nodesize);
 		if ((xdrs->x_op == XDR_DECODE) && (ret == FALSE)) {
 			if (allocated == TRUE) {
-free(sp);
+mem_free(sp, nodesize);
 *cpp = NULL;
 			}
 		}
@@ -793,7 +803,7 @@ xdr_string(XDR *xdrs, char **cpp, u_int 
 		ret = xdr_opaque(xdrs, sp, size);
 		if ((xdrs->x_op == XDR_DECODE) && (ret == FALSE)) {
 			if (allocated == TRUE) {
-free(sp);
+mem_free(sp, nodesize);
 *cpp = NULL;
 			}
 		}
@@ -808,6 +818,8 @@ xdr_string(XDR *xdrs, char **cpp, u_int 
 	return (FALSE);
 }
 
+#if !defined(_KERNEL) && !defined(_STANDALONE)
+
 /* 
  * Wrapper for xdr_string that can be called directly from 
  * routines like clnt_call
@@ -822,6 +834,8 @@ xdr_wrapstring(XDR *xdrs, char **cpp)
 	return xdr_string(xdrs, cpp, RPC_MAXDATASIZE);
 }
 
+#endif /* !_KERNEL && !_STANDALONE */
+
 /*
  * NOTE: xdr_hyper(), xdr_u_hyper(), xdr_longlong_t(), and xdr_u_longlong_t()
  * are in the "non-portable" section because they require that a `long long'
Index: src/common/lib/libc/rpc/xdr_array.c
diff -u src/common/lib/libc/rpc/xdr_array.c:1.1 src/common/lib/libc/rpc/xdr_array.c:1.2
--- src/common/lib/libc/rpc/xdr_array.c:1.1	Tue Jun  4 15:07:55 2019
+++ src/common/lib/libc/rpc/xdr_array.c	Wed Jun  5 16:25:43 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: xdr_array.c,v 1.1 2019/06/04 15:07:55 hannken Exp $	*/
+/*	$NetBSD: xdr_array.c,v 1.2 2019/06/05 16:25:43 hannken Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -37,7 +37,7 @@
 static char *sccsid = "@(#)xdr_array.c 1.10 87/08/11 Copyr 1984 Sun Micro";
 static char *sccsid = "@(#)xdr_array.c	2.1 88/07/29 4.0 RPCSRC";
 #else
-__RCSID("$NetBSD: xdr_array.c,v 1.1 2019/06/04 15:07:55 hannken Exp $");
+__RCSID("$NetBSD: xdr_array.c,v 1.2 2019/06/05 16:25:43 hannken Exp $");
 #endif
 #endif
 
@@ -50,6 +50,15 @@ __RCSID("$NetBSD: xdr_array.c,v 1.1 2019
  * arrays.  See xdr.h for more info on the interface to xdr.
  */
 
+#if defined(_KERNEL) || defined(_STANDALONE)
+
+#include 
+#include 
+#include 
+#include 
+
+#else /* _KERNEL || _STANDALONE */
+
 #include "namespace.h"
 
 #include 
@@ -66,6 +7

CVS commit: src

2019-06-05 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Jun  5 16:28:07 UTC 2019

Modified Files:
src/sys/modules/solaris: Makefile.solmod
Removed Files:
src/external/cddl/osnet/dist/uts/common/rpc: types.h xdr.c xdr.h
xdr_array.c xdr_mem.c

Log Message:
Switch module solaris to native XDR.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r0 src/external/cddl/osnet/dist/uts/common/rpc/types.h
cvs rdiff -u -r1.2 -r0 src/external/cddl/osnet/dist/uts/common/rpc/xdr.c \
src/external/cddl/osnet/dist/uts/common/rpc/xdr_mem.c
cvs rdiff -u -r1.5 -r0 src/external/cddl/osnet/dist/uts/common/rpc/xdr.h
cvs rdiff -u -r1.1.1.1 -r0 \
src/external/cddl/osnet/dist/uts/common/rpc/xdr_array.c
cvs rdiff -u -r1.6 -r1.7 src/sys/modules/solaris/Makefile.solmod

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



CVS commit: src

2019-06-05 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Jun  5 16:28:07 UTC 2019

Modified Files:
src/sys/modules/solaris: Makefile.solmod
Removed Files:
src/external/cddl/osnet/dist/uts/common/rpc: types.h xdr.c xdr.h
xdr_array.c xdr_mem.c

Log Message:
Switch module solaris to native XDR.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r0 src/external/cddl/osnet/dist/uts/common/rpc/types.h
cvs rdiff -u -r1.2 -r0 src/external/cddl/osnet/dist/uts/common/rpc/xdr.c \
src/external/cddl/osnet/dist/uts/common/rpc/xdr_mem.c
cvs rdiff -u -r1.5 -r0 src/external/cddl/osnet/dist/uts/common/rpc/xdr.h
cvs rdiff -u -r1.1.1.1 -r0 \
src/external/cddl/osnet/dist/uts/common/rpc/xdr_array.c
cvs rdiff -u -r1.6 -r1.7 src/sys/modules/solaris/Makefile.solmod

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/solaris/Makefile.solmod
diff -u src/sys/modules/solaris/Makefile.solmod:1.6 src/sys/modules/solaris/Makefile.solmod:1.7
--- src/sys/modules/solaris/Makefile.solmod:1.6	Sun Feb 17 04:05:58 2019
+++ src/sys/modules/solaris/Makefile.solmod	Wed Jun  5 16:28:07 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.solmod,v 1.6 2019/02/17 04:05:58 rin Exp $
+#	$NetBSD: Makefile.solmod,v 1.7 2019/06/05 16:28:07 hannken Exp $
 
 ZFSDIR=	${S}/../external/cddl/osnet
 
@@ -22,7 +22,7 @@ SRCS+=	fm.c
 SRCS+=	list.c
 SRCS+=	nvpair_alloc_system.c
 
-.PATH:	${ZFSDIR}/dist/uts/common/rpc
+.PATH:	${NETBSDSRCDIR}/common/lib/libc/rpc
 
 SRCS+=	xdr.c
 SRCS+=	xdr_array.c



CVS commit: src/external/cddl/osnet

2019-06-06 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Jun  6 14:58:51 UTC 2019

Added Files:
src/external/cddl/osnet/sys: libshare.h
src/external/cddl/osnet/sys/sys: systeminfo.h
Removed Files:
src/external/cddl/osnet/dist/lib/libshare/common: libshare.h
src/external/cddl/osnet/dist/uts/common/sys: systeminfo.h taskq_impl.h

Log Message:
Handle files not present upstream:

dist/lib/libshare/common/libshare.h -> sys/libshare.h
dist/uts/common/sys/systeminfo.h-> sys/sys/systeminfo.h
dist/uts/common/sys/taskq_impl.h-> TRASH

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.3 -r0 \
src/external/cddl/osnet/dist/lib/libshare/common/libshare.h
cvs rdiff -u -r1.1.1.3 -r0 \
src/external/cddl/osnet/dist/uts/common/sys/systeminfo.h \
src/external/cddl/osnet/dist/uts/common/sys/taskq_impl.h
cvs rdiff -u -r0 -r1.1 src/external/cddl/osnet/sys/libshare.h
cvs rdiff -u -r0 -r1.1 src/external/cddl/osnet/sys/sys/systeminfo.h

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



CVS commit: src/external/cddl/osnet

2019-06-06 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Jun  6 14:58:51 UTC 2019

Added Files:
src/external/cddl/osnet/sys: libshare.h
src/external/cddl/osnet/sys/sys: systeminfo.h
Removed Files:
src/external/cddl/osnet/dist/lib/libshare/common: libshare.h
src/external/cddl/osnet/dist/uts/common/sys: systeminfo.h taskq_impl.h

Log Message:
Handle files not present upstream:

dist/lib/libshare/common/libshare.h -> sys/libshare.h
dist/uts/common/sys/systeminfo.h-> sys/sys/systeminfo.h
dist/uts/common/sys/taskq_impl.h-> TRASH

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.3 -r0 \
src/external/cddl/osnet/dist/lib/libshare/common/libshare.h
cvs rdiff -u -r1.1.1.3 -r0 \
src/external/cddl/osnet/dist/uts/common/sys/systeminfo.h \
src/external/cddl/osnet/dist/uts/common/sys/taskq_impl.h
cvs rdiff -u -r0 -r1.1 src/external/cddl/osnet/sys/libshare.h
cvs rdiff -u -r0 -r1.1 src/external/cddl/osnet/sys/sys/systeminfo.h

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

Added files:

Index: src/external/cddl/osnet/sys/libshare.h
diff -u /dev/null src/external/cddl/osnet/sys/libshare.h:1.1
--- /dev/null	Thu Jun  6 14:58:51 2019
+++ src/external/cddl/osnet/sys/libshare.h	Thu Jun  6 14:58:50 2019
@@ -0,0 +1,36 @@
+/*-
+ * Copyright (c) 2007 Pawel Jakub Dawidek 
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS 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 AUTHORS 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.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _OPENSOLARIS_LIBSHARE_H_
+#define _OPENSOLARIS_LIBSHARE_H_
+
+#define	SA_OK	0
+
+#define	SA_INIT_CONTROL_API	0
+
+#endif	/* !_OPENSOLARIS_LIBSHARE_H_ */

Index: src/external/cddl/osnet/sys/sys/systeminfo.h
diff -u /dev/null src/external/cddl/osnet/sys/sys/systeminfo.h:1.1
--- /dev/null	Thu Jun  6 14:58:51 2019
+++ src/external/cddl/osnet/sys/sys/systeminfo.h	Thu Jun  6 14:58:51 2019
@@ -0,0 +1,6 @@
+#ifndef _SYS_SYSTEMINFO_H_
+#define	_SYS_SYSTEMINFO_H_
+
+#define	HW_HOSTID_LEN	11
+
+#endif	/* !_SYS_SYSTEMINFO_H_ */



CVS commit: src/external/cddl/osnet/dist/cmd/stat/common

2019-06-06 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Jun  6 15:59:23 UTC 2019

Removed Files:
src/external/cddl/osnet/dist/cmd/stat/common: timestamp.c

Log Message:
Remove "dist/cmd/stat" containing only one left over and unneeded file.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r0 \
src/external/cddl/osnet/dist/cmd/stat/common/timestamp.c

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



CVS commit: src/external/cddl/osnet/dist/cmd/stat/common

2019-06-06 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Jun  6 15:59:23 UTC 2019

Removed Files:
src/external/cddl/osnet/dist/cmd/stat/common: timestamp.c

Log Message:
Remove "dist/cmd/stat" containing only one left over and unneeded file.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r0 \
src/external/cddl/osnet/dist/cmd/stat/common/timestamp.c

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



CVS commit: src/external/cddl/osnet/sys/kern

2019-06-07 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Jun  7 10:31:21 UTC 2019

Modified Files:
src/external/cddl/osnet/sys/kern: callb.c fm.c

Log Message:
Sync with upstream r315983.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/external/cddl/osnet/sys/kern/callb.c
cvs rdiff -u -r1.2 -r1.3 src/external/cddl/osnet/sys/kern/fm.c

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

Modified files:

Index: src/external/cddl/osnet/sys/kern/callb.c
diff -u src/external/cddl/osnet/sys/kern/callb.c:1.1 src/external/cddl/osnet/sys/kern/callb.c:1.2
--- src/external/cddl/osnet/sys/kern/callb.c:1.1	Fri Aug  7 20:57:57 2009
+++ src/external/cddl/osnet/sys/kern/callb.c	Fri Jun  7 10:31:21 2019
@@ -1,12 +1,9 @@
-/*	$NetBSD: callb.c,v 1.1 2009/08/07 20:57:57 haad Exp $	*/
-
 /*
  * CDDL HEADER START
  *
  * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
  *
  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  * or http://www.opensolaris.org/os/licensing.
@@ -22,12 +19,10 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 #include 
 #include 
 #include 
@@ -111,14 +106,24 @@ void
 callb_fini(void *dummy __unused)
 {
 	callb_t *cp;
+	int i;
 
 	mutex_enter(&ct->ct_lock);
-	while ((cp = ct->ct_freelist) != NULL) {
-		ct->ct_freelist = cp->c_next;
-		ct->ct_ncallb--;
-		kmem_free(cp, sizeof (callb_t));
+	for (i = 0; i < 16; i++) {
+		while ((cp = ct->ct_freelist) != NULL) {
+			ct->ct_freelist = cp->c_next;
+			ct->ct_ncallb--;
+			kmem_free(cp, sizeof (callb_t));
+		}
+		if (ct->ct_ncallb == 0)
+			break;
+		/* Not all callbacks finished, waiting for the rest. */
+		mutex_exit(&ct->ct_lock);
+		tsleep(ct, 0, "callb", hz / 4);
+		mutex_enter(&ct->ct_lock);
 	}
-	ASSERT(ct->ct_ncallb == 0);
+	if (ct->ct_ncallb > 0)
+		printf("%s: Leaked %d callbacks!\n", __func__, ct->ct_ncallb);
 	mutex_exit(&ct->ct_lock);
 	mutex_destroy(&callb_safe_mutex);
 	mutex_destroy(&callb_table.ct_lock);
@@ -270,7 +275,7 @@ callb_execute_class(int class, int code)
 
 #ifdef CALLB_DEBUG
 		printf("callb_execute: name=%s func=%p arg=%p\n",
-			cp->c_name, (void *)cp->c_func, (void *)cp->c_arg);
+		cp->c_name, (void *)cp->c_func, (void *)cp->c_arg);
 #endif /* CALLB_DEBUG */
 
 		mutex_exit(&ct->ct_lock);
@@ -309,12 +314,14 @@ callb_generic_cpr(void *arg, int code)
 	switch (code) {
 	case CB_CODE_CPR_CHKPT:
 		cp->cc_events |= CALLB_CPR_START;
+#ifdef CPR_NOT_THREAD_SAFE
 		while (!(cp->cc_events & CALLB_CPR_SAFE))
 			/* cv_timedwait() returns -1 if it times out. */
-			if ((ret = cv_timedwait(&cp->cc_callb_cv,
-			cp->cc_lockp,
-			callb_timeout_sec * hz)) == -1)
+			if ((ret = cv_reltimedwait(&cp->cc_callb_cv,
+			cp->cc_lockp, (callb_timeout_sec * hz),
+			TR_CLOCK_TICK)) == -1)
 break;
+#endif
 		break;
 
 	case CB_CODE_CPR_RESUME:
@@ -360,3 +367,74 @@ callb_unlock_table(void)
 	cv_broadcast(&ct->ct_busy_cv);
 	mutex_exit(&ct->ct_lock);
 }
+
+#ifdef illumos
+/*
+ * Return a boolean value indicating whether a particular kernel thread is
+ * stopped in accordance with the cpr callback protocol.  If returning
+ * false, also return a pointer to the thread name via the 2nd argument.
+ */
+boolean_t
+callb_is_stopped(kthread_id_t tp, caddr_t *thread_name)
+{
+	callb_t *cp;
+	boolean_t ret_val;
+
+	mutex_enter(&ct->ct_lock);
+
+	for (cp = ct->ct_first_cb[CB_CL_CPR_DAEMON];
+	cp != NULL && tp != cp->c_thread; cp = cp->c_next)
+		;
+
+	ret_val = (cp != NULL);
+	if (ret_val) {
+		/*
+		 * We found the thread in the callback table and have
+		 * provisionally set the return value to true.  Now
+		 * see if it is marked "safe" and is sleeping or stopped.
+		 */
+		callb_cpr_t *ccp = (callb_cpr_t *)cp->c_arg;
+
+		*thread_name = cp->c_name;	/* in case not stopped */
+		mutex_enter(ccp->cc_lockp);
+
+		if (ccp->cc_events & CALLB_CPR_SAFE) {
+			int retry;
+
+			mutex_exit(ccp->cc_lockp);
+			for (retry = 0; retry < CALLB_MAX_RETRY; retry++) {
+thread_lock(tp);
+if (tp->t_state & (TS_SLEEP | TS_STOPPED)) {
+	thread_unlock(tp);
+	break;
+}
+thread_unlock(tp);
+delay(CALLB_THREAD_DELAY);
+			}
+			ret_val = retry < CALLB_MAX_RETRY;
+		} else {
+			ret_val =
+			(ccp->cc_events & CALLB_CPR_ALWAYS_SAFE) != 0;
+			mutex_exit(ccp->cc_lockp);
+		}
+	} else {
+		/*
+		 * Thread not found in callback table.  Make the best
+		 * attempt to identify the thread in the error message.
+		 */
+		ulong_t offset;
+	

CVS commit: src/external/cddl/osnet/sys/kern

2019-06-07 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Jun  7 10:31:21 UTC 2019

Modified Files:
src/external/cddl/osnet/sys/kern: callb.c fm.c

Log Message:
Sync with upstream r315983.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/external/cddl/osnet/sys/kern/callb.c
cvs rdiff -u -r1.2 -r1.3 src/external/cddl/osnet/sys/kern/fm.c

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



CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs

2019-06-11 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Jun 11 09:04:37 UTC 2019

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: vdev_disk.c
src/external/cddl/osnet/dist/uts/common/fs/zfs/sys: vdev_disk.h

Log Message:
Try to retrieve the per-disk maximum transfer size and use it instead
of MAXPHYS.  Eagerly waiting for the merge of tls-maxphys.

Addresses PR port-xen/54273: "zpool create pool xbd2" panics DOMU kernel


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c
cvs rdiff -u -r1.3 -r1.4 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/vdev_disk.h

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

Modified files:

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c:1.9 src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c:1.10
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c:1.9	Sun May 26 10:22:59 2019
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c	Tue Jun 11 09:04:37 2019
@@ -219,6 +219,27 @@ vdev_disk_open(vdev_t *vd, uint64_t *psi
 		return (SET_ERROR(EINVAL));
 	}
 
+	/* XXXNETBSD Once tls-maxphys gets merged this block becomes:
+		pdk = disk_find_blk(vp->v_rdev);
+		dvd->vd_maxphys = (pdk ? disk_maxphys(pdk) : MACHINE_MAXPHYS);
+	*/
+	{
+		struct buf buf = { b_bcount: MAXPHYS };
+		const char *dev_name;
+
+		dev_name = devsw_blk2name(major(vp->v_rdev));
+		if (dev_name) {
+			char disk_name[16];
+
+			snprintf(disk_name, sizeof(disk_name), "%s%d",
+			dev_name, DISKUNIT(vp->v_rdev));
+			pdk = disk_find(disk_name);
+			if (pdk && pdk->dk_driver && pdk->dk_driver->d_minphys)
+(*pdk->dk_driver->d_minphys)(&buf);
+		}
+		dvd->vd_maxphys = buf.b_bcount;
+	}
+
 	/*
 	 * XXXNETBSD Compare the devid to the stored value.
 	 */
@@ -421,6 +442,7 @@ vdev_disk_io_start(zio_t *zio)
 		zio_interrupt(zio);
 		return;
 	}
+	ASSERT3U(dvd->vd_maxphys, >, 0);
 	vp = dvd->vd_vp;
 #endif
 
@@ -473,7 +495,7 @@ vdev_disk_io_start(zio_t *zio)
 		mutex_exit(vp->v_interlock);
 	}
 
-	if (bp->b_bcount <= MAXPHYS) {
+	if (bp->b_bcount <= dvd->vd_maxphys) {
 		/* We can do this I/O in one pass. */
 		(void)VOP_STRATEGY(vp, bp);
 	} else {
@@ -484,7 +506,7 @@ vdev_disk_io_start(zio_t *zio)
 		resid = zio->io_size;
 		off = 0;
 		while (resid != 0) {
-			size = uimin(resid, MAXPHYS);
+			size = uimin(resid, dvd->vd_maxphys);
 			nbp = getiobuf(vp, true);
 			nbp->b_blkno = btodb(zio->io_offset + off);
 			/* Below call increments v_numoutput. */

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/vdev_disk.h
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/vdev_disk.h:1.3 src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/vdev_disk.h:1.4
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/vdev_disk.h:1.3	Mon May 28 21:05:07 2018
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/vdev_disk.h	Tue Jun 11 09:04:37 2019
@@ -52,6 +52,7 @@ typedef struct vdev_disk {
 	char*vd_minor;
 	vnode_t *vd_vp;
 	struct workqueue *vd_wq;
+	int		vd_maxphys;
 #endif
 } vdev_disk_t;
 #endif



CVS commit: src/external/cddl/osnet/sys/kern

2019-06-11 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Jun 11 09:05:33 UTC 2019

Modified Files:
src/external/cddl/osnet/sys/kern: taskq.c

Log Message:
There is no 1:1 relation between cv_signal() and cv_timedwait() as
the latter implicitly calls cv_signal() on error.

This leads to "tq_waiting > 0" with "tq_running == 0" and the
taskq stalls.

Change task_executor() to increment and decrement "tq_waiting"
and always check and run the queue after cv_timedwait().

Use mstohz(), fix timeout and sort includes.

Addresses PR port-xen/54273: "zpool create pool xbd2" panics DOMU kernel


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/external/cddl/osnet/sys/kern/taskq.c

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

Modified files:

Index: src/external/cddl/osnet/sys/kern/taskq.c
diff -u src/external/cddl/osnet/sys/kern/taskq.c:1.9 src/external/cddl/osnet/sys/kern/taskq.c:1.10
--- src/external/cddl/osnet/sys/kern/taskq.c:1.9	Tue May  7 08:49:59 2019
+++ src/external/cddl/osnet/sys/kern/taskq.c	Tue Jun 11 09:05:33 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: taskq.c,v 1.9 2019/05/07 08:49:59 hannken Exp $	*/
+/*	$NetBSD: taskq.c,v 1.10 2019/06/11 09:05:33 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -30,9 +30,11 @@
  */
 
 #include 
-#include 
+#include 
 #include 
+#include 
 #include 
+#include 
 #include 
 #include 
 
@@ -65,7 +67,7 @@ static specificdata_key_t taskq_lwp_key;
 
 /*
  * Threadpool job to service tasks from task queue.
- * Runs until the task queue gets destroyed or the queue is empty for 5 secs.
+ * Runs until the task queue gets destroyed or the queue is empty for 10 secs.
  */
 static void
 task_executor(struct threadpool_job *job)
@@ -73,22 +75,27 @@ task_executor(struct threadpool_job *job
 	struct taskq_executor *state = (struct taskq_executor *)job;
 	taskq_t *tq = state->te_self;
 	taskq_ent_t *tqe; 
+	int error;
 
 	lwp_setspecific(taskq_lwp_key, tq);
 
 	mutex_enter(&tq->tq_lock);
 	while (!tq->tq_destroyed) {
-		tqe = SIMPLEQ_FIRST(&tq->tq_list);
-		if (tqe == NULL) {
+		if (SIMPLEQ_EMPTY(&tq->tq_list)) {
 			if (ISSET(tq->tq_flags, TASKQ_DYNAMIC))
 break;
 			tq->tq_waiting++;
-			if (cv_timedwait(&tq->tq_cv, &tq->tq_lock, 5000) != 0) {
-tq->tq_waiting--;
-break;
+			error = cv_timedwait(&tq->tq_cv, &tq->tq_lock,
+			mstohz(1));
+			tq->tq_waiting--;
+			if (SIMPLEQ_EMPTY(&tq->tq_list)) {
+if (error)
+	break;
+continue;
 			}
-			continue;
 		}
+		tqe = SIMPLEQ_FIRST(&tq->tq_list);
+		KASSERT(tqe != NULL);
 		SIMPLEQ_REMOVE_HEAD(&tq->tq_list, tqent_list);
 		tqe->tqent_queued = 0;
 		mutex_exit(&tq->tq_lock);
@@ -144,7 +151,6 @@ taskq_dispatch_common(taskq_t *tq, taskq
 	tq->tq_active++;
 	if (tq->tq_waiting) {
 		cv_signal(&tq->tq_cv);
-		tq->tq_waiting--;
 		mutex_exit(&tq->tq_lock);
 		return;
 	}



CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs

2019-06-11 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Jun 11 09:04:37 UTC 2019

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: vdev_disk.c
src/external/cddl/osnet/dist/uts/common/fs/zfs/sys: vdev_disk.h

Log Message:
Try to retrieve the per-disk maximum transfer size and use it instead
of MAXPHYS.  Eagerly waiting for the merge of tls-maxphys.

Addresses PR port-xen/54273: "zpool create pool xbd2" panics DOMU kernel


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c
cvs rdiff -u -r1.3 -r1.4 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/vdev_disk.h

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



CVS commit: src/external/cddl/osnet/sys/kern

2019-06-11 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Jun 11 09:05:33 UTC 2019

Modified Files:
src/external/cddl/osnet/sys/kern: taskq.c

Log Message:
There is no 1:1 relation between cv_signal() and cv_timedwait() as
the latter implicitly calls cv_signal() on error.

This leads to "tq_waiting > 0" with "tq_running == 0" and the
taskq stalls.

Change task_executor() to increment and decrement "tq_waiting"
and always check and run the queue after cv_timedwait().

Use mstohz(), fix timeout and sort includes.

Addresses PR port-xen/54273: "zpool create pool xbd2" panics DOMU kernel


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/external/cddl/osnet/sys/kern/taskq.c

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



CVS commit: src/tests/fs/zfs

2019-06-11 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Jun 11 14:00:16 UTC 2019

Modified Files:
src/tests/fs/zfs: t_zpool.sh

Log Message:
Need rumpdev_disk for rumpfs_zfs.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/fs/zfs/t_zpool.sh

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

Modified files:

Index: src/tests/fs/zfs/t_zpool.sh
diff -u src/tests/fs/zfs/t_zpool.sh:1.4 src/tests/fs/zfs/t_zpool.sh:1.5
--- src/tests/fs/zfs/t_zpool.sh:1.4	Sun Dec 16 14:04:14 2018
+++ src/tests/fs/zfs/t_zpool.sh	Tue Jun 11 14:00:16 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: t_zpool.sh,v 1.4 2018/12/16 14:04:14 hannken Exp $
+#	$NetBSD: t_zpool.sh,v 1.5 2019/06/11 14:00:16 hannken Exp $
 #
 # Copyright (c) 2011 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -25,7 +25,7 @@
 # POSSIBILITY OF SUCH DAMAGE.
 #
 
-server='rump_server -lrumpvfs -lrumpkern_solaris -lrumpfs_zfs -lrumpdev -lrumpdev_rnd -d key=/dk,hostpath=zfs.img,size=100m'
+server='rump_server -lrumpvfs -lrumpdev_disk -lrumpkern_solaris -lrumpfs_zfs -lrumpdev -lrumpdev_rnd -d key=/dk,hostpath=zfs.img,size=100m'
 
 export RUMP_SERVER=unix://zsuck
 



CVS commit: src/tests/fs/zfs

2019-06-11 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Jun 11 14:00:16 UTC 2019

Modified Files:
src/tests/fs/zfs: t_zpool.sh

Log Message:
Need rumpdev_disk for rumpfs_zfs.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/fs/zfs/t_zpool.sh

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



CVS commit: src/sys/kern

2019-06-17 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Jun 17 08:07:27 UTC 2019

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

Log Message:
Add an owner field to fstrans mount info and use it to hold
the thread currently suspending this mount.

Remove now unneeded state FSTRANS_EXCL.

It is now possible to suspend a file system from a thread
already holding fstrans locks.  Use with care ...


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/sys/kern/vfs_trans.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_trans.c
diff -u src/sys/kern/vfs_trans.c:1.60 src/sys/kern/vfs_trans.c:1.61
--- src/sys/kern/vfs_trans.c:1.60	Mon May 13 08:16:56 2019
+++ src/sys/kern/vfs_trans.c	Mon Jun 17 08:07:27 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_trans.c,v 1.60 2019/05/13 08:16:56 hannken Exp $	*/
+/*	$NetBSD: vfs_trans.c,v 1.61 2019/06/17 08:07:27 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.60 2019/05/13 08:16:56 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.61 2019/06/17 08:07:27 hannken Exp $");
 
 /*
  * File system transaction operations.
@@ -55,8 +55,7 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,
 
 enum fstrans_lock_type {
 	FSTRANS_LAZY,			/* Granted while not suspended */
-	FSTRANS_SHARED,			/* Granted while not suspending */
-	FSTRANS_EXCL			/* Internal: exclusive lock */
+	FSTRANS_SHARED			/* Granted while not suspending */
 };
 
 struct fscow_handler {
@@ -83,6 +82,7 @@ struct fstrans_mount_info {
 	bool fmi_cow_change;
 	LIST_HEAD(, fscow_handler) fmi_cow_handler;
 	struct mount *fmi_mount;
+	struct lwp *fmi_owner;
 };
 
 static kmutex_t vfs_suspend_lock;	/* Serialize suspensions. */
@@ -101,7 +101,8 @@ static inline struct fstrans_lwp_info *
 fstrans_get_lwp_info(struct mount *, bool);
 static struct fstrans_lwp_info *fstrans_alloc_lwp_info(struct mount *);
 static inline int _fstrans_start(struct mount *, enum fstrans_lock_type, int);
-static bool grant_lock(const enum fstrans_state, const enum fstrans_lock_type);
+static bool grant_lock(const struct fstrans_mount_info *,
+const enum fstrans_lock_type);
 static bool state_change_done(const struct fstrans_mount_info *);
 static bool cow_state_change_done(const struct fstrans_mount_info *);
 static void cow_change_enter(struct fstrans_mount_info *);
@@ -233,6 +234,7 @@ fstrans_mount_dtor(struct fstrans_mount_
 
 	KASSERT(fmi->fmi_state == FSTRANS_NORMAL);
 	KASSERT(LIST_FIRST(&fmi->fmi_cow_handler) == NULL);
+	KASSERT(fmi->fmi_owner == NULL);
 
 	KASSERT(fstrans_gone_count > 0);
 	fstrans_gone_count -= 1;
@@ -258,6 +260,7 @@ fstrans_mount(struct mount *mp)
 	LIST_INIT(&newfmi->fmi_cow_handler);
 	newfmi->fmi_cow_change = false;
 	newfmi->fmi_mount = mp;
+	newfmi->fmi_owner = NULL;
 
 	mutex_enter(&fstrans_mount_lock);
 	mp->mnt_transinfo = newfmi;
@@ -433,14 +436,15 @@ fstrans_get_lwp_info(struct mount *mp, b
  * Check if this lock type is granted at this state.
  */
 static bool
-grant_lock(const enum fstrans_state state, const enum fstrans_lock_type type)
+grant_lock(const struct fstrans_mount_info *fmi,
+const enum fstrans_lock_type type)
 {
 
-	if (__predict_true(state == FSTRANS_NORMAL))
+	if (__predict_true(fmi->fmi_state == FSTRANS_NORMAL))
 		return true;
-	if (type == FSTRANS_EXCL)
+	if (fmi->fmi_owner == curlwp)
 		return true;
-	if  (state == FSTRANS_SUSPENDING && type == FSTRANS_LAZY)
+	if  (fmi->fmi_state == FSTRANS_SUSPENDING && type == FSTRANS_LAZY)
 		return true;
 
 	return false;
@@ -468,14 +472,13 @@ _fstrans_start(struct mount *mp, enum fs
 	fmi = fli->fli_mountinfo;
 
 	if (fli->fli_trans_cnt > 0) {
-		KASSERT(lock_type != FSTRANS_EXCL);
 		fli->fli_trans_cnt += 1;
 
 		return 0;
 	}
 
 	s = pserialize_read_enter();
-	if (__predict_true(grant_lock(fmi->fmi_state, lock_type))) {
+	if (__predict_true(grant_lock(fmi, lock_type))) {
 		fli->fli_trans_cnt = 1;
 		fli->fli_lock_type = lock_type;
 		pserialize_read_exit(s);
@@ -488,7 +491,7 @@ _fstrans_start(struct mount *mp, enum fs
 		return EBUSY;
 
 	mutex_enter(&fstrans_lock);
-	while (! grant_lock(fmi->fmi_state, lock_type))
+	while (! grant_lock(fmi, lock_type))
 		cv_wait(&fstrans_state_cv, &fstrans_lock);
 	fli->fli_trans_cnt = 1;
 	fli->fli_lock_type = lock_type;
@@ -572,15 +575,14 @@ int
 fstrans_is_owner(struct mount *mp)
 {
 	struct fstrans_lwp_info *fli;
+	struct fstrans_mount_info *fmi;
 
 	KASSERT(mp != dead_rootmount);
 
 	fli = fstrans_get_lwp_info(mp, true);
+	fmi = fli->fli_mountinfo;
 
-	if (fli->fli_trans_cnt == 0)
-		return 0;
-
-	return (fli->fli_lock_type == FSTRANS_EXCL);
+	return (fmi->fmi_owner == curlwp);
 }
 
 /*
@@ -598,7 +600,9 @@ state_change_done(const struct fstrans_m
 			continue;
 		if (fli->fli_trans_cnt == 0)
 			continue;
-		if (grant_lock(fmi->fmi_state, fli->fli_lock_type))
+		if (fli->fl

CVS commit: src/sys/kern

2019-06-17 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Jun 17 08:07:27 UTC 2019

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

Log Message:
Add an owner field to fstrans mount info and use it to hold
the thread currently suspending this mount.

Remove now unneeded state FSTRANS_EXCL.

It is now possible to suspend a file system from a thread
already holding fstrans locks.  Use with care ...


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/sys/kern/vfs_trans.c

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



CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs

2019-06-17 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Jun 17 08:07:56 UTC 2019

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_vnops.c

Log Message:
Skip atime update on dead "z_sa_hdl == NULL" znodes.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c

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



CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs

2019-06-17 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Jun 17 08:07:56 UTC 2019

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_vnops.c

Log Message:
Skip atime update on dead "z_sa_hdl == NULL" znodes.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_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/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.48 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.49
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.48	Mon Apr 15 12:59:38 2019
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c	Mon Jun 17 08:07:56 2019
@@ -5759,7 +5759,7 @@ zfs_netbsd_reclaim(void *v)
 	/*
 	 * Process a deferred atime update.
 	 */
-	if (zp->z_atime_dirty && zp->z_unlinked == 0) {
+	if (zp->z_atime_dirty && zp->z_unlinked == 0 && zp->z_sa_hdl != NULL) {
 		dmu_tx_t *tx = dmu_tx_create(zfsvfs->z_os);
 
 		dmu_tx_hold_sa(tx, zp->z_sa_hdl, B_FALSE);



CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs

2019-06-17 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Jun 17 08:08:21 UTC 2019

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_vnops.c

Log Message:
Add fstrans_start()/fstrans_done() and bounds check to zfs_netbsd_getpages().


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c

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



CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs

2019-06-17 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Jun 17 08:08:21 UTC 2019

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_vnops.c

Log Message:
Add fstrans_start()/fstrans_done() and bounds check to zfs_netbsd_getpages().


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_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/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.49 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.50
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.49	Mon Jun 17 08:07:56 2019
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c	Mon Jun 17 08:08:21 2019
@@ -5892,6 +5892,7 @@ zfs_netbsd_getpages(void *v)
 	kmutex_t * const mtx = uobj->vmobjlock;
 	znode_t *zp = VTOZ(vp);
 	zfsvfs_t *zfsvfs = zp->z_zfsvfs;
+	vfs_t *mp;
 	struct vm_page *pg;
 	caddr_t va;
 	int npages, found, err = 0;
@@ -5910,10 +5911,22 @@ zfs_netbsd_getpages(void *v)
 		return EBUSY;
 	}
 
+	mp = vp->v_mount;
+	fstrans_start(mp);
+	if (vp->v_mount != mp) {
+		fstrans_done(mp);
+		return ENOENT;
+	}
 	ZFS_ENTER(zfsvfs);
 	ZFS_VERIFY_ZP(zp);
 
 	mutex_enter(mtx);
+	if (offset >= vp->v_size) {
+		mutex_exit(mtx);
+		ZFS_EXIT(zfsvfs);
+		fstrans_done(mp);
+		return EINVAL;
+	}
 	npages = 1;
 	pg = NULL;
 	uvn_findpages(uobj, offset, &npages, &pg, UFP_ALL);
@@ -5943,6 +5956,7 @@ zfs_netbsd_getpages(void *v)
 	ap->a_m[ap->a_centeridx] = pg;
 
 	ZFS_EXIT(zfsvfs);
+	fstrans_done(mp);
 
 	return (err);
 }



CVS commit: src/external/cddl/osnet

2019-06-17 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Jun 17 08:08:51 UTC 2019

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_znode.c
src/external/cddl/osnet/sys/sys: zfs_context.h

Log Message:
Unmap pages when zfs_rezget() re-establishes a znode with its dbufs.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c
cvs rdiff -u -r1.21 -r1.22 src/external/cddl/osnet/sys/sys/zfs_context.h

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



CVS commit: src/external/cddl/osnet

2019-06-17 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Jun 17 08:08:51 UTC 2019

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_znode.c
src/external/cddl/osnet/sys/sys: zfs_context.h

Log Message:
Unmap pages when zfs_rezget() re-establishes a znode with its dbufs.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c
cvs rdiff -u -r1.21 -r1.22 src/external/cddl/osnet/sys/sys/zfs_context.h

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

Modified files:

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c:1.28 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c:1.29
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c:1.28	Sun May 26 10:21:00 2019
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c	Mon Jun 17 08:08:50 2019
@@ -1560,10 +1560,14 @@ zfs_rezget(znode_t *zp)
 
 	zp->z_unlinked = (zp->z_links == 0);
 	zp->z_blksz = doi.doi_data_block_size;
+#ifdef __NetBSD__
+	mutex_enter(vp->v_interlock);
+	(void)VOP_PUTPAGES(vp, 0, 0, PGO_ALLPAGES|PGO_FREE|PGO_SYNCIO);
+#else
 	vn_pages_remove(vp, 0, 0);
+#endif
 	if (zp->z_size != size)
 		vnode_pager_setsize(vp, zp->z_size);
-
 	ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num);
 
 	return (0);

Index: src/external/cddl/osnet/sys/sys/zfs_context.h
diff -u src/external/cddl/osnet/sys/sys/zfs_context.h:1.21 src/external/cddl/osnet/sys/sys/zfs_context.h:1.22
--- src/external/cddl/osnet/sys/sys/zfs_context.h:1.21	Tue May  7 08:49:59 2019
+++ src/external/cddl/osnet/sys/sys/zfs_context.h	Mon Jun 17 08:08:51 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: zfs_context.h,v 1.21 2019/05/07 08:49:59 hannken Exp $	*/
+/*	$NetBSD: zfs_context.h,v 1.22 2019/06/17 08:08:51 hannken Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -777,7 +777,6 @@ vsprintf(char * __restrict buf, const ch
 
 void zfs_netbsd_setsize(vnode_t *, off_t);
 #define vnode_pager_setsize(vp, size) zfs_netbsd_setsize(vp, size)
-#define vn_pages_remove(a, b, c)
 
 #define getf		fd_getfile
 #define releasef	fd_putfile



CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs

2019-06-17 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Jun 17 08:09:57 UTC 2019

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_vfsops.c

Log Message:
Add native vfs_suspend()/vfs_resume() before and after
zfs_suspend_fs()/zfs_resume_fs() and get rid of dead "z_sa_hdl == NULL"
znodes before vfs_resume() to keep the vnode cache consistent.

Live rollback should work now.

PR port-xen/54273 ("zpool create pool xbd2" panics DOMU kernel)


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c

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



CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs

2019-06-17 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Jun 17 08:09:57 UTC 2019

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_vfsops.c

Log Message:
Add native vfs_suspend()/vfs_resume() before and after
zfs_suspend_fs()/zfs_resume_fs() and get rid of dead "z_sa_hdl == NULL"
znodes before vfs_resume() to keep the vnode cache consistent.

Live rollback should work now.

PR port-xen/54273 ("zpool create pool xbd2" panics DOMU kernel)


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_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/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c:1.23 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c:1.24
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c:1.23	Wed May 22 08:45:32 2019
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c	Mon Jun 17 08:09:57 2019
@@ -121,6 +121,7 @@ VFS_SET(zfs_vfsops, zfs, VFCF_JAIL | VFC
 
 #ifdef __NetBSD__
 
+#include 
 #include 
 #include 
 
@@ -2669,8 +2670,17 @@ zfs_suspend_fs(zfsvfs_t *zfsvfs)
 {
 	int error;
 
+#ifdef __NetBSD__
+	if ((error = vfs_suspend(zfsvfs->z_vfs, 0)) != 0)
+		return error;
+	if ((error = zfsvfs_teardown(zfsvfs, B_FALSE)) != 0) {
+		vfs_resume(zfsvfs->z_vfs);
+		return (error);
+	}
+#else
 	if ((error = zfsvfs_teardown(zfsvfs, B_FALSE)) != 0)
 		return (error);
+#endif
 
 	return (0);
 }
@@ -2682,6 +2692,16 @@ zfs_suspend_fs(zfsvfs_t *zfsvfs)
  * are the same: the relevant objset and associated dataset are owned by
  * zfsvfs, held, and long held on entry.
  */
+#ifdef __NetBSD__
+static bool
+zfs_resume_selector(void *cl, struct vnode *vp)
+{
+
+	if (zfsctl_is_node(vp))
+		return false;
+	return (VTOZ(vp)->z_sa_hdl == NULL);
+}
+#endif
 int
 zfs_resume_fs(zfsvfs_t *zfsvfs, dsl_dataset_t *ds)
 {
@@ -2725,6 +2745,18 @@ bail:
 	/* release the VOPs */
 	rw_exit(&zfsvfs->z_teardown_inactive_lock);
 	rrm_exit(&zfsvfs->z_teardown_lock, FTAG);
+#ifdef __NetBSD__
+	struct vnode_iterator *marker;
+	vnode_t *vp;
+
+	vfs_vnode_iterator_init(zfsvfs->z_vfs, &marker);
+	while ((vp = vfs_vnode_iterator_next(marker,
+	zfs_resume_selector, NULL))) {
+		vgone(vp);
+	}
+	vfs_vnode_iterator_destroy(marker);
+	vfs_resume(zfsvfs->z_vfs);
+#endif
 
 	if (err) {
 		/*



CVS commit: src/external/cddl/osnet

2019-06-19 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Jun 19 08:18:01 UTC 2019

Modified Files:
src/external/cddl/osnet/include: libintl.h stdio_ext.h thread.h
src/external/cddl/osnet/sys/sys: isa_defs.h procset.h sysmacros.h

Log Message:
Sync with upstream r315983.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/cddl/osnet/include/libintl.h
cvs rdiff -u -r1.1 -r1.2 src/external/cddl/osnet/include/stdio_ext.h
cvs rdiff -u -r1.4 -r1.5 src/external/cddl/osnet/include/thread.h
cvs rdiff -u -r1.3 -r1.4 src/external/cddl/osnet/sys/sys/isa_defs.h
cvs rdiff -u -r1.2 -r1.3 src/external/cddl/osnet/sys/sys/procset.h
cvs rdiff -u -r1.9 -r1.10 src/external/cddl/osnet/sys/sys/sysmacros.h

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



CVS commit: src/external/cddl/osnet

2019-06-19 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Jun 19 08:18:01 UTC 2019

Modified Files:
src/external/cddl/osnet/include: libintl.h stdio_ext.h thread.h
src/external/cddl/osnet/sys/sys: isa_defs.h procset.h sysmacros.h

Log Message:
Sync with upstream r315983.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/cddl/osnet/include/libintl.h
cvs rdiff -u -r1.1 -r1.2 src/external/cddl/osnet/include/stdio_ext.h
cvs rdiff -u -r1.4 -r1.5 src/external/cddl/osnet/include/thread.h
cvs rdiff -u -r1.3 -r1.4 src/external/cddl/osnet/sys/sys/isa_defs.h
cvs rdiff -u -r1.2 -r1.3 src/external/cddl/osnet/sys/sys/procset.h
cvs rdiff -u -r1.9 -r1.10 src/external/cddl/osnet/sys/sys/sysmacros.h

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

Modified files:

Index: src/external/cddl/osnet/include/libintl.h
diff -u src/external/cddl/osnet/include/libintl.h:1.3 src/external/cddl/osnet/include/libintl.h:1.4
--- src/external/cddl/osnet/include/libintl.h:1.3	Sun Feb 21 01:46:34 2010
+++ src/external/cddl/osnet/include/libintl.h	Wed Jun 19 08:18:01 2019
@@ -1,42 +1,107 @@
-/*	$NetBSD: libintl.h,v 1.3 2010/02/21 01:46:34 darran Exp $	*/
-
-/*-
- * Copyright (c) 2009 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Andrew Doran.
- *
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2014 Garrett D'Amore 
+ *
+ * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+ * Use is subject to license terms.
  */
 
-#ifndef	_LIBINTL_H_
-#define	_LIBINTL_H_
 
-#include 
-#include 
+#ifndef	_LIBINTL_H
+#define	_LIBINTL_H
+
+#ifdef __NetBSD__
 
 #define	textdomain(domain)	0
 #define	gettext(...)		(__VA_ARGS__)
 #define	dgettext(domain, ...)	(__VA_ARGS__)
 
-#endif	/* !_SOLARIS_H_ */
+#else /* __NetBSD__ */
+
+#include 
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+/*
+ * wchar_t is a built-in type in standard C++ and as such is not
+ * defined here when using standard C++. However, the GNU compiler
+ * fixincludes utility nonetheless creates its own version of this
+ * header for use by gcc and g++. In that version it adds a redundant
+ * guard for __cplusplus. To avoid the creation of a gcc/g++ specific
+ * header we need to include the following magic comment:
+ *
+ * we must use the C++ compiler's type
+ *
+ * The above comment should not be removed or changed until GNU
+ * gcc/fixinc/inclhack.def is updated to bypass this header.
+ */
+#if !defined(__cplusplus) || (__cplusplus < 199711L && !defined(__GNUG__))
+#ifndef _WCHAR_T
+#define	_WCHAR_T
+#if defined(_LP64)
+typedef int	wchar_t;
+#else
+typedef long	wchar_t;
+#endif
+#endif	/* !_WCHAR_T */
+#endif	/* !defined(__cplusplus) ... */
+
+#define	TEXTDOMAINMAX	256
+
+#define	__GNU_GETTE

CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs

2019-06-21 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Jun 21 10:59:50 UTC 2019

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: dmu_tx.c

Log Message:
Disable assertion: illumos 7793 ztest fails assertion in dmu_tx_willuse_space


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_tx.c

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

Modified files:

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_tx.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_tx.c:1.3 src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_tx.c:1.4
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_tx.c:1.3	Sun Jun  3 03:05:56 2018
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_tx.c	Fri Jun 21 10:59:50 2019
@@ -1427,8 +1427,10 @@ dmu_tx_willuse_space(dmu_tx_t *tx, int64
 		return;
 
 	if (delta > 0) {
+/* FreeBSD r318821, illumos 7793 ztest fails assertion in dmu_tx_willuse_space
 		ASSERT3U(refcount_count(&tx->tx_space_written) + delta, <=,
 		tx->tx_space_towrite);
+*/
 		(void) refcount_add_many(&tx->tx_space_written, delta, NULL);
 	} else {
 		(void) refcount_add_many(&tx->tx_space_freed, -delta, NULL);



CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs

2019-06-21 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Jun 21 10:59:50 UTC 2019

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: dmu_tx.c

Log Message:
Disable assertion: illumos 7793 ztest fails assertion in dmu_tx_willuse_space


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_tx.c

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



CVS commit: src

2019-06-22 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Jun 22 09:48:40 UTC 2019

Modified Files:
src/external/cddl/osnet: Makefile.zfs
src/external/cddl/osnet/dist/uts/common/fs/zfs/sys: zfs_context.h
src/usr.sbin/fstyp: Makefile
Added Files:
src/external/cddl/osnet/dist/lib/libzpool/common/sys: zfs_context.h
Removed Files:
src/external/cddl/osnet/sys/sys: zfs_context.h

Log Message:
Sync with upstream r315983.

FreeBSD splits "zfs_context.h" into:
  "lib/libzpool/common/sys/zfs_context.h" for user space
  "uts/common/fs/zfs/sys/zfs_context.h" for kernel space

Do the same here, move and sync "sys/sys/zfs_context.h" to
"dist/lib/libzpool/common/sys/zfs_context.h" and
"dist/uts/common/fs/zfs/sys/zfs_context.h".

Change "Makefile.zfs" to search includes from "dist/lib"
before "dist/uts" so we get the right include file.

Adapt "usr.sbin/fstyp/Makefile" to get the right include file.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/external/cddl/osnet/Makefile.zfs
cvs rdiff -u -r0 -r1.1 \
src/external/cddl/osnet/dist/lib/libzpool/common/sys/zfs_context.h
cvs rdiff -u -r1.1.1.3 -r1.2 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/zfs_context.h
cvs rdiff -u -r1.22 -r0 src/external/cddl/osnet/sys/sys/zfs_context.h
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/fstyp/Makefile

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

Modified files:

Index: src/external/cddl/osnet/Makefile.zfs
diff -u src/external/cddl/osnet/Makefile.zfs:1.8 src/external/cddl/osnet/Makefile.zfs:1.9
--- src/external/cddl/osnet/Makefile.zfs:1.8	Thu Jun  7 13:21:44 2018
+++ src/external/cddl/osnet/Makefile.zfs	Sat Jun 22 09:48:39 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.zfs,v 1.8 2018/06/07 13:21:44 kamil Exp $
+#	$NetBSD: Makefile.zfs,v 1.9 2019/06/22 09:48:39 hannken Exp $
 
 .include 
 
@@ -21,10 +21,6 @@ ZFSDIR=		${NETBSDSRCDIR}/external/cddl/o
 CPPFLAGS+=	-I${ZFSDIR}
 CPPFLAGS+=	-I${ZFSDIR}/include
 CPPFLAGS+=	-I${ZFSDIR}/sys
-CPPFLAGS+=	-I${ZFSDIR}/dist/uts/common
-CPPFLAGS+=	-I${ZFSDIR}/dist/uts/common/zfs
-CPPFLAGS+=	-I${ZFSDIR}/dist/uts/common/fs/zfs
-CPPFLAGS+=	-I${ZFSDIR}/dist/uts/common/sys
 
 CPPFLAGS+=	-I${ZFSDIR}/dist/common/zfs
 CPPFLAGS+=	-I${ZFSDIR}/dist/head
@@ -39,6 +35,11 @@ CPPFLAGS+=	-I${ZFSDIR}/dist/lib/libzpool
 
 CPPFLAGS+=  -I${ZFSDIR}/dist/common
 
+CPPFLAGS+=	-I${ZFSDIR}/dist/uts/common
+CPPFLAGS+=	-I${ZFSDIR}/dist/uts/common/zfs
+CPPFLAGS+=	-I${ZFSDIR}/dist/uts/common/fs/zfs
+CPPFLAGS+=	-I${ZFSDIR}/dist/uts/common/sys
+
 CWARNFLAGS+=	-Wno-missing-field-initializers
 CWARNFLAGS+=	-Wno-strict-prototypes
 CWARNFLAGS+=	-Wno-cast-qual

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/zfs_context.h
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/zfs_context.h:1.1.1.3 src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/zfs_context.h:1.2
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/zfs_context.h:1.1.1.3	Mon May 28 20:53:01 2018
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/zfs_context.h	Sat Jun 22 09:48:39 2019
@@ -46,7 +46,9 @@ extern "C" {
 #include 
 #include 
 #include 
+#ifndef __NetBSD__
 #include 
+#endif
 #include 
 #include 
 #include 
@@ -63,38 +65,51 @@ extern "C" {
 #include 
 #include 
 #include 
+#ifndef __NetBSD__
 #include 
+#else
+#include 
+#endif
 #include 
+#ifndef __NetBSD__
 #include 
+#endif
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#ifndef __NetBSD__
 #include 
 #include 
 #include 
 #include 
 #include 
+#endif
 #include 
 #include 
 #include 
 #include 
 #include 
+#ifndef __NetBSD__
 #include 
+#endif
 #include 
 #include 
+#ifndef __NetBSD__
 #include 
 #include 
+#endif
 #include 
 #include 
 #include 
 #include 
 #include 
-#ifdef illumos
+#if defined(illumos) || defined(__NetBSD__)
 #include 
 #endif
+#ifndef __NetBSD__
 #include 
 #include 
 #include 
@@ -113,6 +128,14 @@ extern "C" {
 #endif
 #include 
 #include 
+#else /* !__NetBSD__ */
+#include 
+#include 
+
+#include 
+#endif /* !__NetBSD__ */
+
+#ifndef __NetBSD__
 
 #define	CPU_SEQID	(curcpu)
 
@@ -124,11 +147,106 @@ extern "C" {
 #define	tsd_get(key)			osd_thread_get(curthread, (key))
 #define	tsd_set(key, value)		osd_thread_set(curthread, (key), (value))
 
+#else /* !__NetBSD__ */
+
+#define ASSERT_VOP_LOCKED(vp, name)	KASSERT(VOP_ISLOCKED(vp) != 0)
+#define ASSERT_VOP_ELOCKED(vp, name)	KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE)
+#define callout_drain(x)		callout_halt(x, NULL)
+#define CPU_SEQID			(curcpu()->ci_data.cpu_index)
+#define FIGNORECASE			0
+#define fm_panic			panic
+#define getffd_getfile
+#define getminor(a)			minor(a)
+#define GID_NOBODY			(-2)
+#define issig(x)			(sigispending(curlwp, 0))
+#define kmem_debugging()		0
+#define releasef			fd_putfile
+#define strfree(str)			kmem_free((str), strlen(str)+1)
+#define td_rul_ru
+#define UID_NOBODY			(-2)
+#define vnode_pager_setsize(vp, size)	zfs_netbsd_setsize(vp, s

CVS commit: src

2019-06-22 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Jun 22 09:48:40 UTC 2019

Modified Files:
src/external/cddl/osnet: Makefile.zfs
src/external/cddl/osnet/dist/uts/common/fs/zfs/sys: zfs_context.h
src/usr.sbin/fstyp: Makefile
Added Files:
src/external/cddl/osnet/dist/lib/libzpool/common/sys: zfs_context.h
Removed Files:
src/external/cddl/osnet/sys/sys: zfs_context.h

Log Message:
Sync with upstream r315983.

FreeBSD splits "zfs_context.h" into:
  "lib/libzpool/common/sys/zfs_context.h" for user space
  "uts/common/fs/zfs/sys/zfs_context.h" for kernel space

Do the same here, move and sync "sys/sys/zfs_context.h" to
"dist/lib/libzpool/common/sys/zfs_context.h" and
"dist/uts/common/fs/zfs/sys/zfs_context.h".

Change "Makefile.zfs" to search includes from "dist/lib"
before "dist/uts" so we get the right include file.

Adapt "usr.sbin/fstyp/Makefile" to get the right include file.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/external/cddl/osnet/Makefile.zfs
cvs rdiff -u -r0 -r1.1 \
src/external/cddl/osnet/dist/lib/libzpool/common/sys/zfs_context.h
cvs rdiff -u -r1.1.1.3 -r1.2 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/zfs_context.h
cvs rdiff -u -r1.22 -r0 src/external/cddl/osnet/sys/sys/zfs_context.h
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/fstyp/Makefile

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



CVS commit: src/tools

2019-06-22 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Jun 22 13:42:53 UTC 2019

Modified Files:
src/tools/compat: configure configure.ac nbtool_config.h.in
src/tools/rpcgen: Makefile

Log Message:
Update tools/compat/configure for new path of "rpc/types.h".

Remove intermediate patch from rpcgen/Makefile.

Patch from Nick Hudson, errors from me.


To generate a diff of this commit:
cvs rdiff -u -r1.95 -r1.96 src/tools/compat/configure
cvs rdiff -u -r1.96 -r1.97 src/tools/compat/configure.ac
cvs rdiff -u -r1.51 -r1.52 src/tools/compat/nbtool_config.h.in
cvs rdiff -u -r1.5 -r1.6 src/tools/rpcgen/Makefile

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



CVS commit: src/tools

2019-06-22 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Jun 22 13:42:53 UTC 2019

Modified Files:
src/tools/compat: configure configure.ac nbtool_config.h.in
src/tools/rpcgen: Makefile

Log Message:
Update tools/compat/configure for new path of "rpc/types.h".

Remove intermediate patch from rpcgen/Makefile.

Patch from Nick Hudson, errors from me.


To generate a diff of this commit:
cvs rdiff -u -r1.95 -r1.96 src/tools/compat/configure
cvs rdiff -u -r1.96 -r1.97 src/tools/compat/configure.ac
cvs rdiff -u -r1.51 -r1.52 src/tools/compat/nbtool_config.h.in
cvs rdiff -u -r1.5 -r1.6 src/tools/rpcgen/Makefile

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

Modified files:

Index: src/tools/compat/configure
diff -u src/tools/compat/configure:1.95 src/tools/compat/configure:1.96
--- src/tools/compat/configure:1.95	Wed Jun 19 23:35:55 2019
+++ src/tools/compat/configure	Sat Jun 22 13:42:53 2019
@@ -4098,8 +4098,7 @@ fi
 fi
 
 for ac_header in sys/mtio.h sys/sysmacros.h sys/syslimits.h stdio_ext.h \
-	getopt.h features.h malloc.h sys/poll.h pthread.h stddef.h rpc/types.h \
-	sys/uio.h
+	getopt.h features.h malloc.h sys/poll.h pthread.h stddef.h sys/uio.h
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
@@ -4129,13 +4128,33 @@ fi
 
 done
 
-for ac_header in rpc/types.h netconfig.h
+for ac_header in rpc/types.h
 do :
-  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+  ac_fn_c_check_header_mongrel "$LINENO" "rpc/types.h" "ac_cv_header_rpc_types_h" "$ac_includes_default"
+if test "x$ac_cv_header_rpc_types_h" = xyes; then :
   cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+#define HAVE_RPC_TYPES_H 1
+_ACEOF
+
+else
+  echo '#include "nbtool_config.h"' >include/$ac_header.new
+	echo '#include "'$srcdir/../../common/include/$ac_header'"' \
+		>>include/$ac_header.new
+	if cmp include/$ac_header.new include/$ac_header >/dev/null 2>&1; then
+		rm -f include/$ac_header.new
+	else
+		mv -f include/$ac_header.new include/$ac_header
+	fi
+fi
+
+done
+
+for ac_header in netconfig.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "netconfig.h" "ac_cv_header_netconfig_h" "$ac_includes_default"
+if test "x$ac_cv_header_netconfig_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_NETCONFIG_H 1
 _ACEOF
 
 else
@@ -5111,8 +5130,6 @@ else
 # ifdef _MSC_VER
 #  include 
 #  define alloca _alloca
-# elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)
-#   include 
 # else
 #  ifdef HAVE_ALLOCA_H
 #   include 
@@ -7502,3 +7519,4 @@ if test -n "$ac_unrecognized_opts" && te
   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
 fi
+

Index: src/tools/compat/configure.ac
diff -u src/tools/compat/configure.ac:1.96 src/tools/compat/configure.ac:1.97
--- src/tools/compat/configure.ac:1.96	Wed Jun 19 23:33:07 2019
+++ src/tools/compat/configure.ac	Sat Jun 22 13:42:53 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: configure.ac,v 1.96 2019/06/19 23:33:07 kamil Exp $
+#	$NetBSD: configure.ac,v 1.97 2019/06/22 13:42:53 hannken Exp $
 #
 # Autoconf definition file for libnbcompat.
 #
@@ -79,13 +79,21 @@ AC_CHECK_HEADERS(sys/ioctl.h sys/mman.h 
 # Find headers that may not be available.
 AC_HEADER_DIRENT
 AC_CHECK_HEADERS(sys/mtio.h sys/sysmacros.h sys/syslimits.h stdio_ext.h \
-	getopt.h features.h malloc.h sys/poll.h pthread.h stddef.h rpc/types.h \
-	sys/uio.h)
+	getopt.h features.h malloc.h sys/poll.h pthread.h stddef.h sys/uio.h)
 AC_CHECK_HEADERS(sys/bswap.h machine/bswap.h sys/cdefs.h machine/endian.h \
 	sys/endian.h sys/featuretest.h err.h inttypes.h libgen.h paths.h \
 	libgen.h stdint.h util.h resolv.h arpa/nameser.h,,
 	[test -f include/$ac_header || touch include/$ac_header])
-AC_CHECK_HEADERS(rpc/types.h netconfig.h,,
+AC_CHECK_HEADERS(rpc/types.h,,
+	[echo '#include "nbtool_config.h"' >include/$ac_header.new
+	echo '#include "'$srcdir/../../common/include/$ac_header'"' \
+		>>include/$ac_header.new
+	if cmp include/$ac_header.new include/$ac_header >/dev/null 2>&1; then
+		rm -f include/$ac_header.new
+	else
+		mv -f include/$ac_header.new include/$ac_header
+	fi])
+AC_CHECK_HEADERS(netconfig.h,,
 	[echo '#include "nbtool_config.h"' >include/$ac_header.new
 	echo '#include "'$srcdir/../../include/$ac_header'"' \
 		>>include/$ac_header.new

Index: src/tools/compat/nbtool_config.h.in
diff -u src/tools/compat/nbtool_config.h.in:1.51 src/tools/compat/nbtool_config.h.in:1.52
--- src/tools/compat/nbtool_config.h.in:1.51	Wed Jun 19 23:35:55 2019
+++ src/tools/compat/nbtool_config.h.in	

CVS commit: src/tools/compat

2019-06-22 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Jun 22 14:40:33 UTC 2019

Modified Files:
src/tools/compat: configure

Log Message:
Bring back two lines deleted by accident.  From Kamil Rytarowski.


To generate a diff of this commit:
cvs rdiff -u -r1.96 -r1.97 src/tools/compat/configure

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

Modified files:

Index: src/tools/compat/configure
diff -u src/tools/compat/configure:1.96 src/tools/compat/configure:1.97
--- src/tools/compat/configure:1.96	Sat Jun 22 13:42:53 2019
+++ src/tools/compat/configure	Sat Jun 22 14:40:33 2019
@@ -5130,6 +5130,8 @@ else
 # ifdef _MSC_VER
 #  include 
 #  define alloca _alloca
+# elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)
+#   include 
 # else
 #  ifdef HAVE_ALLOCA_H
 #   include 



CVS commit: src/tools/compat

2019-06-22 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Jun 22 14:40:33 UTC 2019

Modified Files:
src/tools/compat: configure

Log Message:
Bring back two lines deleted by accident.  From Kamil Rytarowski.


To generate a diff of this commit:
cvs rdiff -u -r1.96 -r1.97 src/tools/compat/configure

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



<    1   2   3   4   5   >