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

2024-04-15 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Mon Apr 15 08:06:36 UTC 2024

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

Log Message:
Add a newline to a printf message.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev.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.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev.c:1.6 src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev.c:1.7
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev.c:1.6	Thu Nov 15 04:55:06 2018
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev.c	Mon Apr 15 08:06:36 2024
@@ -3619,7 +3619,7 @@ vdev_deadman(vdev_t *vd)
 vq->vq_io_complete_ts);
 
 printf("SLOW IO: zio timestamp %lluns, "
-"delta %"PRIu64"ns, last io %lluns",
+"delta %"PRIu64"ns, last io %lluns\n",
 fio->io_timestamp, delta,
 vq->vq_io_complete_ts);
 



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

2024-04-15 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Mon Apr 15 08:06:36 UTC 2024

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

Log Message:
Add a newline to a printf message.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev.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

2024-04-05 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Fri Apr  5 11:20:34 UTC 2024

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

Log Message:
Apply FreeBSD svn r373278 fix for ZFS corruption.  Fix for NetBSD
PR kern/58111 .

It would be extremely unlikely to trip this bug on NetBSD, as we don't
expose SEEK_DATA and SEEK_HOLE and you need to call ioctl(2) with
FIOSEEKDATA and FIOSEEKHOLE directly which no currently known code does,
and even then be unlucky enough to trip a race condition.

With a reproducer based on that in https://www.illumos.org/issues/16087,
I saw 11 groups of failures over 8 hours.  With this patch, no
failures in 10 hours.  The repro for NetBSD will be attached to
https://gnats.netbsd.org/58111 .

Original FreeBSD commit message:

dnode_is_dirty: check dnode and its data for dirtiness

Over its history this the dirty dnode test has been changed between
checking for a dnodes being on `os_dirty_dnodes` (`dn_dirty_link`) and
`dn_dirty_record`.

It turns out both are actually required.

In the case of appending data to a newly created file, the dnode proper
is dirtied (at least to change the blocksize) and dirty records are
added.  Thus, a single logical operation is represented by separate
dirty indicators, and must not be separated.

The incorrect dirty check becomes a problem when the first block of a
file is being appended to while another process is calling lseek to skip
holes. There is a small window where the dnode part is undirtied while
there are still dirty records. In this case, `lseek(fd, 0, SEEK_DATA)`
would not know that the file is dirty, and would go to
`dnode_next_offset()`. Since the object has no data blocks yet, it
returns `ESRCH`, indicating no data found, which results in `ENXIO`
being returned to `lseek()`'s caller.

This change simply updates the dirty check to check both types of dirty.
If there's anything dirty at all, we immediately go to the "wait for
sync" stage, It doesn't really matter after that; both changes are on
disk, so the dirty fields should be correct.

Sponsored by:   Klara, Inc.
Sponsored by:   Wasabi Technology, Inc.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu.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.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu.c:1.6 src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu.c:1.7
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu.c:1.6	Mon May 28 21:05:07 2018
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu.c	Fri Apr  5 11:20:34 2024
@@ -2145,7 +2145,8 @@ dmu_object_wait_synced(objset_t *os, uin
 	}
 
 	for (i = 0; i < TXG_SIZE; i++) {
-		if (list_link_active(>dn_dirty_link[i])) {
+		if (list_link_active(>dn_dirty_link[i]) ||
+		!list_is_empty(>dn_dirty_records[i])) {
 			break;
 		}
 	}



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

2024-04-05 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Fri Apr  5 11:20:34 UTC 2024

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

Log Message:
Apply FreeBSD svn r373278 fix for ZFS corruption.  Fix for NetBSD
PR kern/58111 .

It would be extremely unlikely to trip this bug on NetBSD, as we don't
expose SEEK_DATA and SEEK_HOLE and you need to call ioctl(2) with
FIOSEEKDATA and FIOSEEKHOLE directly which no currently known code does,
and even then be unlucky enough to trip a race condition.

With a reproducer based on that in https://www.illumos.org/issues/16087,
I saw 11 groups of failures over 8 hours.  With this patch, no
failures in 10 hours.  The repro for NetBSD will be attached to
https://gnats.netbsd.org/58111 .

Original FreeBSD commit message:

dnode_is_dirty: check dnode and its data for dirtiness

Over its history this the dirty dnode test has been changed between
checking for a dnodes being on `os_dirty_dnodes` (`dn_dirty_link`) and
`dn_dirty_record`.

It turns out both are actually required.

In the case of appending data to a newly created file, the dnode proper
is dirtied (at least to change the blocksize) and dirty records are
added.  Thus, a single logical operation is represented by separate
dirty indicators, and must not be separated.

The incorrect dirty check becomes a problem when the first block of a
file is being appended to while another process is calling lseek to skip
holes. There is a small window where the dnode part is undirtied while
there are still dirty records. In this case, `lseek(fd, 0, SEEK_DATA)`
would not know that the file is dirty, and would go to
`dnode_next_offset()`. Since the object has no data blocks yet, it
returns `ESRCH`, indicating no data found, which results in `ENXIO`
being returned to `lseek()`'s caller.

This change simply updates the dirty check to check both types of dirty.
If there's anything dirty at all, we immediately go to the "wait for
sync" stage, It doesn't really matter after that; both changes are on
disk, so the dirty fields should be correct.

Sponsored by:   Klara, Inc.
Sponsored by:   Wasabi Technology, Inc.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu.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

2023-09-10 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Sep 10 12:50:38 UTC 2023

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

Log Message:
Revert "Teach zfs bdevsw to do b_psize."

This is used only by dump and swap, which won't work safely on zvols
anyway.  We should make swap work eventually, but right now it's
leading unwary ussers into deadlock scenarios, so let's make it fail
early instead.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.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_ioctl.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c:1.25 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c:1.26
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c:1.25	Mon Oct 31 10:32:28 2022
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c	Sun Sep 10 12:50:38 2023
@@ -7062,29 +7062,6 @@ nb_zvol_strategy(struct buf *bp)
 	(void) zvol_strategy(bp);
 }
 
-static int
-nb_zvol_psize(dev_t dev)
-{
-	minor_t minor = getminor(dev);
-	off_t nbytes;
-	unsigned bytespersector;
-
-	if (minor == 0)		/* /dev/zfs */
-		return -1;
-
-	if (zvol_ioctl(dev, DIOCGMEDIASIZE, (intptr_t), 0,
-		NOCRED, NULL))
-		return -1;
-	if (zvol_ioctl(dev, DIOCGSECTORSIZE, (intptr_t), 0,
-		NOCRED, NULL))
-		return -1;
-	if (bytespersector == 0) /* paranoia */
-		return -1;
-	if (nbytes/bytespersector > INT_MAX) /* paranoia */
-		return -1;
-	return nbytes/bytespersector;
-}
-
 static const struct fileops zfs_fileops = {
 	.fo_name = "zfs",
 	.fo_read = fbadop_read,
@@ -7104,7 +7081,7 @@ const struct bdevsw zfs_bdevsw = {
 	.d_strategy = nb_zvol_strategy,
 	.d_ioctl = nb_zfsdev_ioctl,
 	.d_dump = nodump,
-	.d_psize = nb_zvol_psize,
+	.d_psize = nosize,
 	.d_flag = D_DISK | D_MPSAFE
 };
 



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

2023-09-10 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Sep 10 12:50:38 UTC 2023

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

Log Message:
Revert "Teach zfs bdevsw to do b_psize."

This is used only by dump and swap, which won't work safely on zvols
anyway.  We should make swap work eventually, but right now it's
leading unwary ussers into deadlock scenarios, so let's make it fail
early instead.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.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/dtrace

2023-08-03 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Aug  3 08:04:07 UTC 2023

Modified Files:
src/external/cddl/osnet/dist/uts/common/dtrace: dtrace.c

Log Message:
fix uninitialised variable usage.

found by GCC 12.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 \
src/external/cddl/osnet/dist/uts/common/dtrace/dtrace.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/dtrace/dtrace.c
diff -u src/external/cddl/osnet/dist/uts/common/dtrace/dtrace.c:1.41 src/external/cddl/osnet/dist/uts/common/dtrace/dtrace.c:1.42
--- src/external/cddl/osnet/dist/uts/common/dtrace/dtrace.c:1.41	Tue Nov 17 03:20:33 2020
+++ src/external/cddl/osnet/dist/uts/common/dtrace/dtrace.c	Thu Aug  3 08:04:07 2023
@@ -7577,7 +7577,7 @@ dtrace_probe(dtrace_id_t id, uintptr_t a
 	}
 
 	now = mstate.dtms_timestamp = dtrace_gethrtime();
-	mstate.dtms_present |= DTRACE_MSTATE_TIMESTAMP;
+	mstate.dtms_present = DTRACE_MSTATE_TIMESTAMP;
 	vtime = dtrace_vtime_references != 0;
 
 	if (vtime && curthread->t_dtrace_start)



CVS commit: src/external/cddl/osnet/dist/uts/common/dtrace

2023-08-03 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Aug  3 08:04:07 UTC 2023

Modified Files:
src/external/cddl/osnet/dist/uts/common/dtrace: dtrace.c

Log Message:
fix uninitialised variable usage.

found by GCC 12.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 \
src/external/cddl/osnet/dist/uts/common/dtrace/dtrace.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

2023-03-03 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Mar  3 10:01:31 UTC 2023

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

Log Message:
Adapt zfs_netbsd_access() to ACL support.  As ZFS itself only
handles VREAD, VWRITE, VEXEC and VAPPEND we use kauth_authorize_vnode()
to handle VADMIN.

>From FreeBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 \
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

2023-03-03 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Mar  3 10:01:31 UTC 2023

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

Log Message:
Adapt zfs_netbsd_access() to ACL support.  As ZFS itself only
handles VREAD, VWRITE, VEXEC and VAPPEND we use kauth_authorize_vnode()
to handle VADMIN.

>From FreeBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 \
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.80 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.81
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.80	Mon Oct  3 16:04:19 2022
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c	Fri Mar  3 10:01:31 2023
@@ -5169,33 +5169,47 @@ zfs_netbsd_access(void *v)
 		accmode_t a_accmode;
 		kauth_cred_t a_cred;
 	} */ *ap = v;
-	struct vnode *vp = ap->a_vp;
-	accmode_t accmode = ap->a_accmode;
-	mode_t zfs_mode = 0;
+	vnode_t *vp = ap->a_vp;
+	znode_t *zp = VTOZ(vp);
+	accmode_t accmode;
 	kauth_cred_t cred = ap->a_cred;
-	int error;
+	int error = 0;
 
 	/*
-	 * XXX This is really random, especially the left shift by six,
-	 * and it exists only because of randomness in zfs_unix_to_v4
-	 * and zfs_zaccess_rwx in zfs_acl.c.
+	 * ZFS itself only knowns about VREAD, VWRITE, VEXEC and VAPPEND,
 	 */
-	if (accmode & VREAD)
-		zfs_mode |= S_IROTH;
-	if (accmode & VWRITE)
-		zfs_mode |= S_IWOTH;
-	if (accmode & VEXEC)
-		zfs_mode |= S_IXOTH;
-	zfs_mode <<= 6;
+	accmode = ap->a_accmode & (VREAD|VWRITE|VEXEC|VAPPEND);
+	if (accmode != 0)
+		error = zfs_access(vp, accmode, 0, cred, NULL);
 
-	KASSERT(VOP_ISLOCKED(vp));
-	error = zfs_access(vp, zfs_mode, 0, cred, NULL);
+	/*
+	 * VADMIN has to be handled by kauth_authorize_vnode().
+	 */
+	if (error == 0) {
+		accmode = ap->a_accmode & ~(VREAD|VWRITE|VEXEC|VAPPEND);
+		if (accmode != 0) {
+			error = kauth_authorize_vnode(cred,
+			KAUTH_ACCESS_ACTION(accmode, vp->v_type,
+			zp->z_mode & ALLPERMS), vp, NULL,
+			genfs_can_access(vp, cred, zp->z_uid,
+			zp->z_gid, zp->z_mode & ALLPERMS, NULL, accmode));
+		}
+	}
+
+	/*
+	 * For VEXEC, ensure that at least one execute bit is set for
+	 * non-directories.
+	 */
+	if (error == 0 && (ap->a_accmode & VEXEC) != 0 && vp->v_type != VDIR &&
+	(zp->z_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) == 0) {
+		error = EACCES;
+	}
 
 	/* We expect EACCES as common error. */
 	if (error == EPERM)
 		error = EACCES;
 
-	return (error);
+	return error;
 }
 
 static int



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

2023-02-17 Thread Frank Kardel
Module Name:src
Committed By:   kardel
Date:   Fri Feb 17 21:50:14 UTC 2023

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

Log Message:
provide pathconf for .zfs control directory. avoids errors on
ls -l ../.zfs.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ctldir.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_ctldir.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ctldir.c:1.14 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ctldir.c:1.15
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ctldir.c:1.14	Fri Nov  4 11:20:39 2022
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ctldir.c	Fri Feb 17 21:50:13 2023
@@ -1842,6 +1842,7 @@ const struct vnodeopv_entry_desc zfs_sfs
 	{ _putpages_desc,		genfs_null_putpages },
 	{ _islocked_desc,		genfs_islocked },
 	{ _print_desc,		sfs_print },
