Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drain iput taskq inside z_teardown_lock #3282

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 9 additions & 17 deletions module/zfs/zfs_vfsops.c
Original file line number Diff line number Diff line change
Expand Up @@ -1137,8 +1137,15 @@ zfs_sb_teardown(zfs_sb_t *zsb, boolean_t unmounting)
* drain the iput_taskq to ensure all active references to the
* zfs_sb_t have been handled only then can it be safely destroyed.
*/
if (zsb->z_os)
taskq_wait(dsl_pool_iput_taskq(dmu_objset_pool(zsb->z_os)));
if (zsb->z_os) {
mutex_enter(&zsb->z_znodes_lock);
while (zsb->z_nr_znodes) {
mutex_exit(&zsb->z_znodes_lock);
schedule();
taskq_wait(dsl_pool_iput_taskq(dmu_objset_pool(zsb->z_os)));
}
mutex_exit(&zsb->z_znodes_lock);
}

rrw_enter(&zsb->z_teardown_lock, RW_WRITER, FTAG);

Expand Down Expand Up @@ -1175,21 +1182,6 @@ zfs_sb_teardown(zfs_sb_t *zsb, boolean_t unmounting)
return (SET_ERROR(EIO));
}

/*
* At this point there are no VFS ops active, and any new VFS ops
* will fail with EIO since we have z_teardown_lock for writer (only
* relevant for forced unmount).
*
* Release all holds on dbufs.
*/
mutex_enter(&zsb->z_znodes_lock);
for (zp = list_head(&zsb->z_all_znodes); zp != NULL;
zp = list_next(&zsb->z_all_znodes, zp)) {
if (zp->z_sa_hdl)
zfs_znode_dmu_fini(zp);
}
mutex_exit(&zsb->z_znodes_lock);

/*
* If we are unmounting, set the unmounted flag and let new VFS ops
* unblock. zfs_inactive will have the unmounted behavior, and all
Expand Down