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/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/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.



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


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?


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

2020-03-13 Thread Warner Losh
On Wed, Mar 11, 2020 at 12:13 AM J. Hannken-Illjes 
wrote:

> On 10. Mar 2020, at 13:37, Santhosh Raju  wrote:
>
> On Tue, Mar 10, 2020 at 7:25 AM Santhosh Raju  wrote:
>
>
> Module Name:src
> Committed By:   fox
> Date:   Mon Mar  9 15:40:50 UTC 2020
>
> Modified Files:
>src/external/cddl/osnet/dist/uts/common/fs/zfs: metaslab.c
>
> Log Message:
> external/cddl/osnet: Fix possible null pointer access.
>
> Detected by UBSan and fixed upstream, pick only the fix from the commit.
>
> Cherry-pick:
> From 928e8ad47d3478a3d5d01f0dd6ae74a9371af65e Mon Sep 17 00:00:00 2001
> From: Serapheim Dimitropoulos 
> Date: Wed, 20 Feb 2019 09:59:57 -0800
> Subject: [PATCH] Introduce auxiliary metaslab histograms
>
> Reviewed by: Paul Dagnelie 
> Reviewed-by: Brian Behlendorf 
> Reviewed by: Matt Ahrens 
> Signed-off-by: Serapheim Dimitropoulos 
> Closes #8358
>
> Reviewed by: kamil@
>
>
> 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/metaslab.c
>
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.
>
>
> Forgot to add in the commit log, the changes have been pulled in from
> upstream openzfs.
>
>
> https://github.com/openzfs/zfs/commit/928e8ad47d3478a3d5d01f0dd6ae74a9371af65e#diff-9fd6b453f8153161abe0728c449e6505R4386
>
> --
> Santhosh
>
>
> This is NOT our upstream --
>