+	{ _pathconf_desc,		genfs_pathconf },
 	{ NULL, NULL }
 };
 



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

2023-02-17 Thread Frank Kardel
Module Name:src
Committed By:   kardel
Date:   Fri Feb 17 21:50:14 UTC 2023

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

Log Message:
provide pathconf for .zfs control directory. avoids errors on
ls -l ../.zfs.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ctldir.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/os

2022-10-31 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Mon Oct 31 10:44:29 UTC 2022

Modified Files:
src/external/cddl/osnet/dist/uts/common/os: list.c

Log Message:
Provide an empty ASSERT macro ifdef _STANDALONE.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 \
src/external/cddl/osnet/dist/uts/common/os/list.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/os/list.c
diff -u src/external/cddl/osnet/dist/uts/common/os/list.c:1.1.1.1 src/external/cddl/osnet/dist/uts/common/os/list.c:1.2
--- src/external/cddl/osnet/dist/uts/common/os/list.c:1.1.1.1	Fri Aug  7 18:33:45 2009
+++ src/external/cddl/osnet/dist/uts/common/os/list.c	Mon Oct 31 10:44:29 2022
@@ -35,6 +35,10 @@
 #include 
 #include 
 
+#ifdef _STANDALONE
+#define	ASSERT(x)	/* nothing */
+#endif
+
 #define	list_d2l(a, obj) ((list_node_t *)(((char *)obj) + (a)->list_offset))
 #define	list_object(a, node) ((void *)(((char *)node) - (a)->list_offset))
 #define	list_empty(a) ((a)->list_head.list_next == &(a)->list_head)



CVS commit: src/external/cddl/osnet/dist/uts/common/os

2022-10-31 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Mon Oct 31 10:44:29 UTC 2022

Modified Files:
src/external/cddl/osnet/dist/uts/common/os: list.c

Log Message:
Provide an empty ASSERT macro ifdef _STANDALONE.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 \
src/external/cddl/osnet/dist/uts/common/os/list.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

2022-10-31 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Mon Oct 31 10:32:28 UTC 2022

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

Log Message:
Whitespace nit.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.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_ioctl.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c:1.24 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c:1.25
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c:1.24	Mon Mar 28 12:33:20 2022
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c	Mon Oct 31 10:32:28 2022
@@ -3077,7 +3077,7 @@ zfs_get_vfs(const char *resource)
 		mtx_unlock(_mtx);
 #endif
 #ifdef __NetBSD__
-mount_iterator_t *iter;
+	mount_iterator_t *iter;
 
 	mountlist_iterator_init();
 	while ((vfsp = mountlist_iterator_next(iter)) != NULL) {



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

2022-10-31 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Mon Oct 31 10:32:28 UTC 2022

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

Log Message:
Whitespace nit.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.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

2022-10-03 Thread Frank Kardel
Module Name:src
Committed By:   kardel
Date:   Mon Oct  3 16:04:19 UTC 2022

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

Log Message:
Revert. Spotted by hannken@ - fix needs to be in zfs_ctldir.c it is missing
VOP_PATHCONF.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 \
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.79 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.80
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.79	Tue Sep 27 10:33:21 2022
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c	Mon Oct  3 16:04:19 2022
@@ -5027,7 +5027,7 @@ zfs_pathconf(vnode_t *vp, int cmd, ulong
 #endif
 
 	default:
-		return (EINVAL);
+		return (EOPNOTSUPP);
 	}
 }
 



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

2022-10-03 Thread Frank Kardel
Module Name:src
Committed By:   kardel
Date:   Mon Oct  3 16:04:19 UTC 2022

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

Log Message:
Revert. Spotted by hannken@ - fix needs to be in zfs_ctldir.c it is missing
VOP_PATHCONF.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 \
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.



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

2022-10-03 Thread J. Hannken-Illjes
Yes -- I suppose genfs_pathconf() is sufficient here.

--
J. Hannken-Illjes - hann...@mailbox.org

> On 3. Oct 2022, at 11:40, Frank Kardel  wrote:
> 
> 
> Good to know. So do we need to add path conf there?
> Frank
> 
> 3 Oct 2022 11:34:09 J. Hannken-Illjes :
> 
>> Frank,
>> 
>> the vnode operations for ".zfs" are in zfs_ctldir.c and there
>> is no pathconf operation here ...
>> 
>> --
>> J. Hannken-Illjes - hann...@mailbox.org
>> 
>>> On 3. Oct 2022, at 11:26, Frank Kardel  wrote:
>>> 
>>> Well, I am am happy to do that. But ls got eopnotsupp for fpathconf of ACL 
>>> names and barked at them when listing the .zfs snapshot directory. Ls is 
>>> only ignoring einval at that place. So something must be wrong there wrt 
>>> tog.
>>> Frank
>>> 
>>> 3 Oct 2022 10:53:10 J. Hannken-Illjes :
>>> 
> On 27. Sep 2022, at 12:33, Frank Kardel  wrote:
> 
> Module Name:src
> Committed By:   kardel
> Date:   Tue Sep 27 10:33:21 UTC 2022
> 
> Modified Files:
> src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_vnops.c
> 
> Log Message:
> for unsupported names return EINVAL as per TOG
> https://pubs.opengroup.org/onlinepubs/9699919799/functions/fpathconf.html
> discussed with christos@
> 
> 
> To generate a diff of this commit:
> cvs rdiff -u -r1.78 -r1.79 \
>src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c
 
 This is completely wrong!
 
 The call sequence is "VOP_PATHCONF -> zfs_netbsd_pathconf -> zfs_pathconf"
 where zfs_netbsd_pathconf() handles the NetBSD specific names if
 zfs_pathconf() returns EOPNOTSUPP and also returns EINVAL for
 unsupported names in this case.
 
 Please revert.
 
 --
 J. Hannken-Illjes - hann...@mailbox.org



signature.asc
Description: Message signed with OpenPGP


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

2022-10-03 Thread Frank Kardel


Good to know. So do we need to add path conf there?
Frank

3 Oct 2022 11:34:09 J. Hannken-Illjes :

> Frank,
> 
> the vnode operations for ".zfs" are in zfs_ctldir.c and there
> is no pathconf operation here ...
> 
> --
> J. Hannken-Illjes - hann...@mailbox.org
> 
>> On 3. Oct 2022, at 11:26, Frank Kardel  wrote:
>> 
>> Well, I am am happy to do that. But ls got eopnotsupp for fpathconf of ACL 
>> names and barked at them when listing the .zfs snapshot directory. Ls is 
>> only ignoring einval at that place. So something must be wrong there wrt tog.
>> Frank
>> 
>> 3 Oct 2022 10:53:10 J. Hannken-Illjes :
>> 
 On 27. Sep 2022, at 12:33, Frank Kardel  wrote:
 
 Module Name:    src
 Committed By:   kardel
 Date:   Tue Sep 27 10:33:21 UTC 2022
 
 Modified Files:
     src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_vnops.c
 
 Log Message:
 for unsupported names return EINVAL as per TOG
 https://pubs.opengroup.org/onlinepubs/9699919799/functions/fpathconf.html
 discussed with christos@
 
 
 To generate a diff of this commit:
 cvs rdiff -u -r1.78 -r1.79 \
    src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c
>>> 
>>> This is completely wrong!
>>> 
>>> The call sequence is "VOP_PATHCONF -> zfs_netbsd_pathconf -> zfs_pathconf"
>>> where zfs_netbsd_pathconf() handles the NetBSD specific names if
>>> zfs_pathconf() returns EOPNOTSUPP and also returns EINVAL for
>>> unsupported names in this case.
>>> 
>>> Please revert.
>>> 
>>> --
>>> J. Hannken-Illjes - hann...@mailbox.org


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

2022-10-03 Thread J. Hannken-Illjes
Frank,

the vnode operations for ".zfs" are in zfs_ctldir.c and there
is no pathconf operation here ...

--
J. Hannken-Illjes - hann...@mailbox.org

> On 3. Oct 2022, at 11:26, Frank Kardel  wrote:
> 
> Well, I am am happy to do that. But ls got eopnotsupp for fpathconf of ACL 
> names and barked at them when listing the .zfs snapshot directory. Ls is only 
> ignoring einval at that place. So something must be wrong there wrt tog.
> Frank
> 
> 3 Oct 2022 10:53:10 J. Hannken-Illjes :
> 
>>> On 27. Sep 2022, at 12:33, Frank Kardel  wrote:
>>> 
>>> Module Name:src
>>> Committed By:   kardel
>>> Date:   Tue Sep 27 10:33:21 UTC 2022
>>> 
>>> Modified Files:
>>> src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_vnops.c
>>> 
>>> Log Message:
>>> for unsupported names return EINVAL as per TOG
>>> https://pubs.opengroup.org/onlinepubs/9699919799/functions/fpathconf.html
>>> discussed with christos@
>>> 
>>> 
>>> To generate a diff of this commit:
>>> cvs rdiff -u -r1.78 -r1.79 \
>>>src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c
>> 
>> This is completely wrong!
>> 
>> The call sequence is "VOP_PATHCONF -> zfs_netbsd_pathconf -> zfs_pathconf"
>> where zfs_netbsd_pathconf() handles the NetBSD specific names if
>> zfs_pathconf() returns EOPNOTSUPP and also returns EINVAL for
>> unsupported names in this case.
>> 
>> Please revert.
>> 
>> --
>> J. Hannken-Illjes - hann...@mailbox.org



signature.asc
Description: Message signed with OpenPGP


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

2022-10-03 Thread Frank Kardel
Well, I am am happy to do that. But ls got eopnotsupp for fpathconf of ACL 
names and barked at them when listing the .zfs snapshot directory. Ls is only 
ignoring einval at that place. So something must be wrong there wrt tog.
Frank

3 Oct 2022 10:53:10 J. Hannken-Illjes :

>> On 27. Sep 2022, at 12:33, Frank Kardel  wrote:
>> 
>> Module Name:    src
>> Committed By:   kardel
>> Date:   Tue Sep 27 10:33:21 UTC 2022
>> 
>> Modified Files:
>>     src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_vnops.c
>> 
>> Log Message:
>> for unsupported names return EINVAL as per TOG
>> https://pubs.opengroup.org/onlinepubs/9699919799/functions/fpathconf.html
>> discussed with christos@
>> 
>> 
>> To generate a diff of this commit:
>> cvs rdiff -u -r1.78 -r1.79 \
>>    src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c
> 
> This is completely wrong!
> 
> The call sequence is "VOP_PATHCONF -> zfs_netbsd_pathconf -> zfs_pathconf"
> where zfs_netbsd_pathconf() handles the NetBSD specific names if
> zfs_pathconf() returns EOPNOTSUPP and also returns EINVAL for
> unsupported names in this case.
> 
> Please revert.
> 
> --
> J. Hannken-Illjes - hann...@mailbox.org


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

2022-10-03 Thread J. Hannken-Illjes
> On 27. Sep 2022, at 12:33, Frank Kardel  wrote:
> 
> Module Name:  src
> Committed By: kardel
> Date: Tue Sep 27 10:33:21 UTC 2022
> 
> Modified Files:
>   src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_vnops.c
> 
> Log Message:
> for unsupported names return EINVAL as per TOG
> https://pubs.opengroup.org/onlinepubs/9699919799/functions/fpathconf.html
> discussed with christos@
> 
> 
> To generate a diff of this commit:
> cvs rdiff -u -r1.78 -r1.79 \
>src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c

This is completely wrong!

The call sequence is "VOP_PATHCONF -> zfs_netbsd_pathconf -> zfs_pathconf"
where zfs_netbsd_pathconf() handles the NetBSD specific names if
zfs_pathconf() returns EOPNOTSUPP and also returns EINVAL for
unsupported names in this case.

Please revert.

--
J. Hannken-Illjes - hann...@mailbox.org


signature.asc
Description: Message signed with OpenPGP


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

2022-09-27 Thread Frank Kardel
Module Name:src
Committed By:   kardel
Date:   Tue Sep 27 10:33:21 UTC 2022

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

Log Message:
for unsupported names return EINVAL as per TOG
https://pubs.opengroup.org/onlinepubs/9699919799/functions/fpathconf.html
discussed with christos@


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 \
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.78 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.79
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.78	Sun Mar 27 16:26:26 2022
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c	Tue Sep 27 10:33:21 2022
@@ -5027,7 +5027,7 @@ zfs_pathconf(vnode_t *vp, int cmd, ulong
 #endif
 
 	default:
-		return (EOPNOTSUPP);
+		return (EINVAL);
 	}
 }
 



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

2022-09-27 Thread Frank Kardel
Module Name:src
Committed By:   kardel
Date:   Tue Sep 27 10:33:21 UTC 2022

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

