summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorPaul Zuchowski <[email protected]>2019-08-15 10:27:13 -0400
committerBrian Behlendorf <[email protected]>2019-08-15 08:27:13 -0600
commite2b31b58e8777faa51561342d72a5a30127fa4b6 (patch)
treed97edab581099d6bf3c0a49d126e038484ff1108 /module
parentdc04a8c757d7df91efbca05491174112540f6e7a (diff)
Make txg_wait_synced conditional in zfsvfs_teardown
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 <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Paul Zuchowski <[email protected]> Closes #9115
Diffstat (limited to 'module')
-rw-r--r--module/zfs/zfs_vfsops.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/module/zfs/zfs_vfsops.c b/module/zfs/zfs_vfsops.c
index 8d728adea..af82c7bc4 100644
--- a/module/zfs/zfs_vfsops.c
+++ b/module/zfs/zfs_vfsops.c
@@ -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);