Regardless of NetBSD's "official" upstream, this is the new OpenZFS
upstream. It has moved off illumos earlier in the year to ZoL which was
restructured to be cross platform. It includes FreeBSD support, though that
flavor of ZFS hasn't been completely merged back into FreeBSD just yet
(there's work in progress to make that happen). Since it's the only real
upstream today, you may need to do some updates to cope with the new ZFS
playing field.

Warner


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

2020-03-11 Thread Santhosh Raju
On Wed, Mar 11, 2020 at 7:22 AM Greg Troxel  wrote:
>
> J. Hannken-Illjes  writes:
>
> >> Forgot to add in the commit log, the changes have been pulled in from
> >> upstream openzfs.
> >>
> >> https://github.com/openzfs/zfs/commit/928e8ad47d3478a3d5d01f0dd6ae74a9371af65e#diff-9fd6b453f8153161abe0728c449e6505R4386
> >
> > This is NOT our upstream --
>

For the sake of completeness, the upstream issue was discussed in a
private thread and kamil@ pointed out that the commit exists in the
ZFS on FreeBSD repository too.

https://github.com/zfsonfreebsd/ZoF/commit/928e8ad47d3478a3d5d01f0dd6ae74a9371af65e

Which was pointed out as the upstream from which current
implementation of NetBSD's ZFS was taken.

> This seems to be hard to figure out.  Is there someplace in the tree
> that says what our upsream is, and what theirs is, and how all of the
> various trees out there relate?  And how we should be sending things,
> and getting things?
>
> I tried to figure this out, and ended up with
>
> http://wiki.netbsd.org/zfs/
>
> which has lots of \todo statements.

--
Santhosh


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

2020-03-11 Thread Martin Husemann
On Wed, Mar 11, 2020 at 08:22:26AM -0400, Greg Troxel wrote:
> This seems to be hard to figure out.  Is there someplace in the tree
> that says what our upsream is, and what theirs is, and how all of the
> various trees out there relate?  And how we should be sending things,
> and getting things?

doc/3RDPARTY - but zfs is missing there.

Martin


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

2020-03-11 Thread Greg Troxel
J. Hannken-Illjes  writes:

>> Forgot to add in the commit log, the changes have been pulled in from
>> upstream openzfs.
>> 
>> https://github.com/openzfs/zfs/commit/928e8ad47d3478a3d5d01f0dd6ae74a9371af65e#diff-9fd6b453f8153161abe0728c449e6505R4386
>
> This is NOT our upstream --

This seems to be hard to figure out.  Is there someplace in the tree
that says what our upsream is, and what theirs is, and how all of the
various trees out there relate?  And how we should be sending things,
and getting things?

I tried to figure this out, and ended up with

http://wiki.netbsd.org/zfs/

which has lots of \todo statements.


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

2020-03-11 Thread J . Hannken-Illjes
> On 10. Mar 2020, at 13:37, Santhosh Raju  wrote:
> 
> On Tue, Mar 10, 2020 at 7:25 AM Santhosh Raju  wrote:
>> 
>> Module Name:src
>> Committed By:   fox
>> Date:   Mon Mar  9 15:40:50 UTC 2020
>> 
>> Modified Files:
>>src/external/cddl/osnet/dist/uts/common/fs/zfs: metaslab.c
>> 
>> Log Message:
>> external/cddl/osnet: Fix possible null pointer access.
>> 
>> Detected by UBSan and fixed upstream, pick only the fix from the commit.
>> 
>> Cherry-pick:
>> From 928e8ad47d3478a3d5d01f0dd6ae74a9371af65e Mon Sep 17 00:00:00 2001
>> From: Serapheim Dimitropoulos 
>> Date: Wed, 20 Feb 2019 09:59:57 -0800
>> Subject: [PATCH] Introduce auxiliary metaslab histograms
>> 
>> Reviewed by: Paul Dagnelie 
>> Reviewed-by: Brian Behlendorf 
>> Reviewed by: Matt Ahrens 
>> Signed-off-by: Serapheim Dimitropoulos 
>> Closes #8358
>> 
>> Reviewed by: kamil@
>> 
>> 
>> 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/metaslab.c
>> 
>> Please note that diffs are not public domain; they are subject to the
>> copyright notices on the relevant files.
>> 
> 
> Forgot to add in the commit log, the changes have been pulled in from
> upstream openzfs.
> 
> https://github.com/openzfs/zfs/commit/928e8ad47d3478a3d5d01f0dd6ae74a9371af65e#diff-9fd6b453f8153161abe0728c449e6505R4386
> 
> --
> Santhosh

This is NOT our upstream --

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



signature.asc
Description: Message signed with OpenPGP


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

2020-03-10 Thread Santhosh Raju
On Tue, Mar 10, 2020 at 7:25 AM Santhosh Raju  wrote:
>
> Module Name:src
> Committed By:   fox
> Date:   Mon Mar  9 15:40:50 UTC 2020
>
> Modified Files:
> src/external/cddl/osnet/dist/uts/common/fs/zfs: metaslab.c
>
> Log Message:
> external/cddl/osnet: Fix possible null pointer access.
>
> Detected by UBSan and fixed upstream, pick only the fix from the commit.
>
> Cherry-pick:
> From 928e8ad47d3478a3d5d01f0dd6ae74a9371af65e Mon Sep 17 00:00:00 2001
> From: Serapheim Dimitropoulos 
> Date: Wed, 20 Feb 2019 09:59:57 -0800
> Subject: [PATCH] Introduce auxiliary metaslab histograms
>
> Reviewed by: Paul Dagnelie 
> Reviewed-by: Brian Behlendorf 
> Reviewed by: Matt Ahrens 
> Signed-off-by: Serapheim Dimitropoulos 
> Closes #8358
>
> Reviewed by: kamil@
>
>
> 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/metaslab.c
>
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.
>

Forgot to add in the commit log, the changes have been pulled in from
upstream openzfs.

https://github.com/openzfs/zfs/commit/928e8ad47d3478a3d5d01f0dd6ae74a9371af65e#diff-9fd6b453f8153161abe0728c449e6505R4386

--
Santhosh


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

2019-10-15 Thread Paul Goyette

On Tue, 15 Oct 2019, J. Hannken-Illjes wrote:


Should be fixed with Rev. 1.4 of
  src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_diff.c


Yup - thanks!


++--+---+
| Paul Goyette   | PGP Key fingerprint: | E-mail addresses: |
| (Retired)  | FA29 0E3B 35AF E8AE 6651 | p...@whooppee.com |
| Software Developer | 0786 F758 55DE 53BA 7731 | pgoye...@netbsd.org   |
++--+---+


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

2019-10-15 Thread J. Hannken-Illjes
Should be fixed with Rev. 1.4 of
   src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_diff.c

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



> On 15. Oct 2019, at 00:13, Paul Goyette  wrote:
> 
> I'm now seeing a build error:
> 
> #   compile  libzpool/dmu_diff.pico
> /build/netbsd-local/tools/x86_64/amd64/bin/x86_64--netbsd-gcc -O2   
> -std=gnu99-Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith 
> -Wno-sign-compare  -Wsystem-headers   -Wno-traditional  -Wreturn-type 
> -Wswitch -Wshadow -Wcast-qual -Wwrite-strings -Wextra -Wno-unused-parameter 
> -Wno-sign-compare -Wold-style-definition -Wsign-compare -Wformat=2  
> -Wno-format-zero-length   -Wno-missing-field-initializers 
> -Wno-strict-prototypes -Wno-cast-qual  -Wno-discarded-qualifiers  -Wno-switch 
> -Wno-missing-prototypes -Wno-unused-variable -Wno-shadow 
> -Wno-missing-field-initializers -Wno-parentheses   -fPIE
> -Wno-unknown-pragmas -Wno-sign-compare -D_KERNTYPES -D_KERNTYPES 
> --sysroot=/build/netbsd-local/dest/amd64 -std=c99 -D_SUNOS_VTOC_16 
> -D_PROPLIB_ZFS_CONFLICT -I/build/netbsd-local/src_ro/external/cddl/osnet 
> -I/build/netbsd-local/src_ro/external/cddl/osnet/include 
> -I/build/netbsd-local/src_ro/external/cddl/osnet/sys 
> -I/build/netbsd-local/src_ro/external/cddl/osnet/dist/common/zfs 
> -I/build/netbsd-local/src_ro/external/cddl/osnet/dist/head 
> -I/build/netbsd-local/src_ro/external/cddl/osnet/dist/lib/libdevinfo 
> -I/build/netbsd-local/src_ro/external/cddl/osnet/dist/lib/libnvpair 
> -I/build/netbsd-local/src_ro/external/cddl/osnet/dist/lib/libshare/common 
> -I/build/netbsd-local/src_ro/external/cddl/osnet/dist/lib/libumem 
> -I/build/netbsd-local/src_ro/external/cddl/osnet/dist/lib/libuutil/common 
> -I/build/netbsd-local/src_ro/external/cddl/osnet/dist/lib/libzfs/common 
> -I/build/netbsd-local/src_ro/external/cddl/osnet/dist/lib/libzfs_core/common 
> -I/build/netbsd-local/src_ro/external/cddl/osnet/dist/lib/libzpool/common 
> -I/build/netbsd-local/src_ro/external/cddl/osnet/dist/common 
> -I/build/netbsd-local/src_ro/external/cddl/osnet/dist/uts/common 
> -I/build/netbsd-local/src_ro/external/cddl/osnet/dist/uts/common/zfs 
> -I/build/netbsd-local/src_ro/external/cddl/osnet/dist/uts/common/fs/zfs 
> -I/build/netbsd-local/src_ro/external/cddl/osnet/dist/uts/common/sys -std=c99 
>  -c-fPIC   -g 
> /build/netbsd-local/src_ro/external/cddl/osnet/lib/libzpool/../../dist/uts/common/fs/zfs/dmu_diff.c
>  -o dmu_diff.pico
> /build/netbsd-local/src_ro/external/cddl/osnet/lib/libzpool/../../dist/uts/common/fs/zfs/dmu_diff.c:
>  In function 'write_bytes':
> /build/netbsd-local/src_ro/external/cddl/osnet/lib/libzpool/../../dist/uts/common/fs/zfs/dmu_diff.c:70:6:
>  error: 'struct uio' has no member named 'uio_vmspace'
>  auio.uio_vmspace = vmspace_kernel();
>  ^
> /build/netbsd-local/src_ro/external/cddl/osnet/lib/libzpool/../../dist/uts/common/fs/zfs/dmu_diff.c:70:21:
>  warning: implicit declaration of function 'vmspace_kernel' 
> [-Wimplicit-function-declaration]
>  auio.uio_vmspace = vmspace_kernel();
> ^~
> /build/netbsd-local/src_ro/external/cddl/osnet/lib/libzpool/../../dist/uts/common/fs/zfs/dmu_diff.c:56:13:
>  warning: variable 'auio' set but not used [-Wunused-but-set-variable]
>  struct uio auio;
> ^~~~
> *** [dmu_diff.pico] Error code 1
> 
> 
> 
> 
> 
> ++--+---+
> | Paul Goyette   | PGP Key fingerprint: | E-mail addresses: |
> | (Retired)  | FA29 0E3B 35AF E8AE 6651 | p...@whooppee.com |
> | Software Developer | 0786 F758 55DE 53BA 7731 | pgoye...@netbsd.org   |
> ++--+---+



signature.asc
Description: Message signed with OpenPGP


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

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

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

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


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

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



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

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

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

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


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

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

Modified files:

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



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

2019-10-14 Thread Paul Goyette

I'm now seeing a build error:

#   compile  libzpool/dmu_diff.pico
/build/netbsd-local/tools/x86_64/amd64/bin/x86_64--netbsd-gcc -O2   -std=gnu99  
  -Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith 
-Wno-sign-compare  -Wsystem-headers   -Wno-traditional  -Wreturn-type -Wswitch 
-Wshadow -Wcast-qual -Wwrite-strings -Wextra -Wno-unused-parameter 
-Wno-sign-compare -Wold-style-definition -Wsign-compare -Wformat=2  
-Wno-format-zero-length   -Wno-missing-field-initializers 
-Wno-strict-prototypes -Wno-cast-qual  -Wno-discarded-qualifiers  -Wno-switch 
-Wno-missing-prototypes -Wno-unused-variable -Wno-shadow 
-Wno-missing-field-initializers -Wno-parentheses   -fPIE
-Wno-unknown-pragmas -Wno-sign-compare -D_KERNTYPES -D_KERNTYPES 
--sysroot=/build/netbsd-local/dest/amd64 -std=c99 -D_SUNOS_VTOC_16 
-D_PROPLIB_ZFS_CONFLICT -I/build/netbsd-local/src_ro/external/cddl/osnet 
-I/build/netbsd-local/src_ro/external/cddl/osnet/include 
-I/build/netbsd-local/src_ro/external/cddl/osnet/sys 
-I/build/netbsd-local/src_ro/external/cddl/osnet/dist/common/zfs 
-I/build/netbsd-local/src_ro/external/cddl/osnet/dist/head 
-I/build/netbsd-local/src_ro/external/cddl/osnet/dist/lib/libdevinfo 
-I/build/netbsd-local/src_ro/external/cddl/osnet/dist/lib/libnvpair 
-I/build/netbsd-local/src_ro/external/cddl/osnet/dist/lib/libshare/common 
-I/build/netbsd-local/src_ro/external/cddl/osnet/dist/lib/libumem 
-I/build/netbsd-local/src_ro/external/cddl/osnet/dist/lib/libuutil/common 
-I/build/netbsd-local/src_ro/external/cddl/osnet/dist/lib/libzfs/common 
-I/build/netbsd-local/src_ro/external/cddl/osnet/dist/lib/libzfs_core/common 
-I/build/netbsd-local/src_ro/external/cddl/osnet/dist/lib/libzpool/common 
-I/build/netbsd-local/src_ro/external/cddl/osnet/dist/common 
-I/build/netbsd-local/src_ro/external/cddl/osnet/dist/uts/common 
-I/build/netbsd-local/src_ro/external/cddl/osnet/dist/uts/common/zfs 
-I/build/netbsd-local/src_ro/external/cddl/osnet/dist/uts/common/fs/zfs 
-I/build/netbsd-local/src_ro/external/cddl/osnet/dist/uts/common/sys -std=c99  
-c-fPIC   -g 
/build/netbsd-local/src_ro/external/cddl/osnet/lib/libzpool/../../dist/uts/common/fs/zfs/dmu_diff.c
 -o dmu_diff.pico
/build/netbsd-local/src_ro/external/cddl/osnet/lib/libzpool/../../dist/uts/common/fs/zfs/dmu_diff.c:
 In function 'write_bytes':
/build/netbsd-local/src_ro/external/cddl/osnet/lib/libzpool/../../dist/uts/common/fs/zfs/dmu_diff.c:70:6:
 error: 'struct uio' has no member named 'uio_vmspace'
  auio.uio_vmspace = vmspace_kernel();
  ^
/build/netbsd-local/src_ro/external/cddl/osnet/lib/libzpool/../../dist/uts/common/fs/zfs/dmu_diff.c:70:21:
 warning: implicit declaration of function 'vmspace_kernel' 
[-Wimplicit-function-declaration]
  auio.uio_vmspace = vmspace_kernel();
 ^~
/build/netbsd-local/src_ro/external/cddl/osnet/lib/libzpool/../../dist/uts/common/fs/zfs/dmu_diff.c:56:13:
 warning: variable 'auio' set but not used [-Wunused-but-set-variable]
  struct uio auio;
 ^~~~
*** [dmu_diff.pico] Error code 1





++--+---+
| Paul Goyette   | PGP Key fingerprint: | E-mail addresses: |
| (Retired)  | FA29 0E3B 35AF E8AE 6651 | p...@whooppee.com |
| Software Developer | 0786 F758 55DE 53BA 7731 | pgoye...@netbsd.org   |
++--+---+

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

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

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

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

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


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

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



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

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

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

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

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


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

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

Modified files:

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

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

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

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

2019-10-04 Thread Brad Spencer
Module Name:src
Committed By:   brad
Date:   Fri Oct  4 23:06:19 UTC 2019

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

Log Message:
For ZFS on NetBSD there are a number of functions called
zfs_netbsd_{create,mknod,link,etc..} that call functions called
zfs_{create,mknod,link,etc..}.  These later functions may return a
error code along with a *vpp that is NULL.  This situation was not
handled by the zfs_netbsd_* functions and would result in a panic in a
number of cases.  The simplest to trigger it was filling up a dataset
or pool resulting in a over quota condition.  An attempt to create
another file, or directory at that point would panic.


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

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



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

2019-10-04 Thread Brad Spencer
Module Name:src
Committed By:   brad
Date:   Fri Oct  4 23:06:19 UTC 2019

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

Log Message:
For ZFS on NetBSD there are a number of functions called
zfs_netbsd_{create,mknod,link,etc..} that call functions called
zfs_{create,mknod,link,etc..}.  These later functions may return a
error code along with a *vpp that is NULL.  This situation was not
handled by the zfs_netbsd_* functions and would result in a panic in a
number of cases.  The simplest to trigger it was filling up a dataset
or pool resulting in a over quota condition.  An attempt to create
another file, or directory at that point would panic.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 \
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.52 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.53
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.52	Sat Aug 24 12:59:05 2019
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c	Fri Oct  4 23:06:19 2019
@@ -5318,7 +5318,8 @@ zfs_netbsd_create(void *v)
 	KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
 	if (error == 0)
 		VN_KNOTE(dvp, NOTE_WRITE);
-	VOP_UNLOCK(*vpp, 0);
+	if (*vpp != NULL)
+		VOP_UNLOCK(*vpp, 0);
 
 	return (error);
 }
