Skip to content

Commit

Permalink
Wait iput_async before evict_inodes to prevent race
Browse files Browse the repository at this point in the history
wait for iput_async before entering evict_inodes in generic_shutdown_super.
The reason we must finish before evict_inodes is iput when lazytime and
zfs_purgedir calling zfs_zget would bump i_count from 0 to 1. This would race
with the i_count check in evict_inodes, so it could destroy the inode while
we are still using it.

Signed-off-by: Chunwei Chen <[email protected]>
  • Loading branch information
Chunwei Chen committed Jul 15, 2016
1 parent dfbc863 commit eb35f33
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions module/zfs/zfs_vfsops.c
Original file line number Diff line number Diff line change
Expand Up @@ -1415,6 +1415,21 @@ zfs_preumount(struct super_block *sb)

if (zsb)
zfsctl_destroy(sb->s_fs_info);
/*
* wait for iput_async before entering evict_inodes in
* generic_shutdown_super. The reason we must finish before
* evict_inodes is iput when lazytime and zfs_purgedir calling
* zfs_zget would bump i_count from 0 to 1. This would race with the
* i_count check in evict_inodes, so it could destroy the inode while
* we are still using it.
*
* We wait for two pass, first pass are xattr dirs, second pass are
* xattr entries.
*/
taskq_wait_outstanding(dsl_pool_iput_taskq(
dmu_objset_pool(zsb->z_os)), 0);
taskq_wait_outstanding(dsl_pool_iput_taskq(
dmu_objset_pool(zsb->z_os)), 0);
}
EXPORT_SYMBOL(zfs_preumount);

Expand Down

0 comments on commit eb35f33

Please sign in to comment.