Mon Mar 9 09:52:00 2020 UTC ()
Pull up following revision(s) (requested by riastradh in ticket #769):

	external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c: revision 1.63

Avoid unnecessary zil_commit on rm.

1. Issue zil_commit only if we're actually updating something --
   there's no need to commit if we're unlinking the file or if
   there's no atime update being applied.

2. Issue zil_commit only if the zfs has sync=always set -- for
   sync=standard there's no need for us to commit anything here since
   no application asked for an explicit sync.

Speeds up untarring base.tgz on top of itself by a factor of about
2x, and speeds up rm by a factor of about 10x, on my system with an
SSD SLOG over SATA.  Histogram of unlink, rmdir, and rename timing
shows dramatic reduction in latency for most samples.

(To be fair, this was not an improvement over zfs; issuing the
unnecessary zil_commit was a self-inflicted performance wound.)


(martin)
diff -r1.50.2.6 -r1.50.2.7 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c

cvs diff -r1.50.2.6 -r1.50.2.7 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c (expand / switch to unified diff)

--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c 2020/02/25 20:03:12 1.50.2.6
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c 2020/03/09 09:52:00 1.50.2.7
@@ -5826,30 +5826,30 @@ zfs_netbsd_reclaim(void *v) @@ -5826,30 +5826,30 @@ zfs_netbsd_reclaim(void *v)
5826 dmu_tx_t *tx = dmu_tx_create(zfsvfs->z_os); 5826 dmu_tx_t *tx = dmu_tx_create(zfsvfs->z_os);
5827 5827
5828 dmu_tx_hold_sa(tx, zp->z_sa_hdl, B_FALSE); 5828 dmu_tx_hold_sa(tx, zp->z_sa_hdl, B_FALSE);
5829 zfs_sa_upgrade_txholds(tx, zp); 5829 zfs_sa_upgrade_txholds(tx, zp);
5830 error = dmu_tx_assign(tx, TXG_WAIT); 5830 error = dmu_tx_assign(tx, TXG_WAIT);
5831 if (error) { 5831 if (error) {
5832 dmu_tx_abort(tx); 5832 dmu_tx_abort(tx);
5833 } else { 5833 } else {
5834 (void) sa_update(zp->z_sa_hdl, SA_ZPL_ATIME(zfsvfs), 5834 (void) sa_update(zp->z_sa_hdl, SA_ZPL_ATIME(zfsvfs),
5835 (void *)&zp->z_atime, sizeof (zp->z_atime), tx); 5835 (void *)&zp->z_atime, sizeof (zp->z_atime), tx);
5836 zp->z_atime_dirty = 0; 5836 zp->z_atime_dirty = 0;
5837 dmu_tx_commit(tx); 5837 dmu_tx_commit(tx);
5838 } 5838 }
5839 } 
5840 5839
5841 if (zfsvfs->z_log) 5840 if (zfsvfs->z_os->os_sync == ZFS_SYNC_ALWAYS)
5842 zil_commit(zfsvfs->z_log, zp->z_id); 5841 zil_commit(zfsvfs->z_log, zp->z_id);
 5842 }
5843 5843
5844 if (zp->z_sa_hdl == NULL) 5844 if (zp->z_sa_hdl == NULL)
5845 zfs_znode_free(zp); 5845 zfs_znode_free(zp);
5846 else 5846 else
5847 zfs_zinactive(zp); 5847 zfs_zinactive(zp);
5848 rw_exit(&zfsvfs->z_teardown_inactive_lock); 5848 rw_exit(&zfsvfs->z_teardown_inactive_lock);
5849 return 0; 5849 return 0;
5850} 5850}
5851 5851
5852static int 5852static int
5853zfs_netbsd_fid(void *v) 5853zfs_netbsd_fid(void *v)
5854{ 5854{
5855 struct vop_fid_args *ap = v; 5855 struct vop_fid_args *ap = v;