Skip to content

Commit

Permalink
Make txg_wait_synced conditional in zfsvfs_teardown
Browse files Browse the repository at this point in the history
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
  • Loading branch information
PaulZ-98 authored and tonyhutter committed Jan 22, 2020
1 parent 93fd910 commit 9d4ca81
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion module/zfs/zfs_vfsops.c
Original file line number Diff line number Diff line change
Expand Up @@ -1785,8 +1785,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);
Expand Down

0 comments on commit 9d4ca81

Please sign in to comment.