@@ -5358,7 +5359,8 @@ zfs_netbsd_mknod(void *v)
 	KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
 	if (error == 0)
 		VN_KNOTE(dvp, NOTE_WRITE);
-	VOP_UNLOCK(*vpp, 0);
+	if (*vpp != NULL)
+		VOP_UNLOCK(*vpp, 0);
 
 	return (error);
 }
@@ -5428,7 +5430,8 @@ zfs_netbsd_mkdir(void *v)
 	KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
 	if (error == 0)
 		VN_KNOTE(dvp, NOTE_WRITE | NOTE_LINK);
-	VOP_UNLOCK(*vpp, 0);
+	if (*vpp != NULL)
+		VOP_UNLOCK(*vpp, 0);
 
 	return (error);
 }
@@ -5717,7 +5720,8 @@ zfs_netbsd_symlink(void *v)
 		VN_KNOTE(ap->a_dvp, NOTE_WRITE);
 	KASSERT((error == 0) == (*vpp != NULL));
 	KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
-	VOP_UNLOCK(*vpp, 0);
+	if (*vpp != NULL)
+		VOP_UNLOCK(*vpp, 0);
 
 	return (error);
 }



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

2019-08-24 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Aug 24 12:59:34 UTC 2019

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

Log Message:
Add missing dmu_zfetch_fini() when dnode_create() lost the race.


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

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



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

