aboutsummaryrefslogtreecommitdiffstats
path: root/module/zfs/zfs_vnops.c
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2014-08-04 13:30:20 -0700
committerBrian Behlendorf <[email protected]>2014-08-11 16:11:43 -0700
commit0a50679ce9eb8ded7bf20685e9d32724ded9cb8d (patch)
tree0087b2570d24eb85e710051c4c3721bc22469069 /module/zfs/zfs_vnops.c
parent4dd18932ba4cfdcf9b16609f6a80c2d6c239cb15 (diff)
Add zfs_iput_async() interface
Handle all iputs in zfs_purgedir() and zfs_inode_destroy() asynchronously to prevent deadlocks. When the iputs are allowed to run synchronously in the destroy call path deadlocks between xattr directory inodes and their parent file inodes are possible. Signed-off-by: Brian Behlendorf <[email protected]> Signed-off-by: Richard Yao <[email protected]> Closes #457
Diffstat (limited to 'module/zfs/zfs_vnops.c')
-rw-r--r--module/zfs/zfs_vnops.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/module/zfs/zfs_vnops.c b/module/zfs/zfs_vnops.c
index 4f531733e..18b2564a2 100644
--- a/module/zfs/zfs_vnops.c
+++ b/module/zfs/zfs_vnops.c
@@ -101,7 +101,7 @@
* pushing cached pages (which acquires range locks) and syncing out
* cached atime changes. Third, zfs_zinactive() may require a new tx,
* which could deadlock the system if you were already holding one.
- * If you must call iput() within a tx then use iput_ASYNC().
+ * If you must call iput() within a tx then use zfs_iput_async().
*
* (3) All range locks must be grabbed before calling dmu_tx_assign(),
* as they can span dmu_tx_assign() calls.
@@ -927,12 +927,17 @@ zfs_write(struct inode *ip, uio_t *uio, int ioflag, cred_t *cr)
}
EXPORT_SYMBOL(zfs_write);
-static void
-iput_async(struct inode *ip, taskq_t *taskq)
+void
+zfs_iput_async(struct inode *ip)
{
+ objset_t *os = ITOZSB(ip)->z_os;
+
ASSERT(atomic_read(&ip->i_count) > 0);
+ ASSERT(os != NULL);
+
if (atomic_read(&ip->i_count) == 1)
- taskq_dispatch(taskq, (task_func_t *)iput, ip, TQ_PUSHPAGE);
+ taskq_dispatch(dsl_pool_iput_taskq(dmu_objset_pool(os)),
+ (task_func_t *)iput, ip, TQ_PUSHPAGE);
else
iput(ip);
}
@@ -941,7 +946,6 @@ void
zfs_get_done(zgd_t *zgd, int error)
{
znode_t *zp = zgd->zgd_private;
- objset_t *os = ZTOZSB(zp)->z_os;
if (zgd->zgd_db)
dmu_buf_rele(zgd->zgd_db, zgd);
@@ -952,7 +956,7 @@ zfs_get_done(zgd_t *zgd, int error)
* Release the vnode asynchronously as we currently have the
* txg stopped from syncing.
*/
- iput_async(ZTOI(zp), dsl_pool_iput_taskq(dmu_objset_pool(os)));
+ zfs_iput_async(ZTOI(zp));
if (error == 0 && zgd->zgd_bp)
zil_add_block(zgd->zgd_zilog, zgd->zgd_bp);
@@ -994,7 +998,7 @@ zfs_get_data(void *arg, lr_write_t *lr, char *buf, zio_t *zio)
* Release the vnode asynchronously as we currently have the
* txg stopped from syncing.
*/
- iput_async(ZTOI(zp), dsl_pool_iput_taskq(dmu_objset_pool(os)));
+ zfs_iput_async(ZTOI(zp));
return (SET_ERROR(ENOENT));
}