Log Message:
for unsupported names return EINVAL as per TOG
https://pubs.opengroup.org/onlinepubs/9699919799/functions/fpathconf.html
discussed with christos@


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 \
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

2022-08-02 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Wed Aug  3 01:53:06 UTC 2022

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

Log Message:
change the ARC reclaim code to use the pagedaemon's free page target
rather than having a separate target.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/arc.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/arc.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/arc.c:1.21 src/external/cddl/osnet/dist/uts/common/fs/zfs/arc.c:1.22
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/arc.c:1.21	Wed May  4 15:49:55 2022
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/arc.c	Wed Aug  3 01:53:06 2022
@@ -288,6 +288,7 @@ int arc_procfd;
 #define	freemem		uvm_availmem(false)
 #define	minfree		uvmexp.freemin
 #define	desfree		uvmexp.freetarg
+#define	zfs_arc_free_target desfree
 #define	lotsfree	(desfree * 2)
 #define	availrmem	desfree
 #define	swapfs_minfree	0
@@ -387,7 +388,6 @@ int zfs_arc_grow_retry = 0;
 int zfs_arc_shrink_shift = 0;
 int zfs_arc_p_min_shift = 0;
 uint64_t zfs_arc_average_blocksize = 8 * 1024; /* 8KB */
-u_int zfs_arc_free_target = 0;
 
 /* Absolute min for arc min / max is 16MB. */
 static uint64_t arc_abs_min = 16 << 20;
@@ -395,6 +395,8 @@ static uint64_t arc_abs_min = 16 << 20;
 boolean_t zfs_compressed_arc_enabled = B_TRUE;
 
 #if defined(__FreeBSD__) && defined(_KERNEL)
+u_int zfs_arc_free_target = 0;
+
 static int sysctl_vfs_zfs_arc_free_target(SYSCTL_HANDLER_ARGS);
 static int sysctl_vfs_zfs_arc_meta_limit(SYSCTL_HANDLER_ARGS);
 static int sysctl_vfs_zfs_arc_max(SYSCTL_HANDLER_ARGS);



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

2022-08-02 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Wed Aug  3 01:53:06 UTC 2022

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

Log Message:
change the ARC reclaim code to use the pagedaemon's free page target
rather than having a separate target.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/arc.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

2022-05-04 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Wed May  4 15:49:55 UTC 2022

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

Log Message:
fix ARC checks for available memory:
there's an extra check that we inherited from FreeBSD that tries to
detect KVA exhaustion on platforms with limited KVA, but the condition
that decided whether to use the extra check was using a FreeBSDism
that doesn't exist on NetBSD, resulting in this check being used on
all platforms.  on amd64 systems with lots of memory, this extra check
would result in the ARC thinking that it constantly needed to reclaim memory,
resulting in all the xcall threads running all the time but not doing
anything useful.  change this condition so that this extra check for
KVA exhaustion is only used on 32-bit platforms.  fixes PR 55707.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/arc.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/arc.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/arc.c:1.20 src/external/cddl/osnet/dist/uts/common/fs/zfs/arc.c:1.21
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/arc.c:1.20	Wed Apr 21 10:02:34 2021
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/arc.c	Wed May  4 15:49:55 2022
@@ -3963,7 +3963,7 @@ arc_available_memory(void)
 	}
 
 #endif	/* illumos */
-#if defined(__i386) || !defined(UMA_MD_SMALL_ALLOC)
+#if !defined(_LP64)
 	/*
 	 * If we're on an i386 platform, it's possible that we'll exhaust the
 	 * kernel heap space before we ever run out of available physical
@@ -5750,7 +5750,7 @@ arc_memory_throttle(uint64_t reserve, ui
 	static uint64_t page_load = 0;
 	static uint64_t last_txg = 0;
 
-#if defined(__i386) || !defined(UMA_MD_SMALL_ALLOC)
+#if !defined(_LP64)
 	available_memory =
 	MIN(available_memory, ptob(vmem_size(heap_arena, VMEM_FREE)));
 #endif



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

2022-05-04 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Wed May  4 15:49:55 UTC 2022

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

Log Message:
fix ARC checks for available memory:
there's an extra check that we inherited from FreeBSD that tries to
detect KVA exhaustion on platforms with limited KVA, but the condition
that decided whether to use the extra check was using a FreeBSDism
that doesn't exist on NetBSD, resulting in this check being used on
all platforms.  on amd64 systems with lots of memory, this extra check
would result in the ARC thinking that it constantly needed to reclaim memory,
resulting in all the xcall threads running all the time but not doing
anything useful.  change this condition so that this extra check for
KVA exhaustion is only used on 32-bit platforms.  fixes PR 55707.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/arc.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

2022-04-16 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Apr 16 07:56:45 UTC 2022

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

Log Message:
Unlock vnode for VOP_IOCTL().


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 \
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.19 src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c:1.20
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c:1.19	Sat Nov 28 22:53:06 2020
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c	Sat Apr 16 07:56:45 2022
@@ -132,9 +132,7 @@ vdev_disk_flush(struct work *work, void 
 	KASSERT(vp == dvd->vd_vp);
 
 	cmd = 1;
-	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
 	error = VOP_IOCTL(vp, DIOCCACHESYNC, , FREAD|FWRITE, kcred);
-	VOP_UNLOCK(vp, 0);
 	bp->b_error = error;
 	vdev_disk_io_intr(bp);
 }



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

2022-04-16 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Apr 16 07:56:45 UTC 2022

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

Log Message:
Unlock vnode for VOP_IOCTL().


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 \
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

2022-03-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar 27 16:26:26 UTC 2022

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

Log Message:
add a kauth vnode check for adding links


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 \
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.77 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.78
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.77	Wed Dec 22 09:04:10 2021
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c	Sun Mar 27 12:26:26 2022
@@ -5794,10 +5794,19 @@ zfs_netbsd_link(void *v)
 	nm = PNBUF_GET();
 	(void)strlcpy(nm, cnp->cn_nameptr, cnp->cn_namelen + 1);
 
-	vn_lock(vp, LK_EXCLUSIVE);
+	if ((error = vn_lock(vp, LK_EXCLUSIVE)) != 0) {
+		/* XXX: No ABORTOP? */
+		PNBUF_PUT(nm);
+		return error;
+	}
+	error = kauth_authorize_vnode(cnp->cn_cred, KAUTH_VNODE_ADD_LINK, vp,
+	dvp, 0);
+	if (error)
+		goto out;
 	error = zfs_link(dvp, vp, nm, cnp->cn_cred,
 	NULL, 0);
 
+out:
 	PNBUF_PUT(nm);
 	VOP_UNLOCK(vp, 0);
 	return error;



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

2022-03-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar 27 16:26:26 UTC 2022

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

Log Message:
add a kauth vnode check for adding links


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 \
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/sys

2021-12-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Dec 28 17:51:23 UTC 2021

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

Log Message:
zfs: Expose hostid to zfs, as in gethostid/sethostid(3).

If set to nonzero, the hostid is recorded in the metadata of a zpool,
and checked by `zpool import' when the pool has not been explicitly
exported.  After reboot, zpool import will not need `-f' to reimport
the pool.