2019-08-24 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Aug 24 12:59:34 UTC 2019

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

Log Message:
Add missing dmu_zfetch_fini() when dnode_create() lost the race.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/dnode.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.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/dnode.c:1.7 src/external/cddl/osnet/dist/uts/common/fs/zfs/dnode.c:1.8
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/dnode.c:1.7	Sun May 26 10:21:00 2019
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/dnode.c	Sat Aug 24 12:59:34 2019
@@ -447,6 +447,9 @@ dnode_create(objset_t *os, dnode_phys_t 
 	if (dnh->dnh_dnode != NULL) {
 		/* Lost the allocation race. */
 		mutex_exit(>os_lock);
+#ifdef __NetBSD__
+		dmu_zfetch_fini(>dn_zfetch);
+#endif
 		kmem_cache_free(dnode_cache, dn);
 		return (dnh->dnh_dnode);
 	}



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

2019-08-24 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Aug 24 12:59:06 UTC 2019

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

Log Message:
Implement kqueue support.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 \
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.51 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.52
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.51	Sat Aug 24 12:58:24 2019
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c	Sat Aug 24 12:59:05 2019
@@ -,6 +,16 @@ zfs_rename(vnode_t *sdvp, vnode_t **svpp
 			if (*tvpp != NULL)
 cache_purge(*tvpp);
 			cache_purge_negative(tdvp);
+#ifdef __NetBSD__
+			if (*svpp == *tvpp) {
+VN_KNOTE(sdvp, NOTE_WRITE);
+VN_KNOTE(*svpp, (szp->z_links == 0 ?
+NOTE_DELETE : NOTE_LINK));
+			} else {
+genfs_rename_knote(sdvp, *svpp, tdvp, *tvpp,
+((tzp != NULL) && (tzp->z_links == 0)));
+			}
+#endif
 		}
 	}
 
@@ -5094,6 +5104,10 @@ zfs_netbsd_write(void *v)
 {
 	struct vop_write_args *ap = v;
 	vnode_t *vp = ap->a_vp;
+	znode_t *zp = VTOZ(vp);
+	struct uio *uio = ap->a_uio;
+	off_t osize = zp->z_size;
+	int error, resid;
 
 	switch (vp->v_type) {
 	case VBLK:
@@ -5105,7 +5119,13 @@ zfs_netbsd_write(void *v)
 		return (VOCALL(fifo_vnodeop_p, VOFFSET(vop_write), ap));
 	}
 
-	return (zfs_write(vp, ap->a_uio, ioflags(ap->a_ioflag), ap->a_cred, NULL));
+	resid = uio->uio_resid;
+	error = zfs_write(vp, uio, ioflags(ap->a_ioflag), ap->a_cred, NULL);
+	if (resid > uio->uio_resid)
+		VN_KNOTE(vp, NOTE_WRITE |
+		(zp->z_size > osize ? NOTE_EXTEND : 0));
+
+	return error;
 }
 
 static int
@@ -5296,6 +5316,8 @@ zfs_netbsd_create(void *v)
 
 	KASSERT((error == 0) == (*vpp != NULL));
 	KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
+	if (error == 0)
+		VN_KNOTE(dvp, NOTE_WRITE);
 	VOP_UNLOCK(*vpp, 0);
 
 	return (error);
@@ -5334,6 +5356,8 @@ zfs_netbsd_mknod(void *v)
 
 	KASSERT((error == 0) == (*vpp != NULL));
 	KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
+	if (error == 0)
+		VN_KNOTE(dvp, NOTE_WRITE);
 	VOP_UNLOCK(*vpp, 0);
 
 	return (error);
@@ -5363,6 +5387,10 @@ zfs_netbsd_remove(void *v)
 	error = zfs_remove(dvp, vp, nm, cnp->cn_cred);
 
 	PNBUF_PUT(nm);
+	if (error == 0) {
+		VN_KNOTE(vp, NOTE_DELETE);
+		VN_KNOTE(dvp, NOTE_WRITE);
+	}
 	vput(vp);
 	KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
 	return (error);
@@ -5398,6 +5426,8 @@ zfs_netbsd_mkdir(void *v)
 
 	KASSERT((error == 0) == (*vpp != NULL));
 	KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
+	if (error == 0)
+		VN_KNOTE(dvp, NOTE_WRITE | NOTE_LINK);
 	VOP_UNLOCK(*vpp, 0);
 
 	return (error);
@@ -5427,6 +5457,10 @@ zfs_netbsd_rmdir(void *v)
 	error = zfs_rmdir(dvp, vp, nm, cnp->cn_cred);
 
 	PNBUF_PUT(nm);
+	if (error == 0) {
+		VN_KNOTE(dvp, NOTE_WRITE | NOTE_LINK);
+		VN_KNOTE(vp, NOTE_DELETE);
+	}
 	vput(vp);
 	KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
 	return error;
@@ -5571,7 +5605,11 @@ zfs_netbsd_setattr(void *v)
 			return error;
 	}
 
-	return (zfs_setattr(vp, (vattr_t *), flags, cred, NULL));
+	error = zfs_setattr(vp, (vattr_t *), flags, cred, NULL);
+	if (error == 0)
+		VN_KNOTE(vp, NOTE_ATTRIB);
+
+	return error;
 }
 
 static int
@@ -5675,7 +5713,8 @@ zfs_netbsd_symlink(void *v)
 	error = zfs_symlink(dvp, vpp, nm, vap, target, cnp->cn_cred, 0);
 
 	PNBUF_PUT(nm);
-
+	if (error == 0)
+		VN_KNOTE(ap->a_dvp, NOTE_WRITE);
 	KASSERT((error == 0) == (*vpp != NULL));
 	KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
 	VOP_UNLOCK(*vpp, 0);
@@ -5716,6 +5755,10 @@ zfs_netbsd_link(void *v)
 	NULL, 0);
 
 	PNBUF_PUT(nm);
+	if (error == 0) {
+		VN_KNOTE(vp, NOTE_LINK);
+		VN_KNOTE(dvp, NOTE_WRITE);
+	}
 	VOP_UNLOCK(vp, 0);
 	return error;
 }
@@ -6235,6 +6278,7 @@ const struct vnodeopv_entry_desc zfs_vno
 	{ _write_desc,		zfs_netbsd_write },
 	{ _ioctl_desc,		zfs_netbsd_ioctl },
 	{ _poll_desc,		genfs_poll },
+	{ _kqfilter_desc,		genfs_kqfilter },
 	{ _fsync_desc,		zfs_netbsd_fsync },
 	{ _remove_desc,		zfs_netbsd_remove },
 	{ _link_desc,		zfs_netbsd_link },
@@ -6278,6 +6322,7 @@ const struct vnodeopv_entry_desc zfs_spe
 	{ _write_desc,		/**/zfs_netbsd_write },
 	{ _ioctl_desc,		spec_ioctl },
 	{ _poll_desc,		spec_poll },
