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 <sys/fstrans.h>
 #include <sys/mkdev.h>
 #include <miscfs/genfs/genfs.h>
 
@@ -2669,8 +2670,17 @@ zfs_suspend_fs(zfsvfs_t *zfsvfs)
 {
 	int error;
 
+#ifdef __NetBSD__
+	if ((error = vfs_suspend(zfsvfs->z_vfs, 0)) != 0)
+		return error;
+	if ((error = zfsvfs_teardown(zfsvfs, B_FALSE)) != 0) {
+		vfs_resume(zfsvfs->z_vfs);
+		return (error);
+	}
+#else
 	if ((error = zfsvfs_teardown(zfsvfs, B_FALSE)) != 0)
 		return (error);
+#endif
 
 	return (0);
 }
@@ -2682,6 +2692,16 @@ zfs_suspend_fs(zfsvfs_t *zfsvfs)
  * are the same: the relevant objset and associated dataset are owned by
  * zfsvfs, held, and long held on entry.
  */
+#ifdef __NetBSD__
+static bool
+zfs_resume_selector(void *cl, struct vnode *vp)
+{
+
+	if (zfsctl_is_node(vp))
+		return false;
+	return (VTOZ(vp)->z_sa_hdl == NULL);
+}
+#endif
 int
 zfs_resume_fs(zfsvfs_t *zfsvfs, dsl_dataset_t *ds)
 {
@@ -2725,6 +2745,18 @@ bail:
 	/* release the VOPs */
 	rw_exit(&zfsvfs->z_teardown_inactive_lock);
 	rrm_exit(&zfsvfs->z_teardown_lock, FTAG);
+#ifdef __NetBSD__
+	struct vnode_iterator *marker;
+	vnode_t *vp;
+
+	vfs_vnode_iterator_init(zfsvfs->z_vfs, &marker);
+	while ((vp = vfs_vnode_iterator_next(marker,
+	    zfs_resume_selector, NULL))) {
+		vgone(vp);
+	}
+	vfs_vnode_iterator_destroy(marker);
+	vfs_resume(zfsvfs->z_vfs);
+#endif
 
 	if (err) {
 		/*

Reply via email to