Setting the hostid must be done explicitly through sysctl (or the
sethostid(3) library call) on all ports except acorn32, amiga,
mvme68k, newsmips, sparc, sparc64, sun2, and sun3.  So for most users
this change will have no immediate effect.  But you can obviate the
need for `zpool import -f' by adding `kern.hostid=123456789' to
/etc/sysctl.conf and importing the pool one last time with `-f'.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/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/sys/zfs_context.h
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/zfs_context.h:1.3 src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/zfs_context.h:1.4
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/zfs_context.h:1.3	Tue Feb 16 09:54:17 2021
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/zfs_context.h	Tue Dec 28 17:51:23 2021
@@ -130,6 +130,7 @@ extern "C" {
 #include 
 #else /* !__NetBSD__ */
 #include 
+#include 
 #include 
 
 #include 
@@ -165,7 +166,7 @@ extern "C" {
 #define td_rul_ru
 #define UID_NOBODY			(32767)
 #define vnode_pager_setsize(vp, size)	zfs_netbsd_setsize(vp, size)
-#define zone_get_hostid(a)		0
+#define zone_get_hostid(a)		((unsigned)hostid)
 
 extern struct utsname utsname;
 



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

2021-12-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Dec 28 17:51:23 UTC 2021

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

Log Message:
zfs: Expose hostid to zfs, as in gethostid/sethostid(3).

If set to nonzero, the hostid is recorded in the metadata of a zpool,
and checked by `zpool import' when the pool has not been explicitly
exported.  After reboot, zpool import will not need `-f' to reimport
the pool.

Setting the hostid must be done explicitly through sysctl (or the
sethostid(3) library call) on all ports except acorn32, amiga,
mvme68k, newsmips, sparc, sparc64, sun2, and sun3.  So for most users
this change will have no immediate effect.  But you can obviate the
need for `zpool import -f' by adding `kern.hostid=123456789' to
/etc/sysctl.conf and importing the pool one last time with `-f'.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/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/dist/uts/common/fs/zfs

2021-12-22 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Wed Dec 22 14:04:10 UTC 2021

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

Log Message:
In zfs_setattr() don't recheck the auth policy for a "nodump" flags
change. zfs_netbsd_setattr() has already checked if this request is
authorised, and our secpolicy_xvattr() doesn't check kauth chflags.

XXX: Fix this propery when we migrate to openzfs.

riastradh@: Seems reasonable.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 \
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.76 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.77
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.76	Wed Oct 20 03:08:19 2021
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c	Wed Dec 22 14:04:10 2021
@@ -3503,7 +3503,17 @@ zfs_setattr(vnode_t *vp, vattr_t *vap, i
 		if (XVA_ISSET_REQ(xvap, XAT_NODUMP)) {
 			if (xoap->xoa_nodump !=
 			((zp->z_pflags & ZFS_NODUMP) != 0)) {
+#if 0
+/*
+ * XXXSB - zfs_netbsd_setattr()
+ * has already checked if this
+ * request is authorised, and our
+ * secpolicy_xvattr() doesn't check
+ * kauth chflags.  Fix this when we
+ * migrate to openzfs.
+ */
 need_policy = TRUE;
+#endif
 			} else {
 XVA_CLR_REQ(xvap, XAT_NODUMP);
 XVA_SET_REQ(, XAT_NODUMP);



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

2021-12-22 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Wed Dec 22 14:04:10 UTC 2021

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

Log Message:
In zfs_setattr() don't recheck the auth policy for a "nodump" flags
change. zfs_netbsd_setattr() has already checked if this request is
authorised, and our secpolicy_xvattr() doesn't check kauth chflags.

XXX: Fix this propery when we migrate to openzfs.

riastradh@: Seems reasonable.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 \
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

2021-12-21 Thread Hauke Fath
Module Name:src
Committed By:   hauke
Date:   Tue Dec 21 15:08:14 UTC 2021

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

Log Message:
Default files to BSD group ownership in line with ffs, after the lead
of FreeBSD 
(patch by hannken@)


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_acl.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

2021-12-21 Thread Hauke Fath
Module Name:src
Committed By:   hauke
Date:   Tue Dec 21 15:08:14 UTC 2021

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

Log Message:
Default files to BSD group ownership in line with ffs, after the lead
of FreeBSD 
(patch by hannken@)


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_acl.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_acl.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_acl.c:1.6 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_acl.c:1.7
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_acl.c:1.6	Tue Mar 17 00:54:03 2020
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_acl.c	Tue Dec 21 15:08:14 2021
@@ -1661,7 +1661,7 @@ zfs_acl_ids_create(znode_t *dzp, int fla
 			} else {
 acl_ids->z_fgid = zfs_fuid_create_cred(zfsvfs,
 ZFS_GROUP, cr, _ids->z_fuidp);
-#ifdef __FreeBSD_kernel__
+#if defined(__FreeBSD_kernel__) || defined(__NetBSD__)
 gid = acl_ids->z_fgid = dzp->z_gid;
 #else
 gid = crgetgid(cr);



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

2021-11-30 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Tue Nov 30 12:37:38 UTC 2021

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

Log Message:
In zfs_statvfs(), set f_bresvd and f_fresvd to 0.  Fixes random kernel
accounting suspend/resumes with erroneous values leaking out.

Note: no userland leakage as statvfs(2) handler memset 0's the buffer.

XXX: Should be fixed with a memset in VFS_STATVFS().


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 \
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.29 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c:1.30
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c:1.29	Thu Aug 27 09:57:33 2020
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c	Tue Nov 30 12:37:38 2021
@@ -2182,6 +2182,7 @@ zfs_statvfs(vfs_t *vfsp, struct statvfs 
 	statp->f_blocks = (refdbytes + availbytes) >> SPA_MINBLOCKSHIFT;
 	statp->f_bfree = availbytes / statp->f_bsize;
 	statp->f_bavail = statp->f_bfree; /* no root reservation */
+	statp->f_bresvd = 0;
 
 	/*
 	 * statvfs() should really be called statufs(), because it assumes
@@ -2196,6 +2197,7 @@ zfs_statvfs(vfs_t *vfsp, struct statvfs 
 	statp->f_favail = statp->f_ffree;	/* no "root reservation" */
 #endif
 	statp->f_files = statp->f_ffree + usedobjs;
+	statp->f_fresvd = 0;
 
 #ifdef __FreeBSD__
 	(void) cmpldev(, vfsp->vfs_dev);



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

2021-11-30 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Tue Nov 30 12:37:38 UTC 2021

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

Log Message:
In zfs_statvfs(), set f_bresvd and f_fresvd to 0.  Fixes random kernel
accounting suspend/resumes with erroneous values leaking out.

Note: no userland leakage as statvfs(2) handler memset 0's the buffer.

XXX: Should be fixed with a memset in VFS_STATVFS().


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 \
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

2021-09-06 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Mon Sep  6 08:37:43 UTC 2021

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

Log Message:
Clamp zfs nlinks at UINT32_MAX (nlink_t max) instead of (much) smaller
16-bit LINK_MAX until we bump LINK_MAX.  Fixes fts(3) problems with
"rm -rf" on zfs directories with > 32766 subdirectories.

Thanks mlelstv@ and mrg@ for helping debug this.


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 \
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.74 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.75
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.74	Sun Jul 18 23:57:13 2021
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c	Mon Sep  6 08:37:43 2021
@@ -3116,7 +3116,8 @@ zfs_getattr(vnode_t *vp, vattr_t *vap, i
 		links = zp->z_links + 1;
 	else
 		links = zp->z_links;
-	vap->va_nlink = MIN(links, LINK_MAX);	/* nlink_t limit! */
+	/* XXX NetBSD: use LINK_MAX when that value matches 32-bit nlink_t */
+	vap->va_nlink = MIN(links, UINT32_MAX);	/* nlink_t limit! */
 	vap->va_size = zp->z_size;
 #ifdef illumos
 	vap->va_rdev = vp->v_rdev;



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

2021-09-06 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Mon Sep  6 08:37:43 UTC 2021

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

Log Message:
Clamp zfs nlinks at UINT32_MAX (nlink_t max) instead of (much) smaller
16-bit LINK_MAX until we bump LINK_MAX.  Fixes fts(3) problems with
"rm -rf" on zfs directories with > 32766 subdirectories.

Thanks mlelstv@ and mrg@ for helping debug this.


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 \
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

2021-07-04 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun Jul  4 11:25:07 UTC 2021

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

Log Message:
Add VOP_PARSEPATH to zfs control dir vnode op table.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ctldir.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_ctldir.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ctldir.c:1.12 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ctldir.c:1.13
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ctldir.c:1.12	Sat May 16 18:31:46 2020
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ctldir.c	Sun Jul  4 11:25:07 2021
@@ -1825,6 +1825,7 @@ sfs_print(void *v)
 
 const struct vnodeopv_entry_desc zfs_sfsop_entries[] = {
 	{ _default_desc,		vn_default_error },
+	{ _parsepath_desc,		genfs_parsepath },
 	{ _lookup_desc,		sfs_lookup },
 	{ _open_desc,		sfs_open },
 	{ _close_desc,		sfs_close },



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

2021-07-04 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun Jul  4 11:25:07 UTC 2021

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

Log Message:
Add VOP_PARSEPATH to zfs control dir vnode op table.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ctldir.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

2021-07-02 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Fri Jul  2 17:14:37 UTC 2021

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

Log Message:
Add VOP_PARSEPATH to zfs's vnode table. "oops"

zfs not being under src/sys strikes again :-(


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 \
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.71 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.72
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.71	Sun Nov 15 00:54:13 2020
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c	Fri Jul  2 17:14:36 2021
@@ -6347,6 +6347,7 @@ const struct genfs_ops zfs_genfsops = {
 int (**zfs_vnodeop_p)(void *);
 const struct vnodeopv_entry_desc zfs_vnodeop_entries[] = {
 	{ _default_desc,		vn_default_error },
+	{ _parsepath_desc,		genfs_parsepath },
 	{ _lookup_desc,		zfs_netbsd_lookup },
 	{ _create_desc,		zfs_netbsd_create },
 	{ _mknod_desc,		zfs_netbsd_mknod },



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

2021-07-02 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Fri Jul  2 17:14:37 UTC 2021

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

Log Message:
Add VOP_PARSEPATH to zfs's vnode table. "oops"

zfs not being under src/sys strikes again :-(


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 \
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

2021-04-21 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Apr 21 10:02:34 UTC 2021

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

Log Message:
Prevent blocking l2arc_feed_thread() forever, skip the
cv_timedwait() for negative or zero ticks.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/arc.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

2021-04-21 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Apr 21 10:02:34 UTC 2021

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

Log Message:
Prevent blocking l2arc_feed_thread() forever, skip the
cv_timedwait() for negative or zero ticks.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/arc.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/arc.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/arc.c:1.19 src/external/cddl/osnet/dist/uts/common/fs/zfs/arc.c:1.20
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/arc.c:1.19	Thu Jun 11 19:20:42 2020
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/arc.c	Wed Apr 21 10:02:34 2021
@@ -7246,8 +7246,15 @@ l2arc_feed_thread(void *dummy __unused)
 
 	while (l2arc_thread_exit == 0) {
 		CALLB_CPR_SAFE_BEGIN();
+#ifdef __NetBSD__
+		clock_t now = ddi_get_lbolt();
+		if (next > now)
+			(void) cv_timedwait(_feed_thr_cv,
+			_feed_thr_lock, next - now);
+#else
 		(void) cv_timedwait(_feed_thr_cv, _feed_thr_lock,
 		next - ddi_get_lbolt());
+#endif
 		CALLB_CPR_SAFE_END(, _feed_thr_lock);
 		next = ddi_get_lbolt() + hz;
 



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

2021-03-25 Thread Greg Troxel
Module Name:src
Committed By:   gdt
Date:   Thu Mar 25 18:41:29 UTC 2021

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

Log Message:
zfs_ioctl.c: Drop WARNING that ZFS is under development

Following discussions on current-users@, it seems many rely on ZFS to
store data, and there are not particularly large issues with ZFS.  ATF
tests with /tmp as tmpfs, ffs2, and zfs are similar, with only a
slight increase in failures under zfs.

(This commit should probably NOT be pulled up to 9.)


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.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_ioctl.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c:1.22 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c:1.23
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c:1.22	Fri Feb 28 03:52:26 2020
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c	Thu Mar 25 18:41:29 2021
@@ -7194,7 +7194,6 @@ zfs_modcmd(modcmd_t cmd, void *arg)
 		/* XXXNETBSD trim is not supported yet */
 		zfs_trim_enabled = B_FALSE;
 
-		printf("WARNING: ZFS on NetBSD is under development\n");
 		availrmem = (uint64_t)physmem * PAGE_SIZE / 1048576;
 		if (availrmem < ZFS_MIN_MEGS * 80 / 100) {
 			printf("ERROR: at least %dMB of memory required to "



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

2021-03-25 Thread Greg Troxel
Module Name:src
Committed By:   gdt
Date:   Thu Mar 25 18:41:29 UTC 2021

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

Log Message:
zfs_ioctl.c: Drop WARNING that ZFS is under development

Following discussions on current-users@, it seems many rely on ZFS to
store data, and there are not particularly large issues with ZFS.  ATF
tests with /tmp as tmpfs, ffs2, and zfs are similar, with only a
slight increase in failures under zfs.

(This commit should probably NOT be pulled up to 9.)


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.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/sys

2021-02-16 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Feb 16 09:54:17 UTC 2021

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

Log Message:
Use the right uid / gid for nobody:nobody like FreeBSD does.

Prevents null pointer dereferences when ZFS replaces this
illegal (according to IS_EPHEMERAL()) id with another
illegal id in operation zfs_fuid_create_cred() and
finally zfs_log_create() dereferences fuidp being NULL.

Adresses PR misc/55042 (Panic when creating a directory on a NFS served ZFS)


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/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/sys/zfs_context.h
diff -u 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.3
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/zfs_context.h:1.2	Sat Jun 22 09:48:39 2019
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/zfs_context.h	Tue Feb 16 09:54:17 2021
@@ -157,13 +157,13 @@ extern "C" {
 #define fm_panic			panic
 #define getffd_getfile
 #define getminor(a)			minor(a)
-#define GID_NOBODY			(-2)
+#define GID_NOBODY			(39)
 #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 UID_NOBODY			(32767)
 #define vnode_pager_setsize(vp, size)	zfs_netbsd_setsize(vp, size)
 #define zone_get_hostid(a)		0
 



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

2021-02-16 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Feb 16 09:54:17 UTC 2021

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

Log Message:
Use the right uid / gid for nobody:nobody like FreeBSD does.

Prevents null pointer dereferences when ZFS replaces this
illegal (according to IS_EPHEMERAL()) id with another
illegal id in operation zfs_fuid_create_cred() and
finally zfs_log_create() dereferences fuidp being NULL.

Adresses PR misc/55042 (Panic when creating a directory on a NFS served ZFS)


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

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



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

2020-11-29 Thread Yorick Hardy
On 2020-11-28, Yorick Hardy wrote:
> Module Name:  src
> Committed By: yhardy
> Date: Sat Nov 28 22:53:06 UTC 2020
> 
> Modified Files:
>   src/external/cddl/osnet/dist/uts/common/fs/zfs: vdev_disk.c
> 
> Log Message:
> Use vn_close to release the vnodes in the error handling blocks, since
> the vnodes were opened for writing. Fix proposed on current-users
> and improved by hannken@.
> 
> 
> To generate a diff of this commit:
> cvs rdiff -u -r1.18 -r1.19 \
> 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.


Oops, that should have been "proposed on tech-kern":

 http://mail-index.netbsd.org/tech-kern/2020/11/28/msg026984.html

-- 
Kind regards,

Yorick Hardy


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

2020-11-28 Thread Yorick Hardy
Module Name:src
Committed By:   yhardy
Date:   Sat Nov 28 22:53:06 UTC 2020

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

Log Message:
Use vn_close to release the vnodes in the error handling blocks, since
the vnodes were opened for writing. Fix proposed on current-users
and improved by hannken@.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 \
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.18 src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c:1.19
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c:1.18	Thu Jun 25 09:39:15 2020
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c	Sat Nov 28 22:53:06 2020
@@ -215,7 +215,11 @@ vdev_disk_open(vdev_t *vd, uint64_t *psi
 		return (SET_ERROR(error));
 	}
 	if (vp->v_type != VBLK) {
+#ifdef __NetBSD__
+		vn_close(vp, FREAD|FWRITE, kcred);
+#else
 		vrele(vp);
+#endif
 		vd->vdev_stat.vs_aux = VDEV_AUX_OPEN_FAILED;
 		return (SET_ERROR(EINVAL));
 	}
@@ -247,7 +251,11 @@ vdev_disk_open(vdev_t *vd, uint64_t *psi
 	error = workqueue_create(>vd_wq, "vdevsync",
 	vdev_disk_flush, dvd, PRI_NONE, IPL_NONE, WQ_MPSAFE);
 	if (error != 0) {
+#ifdef __NetBSD__
+		vn_close(vp, FREAD|FWRITE, kcred);
+#else
 		vrele(vp);
+#endif
 		return (SET_ERROR(error));
 	}
 



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

2020-11-28 Thread Yorick Hardy
Module Name:src
Committed By:   yhardy
Date:   Sat Nov 28 22:53:06 UTC 2020

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

Log Message:
Use vn_close to release the vnodes in the error handling blocks, since
the vnodes were opened for writing. Fix proposed on current-users
and improved by hannken@.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 \
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/dtrace

2020-11-16 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Tue Nov 17 03:20:33 UTC 2020

Modified Files:
src/external/cddl/osnet/dist/uts/common/dtrace: dtrace.c

Log Message:
Remove a pointless printf.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 \
src/external/cddl/osnet/dist/uts/common/dtrace/dtrace.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/dtrace

2020-11-16 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Tue Nov 17 03:20:33 UTC 2020

Modified Files:
src/external/cddl/osnet/dist/uts/common/dtrace: dtrace.c

Log Message:
Remove a pointless printf.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 \
src/external/cddl/osnet/dist/uts/common/dtrace/dtrace.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/dtrace/dtrace.c
diff -u src/external/cddl/osnet/dist/uts/common/dtrace/dtrace.c:1.40 src/external/cddl/osnet/dist/uts/common/dtrace/dtrace.c:1.41
--- src/external/cddl/osnet/dist/uts/common/dtrace/dtrace.c:1.40	Sat May 23 23:42:41 2020
+++ src/external/cddl/osnet/dist/uts/common/dtrace/dtrace.c	Tue Nov 17 03:20:33 2020
@@ -13840,7 +13840,6 @@ doferr:
 	return (NULL);
 #endif /* __FreeBSD__ */
 #ifdef __NetBSD__
-	printf("dtrace: XXX %s not implemented (name=%s)\n", __func__, name);
 	return (NULL);
 #endif /* __NetBSD__ */
 }



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

2020-11-14 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Sun Nov 15 00:54:13 UTC 2020

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

Log Message:
Commit the ZFS file that I forgot in this previous commit:

Move the handling of PG_PAGEOUT from uvm_aio_aiodone_pages() to
uvm_page_unbusy() so that all callers of uvm_page_unbusy() don't need to
handle this flag separately.  Split out the pages part of uvm_aio_aiodone()
into uvm_aio_aiodone_pages() in rump just like in the real kernel.
In ZFS functions that can fail to copy data between the ARC and VM pages,
use uvm_aio_aiodone_pages() rather than uvm_page_unbusy() so that we can
handle these "I/O" errors.  Fixes PR 55702.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 \
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

2020-11-14 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Sun Nov 15 00:54:13 UTC 2020

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

Log Message:
Commit the ZFS file that I forgot in this previous commit:

Move the handling of PG_PAGEOUT from uvm_aio_aiodone_pages() to
uvm_page_unbusy() so that all callers of uvm_page_unbusy() don't need to
handle this flag separately.  Split out the pages part of uvm_aio_aiodone()
into uvm_aio_aiodone_pages() in rump just like in the real kernel.
In ZFS functions that can fail to copy data between the ARC and VM pages,
use uvm_aio_aiodone_pages() rather than uvm_page_unbusy() so that we can
handle these "I/O" errors.  Fixes PR 55702.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 \
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.70 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.71
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.70	Thu Aug 27 09:57:33 2020
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c	Sun Nov 15 00:54:13 2020
@@ -6049,20 +6049,13 @@ zfs_netbsd_getpages(void *v)
 			PAGE_SIZE, va, DMU_READ_PREFETCH);
 			zfs_unmap_page(pg, va);
 
-			rw_enter(rw, RW_WRITER);
 			if (err != 0) {
-for (i = 0; i < npages; i++) {
-	pg = ap->a_m[i];
-	if ((pg->flags & PG_FAKE) != 0) {
-		uvm_pagefree(pg);
-	} else {
-		uvm_page_unbusy(, 1);
-	}
-}
+uvm_aio_aiodone_pages(ap->a_m, npages, false, err);
 memset(ap->a_m, 0, sizeof(ap->a_m[0]) *
 npages);
 break;
 			}
+			rw_enter(rw, RW_WRITER);
 			pg->flags &= ~(PG_FAKE);
 		}
 
@@ -6089,14 +6082,13 @@ zfs_putapage(vnode_t *vp, page_t **pp, i
 	voff_t		len, klen;
 	int		err;
 
-	bool async = (flags & PGO_SYNCIO) == 0;
 	bool *cleanedp;
 	struct uvm_object *uobj = >v_uobj;
 	krwlock_t *rw = uobj->vmobjlock;
 
 	if (zp->z_sa_hdl == NULL) {
 		err = 0;
-		goto out_unbusy;
+		goto out;
 	}
 
 	/*
@@ -6170,12 +6162,8 @@ zfs_putapage(vnode_t *vp, page_t **pp, i
 	}
 	dmu_tx_commit(tx);
 
-out_unbusy:
-	rw_enter(rw, RW_WRITER);
-	uvm_page_unbusy(pp, count);
-	rw_exit(rw);
-
 out:
+	uvm_aio_aiodone_pages(pp, count, true, err);
 	return (err);
 }
 



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

2020-10-09 Thread Frank Kardel
Module Name:src
Committed By:   kardel
Date:   Fri Oct  9 08:18:01 UTC 2020

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

Log Message:
PR kern/55705:
don't attempt to sleep for negative time, we are late anyway - avoids 
DIAGNOSTIC panic


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
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/external/cddl/osnet/dist/uts/common/fs/zfs

2020-10-09 Thread Frank Kardel
Module Name:src
Committed By:   kardel
Date:   Fri Oct  9 08:18:01 UTC 2020

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

Log Message:
PR kern/55705:
don't attempt to sleep for negative time, we are late anyway - avoids 
DIAGNOSTIC panic


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
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.5 src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_tx.c:1.6
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_tx.c:1.5	Mon Mar  9 15:37:46 2020
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_tx.c	Fri Oct  9 08:18:01 2020
@@ -1153,6 +1153,9 @@ dmu_tx_delay(dmu_tx_t *tx, uint64_t dirt
 #ifdef __NetBSD__
 	int timo = (wakeup - now) * hz / 10;
 
+	if (timo < 0)
+		return;
+
 	if (timo == 0)
 		timo = 1;
 	kpause("dmu_tx_delay", false, timo, NULL);



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

2020-09-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Sep  7 19:04:27 UTC 2020

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

Log Message:
Comment out index out of bounds debugging code.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/dnode_sync.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/dnode_sync.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/dnode_sync.c:1.6 src/external/cddl/osnet/dist/uts/common/fs/zfs/dnode_sync.c:1.7
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/dnode_sync.c:1.6	Mon May 28 17:05:07 2018
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/dnode_sync.c	Mon Sep  7 15:04:27 2020
@@ -689,6 +689,7 @@ dnode_sync(dnode_t *dn, dmu_tx_t *tx)
 			bzero(dnp->dn_blkptr + dnp->dn_nblkptr,
 			sizeof (blkptr_t) *
 			(dn->dn_next_nblkptr[txgoff] - dnp->dn_nblkptr));
+#ifdef notyet /* XXX: gcc-9 */
 #ifdef ZFS_DEBUG
 		} else {
 			int i;
@@ -698,6 +699,7 @@ dnode_sync(dnode_t *dn, dmu_tx_t *tx)
 			i < dnp->dn_nblkptr; i++)
 ASSERT(BP_IS_HOLE(>dn_blkptr[i]));
 #endif
+#endif
 		}
 		mutex_enter(>dn_mtx);
 		dnp->dn_nblkptr = dn->dn_next_nblkptr[txgoff];



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

2020-09-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Sep  7 19:04:27 UTC 2020

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

Log Message:
Comment out index out of bounds debugging code.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/dnode_sync.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

2020-09-07 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Sep  7 07:44:53 UTC 2020

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

Log Message:
i can't confirm or deny that GCC 9 is wrong about parity_valid[]
having uninitialised members, but since setting up reconstruct
isn't a hot path, just zero init the whole thing to be sure.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_raidz.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_raidz.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_raidz.c:1.2 src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_raidz.c:1.3
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_raidz.c:1.2	Mon May 28 21:05:07 2018
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_raidz.c	Mon Sep  7 07:44:53 2020
@@ -1412,7 +1412,7 @@ vdev_raidz_reconstruct(raidz_map_t *rm, 
 	int i, c;
 	int code;
 	int nbadparity, nbaddata;
-	int parity_valid[VDEV_RAIDZ_MAXPARITY];
+	int parity_valid[VDEV_RAIDZ_MAXPARITY] = {0};
 
 	/*
 	 * The tgts list must already be sorted.



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

2020-09-07 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Sep  7 07:44:53 UTC 2020

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

Log Message:
i can't confirm or deny that GCC 9 is wrong about parity_valid[]
having uninitialised members, but since setting up reconstruct
isn't a hot path, just zero init the whole thing to be sure.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_raidz.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

2020-08-27 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Aug 27 09:57:34 UTC 2020

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

Log Message:
Enable NCLOOKUP for ZFS.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c
cvs rdiff -u -r1.69 -r1.70 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c
cvs rdiff -u -r1.33 -r1.34 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.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.28 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c:1.29
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c:1.28	Tue May 26 08:39:27 2020
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c	Thu Aug 27 09:57:33 2020
@@ -1517,7 +1517,7 @@ zfs_domount(vfs_t *vfsp, char *osname)
 #endif
 #ifdef __NetBSD__
 	vfsp->mnt_flag |= MNT_LOCAL;
-	vfsp->mnt_iflag |= IMNT_MPSAFE;
+	vfsp->mnt_iflag |= IMNT_MPSAFE | IMNT_NCLOOKUP;
 #endif
 
 	/*
@@ -2078,7 +2078,7 @@ zfs_mount(vfs_t *vfsp, const char *path,
 	vfsp->vfs_flag |= MNT_NFS4ACLS;
 #endif
 #ifdef __NetBSD__
-	vfsp->mnt_iflag |= IMNT_MPSAFE;
+	vfsp->mnt_iflag |= IMNT_MPSAFE | IMNT_NCLOOKUP;
 #endif
 
 	/*

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.69 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.70
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.69	Thu May 21 20:43:23 2020
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c	Thu Aug 27 09:57:33 2020
@@ -1354,6 +1354,10 @@ zfs_write(vnode_t *vp, uio_t *uio, int i
 			newmode = zp->z_mode;
 			(void) sa_update(zp->z_sa_hdl, SA_ZPL_MODE(zfsvfs),
 			(void *), sizeof (uint64_t), tx);
+#ifdef __NetBSD__
+			cache_enter_id(vp, zp->z_mode, zp->z_uid, zp->z_gid,
+			true);
+#endif
 		}
 		mutex_exit(>z_acl_lock);
 
@@ -5645,8 +5649,11 @@ zfs_netbsd_setattr(void *v)
 	}
 
 	error = zfs_setattr(vp, (vattr_t *), flags, cred, NULL);
-	if (error == 0)
-		VN_KNOTE(vp, NOTE_ATTRIB);
+	if (error)
+		return error;
+
+	VN_KNOTE(vp, NOTE_ATTRIB);
+	cache_enter_id(vp, zp->z_mode, zp->z_uid, zp->z_gid, true);
 
 	return error;
 }

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.33 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c:1.34
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c:1.33	Thu May  7 09:13:06 2020
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c	Thu Aug 27 09:57:33 2020
@@ -871,6 +871,7 @@ zfs_loadvnode(struct mount *mp, struct v
 		return (SET_ERROR(ENOENT));
 	}
 	ASSERT(zp == VTOZ(vp));
+	cache_enter_id(vp, zp->z_mode, zp->z_uid, zp->z_gid, true);
 
 	ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num);
 
@@ -891,6 +892,8 @@ zfs_newvnode(struct mount *mp, vnode_t *
 
 	zfs_mknode1(dzp, vap, tx, cr, flag, , acl_ids, vp);
 	ASSERT(zp == VTOZ(vp));
+	cache_enter_id(vp, zp->z_mode, zp->z_uid, zp->z_gid, true);
+
 	*key_len = sizeof(zp->z_id);
 	*new_key = >z_id;
 



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

2020-08-27 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Aug 27 09:57:34 UTC 2020

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

Log Message:
Enable NCLOOKUP for ZFS.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c
cvs rdiff -u -r1.69 -r1.70 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c
cvs rdiff -u -r1.33 -r1.34 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.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

2020-06-27 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sat Jun 27 21:21:11 UTC 2020

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

Log Message:
fix bug introduced in conversion to kmem(9), passing address of the local
variable instead of pointer to allocated memory

should fix PR kern/55426 by Andreas Gustafsson


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_queue.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

2020-06-27 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sat Jun 27 21:21:11 UTC 2020

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

Log Message:
fix bug introduced in conversion to kmem(9), passing address of the local
variable instead of pointer to allocated memory

should fix PR kern/55426 by Andreas Gustafsson


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_queue.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_queue.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_queue.c:1.2 src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_queue.c:1.3
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_queue.c:1.2	Wed Jun 24 16:16:01 2020
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_queue.c	Sat Jun 27 21:21:11 2020
@@ -820,7 +820,7 @@ again:
 	search = kmem_zalloc(sizeof (*search), KM_NOSLEEP);
 	if (search) {
 		search->io_offset = vq->vq_last_offset + 1;
-		VERIFY3P(avl_find(tree, , ), ==, NULL);
+		VERIFY3P(avl_find(tree, search, ), ==, NULL);
 		kmem_free(search, sizeof (*search));
 		zio = avl_nearest(tree, idx, AVL_AFTER);
 	} else {



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

2020-06-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Jun 25 09:39:15 UTC 2020

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

Log Message:
Don't assume everything is a wedge and has a parent device. On non-wedges
this crashes.

Instead, just talk to the referenced device and rely on the dk driver
to pass requests correctly.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 \
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.17 src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c:1.18
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c:1.17	Sun Jun 21 21:29:11 2020
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c	Thu Jun 25 09:39:15 2020
@@ -222,19 +222,18 @@ vdev_disk_open(vdev_t *vd, uint64_t *psi
 
 	pdk = NULL;
 	if (getdiskinfo(vp, ) == 0)
-		pdk = disk_find(dkw.dkw_parent);
+		pdk = disk_find(dkw.dkw_devname);
 
 	/* XXXNETBSD Once tls-maxphys gets merged this block becomes:
 		dvd->vd_maxphys = (pdk ? disk_maxphys(pdk) : MACHINE_MAXPHYS);
 	*/
 	{
 		struct buf buf = {
+			.b_dev = vp->v_rdev,
 			.b_bcount = MAXPHYS,
 		};
-		if (pdk && pdk->dk_driver && pdk->dk_driver->d_minphys) {
-			buf.b_dev = pdk->dk_rawvp->v_rdev;
+		if (pdk && pdk->dk_driver && pdk->dk_driver->d_minphys)
 			(*pdk->dk_driver->d_minphys)();
-		}
 		dvd->vd_maxphys = buf.b_bcount;
 	}
 



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

2020-06-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Jun 25 09:39:15 UTC 2020

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

Log Message:
Don't assume everything is a wedge and has a parent device. On non-wedges
this crashes.

Instead, just talk to the referenced device and rely on the dk driver
to pass requests correctly.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 \
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

2020-06-24 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Wed Jun 24 16:29:34 UTC 2020

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

Log Message:
reduce stack usage in dsl_scan_recurse() - allocate memory for
temporary zbookmark_phys_t using kmem_alloc() rather than stack;
this recuses several times usually, and this saves 2x
sizeof(zbookmark_phys_t) == 64 bytes per recursion

part of fix for PR kern/55402 by Frank Kardel


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/dsl_scan.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/dsl_scan.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/dsl_scan.c:1.2 src/external/cddl/osnet/dist/uts/common/fs/zfs/dsl_scan.c:1.3
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/dsl_scan.c:1.2	Wed Jun 24 16:23:16 2020
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/dsl_scan.c	Wed Jun 24 16:29:34 2020
@@ -397,7 +397,7 @@ static void dsl_scan_visitbp(blkptr_t *b
 dmu_objset_type_t ostype, dmu_tx_t *tx);
 static void dsl_scan_visitdnode(dsl_scan_t *, dsl_dataset_t *ds,
 dmu_objset_type_t ostype,
-dnode_phys_t *dnp, uint64_t object, dmu_tx_t *tx);
+dnode_phys_t *dnp, uint64_t object, dmu_tx_t *tx, zbookmark_phys_t *);
 
 void
 dsl_free(dsl_pool_t *dp, uint64_t txg, const blkptr_t *bp)
@@ -585,9 +585,8 @@ dsl_scan_zil(dsl_pool_t *dp, zil_header_
 /* ARGSUSED */
 static void
 dsl_scan_prefetch(dsl_scan_t *scn, arc_buf_t *buf, blkptr_t *bp,
-uint64_t objset, uint64_t object, uint64_t blkid)
+uint64_t objset, uint64_t object, uint64_t blkid, zbookmark_phys_t *czb)
 {
-	zbookmark_phys_t czb;
 	arc_flags_t flags = ARC_FLAG_NOWAIT | ARC_FLAG_PREFETCH;
 
 	if (zfs_no_scrub_prefetch)
@@ -597,11 +596,11 @@ dsl_scan_prefetch(dsl_scan_t *scn, arc_b
 	(BP_GET_LEVEL(bp) == 0 && BP_GET_TYPE(bp) != DMU_OT_DNODE))
 		return;
 
-	SET_BOOKMARK(, objset, object, BP_GET_LEVEL(bp), blkid);
+	SET_BOOKMARK(czb, objset, object, BP_GET_LEVEL(bp), blkid);
 
 	(void) arc_read(scn->scn_zio_root, scn->scn_dp->dp_spa, bp,
 	NULL, NULL, ZIO_PRIORITY_ASYNC_READ,
-	ZIO_FLAG_CANFAIL | ZIO_FLAG_SCAN_THREAD, , );
+	ZIO_FLAG_CANFAIL | ZIO_FLAG_SCAN_THREAD, , czb);
 }
 
 static boolean_t
@@ -659,6 +658,7 @@ dsl_scan_recurse(dsl_scan_t *scn, dsl_da
 		blkptr_t *cbp;
 		int epb = BP_GET_LSIZE(bp) >> SPA_BLKPTRSHIFT;
 		arc_buf_t *buf;
+		zbookmark_phys_t *czb;
 
 		err = arc_read(NULL, dp->dp_spa, bp, arc_getbuf_func, ,
 		ZIO_PRIORITY_ASYNC_READ, zio_flags, , zb);
@@ -666,19 +666,19 @@ dsl_scan_recurse(dsl_scan_t *scn, dsl_da
 			scn->scn_phys.scn_errors++;
 			return (err);
 		}
+		czb = kmem_alloc(sizeof (*czb), KM_SLEEP);
 		for (i = 0, cbp = buf->b_data; i < epb; i++, cbp++) {
 			dsl_scan_prefetch(scn, buf, cbp, zb->zb_objset,
-			zb->zb_object, zb->zb_blkid * epb + i);
+			zb->zb_object, zb->zb_blkid * epb + i, czb);
 		}
 		for (i = 0, cbp = buf->b_data; i < epb; i++, cbp++) {
-			zbookmark_phys_t czb;
-
-			SET_BOOKMARK(, zb->zb_objset, zb->zb_object,
+			SET_BOOKMARK(czb, zb->zb_objset, zb->zb_object,
 			zb->zb_level - 1,
 			zb->zb_blkid * epb + i);
-			dsl_scan_visitbp(cbp, , dnp,
+			dsl_scan_visitbp(cbp, czb, dnp,
 			ds, scn, ostype, tx);
 		}
+		kmem_free(czb, sizeof (*czb));
 		arc_buf_destroy(buf, );
 	} else if (BP_GET_TYPE(bp) == DMU_OT_DNODE) {
 		arc_flags_t flags = ARC_FLAG_WAIT;
@@ -686,6 +686,7 @@ dsl_scan_recurse(dsl_scan_t *scn, dsl_da
 		int i, j;
 		int epb = BP_GET_LSIZE(bp) >> DNODE_SHIFT;
 		arc_buf_t *buf;
+		zbookmark_phys_t *czb;
 
 		err = arc_read(NULL, dp->dp_spa, bp, arc_getbuf_func, ,
 		ZIO_PRIORITY_ASYNC_READ, zio_flags, , zb);
@@ -693,23 +694,27 @@ dsl_scan_recurse(dsl_scan_t *scn, dsl_da
 			scn->scn_phys.scn_errors++;
 			return (err);
 		}
+		czb = kmem_alloc(sizeof (*czb), KM_SLEEP);
 		for (i = 0, cdnp = buf->b_data; i < epb; i++, cdnp++) {
 			for (j = 0; j < cdnp->dn_nblkptr; j++) {
 blkptr_t *cbp = >dn_blkptr[j];
 dsl_scan_prefetch(scn, buf, cbp,
-zb->zb_objset, zb->zb_blkid * epb + i, j);
+zb->zb_objset, zb->zb_blkid * epb + i, j,
+czb);
 			}
 		}
 		for (i = 0, cdnp = buf->b_data; i < epb; i++, cdnp++) {
 			dsl_scan_visitdnode(scn, ds, ostype,
-			cdnp, zb->zb_blkid * epb + i, tx);
+			cdnp, zb->zb_blkid * epb + i, tx, czb);
 		}
+		kmem_free(czb, sizeof (*czb));
 
 		arc_buf_destroy(buf, );
 	} else if (BP_GET_TYPE(bp) == DMU_OT_OBJSET) {
 		arc_flags_t flags = ARC_FLAG_WAIT;
 		objset_phys_t *osp;
 		arc_buf_t *buf;
+		zbookmark_phys_t *czb;
 
 		err = arc_read(NULL, dp->dp_spa, bp, arc_getbuf_func, ,
 		ZIO_PRIORITY_ASYNC_READ, zio_flags, , zb);
@@ -720,8 +725,9 @@ dsl_scan_recurse(dsl_scan_t *scn, dsl_da
 
 		osp = buf->b_data;
 
+		czb = kmem_alloc(sizeof (*czb), KM_SLEEP);
 		

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

2020-06-24 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Wed Jun 24 16:29:34 UTC 2020

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

Log Message:
reduce stack usage in dsl_scan_recurse() - allocate memory for
temporary zbookmark_phys_t using kmem_alloc() rather than stack;
this recuses several times usually, and this saves 2x
sizeof(zbookmark_phys_t) == 64 bytes per recursion

part of fix for PR kern/55402 by Frank Kardel


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/dsl_scan.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

2020-06-24 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Wed Jun 24 16:23:16 UTC 2020

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

Log Message:
change dsl_scan_visitbp() to allocate blkptr_t dynamically rather than
on-stack - this function is called recursively, and the 120 bytes per call
add up; also remove unused variable

part of fix for PR kern/55402 by Frank Kardel


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/dsl_scan.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/dsl_scan.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/dsl_scan.c:1.1.1.1 src/external/cddl/osnet/dist/uts/common/fs/zfs/dsl_scan.c:1.2
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/dsl_scan.c:1.1.1.1	Mon May 28 20:52:57 2018
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/dsl_scan.c	Wed Jun 24 16:23:16 2020
@@ -778,10 +778,7 @@ dsl_scan_visitbp(blkptr_t *bp, const zbo
 dmu_objset_type_t ostype, dmu_tx_t *tx)
 {
 	dsl_pool_t *dp = scn->scn_dp;
-	arc_buf_t *buf = NULL;
-	blkptr_t bp_toread = *bp;
-
-	/* ASSERT(pbuf == NULL || arc_released(pbuf)); */
+	blkptr_t *bp_toread = NULL;
 
 	if (dsl_scan_check_pause(scn, zb))
 		return;
@@ -803,8 +800,11 @@ dsl_scan_visitbp(blkptr_t *bp, const zbo
 	if (bp->blk_birth <= scn->scn_phys.scn_cur_min_txg)
 		return;
 
-	if (dsl_scan_recurse(scn, ds, ostype, dnp, _toread, zb, tx) != 0)
-		return;
+	bp_toread = kmem_alloc(sizeof (blkptr_t), KM_SLEEP);
+	*bp_toread = *bp;
+
+	if (dsl_scan_recurse(scn, ds, ostype, dnp, bp_toread, zb, tx) != 0)
+		goto out;
 
 	/*
 	 * If dsl_scan_ddt() has aready visited this block, it will have
@@ -813,8 +813,7 @@ dsl_scan_visitbp(blkptr_t *bp, const zbo
 	 */
 	if (ddt_class_contains(dp->dp_spa,
 	scn->scn_phys.scn_ddt_class_max, bp)) {
-		ASSERT(buf == NULL);
-		return;
+		goto out;
 	}
 
 	/*
@@ -827,6 +826,9 @@ dsl_scan_visitbp(blkptr_t *bp, const zbo
 	if (BP_PHYSICAL_BIRTH(bp) <= scn->scn_phys.scn_cur_max_txg) {
 		scan_funcs[scn->scn_phys.scn_func](dp, bp, zb);
 	}
+
+out:
+	kmem_free(bp_toread, sizeof (blkptr_t));
 }
 
 static void



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

2020-06-24 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Wed Jun 24 16:23:16 UTC 2020

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

Log Message:
change dsl_scan_visitbp() to allocate blkptr_t dynamically rather than
on-stack - this function is called recursively, and the 120 bytes per call
add up; also remove unused variable

part of fix for PR kern/55402 by Frank Kardel


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/dsl_scan.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

2020-06-24 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Wed Jun 24 16:16:01 UTC 2020

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

Log Message:
reduce stack usage in vdev_queue_io_to_issue() - zio_t is about 1KB, and
the function potentially recurses into itself

part of fix for PR kern/55402 by Frank Kardel


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.3 -r1.2 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_queue.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_queue.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_queue.c:1.1.1.3 src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_queue.c:1.2
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_queue.c:1.1.1.3	Mon May 28 20:52:59 2018
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_queue.c	Wed Jun 24 16:16:01 2020
@@ -798,7 +798,7 @@ vdev_queue_io_to_issue(vdev_queue_t *vq)
 	zio_priority_t p;
 	avl_index_t idx;
 	avl_tree_t *tree;
-	zio_t search;
+	zio_t *search;
 
 again:
 	ASSERT(MUTEX_HELD(>vq_lock));
@@ -817,10 +817,16 @@ again:
 	 * For FIFO queues (sync), issue the i/o with the lowest timestamp.
 	 */
 	tree = vdev_queue_class_tree(vq, p);
-	search.io_timestamp = 0;
-	search.io_offset = vq->vq_last_offset + 1;
-	VERIFY3P(avl_find(tree, , ), ==, NULL);
-	zio = avl_nearest(tree, idx, AVL_AFTER);
+	search = kmem_zalloc(sizeof (*search), KM_NOSLEEP);
+	if (search) {
+		search->io_offset = vq->vq_last_offset + 1;
+		VERIFY3P(avl_find(tree, , ), ==, NULL);
+		kmem_free(search, sizeof (*search));
+		zio = avl_nearest(tree, idx, AVL_AFTER);
+	} else {
+		/* Can't find nearest, fallback to first */
+		zio = NULL;
+	}
 	if (zio == NULL)
 		zio = avl_first(tree);
 	ASSERT3U(zio->io_priority, ==, p);



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

2020-06-24 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Wed Jun 24 16:16:01 UTC 2020

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

Log Message:
reduce stack usage in vdev_queue_io_to_issue() - zio_t is about 1KB, and
the function potentially recurses into itself

part of fix for PR kern/55402 by Frank Kardel


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.3 -r1.2 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_queue.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

2020-06-21 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Jun 21 21:29:11 UTC 2020

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

Log Message:
If calling d_minphys on the parent disk device, make sure we use the
parent disk device's dev_t. Fixes zfs on wedges on ld(4).

XXX pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 \
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

2020-06-21 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Jun 21 21:29:11 UTC 2020

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

Log Message:
If calling d_minphys on the parent disk device, make sure we use the
parent disk device's dev_t. Fixes zfs on wedges on ld(4).

XXX pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 \
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.16 src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c:1.17
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c:1.16	Wed Apr 29 04:30:40 2020
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c	Sun Jun 21 21:29:11 2020
@@ -229,11 +229,12 @@ vdev_disk_open(vdev_t *vd, uint64_t *psi
 	*/
 	{
 		struct buf buf = {
-			.b_dev = vp->v_rdev,
 			.b_bcount = MAXPHYS,
 		};
-		if (pdk && pdk->dk_driver && pdk->dk_driver->d_minphys)
+		if (pdk && pdk->dk_driver && pdk->dk_driver->d_minphys) {
+			buf.b_dev = pdk->dk_rawvp->v_rdev;
 			(*pdk->dk_driver->d_minphys)();
+		}
 		dvd->vd_maxphys = buf.b_bcount;
 	}
 



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

2020-06-19 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Fri Jun 19 14:13:23 UTC 2020

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

Log Message:
use pool_cache for (meta)data buffers also on NetBSD

this should generally slightly improve performance on MP systems, and
specifically for xbd(4) storage avoids slow unaligned I/O buffer handling

this change requires updated kernel, to allow up to SPA_MAXBLOCKSHIFT item
size for pools

fixes PR kern/55397 by Frank Kardel


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/external/cddl/osnet/dist/uts/common/fs/zfs/zio.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/zio.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zio.c:1.6 src/external/cddl/osnet/dist/uts/common/fs/zfs/zio.c:1.7
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zio.c:1.6	Tue May  7 08:49:59 2019
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zio.c	Fri Jun 19 14:13:23 2020
@@ -46,7 +46,7 @@
 SYSCTL_DECL(_vfs_zfs);
 SYSCTL_NODE(_vfs_zfs, OID_AUTO, zio, CTLFLAG_RW, 0, "ZFS ZIO");
 #ifdef __NetBSD__
-const int zio_use_uma = 0;
+const int zio_use_uma = 1;
 #else
 #if defined(__amd64__)
 static int zio_use_uma = 1;
@@ -156,7 +156,6 @@ zio_init(void)
 	zio_link_cache = kmem_cache_create("zio_link_cache",
 	sizeof (zio_link_t), 0, NULL, NULL, NULL, NULL, NULL, 0);
 
-#ifndef __NetBSD__
 	if (!zio_use_uma)
 		goto out;
 
@@ -220,7 +219,6 @@ zio_init(void)
 			zio_data_buf_cache[c - 1] = zio_data_buf_cache[c];
 	}
 out:
-#endif /* __NetBSD__ */
 
 	zio_inject_init();
 
@@ -242,7 +240,6 @@ zio_fini(void)
 	kmem_cache_t *last_cache = NULL;
 	kmem_cache_t *last_data_cache = NULL;
 
-#ifndef __NetBSD__	
 	for (c = 0; c < SPA_MAXBLOCKSIZE >> SPA_MINBLOCKSHIFT; c++) {
 		if (zio_buf_cache[c] != last_cache) {
 			last_cache = zio_buf_cache[c];
@@ -256,7 +253,6 @@ zio_fini(void)
 		}
 		zio_data_buf_cache[c] = NULL;
 	}
-#endif /* __NetBSD__ */
 
 	kmem_cache_destroy(zio_link_cache);
 	kmem_cache_destroy(zio_cache);



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

2020-06-19 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Fri Jun 19 14:13:23 UTC 2020

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

Log Message:
use pool_cache for (meta)data buffers also on NetBSD

this should generally slightly improve performance on MP systems, and
specifically for xbd(4) storage avoids slow unaligned I/O buffer handling

this change requires updated kernel, to allow up to SPA_MAXBLOCKSHIFT item
size for pools

fixes PR kern/55397 by Frank Kardel


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/external/cddl/osnet/dist/uts/common/fs/zfs/zio.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

2020-05-21 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Thu May 21 20:43:23 UTC 2020

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

Log Message:
Fix bugs in previous.


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 \
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

2020-05-21 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Thu May 21 20:43:23 UTC 2020

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

Log Message:
Fix bugs in previous.


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 \
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.68 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.69
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.68	Wed May 20 20:47:18 2020
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c	Thu May 21 20:43:23 2020
@@ -5971,7 +5971,6 @@ zfs_netbsd_getpages(void *v)
 	} */ * const ap = v;
 
 	vnode_t *const vp = ap->a_vp;
-	off_t offset = ap->a_offset + (ap->a_centeridx << PAGE_SHIFT);
 	const int flags = ap->a_flags;
 	const bool async = (flags & PGO_SYNCIO) == 0;
 	const bool memwrite = (ap->a_access_type & VM_PROT_WRITE) != 0;
@@ -5983,12 +5982,13 @@ zfs_netbsd_getpages(void *v)
 	vfs_t *mp;
 	struct vm_page *pg;
 	caddr_t va;
-	int npages, found, err = 0;
+	int npages = *ap->a_count, found, err = 0;
 
 	if (flags & PGO_LOCKED) {
- 		uvn_findpages(uobj, ap->a_offset, ap->a_count, ap->a_m, NULL,
+ 		uvn_findpages(uobj, ap->a_offset, , ap->a_m, NULL,
 		UFP_NOWAIT | UFP_NOALLOC | UFP_NOBUSY |
 		(memwrite ? UFP_NORDONLY : 0));
+		KASSERT(npages == *ap->a_count);
 		if (memwrite) {
 			KASSERT(rw_write_held(uobj->vmobjlock));
 			for (int i = 0; i < npages; i++) {
@@ -6010,9 +6010,6 @@ zfs_netbsd_getpages(void *v)
 	if (async) {
 		return 0;
 	}
-	if (*ap->a_count != 1) {
-		return EBUSY;
-	}
 
 	mp = vp->v_mount;
 	fstrans_start(mp);
@@ -6024,18 +6021,20 @@ zfs_netbsd_getpages(void *v)
 	ZFS_VERIFY_ZP(zp);
 
 	rw_enter(rw, RW_WRITER);
-	if (offset >= vp->v_size) {
+	if (ap->a_offset + (npages << PAGE_SHIFT) > round_page(vp->v_size)) {
 		rw_exit(rw);
 		ZFS_EXIT(zfsvfs);
 		fstrans_done(mp);
 		return EINVAL;
 	}
-	npages = *ap->a_count;
-	uvn_findpages(uobj, offset, , ap->a_m, NULL, UFP_ALL);
+	uvn_findpages(uobj, ap->a_offset, , ap->a_m, NULL, UFP_ALL);
+	KASSERT(npages == *ap->a_count);
 
 	for (int i = 0; i < npages; i++) {
 		pg = ap->a_m[i];
 		if (pg->flags & PG_FAKE) {
+			voff_t offset = pg->offset;
+			KASSERT(pg->offset == ap->a_offset + (i << PAGE_SHIFT));
 			rw_exit(rw);
 
 			va = zfs_map_page(pg, S_WRITE);



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

2020-05-20 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Wed May 20 20:47:18 UTC 2020

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

Log Message:
zfs_netbsd_getpages:

- implement the PGO_LOCKED case
- handle npages > 1 for PGO_SYNCIO


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 \
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.67 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.68
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.67	Sat May 16 18:31:46 2020
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c	Wed May 20 20:47:18 2020
@@ -755,15 +755,14 @@ mappedread(vnode_t *vp, int nbytes, uio_
 			va = zfs_map_page(pp, S_READ);
 			error = uiomove(va + off, bytes, UIO_READ, uio);
 			zfs_unmap_page(pp, va);
+			rw_enter(rw, RW_WRITER);
+			uvm_page_unbusy(, 1);
+			rw_exit(rw);
 		} else {
 			error = dmu_read_uio_dbuf(sa_get_db(zp->z_sa_hdl),
 			uio, bytes);
 		}
 
-		rw_enter(rw, RW_WRITER);
-		uvm_page_unbusy(, 1);
-		rw_exit(rw);
-
 		len -= bytes;
 		off = 0;
 		if (error)
@@ -5987,9 +5986,24 @@ zfs_netbsd_getpages(void *v)
 	int npages, found, err = 0;
 
 	if (flags & PGO_LOCKED) {
-		*ap->a_count = 0;
-		ap->a_m[ap->a_centeridx] = NULL;
-		return EBUSY;
+ 		uvn_findpages(uobj, ap->a_offset, ap->a_count, ap->a_m, NULL,
+		UFP_NOWAIT | UFP_NOALLOC | UFP_NOBUSY |
+		(memwrite ? UFP_NORDONLY : 0));
+		if (memwrite) {
+			KASSERT(rw_write_held(uobj->vmobjlock));
+			for (int i = 0; i < npages; i++) {
+pg = ap->a_m[i];
+if (pg == NULL || pg == PGO_DONTCARE) {
+	continue;
+}
+if (uvm_pagegetdirty(pg) ==
+UVM_PAGE_STATUS_CLEAN) {
+	uvm_pagemarkdirty(pg,
+	UVM_PAGE_STATUS_UNKNOWN);
+}
+			}
+		}
+		return ap->a_m[ap->a_centeridx] == NULL ? EBUSY : 0;
 	}
 	rw_exit(rw);
 
@@ -6016,28 +6030,42 @@ zfs_netbsd_getpages(void *v)
 		fstrans_done(mp);
 		return EINVAL;
 	}
-	npages = 1;
-	pg = NULL;
-	uvn_findpages(uobj, offset, , , NULL, UFP_ALL);
+	npages = *ap->a_count;
+	uvn_findpages(uobj, offset, , ap->a_m, NULL, UFP_ALL);
 
-	if (pg->flags & PG_FAKE) {
-		rw_exit(rw);
+	for (int i = 0; i < npages; i++) {
+		pg = ap->a_m[i];
+		if (pg->flags & PG_FAKE) {
+			rw_exit(rw);
 
-		va = zfs_map_page(pg, S_WRITE);
-		err = dmu_read(zfsvfs->z_os, zp->z_id, offset, PAGE_SIZE,
-		va, DMU_READ_PREFETCH);
-		zfs_unmap_page(pg, va);
+			va = zfs_map_page(pg, S_WRITE);
+			err = dmu_read(zfsvfs->z_os, zp->z_id, offset,
+			PAGE_SIZE, va, DMU_READ_PREFETCH);
+			zfs_unmap_page(pg, va);
 
-		rw_enter(rw, RW_WRITER);
-		pg->flags &= ~(PG_FAKE);
-	}
+			rw_enter(rw, RW_WRITER);
+			if (err != 0) {
+for (i = 0; i < npages; i++) {
+	pg = ap->a_m[i];
+	if ((pg->flags & PG_FAKE) != 0) {
+		uvm_pagefree(pg);
+	} else {
+		uvm_page_unbusy(, 1);
+	}
+}
+memset(ap->a_m, 0, sizeof(ap->a_m[0]) *
+npages);
+break;
+			}
+			pg->flags &= ~(PG_FAKE);
+		}
 
-	if (memwrite && uvm_pagegetdirty(pg) == UVM_PAGE_STATUS_CLEAN) {
-		/* For write faults, start dirtiness tracking. */
-		uvm_pagemarkdirty(pg, UVM_PAGE_STATUS_UNKNOWN);
+		if (memwrite && uvm_pagegetdirty(pg) == UVM_PAGE_STATUS_CLEAN) {
+			/* For write faults, start dirtiness tracking. */
+			uvm_pagemarkdirty(pg, UVM_PAGE_STATUS_UNKNOWN);
+		}
 	}
 	rw_exit(rw);
-	ap->a_m[ap->a_centeridx] = pg;
 
 	ZFS_EXIT(zfsvfs);
 	fstrans_done(mp);



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

2020-05-20 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Wed May 20 20:47:18 UTC 2020

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

Log Message:
zfs_netbsd_getpages:

- implement the PGO_LOCKED case
- handle npages > 1 for PGO_SYNCIO


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 \
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

2020-05-12 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Wed May 13 05:52:54 UTC 2020

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

Log Message:
fix the handling in putpage of the page containing EOF.


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 \
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.65 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.66
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.65	Thu May  7 09:12:03 2020
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c	Wed May 13 05:52:54 2020
@@ -6066,9 +6066,29 @@ zfs_putapage(vnode_t *vp, page_t **pp, i
 		goto out_unbusy;
 	}
 
+	/*
+	 * Calculate the length and assert that no whole pages are past EOF.
+	 * This check is equivalent to "off + len <= round_page(zp->z_size)",
+	 * with gyrations to avoid signed integer overflow.
+	 */
+
 	off = pp[0]->offset;
 	len = count * PAGESIZE;
-	KASSERT(off + len <= round_page(zp->z_size));
+	KASSERT(off <= zp->z_size);
+	KASSERT(len <= round_page(zp->z_size));
+	KASSERT(off <= round_page(zp->z_size) - len);
+
+	/*
+	 * If EOF is within the last page, reduce len to avoid writing past
+	 * the file size in the ZFS buffer.  Assert that
+	 * "off + len <= zp->z_size", again avoiding signed integer overflow.
+	 */
+
+	if (len > zp->z_size - off) {
+		len = zp->z_size - off;
+	}
+	KASSERT(len <= zp->z_size);
+	KASSERT(off <= zp->z_size - len);
 
 	if (zfs_owner_overquota(zfsvfs, zp, B_FALSE) ||
 	zfs_owner_overquota(zfsvfs, zp, B_TRUE)) {



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

2020-05-12 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Wed May 13 05:52:54 UTC 2020

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

Log Message:
fix the handling in putpage of the page containing EOF.


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 \
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.



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

2020-05-07 Thread J. Hannken-Illjes
> On May 7, 2020, at 5:47 PM, Taylor R Campbell 
>  wrote:
> 
>> Module Name:src
>> Committed By:   hannken
>> Date:   Thu May  7 09:12:03 UTC 2020
>> 
>> Modified Files:
>>src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_vnops.c
>> 
>> Log Message:
>> Revert Rev. 1.63 and add a comment why we have to zil_commit() here:
>> 
>> Operation zfs_znode.c::zfs_zget_cleaner() depends on this
>> zil_commit() as a barrier to guarantee the znode cannot
>> get freed before its log entries are resolved.
> 
> We must be doing something wrong.
> 
> The only times we should ever call zil_commit are when someone called
> fsync or the file system is mounted sync=always.  Calling zil_commit
> whenever we delete a file absolutely wrecks performance and shouldn't
> be needed for on-disk correctness in normal zfs semantics unless I
> terribly misunderstand something, so we must be doing something wrong
> with the in-memory state if we seem to need this.

The problem is the way we get data in zfs_get_data().  Other OS use
zfs_zget() to obtain a referenced vnode/znode and use it to retrieve
tha data.  For us this results in deadlocks either as locking-against-self
if called during vcache_reclaim() or more difficult deadlocks as another
operation needs to proceed and we currently have txg stopped from syncing.

Chuq resolved it with zfs_zget_cleaner() that doesn't reference the
vnode/znode and works for in-memory znodes only so we have to guarantee
it doesn't get called after VOP_RECLAIM().

> Do you have a test case that can trigger the problem?

Under load I get use-after-free of znodes in zfs_get_data() or entirely
miss znodes here.  See the other commit asserting zfs_zget_cleaner()
never fails.

--
J. Hannken-Illjes - hann...@eis.cs.tu-bs.de - TU Braunschweig (Germany)


signature.asc
Description: Message signed with OpenPGP


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

2020-05-07 Thread Taylor R Campbell
> Module Name:src
> Committed By:   hannken
> Date:   Thu May  7 09:12:03 UTC 2020
> 
> Modified Files:
> src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_vnops.c
> 
> Log Message:
> Revert Rev. 1.63 and add a comment why we have to zil_commit() here:
> 
> Operation zfs_znode.c::zfs_zget_cleaner() depends on this
> zil_commit() as a barrier to guarantee the znode cannot
> get freed before its log entries are resolved.

We must be doing something wrong.

The only times we should ever call zil_commit are when someone called
fsync or the file system is mounted sync=always.  Calling zil_commit
whenever we delete a file absolutely wrecks performance and shouldn't
be needed for on-disk correctness in normal zfs semantics unless I
terribly misunderstand something, so we must be doing something wrong
with the in-memory state if we seem to need this.

Do you have a test case that can trigger the problem?


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

2020-05-07 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu May  7 09:13:06 UTC 2020

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

Log Message:
Operation zfs_zget_cleaner() cannot fail, comment and add assertions.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.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_znode.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c:1.32 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c:1.33
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c:1.32	Thu May  7 09:12:31 2020
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c	Thu May  7 09:13:06 2020
@@ -1288,6 +1288,12 @@ zfs_zget(zfsvfs_t *zfsvfs, uint64_t obj_
 	return error;
 }
 
+/*
+ * Get a known cached znode, to be used from zil_commit()->zfs_get_data()
+ * to resolve log entries.  Doesn't take a reference, will never fail and
+ * depends on zfs_vnops.c::zfs_netbsd_reclaim() running a zil_commit()
+ * before the znode gets freed.
+ */
 int
 zfs_zget_cleaner(zfsvfs_t *zfsvfs, uint64_t obj_num, znode_t **zpp)
 {
@@ -1295,31 +1301,26 @@ zfs_zget_cleaner(zfsvfs_t *zfsvfs, uint6
 	sa_handle_t *hdl;
 	dmu_object_info_t doi;
 	znode_t *zp;
-	int err;
 
 	ZFS_OBJ_HOLD_ENTER(zfsvfs, obj_num);
 
-	err = sa_buf_hold(zfsvfs->z_os, obj_num, NULL, );
-	if (err) {
-		ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num);
-		return (SET_ERROR(err));
-	}
+	VERIFY(0 == sa_buf_hold(zfsvfs->z_os, obj_num, NULL, ));
 
 	dmu_object_info_from_db(db, );
-	if (doi.doi_bonus_type != DMU_OT_SA &&
-	(doi.doi_bonus_type != DMU_OT_ZNODE ||
+	ASSERT(doi.doi_bonus_type == DMU_OT_SA ||
 	(doi.doi_bonus_type == DMU_OT_ZNODE &&
-	doi.doi_bonus_size < sizeof (znode_phys_t {
-		sa_buf_rele(db, NULL);
-		ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num);
-		return (SET_ERROR(EINVAL));
-	}
+	doi.doi_bonus_size >= sizeof (znode_phys_t)));
+
 	hdl = dmu_buf_get_user(db);
 	ASSERT3P(hdl, !=, NULL);
+
 	zp = sa_get_userdata(hdl);
 	ASSERT3U(zp->z_id, ==, obj_num);
+
 	sa_buf_rele(db, NULL);
+
 	ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num);
+
 	*zpp = zp;
 	return (0);
 }



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

2020-05-07 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu May  7 09:13:06 UTC 2020

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

Log Message:
Operation zfs_zget_cleaner() cannot fail, comment and add assertions.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.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

2020-05-07 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu May  7 09:12:03 UTC 2020

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

Log Message:
Revert Rev. 1.63 and add a comment why we have to zil_commit() here:

Operation zfs_znode.c::zfs_zget_cleaner() depends on this
zil_commit() as a barrier to guarantee the znode cannot
get freed before its log entries are resolved.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 \
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.64 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.65
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.64	Sat Mar 14 20:45:23 2020
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c	Thu May  7 09:12:03 2020
@@ -5858,11 +5858,16 @@ zfs_netbsd_reclaim(void *v)
 			zp->z_atime_dirty = 0;
 			dmu_tx_commit(tx);
 		}
-
-		if (zfsvfs->z_os->os_sync == ZFS_SYNC_ALWAYS)
-			zil_commit(zfsvfs->z_log, zp->z_id);
 	}
 
+	/*
+	 * Operation zfs_znode.c::zfs_zget_cleaner() depends on this
+	 * zil_commit() as a barrier to guarantee the znode cannot
+	 * get freed before its log entries are resolved.
+	 */
+	if (zfsvfs->z_log)
+		zil_commit(zfsvfs->z_log, zp->z_id);
+
 	if (zp->z_sa_hdl == NULL)
 		zfs_znode_free(zp);
 	else



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

2020-05-07 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu May  7 09:12:32 UTC 2020

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

Log Message:
Revert Rev. 1.31 as it is no longer possible for the handle to be NULL.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.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

2020-05-07 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu May  7 09:12:03 UTC 2020

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

Log Message:
Revert Rev. 1.63 and add a comment why we have to zil_commit() here:

Operation zfs_znode.c::zfs_zget_cleaner() depends on this
zil_commit() as a barrier to guarantee the znode cannot
get freed before its log entries are resolved.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 \
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

2020-05-07 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu May  7 09:12:32 UTC 2020

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

Log Message:
Revert Rev. 1.31 as it is no longer possible for the handle to be NULL.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.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_znode.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c:1.31 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c:1.32
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c:1.31	Fri Mar 20 08:26:01 2020
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c	Thu May  7 09:12:31 2020
@@ -1315,11 +1315,7 @@ zfs_zget_cleaner(zfsvfs_t *zfsvfs, uint6
 		return (SET_ERROR(EINVAL));
 	}
 	hdl = dmu_buf_get_user(db);
-	if (hdl == NULL) {
-		sa_buf_rele(db, NULL);
-		ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num);
-		return (SET_ERROR(EINVAL));
-	}
+	ASSERT3P(hdl, !=, NULL);
 	zp = sa_get_userdata(hdl);
 	ASSERT3U(zp->z_id, ==, obj_num);
 	sa_buf_rele(db, NULL);



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

2020-04-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Apr 29 04:30:40 UTC 2020

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

Log Message:
Set up more of a fake struct buf, for ldminphys.

Fixes:

arm64# zpool create rpool ld4
[ 198.4376097] panic: Trap: Data Abort (EL1): Translation Fault L1 with read 
access for 0178: pc c017acf4: opcode f940bc00: ldr x0, 
[x0,#376]
[ 198.4694793] fp c00073026660 ldminphys() at c017acf4 
netbsd:ldminphys+0x34
[ 198.4792624] fp c00073026680 vdev_disk_open.part.4() at c13d4c4c 
zfs:vdev_disk_open.part.4+0x37c
[ 198.4792624] fp c000730268d0 vdev_open() at c13d2530 
zfs:vdev_open+0x68
[ 198.4792624] fp c00073026920 vdev_open_children() at c13d2958 
zfs:vdev_open_children+0x40
[ 198.4792624] fp c00073026950 vdev_root_open() at c13dad48 
zfs:vdev_root_open+0x30

XXX pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 \
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.15 src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c:1.16
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c:1.15	Mon Mar  2 16:01:56 2020
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c	Wed Apr 29 04:30:40 2020
@@ -228,7 +228,10 @@ vdev_disk_open(vdev_t *vd, uint64_t *psi
 		dvd->vd_maxphys = (pdk ? disk_maxphys(pdk) : MACHINE_MAXPHYS);
 	*/
 	{
-		struct buf buf = { .b_bcount = MAXPHYS };
+		struct buf buf = {
+			.b_dev = vp->v_rdev,
+			.b_bcount = MAXPHYS,
+		};
 		if (pdk && pdk->dk_driver && pdk->dk_driver->d_minphys)
 			(*pdk->dk_driver->d_minphys)();
 		dvd->vd_maxphys = buf.b_bcount;



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

2020-04-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Apr 29 04:30:40 UTC 2020

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

Log Message:
Set up more of a fake struct buf, for ldminphys.

Fixes:

arm64# zpool create rpool ld4
[ 198.4376097] panic: Trap: Data Abort (EL1): Translation Fault L1 with read 
access for 0178: pc c017acf4: opcode f940bc00: ldr x0, 
[x0,#376]
[ 198.4694793] fp c00073026660 ldminphys() at c017acf4 
netbsd:ldminphys+0x34
[ 198.4792624] fp c00073026680 vdev_disk_open.part.4() at c13d4c4c 
zfs:vdev_disk_open.part.4+0x37c
[ 198.4792624] fp c000730268d0 vdev_open() at c13d2530 
zfs:vdev_open+0x68
[ 198.4792624] fp c00073026920 vdev_open_children() at c13d2958 
zfs:vdev_open_children+0x40
[ 198.4792624] fp c00073026950 vdev_root_open() at c13dad48 
zfs:vdev_root_open+0x30

XXX pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 \
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

2020-03-20 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Mar 20 08:26:01 UTC 2020

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

Log Message:
With zfs_netbsd_reclaim() no longer doing an unconditional
zil commit dmu_buf_get_user() may return a NULL handle when
the znode already disappeared.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.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_znode.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c:1.30 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c:1.31
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c:1.30	Sun Feb 23 15:46:38 2020
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c	Fri Mar 20 08:26:01 2020
@@ -1315,7 +1315,11 @@ zfs_zget_cleaner(zfsvfs_t *zfsvfs, uint6
 		return (SET_ERROR(EINVAL));
 	}
 	hdl = dmu_buf_get_user(db);
-	ASSERT3P(hdl, !=, NULL);
+	if (hdl == NULL) {
+		sa_buf_rele(db, NULL);
+		ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num);
+		return (SET_ERROR(EINVAL));
+	}
 	zp = sa_get_userdata(hdl);
 	ASSERT3U(zp->z_id, ==, obj_num);
 	sa_buf_rele(db, NULL);



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

2020-03-20 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Mar 20 08:26:01 UTC 2020

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

Log Message:
With zfs_netbsd_reclaim() no longer doing an unconditional
zil commit dmu_buf_get_user() may return a NULL handle when
the znode already disappeared.


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

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



  1   2   3   4   5   >