+	{ _kqfilter_desc,		spec_kqfilter },
 	{ _fsync_desc,		zfs_netbsd_fsync },
 	{ _remove_desc,		spec_remove },
 	{ _link_desc,		spec_link },
@@ -6321,6 +6366,7 @@ const struct vnodeopv_entry_desc zfs_fif
 	{ _write_desc,		/**/zfs_netbsd_write },
 	{ _ioctl_desc,		vn_fifo_bypass },
 	{ _poll_desc,		vn_fifo_bypass },
+	{ _kqfilter_desc,		vn_fifo_bypass },
 	{ _fsync_desc,		zfs_netbsd_fsync },
 	{ _remove_desc,		vn_fifo_bypass },
 	{ _link_desc,		vn_fifo_bypass },



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

2019-08-24 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Aug 24 12:59:06 UTC 2019

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

Log Message:
Implement kqueue support.


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

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



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

2019-08-24 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Aug 24 12:58:25 UTC 2019

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

Log Message:
Implement poll support.


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

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



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

2019-08-24 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Aug 24 12:58:25 UTC 2019

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

Log Message:
Implement poll support.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 \
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.50 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.51
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.50	Mon Jun 17 08:08:21 2019
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c	Sat Aug 24 12:58:24 2019
@@ -6234,6 +6234,7 @@ const struct vnodeopv_entry_desc zfs_vno
 	{ _read_desc,		zfs_netbsd_read },
 	{ _write_desc,		zfs_netbsd_write },
 	{ _ioctl_desc,		zfs_netbsd_ioctl },
+	{ _poll_desc,		genfs_poll },
 	{ _fsync_desc,		zfs_netbsd_fsync },
 	{ _remove_desc,		zfs_netbsd_remove },
 	{ _link_desc,		zfs_netbsd_link },
@@ -6276,6 +6277,7 @@ const struct vnodeopv_entry_desc zfs_spe
 	{ _read_desc,		/**/zfs_netbsd_read },
 	{ _write_desc,		/**/zfs_netbsd_write },
 	{ _ioctl_desc,		spec_ioctl },
+	{ _poll_desc,		spec_poll },
 	{ _fsync_desc,		zfs_netbsd_fsync },
 	{ _remove_desc,		spec_remove },
 	{ _link_desc,		spec_link },
@@ -6318,6 +6320,7 @@ const struct vnodeopv_entry_desc zfs_fif
 	{ _read_desc,		/**/zfs_netbsd_read },
 	{ _write_desc,		/**/zfs_netbsd_write },
 	{ _ioctl_desc,		vn_fifo_bypass },
+	{ _poll_desc,		vn_fifo_bypass },
 	{ _fsync_desc,		zfs_netbsd_fsync },
 	{ _remove_desc,		vn_fifo_bypass },
 	{ _link_desc,		vn_fifo_bypass },



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

2019-08-20 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Aug 20 08:12:14 UTC 2019

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

