]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Make txg_wait_synced conditional in zfsvfs_teardown
authorPaul Zuchowski <31706010+PaulZ-98@users.noreply.github.com>
Thu, 15 Aug 2019 14:27:13 +0000 (10:27 -0400)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 15 Aug 2019 14:27:13 +0000 (08:27 -0600)
The call to txg_wait_synced in zfsvfs_teardown should
be made conditional on the objset having dirty data.
This can prevent unnecessary txg_wait_synced during
some unmount operations.

Reviewed-by: Matt Ahrens <matt@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Paul Zuchowski <pzuchowski@datto.com>
Closes #9115

module/zfs/zfs_vfsops.c

index 8d728adeae94b8f9fc8de5cfcf41c4f1659f2a68..af82c7bc48006d0fd91829ada9c8aefc9d1b6924 100644 (file)
@@ -1778,8 +1778,17 @@ zfsvfs_teardown(zfsvfs_t *zfsvfs, boolean_t unmounting)
         * Evict cached data. We must write out any dirty data before
         * disowning the dataset.
         */
-       if (!zfs_is_readonly(zfsvfs))
+       objset_t *os = zfsvfs->z_os;
+       boolean_t os_dirty = B_FALSE;
+       for (int t = 0; t < TXG_SIZE; t++) {
+               if (dmu_objset_is_dirty(os, t)) {
+                       os_dirty = B_TRUE;
+                       break;
+               }
+       }
+       if (!zfs_is_readonly(zfsvfs) && os_dirty) {
                txg_wait_synced(dmu_objset_pool(zfsvfs->z_os), 0);
+       }
        dmu_objset_evict_dbufs(zfsvfs->z_os);
 
        return (0);