Module Name:    src
Committed By:   hannken
Date:           Sat Jan  5 09:20:29 UTC 2019

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

Log Message:
Even though zfs_netbsd_putpages() cannot use ZFS_ENTER() it has
to respect the teardown lock.

Enter z_teardown_lock as reader and ZFS_EXIT().

Instead of ZFS_VERIFY_ZP() return without writing and without
error from zfs_putapage() if "z_sa_hdl == NULL".


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 \
    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.41 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.42
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.41	Tue Jan  1 10:09:26 2019
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c	Sat Jan  5 09:20:29 2019
@@ -5863,6 +5863,11 @@ zfs_putapage(vnode_t *vp, page_t **pp, i
 	struct uvm_object *uobj = &vp->v_uobj;
 	kmutex_t *mtx = uobj->vmobjlock;
 
+	if (zp->z_sa_hdl == NULL) {
+		err = 0;
+		goto out_unbusy;
+	}
+
 	off = pp[0]->offset;
 	len = count * PAGESIZE;
 	KASSERT(off + len <= round_page(zp->z_size));
@@ -5914,6 +5919,7 @@ zfs_putapage(vnode_t *vp, page_t **pp, i
 	}
 	dmu_tx_commit(tx);
 
+out_unbusy:
 	mutex_enter(mtx);
 	mutex_enter(&uvm_pageqlock);
 	uvm_page_unbusy(pp, count);
@@ -5994,6 +6000,12 @@ zfs_netbsd_putpages(void *v)
 				return 0;
 			}
 		}
+		/*
+		 * Cannot use ZFS_ENTER() here as it returns with error
+		 * if z_unmounted.  The next statement is equivalent.
+		 */
+		rrm_enter(&zfsvfs->z_teardown_lock, RW_READER, FTAG);
+
 		rl = zfs_range_lock(zp, offlo, len, RL_WRITER);
 		mutex_enter(vp->v_interlock);
 		tsd_set(zfs_putpage_key, &cleaned);
@@ -6011,6 +6023,7 @@ zfs_netbsd_putpages(void *v)
 		if (cleaned)
 		if (!async || zfsvfs->z_os->os_sync == ZFS_SYNC_ALWAYS)
 			zil_commit(zfsvfs->z_log, zp->z_id);
+		ZFS_EXIT(zfsvfs);
 		fstrans_done(vp->v_mount);
 	}
 	return error;

Reply via email to