Log Message:
Rearrange the evaluation of "dvd_maxphys" so it works for wedges too.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 \
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.11 src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c:1.12
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c:1.11	Wed Jun 12 04:20:18 2019
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c	Tue Aug 20 08:12:14 2019
@@ -220,23 +220,33 @@ vdev_disk_open(vdev_t *vd, uint64_t *psi
 	}
 
 	/* XXXNETBSD Once tls-maxphys gets merged this block becomes:
-		pdk = disk_find_blk(vp->v_rdev);
+		if (VOP_IOCTL(vp, DIOCGWEDGEINFO, , FREAD, NOCRED) == 0)
+			pdk = disk_find(dkw.dkw_parent);
+		else
+			pdk = disk_find_blk(vp->v_rdev);
 		dvd->vd_maxphys = (pdk ? disk_maxphys(pdk) : MACHINE_MAXPHYS);
 	*/
 	{
 		struct buf buf = { .b_bcount = MAXPHYS };
-		const char *dev_name;
 
-		dev_name = devsw_blk2name(major(vp->v_rdev));
-		if (dev_name) {
-			char disk_name[16];
-
-			snprintf(disk_name, sizeof(disk_name), "%s%d",
-			dev_name, DISKUNIT(vp->v_rdev));
-			pdk = disk_find(disk_name);
-			if (pdk && pdk->dk_driver && pdk->dk_driver->d_minphys)
-(*pdk->dk_driver->d_minphys)();
+		if (VOP_IOCTL(vp, DIOCGWEDGEINFO, , FREAD, NOCRED) == 0) {
+			pdk = disk_find(dkw.dkw_parent);
+		} else {
+			const char *dev_name;
+
+			dev_name = devsw_blk2name(major(vp->v_rdev));
+			if (dev_name) {
+char disk_name[16];
+
+snprintf(disk_name, sizeof(disk_name), "%s%d",
+dev_name, DISKUNIT(vp->v_rdev));
+pdk = disk_find(disk_name);
+			} else {
+pdk = NULL;
+			}
 		}
+		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

2019-08-20 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Aug 20 08:12:14 UTC 2019

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

Log Message:
Rearrange the evaluation of "dvd_maxphys" so it works for wedges too.


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

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



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

2019-08-13 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Aug 13 08:03:25 UTC 2019

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

Log Message:
Add missing "defined(__NetBSD__)" to make "zfs promote" work.


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

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



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

2019-08-13 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Aug 13 08:03:25 UTC 2019

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

Log Message:
Add missing "defined(__NetBSD__)" to make "zfs promote" work.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/dsl_dataset.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_dataset.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/dsl_dataset.c:1.4 src/external/cddl/osnet/dist/uts/common/fs/zfs/dsl_dataset.c:1.5
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/dsl_dataset.c:1.4	Wed May 22 08:45:32 2019
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/dsl_dataset.c	Tue Aug 13 08:03:25 2019
@@ -2796,7 +2796,7 @@ dsl_dataset_promote_sync(void *arg, dmu_
 		ASSERT(!dsl_prop_hascb(ds));
 	}
 
-#if defined(__FreeBSD__) && defined(_KERNEL)
+#if (defined(__FreeBSD__) || defined(__NetBSD__)) && defined(_KERNEL)
 	mutex_exit(_namespace_lock);
 
 	kmem_free(newname, MAXPATHLEN);



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

2019-08-07 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Wed Aug  7 20:45:53 UTC 2019

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

Log Message:
validate the length of args (like other filesystems)

ok riastradh


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 \
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.24 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c:1.25
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c:1.24	Mon Jun 17 08:09:57 2019
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c	Wed Aug  7 20:45:53 2019
@@ -1993,6 +1993,9 @@ zfs_mount(vfs_t *vfsp, const char *path,
 	if (uap == NULL)
 		return (SET_ERROR(EINVAL));
 
+	if (*data_len < sizeof *uap)
+		return (SET_ERROR(EINVAL));
+
 	if (mvp->v_type != VDIR)
 		return (SET_ERROR(ENOTDIR));
 



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

2019-08-07 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Wed Aug  7 20:45:53 UTC 2019

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

Log Message:
validate the length of args (like other filesystems)

ok riastradh


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

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



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

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

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

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


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

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

Modified files:

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



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

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

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

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


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

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



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

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

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

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

Live rollback should work now.

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


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

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

Modified files:

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



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

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

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

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

Live rollback should work now.

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


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

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



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

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

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

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


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

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

Modified files:

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



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

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

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

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


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

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



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

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

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

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


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

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

Modified files:

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.48 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.49
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.48	Mon Apr 15 12:59:38 2019
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c	Mon Jun 17 08:07:56 2019
@@ -5759,7 +5759,7 @@ zfs_netbsd_reclaim(void *v)
 	/*
 	 * Process a deferred atime update.
 	 */
-	if (zp->z_atime_dirty && zp->z_unlinked == 0) {
+	if (zp->z_atime_dirty && zp->z_unlinked == 0 && zp->z_sa_hdl != NULL) {
 		dmu_tx_t *tx = dmu_tx_create(zfsvfs->z_os);
 
 		dmu_tx_hold_sa(tx, zp->z_sa_hdl, B_FALSE);



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

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

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

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


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

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



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

2019-06-11 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed Jun 12 04:20:18 UTC 2019

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

Log Message:
Fix build with -Wgnu-designator in the ZFS code

struct buf buf = { b_bcount: MAXPHYS }; is a legacy style designator
extension and this raised a compiler error reported by a.rin@mix.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 \
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.10 src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c:1.11
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c:1.10	Tue Jun 11 09:04:37 2019
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c	Wed Jun 12 04:20:18 2019
@@ -224,7 +224,7 @@ 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_bcount = MAXPHYS };
 		const char *dev_name;
 
 		dev_name = devsw_blk2name(major(vp->v_rdev));



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

2019-06-11 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed Jun 12 04:20:18 UTC 2019

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

Log Message:
Fix build with -Wgnu-designator in the ZFS code

struct buf buf = { b_bcount: MAXPHYS }; is a legacy style designator
extension and this raised a compiler error reported by a.rin@mix.


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

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



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

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

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

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

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


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

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



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

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

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

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

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


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

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

Modified files:

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

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



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

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

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

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

PR kern/54219 zpool create pool dk5 causes kernel panic


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

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



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

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

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

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

PR kern/54219 zpool create pool dk5 causes kernel panic


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

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

Modified files:

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



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

2019-05-22 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed May 22 08:46:27 UTC 2019

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

Log Message:
Add missing zvol_close() to zfsdev_close().

Change zvol_size_changed() to initialize "zv->zv_volsize"
and initialize only "dg_secsize" and "dg_secperunit".
Calling disk_set_info() will initialize the remaining
parts of the geometry.

Set "doread" in zvol_strategy() to make reading from
device possible.

Reorganize/add disk_busy()/disk_unbusy() instrumentation.

Redo zvol_ioctl() to implement DIOCGWEDGEINFO and let
disk_ioctl() process the remaining ioctls.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c
cvs rdiff -u -r1.10 -r1.11 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zvol.c

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



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

2019-05-22 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed May 22 08:45:32 UTC 2019

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: dsl_dataset.c dsl_dir.c
spa.c zfs_ioctl.c zfs_vfsops.c zvol.c
src/external/cddl/osnet/dist/uts/common/fs/zfs/sys: zvol.h

Log Message:
Enable the zvol minor management to create and remove device nodes.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/dsl_dataset.c
cvs rdiff -u -r1.2 -r1.3 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/dsl_dir.c
cvs rdiff -u -r1.8 -r1.9 src/external/cddl/osnet/dist/uts/common/fs/zfs/spa.c
cvs rdiff -u -r1.18 -r1.19 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c
cvs rdiff -u -r1.22 -r1.23 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c
cvs rdiff -u -r1.9 -r1.10 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zvol.c
cvs rdiff -u -r1.4 -r1.5 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/zvol.h

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



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

2019-05-22 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed May 22 08:45:32 UTC 2019

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: dsl_dataset.c dsl_dir.c
spa.c zfs_ioctl.c zfs_vfsops.c zvol.c
src/external/cddl/osnet/dist/uts/common/fs/zfs/sys: zvol.h

Log Message:
Enable the zvol minor management to create and remove device nodes.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/dsl_dataset.c
cvs rdiff -u -r1.2 -r1.3 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/dsl_dir.c
cvs rdiff -u -r1.8 -r1.9 src/external/cddl/osnet/dist/uts/common/fs/zfs/spa.c
cvs rdiff -u -r1.18 -r1.19 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c
cvs rdiff -u -r1.22 -r1.23 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c
cvs rdiff -u -r1.9 -r1.10 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zvol.c
cvs rdiff -u -r1.4 -r1.5 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/zvol.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/dsl_dataset.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/dsl_dataset.c:1.3 src/external/cddl/osnet/dist/uts/common/fs/zfs/dsl_dataset.c:1.4
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/dsl_dataset.c:1.3	Mon May 28 21:05:07 2018
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/dsl_dataset.c	Wed May 22 08:45:32 2019
@@ -1612,7 +1612,7 @@ dsl_dataset_snapshot(nvlist_t *snaps, nv
 		fnvlist_free(suspended);
 	}
 
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__NetBSD__)
 #ifdef _KERNEL
 	if (error == 0) {
 		for (pair = nvlist_next_nvpair(snaps, NULL); pair != NULL;
@@ -2164,7 +2164,7 @@ static int
 dsl_dataset_rename_snapshot_sync_impl(dsl_pool_t *dp,
 dsl_dataset_t *hds, void *arg)
 {
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__NetBSD__)
 #ifdef _KERNEL
 	char *oldname, *newname;
 #endif
@@ -2197,7 +2197,7 @@ dsl_dataset_rename_snapshot_sync_impl(ds
 	dsl_dataset_phys(hds)->ds_snapnames_zapobj,
 	ds->ds_snapname, 8, 1, >ds_object, tx));
 
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__NetBSD__)
 #ifdef _KERNEL
 	oldname = kmem_alloc(MAXPATHLEN, KM_SLEEP);
 	newname = kmem_alloc(MAXPATHLEN, KM_SLEEP);
@@ -2640,7 +2640,7 @@ dsl_dataset_promote_sync(void *arg, dmu_
 	dsl_dir_t *odd = NULL;
 	uint64_t oldnext_obj;
 	int64_t delta;
-#if defined(__FreeBSD__) && defined(_KERNEL)
+#if (defined(__FreeBSD__) || defined(__NetBSD__)) && defined(_KERNEL)
 	char *oldname, *newname;
 #endif
 
@@ -2710,7 +2710,7 @@ dsl_dataset_promote_sync(void *arg, dmu_
 		dsl_dir_phys(dd)->dd_clones, origin_head->ds_object, tx));
 	}
 
-#if defined(__FreeBSD__) && defined(_KERNEL)
+#if (defined(__FreeBSD__) || defined(__NetBSD__)) && defined(_KERNEL)
 	/* Take the spa_namespace_lock early so zvol renames don't deadlock. */
 	mutex_enter(_namespace_lock);
 
@@ -2752,7 +2752,7 @@ dsl_dataset_promote_sync(void *arg, dmu_
 		VERIFY0(dsl_dir_hold_obj(dp, dd->dd_object,
 		NULL, ds, >ds_dir));
 
-#if defined(__FreeBSD__) && defined(_KERNEL)
+#if (defined(__FreeBSD__) || defined(__NetBSD__)) && defined(_KERNEL)
 		dsl_dataset_name(ds, newname);
 		zfsvfs_update_fromname(oldname, newname);
 		zvol_rename_minors(oldname, newname);

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/dsl_dir.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/dsl_dir.c:1.2 src/external/cddl/osnet/dist/uts/common/fs/zfs/dsl_dir.c:1.3
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/dsl_dir.c:1.2	Mon May 28 21:05:07 2018
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/dsl_dir.c	Wed May 22 08:45:32 2019
@@ -1912,7 +1912,7 @@ dsl_dir_rename_sync(void *arg, dmu_tx_t 
 	VERIFY0(zap_add(mos, dsl_dir_phys(newparent)->dd_child_dir_zapobj,
 	dd->dd_myname, 8, 1, >dd_object, tx));
 
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__NetBSD__)
 #ifdef _KERNEL
 	zfsvfs_update_fromname(ddra->ddra_oldname, ddra->ddra_newname);
 	zvol_rename_minors(ddra->ddra_oldname, ddra->ddra_newname);

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/spa.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/spa.c:1.8 src/external/cddl/osnet/dist/uts/common/fs/zfs/spa.c:1.9
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/spa.c:1.8	Tue May  7 08:49:59 2019
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/spa.c	Wed May 22 08:45:32 2019
@@ -3226,7 +3226,7 @@ spa_open_common(const char *pool, spa_t 
 		spa->spa_last_ubsync_txg = 0;
 		spa->spa_load_txg = 0;
 		mutex_exit(_namespace_lock);
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__NetBSD__)
 #ifdef _KERNEL
 		if (firstopen)
 			zvol_create_minors(spa->spa_name);
@@ -4508,7 +4508,7 @@ spa_import(const char *pool, nvlist_t *c
 
 	mutex_exit(_namespace_lock);
 
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || 

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

2012-10-16 Thread Alan Barrett

On Mon, 15 Oct 2012, Taylor R Campbell wrote:

@@ -796,7 +794,11 @@ zfs_link_destroy(zfs_dirlock_t *dl, znod
if (zp_is_dir  !zfs_dirempty(zp)) {   /* dir not empty */
mutex_exit(zp-z_lock);
vn_vfsunlock(vp);
+#ifdef __NetBSD__  /* XXX Make our dumb tests happier...  */
+   return (ENOTEMPTY);
+#else
return (EEXIST);
+#endif
}


I'd suggest using ifdef ENOTEMPTY instead of ifdef __NetBSD__ here.

(And the log message did not mention this change.)

--apb (Alan Barrett)


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

2012-10-16 Thread Taylor R Campbell
   Date: Tue, 16 Oct 2012 09:47:32 +0200
   From: Alan Barrett a...@cequrux.com

   On Mon, 15 Oct 2012, Taylor R Campbell wrote:
   @@ -796,7 +794,11 @@ zfs_link_destroy(zfs_dirlock_t *dl, znod
   if (zp_is_dir  !zfs_dirempty(zp)) {   /* dir not empty */
   mutex_exit(zp-z_lock);
   vn_vfsunlock(vp);
   +#ifdef __NetBSD__  /* XXX Make our dumb tests happier...  */
   +   return (ENOTEMPTY);
   +#else
   return (EEXIST);
   +#endif
   }

   I'd suggest using ifdef ENOTEMPTY instead of ifdef __NetBSD__ here.

Well, both NetBSD and Solaris have ENOTEMPTY -- it's in POSIX.  POSIX
says that rmdir and rename can return either ENOTEMPTY or EEXIST.
It's just that all our other file systems return ENOTEMPTY in this
case.

   (And the log message did not mention this change.)

Oops, sorry -- that change was supposed to go in a separate commit.
Should I change the commit message with `cvs admin', or revert the
change and fix the tests instead, or do something else altogether?


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

2012-10-15 Thread Taylor R Campbell
   Module Name:src
   Committed By:   riastradh   
   Date:   Mon Oct 15 14:03:06 UTC 2012

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

   Log Message:
   Do reference counting for zfs range lock waiters.

Pasted the wrong commit message here.  Fixed now with `cvs admin'.
Sorry for the confusion!


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

2010-03-01 Thread Adam Hamsik
Module Name:src
Committed By:   haad
Date:   Mon Mar  1 20:38:19 UTC 2010

Removed Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: fletcher.c

Log Message:
Remove fletcher.c from dist it was moved to common/zfs/zfs_fletcher.c in 
upstream.


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

2010-01-09 Thread Adam Hamsik
Module Name:src
Committed By:   haad
Date:   Sun Jan 10 01:35:39 UTC 2010

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

Log Message:
Fix problem in ZFS ZIL layer where unclean shutdown of filesystem can change
replayed file permissions to 777. Patch from FreeBSD. Original commit message:

Be careful which vattr fields are set during setattr replay.
Without this fix strange things can appear after unclean shutdown like
files with mode set to 0.


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

2009-10-30 Thread Adam Hamsik


On Oct,Friday 30 2009, at 12:25 AM, Bill Stouder-Studenmund wrote:


On Thu, Oct 29, 2009 at 11:58:32PM +0100, Adam Hamsik wrote:


On Oct,Thursday 29 2009, at 8:15 PM, David Laight wrote:


On Wed, Oct 28, 2009 at 11:44:51PM +, Adam Hamsik wrote:

Module Name:src
Committed By:   haad
Date:   Wed Oct 28 23:44:51 UTC 2009

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

Log Message:
Add workaround about zfs vnode reclaiming deadlock by checking if
we don't
ehld ZFS_MUTEX_OBJ already. If we can lock OBJ_MUTEX deffer
execution of
zfs_zinactive to taskq. Code was inspired by FreeBSD
zfs_freebsd_reclaim.


This doesn't sound right at all ...

If the 'If we can lock OBJ_MUTEX' test is a try_mutex_enter() then
it may fail because another lwp owns it ...
I hope it is only the checkin comment that is inverted!


There are 3 option which can happen

1) Our lwp already holds mutex
2) mutex is not held at all
3) Another LWP holds it

In case 1 we can call reclaim vnode, in case 2 we lock it with
try_mutex_enter and reclaim it and in case 3 we use taskq for
reclaiming of vnode.


This is reclaiming in response to someone trying to get a cleaned  
vnode,
correct? If so, we should just change the reclaim API and return  
something
like EBUSY. If it's just cleaning to clean, then having a taskq do  
it is

fine.


That can be done but ti will require to change all fses +  
getcleanvnode because currently when it can't clean vnode it panics.



Where you able to look at the repository at macosforge.org before it  
shut

down? I think that would show a take at solving similar issues.


Yeah I have it somewhere around here, but as I noted I used freebsd  
version as a working example for this patch.



Regards

Adam.



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

2009-10-30 Thread Bill Stouder-Studenmund
On Fri, Oct 30, 2009 at 08:32:30AM +0100, Adam Hamsik wrote:
 
 On Oct,Friday 30 2009, at 12:25 AM, Bill Stouder-Studenmund wrote:
 
 On Thu, Oct 29, 2009 at 11:58:32PM +0100, Adam Hamsik wrote:
 
 On Oct,Thursday 29 2009, at 8:15 PM, David Laight wrote:
 
 On Wed, Oct 28, 2009 at 11:44:51PM +, Adam Hamsik wrote:
 Module Name:  src
 Committed By: haad
 Date: Wed Oct 28 23:44:51 UTC 2009
 
 Modified Files:
   src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_vnops.c
 zfs_znode.c
 
 Log Message:
 Add workaround about zfs vnode reclaiming deadlock by checking if
 we don't
 ehld ZFS_MUTEX_OBJ already. If we can lock OBJ_MUTEX deffer
 execution of
 zfs_zinactive to taskq. Code was inspired by FreeBSD
 zfs_freebsd_reclaim.
 
 This doesn't sound right at all ...
 
 If the 'If we can lock OBJ_MUTEX' test is a try_mutex_enter() then
 it may fail because another lwp owns it ...
 I hope it is only the checkin comment that is inverted!
 
 There are 3 option which can happen
 
 1) Our lwp already holds mutex
 2) mutex is not held at all
 3) Another LWP holds it
 
 In case 1 we can call reclaim vnode, in case 2 we lock it with
 try_mutex_enter and reclaim it and in case 3 we use taskq for
 reclaiming of vnode.
 
 This is reclaiming in response to someone trying to get a cleaned  
 vnode,
 correct? If so, we should just change the reclaim API and return  
 something
 like EBUSY. If it's just cleaning to clean, then having a taskq do  
 it is
 fine.
 
 That can be done but ti will require to change all fses +  
 getcleanvnode because currently when it can't clean vnode it panics.

