Skip to content

Commit e2b31b5

Browse files
PaulZ-98behlendorf
authored andcommitted
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 <matt@delphix.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Paul Zuchowski <pzuchowski@datto.com> Closes #9115
1 parent dc04a8c commit e2b31b5

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

module/zfs/zfs_vfsops.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1778,8 +1778,17 @@ zfsvfs_teardown(zfsvfs_t *zfsvfs, boolean_t unmounting)
17781778
* Evict cached data. We must write out any dirty data before
17791779
* disowning the dataset.
17801780
*/
1781-
if (!zfs_is_readonly(zfsvfs))
1781+
objset_t *os = zfsvfs->z_os;
1782+
boolean_t os_dirty = B_FALSE;
1783+
for (int t = 0; t < TXG_SIZE; t++) {
1784+
if (dmu_objset_is_dirty(os, t)) {
1785+
os_dirty = B_TRUE;
1786+
break;
1787+
}
1788+
}
1789+
if (!zfs_is_readonly(zfsvfs) && os_dirty) {
17821790
txg_wait_synced(dmu_objset_pool(zfsvfs->z_os), 0);
1791+
}
17831792
dmu_objset_evict_dbufs(zfsvfs->z_os);
17841793

17851794
return (0);

0 commit comments

Comments
 (0)