Yes, you have to change getcleanvnode, but why do the file systems need to 
change? That's making this harder than it has to be.

Pick an error value. I now thing EDEADLK is best, since it describes 
what's going on. Make getcleanvnode just skip to the next one in the list 
if it gets this error value back. Let it panic otherwise.

The only thing you need to do with other file systems is make sure their 
reclaim doesn't report EDEADLK when the code really wants to panic the 
kernel. Since we don't hear a lot about panicing while getting new vnodes 
(other than this bug), I think you're safe.

Take care,

Bill


pgp3IEtVj3AHx.pgp
Description: PGP signature


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

2009-10-29 Thread David Laight
On Wed, Oct 28, 2009 at 11:44:51PM +, Adam Hamsik wrote:
 Module Name:  src
 Committed By: haad
 Date: Wed Oct 28 23:44:51 UTC 2009
 
 Modified Files:
   src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_vnops.c zfs_znode.c
 
 Log Message:
 Add workaround about zfs vnode reclaiming deadlock by checking if we don't
 ehld ZFS_MUTEX_OBJ already. If we can lock OBJ_MUTEX deffer execution of
 zfs_zinactive to taskq. Code was inspired by FreeBSD zfs_freebsd_reclaim.

This doesn't sound right at all ...

If the 'If we can lock OBJ_MUTEX' test is a try_mutex_enter() then
it may fail because another lwp owns it ...
I hope it is only the checkin comment that is inverted!

David

-- 
David Laight: da...@l8s.co.uk


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

2009-10-29 Thread Adam Hamsik


On Oct,Thursday 29 2009, at 8:15 PM, David Laight wrote:


On Wed, Oct 28, 2009 at 11:44:51PM +, Adam Hamsik wrote:

Module Name:src
Committed By:   haad
Date:   Wed Oct 28 23:44:51 UTC 2009

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


Log Message:
Add workaround about zfs vnode reclaiming deadlock by checking if  
we don't
ehld ZFS_MUTEX_OBJ already. If we can lock OBJ_MUTEX deffer  
execution of
zfs_zinactive to taskq. Code was inspired by FreeBSD  
zfs_freebsd_reclaim.


This doesn't sound right at all ...

If the 'If we can lock OBJ_MUTEX' test is a try_mutex_enter() then
it may fail because another lwp owns it ...
I hope it is only the checkin comment that is inverted!


There are 3 option which can happen

1) Our lwp already holds mutex
2) mutex is not held at all
3) Another LWP holds it

In case 1 we can call reclaim vnode, in case 2 we lock it with  
try_mutex_enter and reclaim it and in case 3 we use taskq for  
reclaiming of vnode.

Regards

Adam.



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

2009-10-29 Thread Bill Stouder-Studenmund
On Thu, Oct 29, 2009 at 11:58:32PM +0100, Adam Hamsik wrote:
 
 On Oct,Thursday 29 2009, at 8:15 PM, David Laight wrote:
 
 On Wed, Oct 28, 2009 at 11:44:51PM +, Adam Hamsik wrote:
 Module Name:src
 Committed By:   haad
 Date:   Wed Oct 28 23:44:51 UTC 2009
 
 Modified Files:
 src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_vnops.c  
 zfs_znode.c
 
 Log Message:
 Add workaround about zfs vnode reclaiming deadlock by checking if  
 we don't
 ehld ZFS_MUTEX_OBJ already. If we can lock OBJ_MUTEX deffer  
 execution of
 zfs_zinactive to taskq. Code was inspired by FreeBSD  
 zfs_freebsd_reclaim.
 
 This doesn't sound right at all ...
 
 If the 'If we can lock OBJ_MUTEX' test is a try_mutex_enter() then
 it may fail because another lwp owns it ...
 I hope it is only the checkin comment that is inverted!
 
 There are 3 option which can happen
 
 1) Our lwp already holds mutex
 2) mutex is not held at all
 3) Another LWP holds it
 
 In case 1 we can call reclaim vnode, in case 2 we lock it with  
 try_mutex_enter and reclaim it and in case 3 we use taskq for  
 reclaiming of vnode.

This is reclaiming in response to someone trying to get a cleaned vnode, 
correct? If so, we should just change the reclaim API and return something 
like EBUSY. If it's just cleaning to clean, then having a taskq do it is 
fine.

Where you able to look at the repository at macosforge.org before it shut 
down? I think that would show a take at solving similar issues.

Take care,

Bill


pgpKqLrLUhuOJ.pgp
Description: PGP signature


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

2009-10-29 Thread Jason Thorpe

On Oct 29, 2009, at 4:25 PM, Bill Stouder-Studenmund wrote:

 Where you able to look at the repository at macosforge.org before it shut 
 down? I think that would show a take at solving similar issues.

Note that the XNU vnode lifecycle, referencing, and locking implementation is 
significantly different from ours.

-- thorpej