diff options
author | Brian Behlendorf <[email protected]> | 2014-07-13 14:35:19 -0400 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2015-01-16 14:28:05 -0800 |
commit | 92119cc259ee2f9ebde14145f549d6313f557759 (patch) | |
tree | f401b89e39084c21c15049d26951a1e99d4aebef /module/zfs/vdev_file.c | |
parent | d958324f97f4668a2a6e4a6ce3e5ca09b71b31d9 (diff) |
Mark IO pipeline with PF_FSTRANS
In order to avoid deadlocking in the IO pipeline it is critical that
pageout be avoided during direct memory reclaim. This ensures that
the pipeline threads can always make forward progress and never end
up blocking on a DMU transaction. For this very reason Linux now
provides the PF_FSTRANS flag which may be set in the process context.
Signed-off-by: Brian Behlendorf <[email protected]>
Diffstat (limited to 'module/zfs/vdev_file.c')
-rw-r--r-- | module/zfs/vdev_file.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/module/zfs/vdev_file.c b/module/zfs/vdev_file.c index 8059cdea4..8573a3a66 100644 --- a/module/zfs/vdev_file.c +++ b/module/zfs/vdev_file.c @@ -161,6 +161,17 @@ vdev_file_io_strategy(void *arg) zio_interrupt(zio); } +static void +vdev_file_io_fsync(void *arg) +{ + zio_t *zio = (zio_t *)arg; + vdev_file_t *vf = zio->io_vd->vdev_tsd; + + zio->io_error = VOP_FSYNC(vf->vf_vnode, FSYNC | FDSYNC, kcred, NULL); + + zio_interrupt(zio); +} + static int vdev_file_io_start(zio_t *zio) { @@ -180,6 +191,19 @@ vdev_file_io_start(zio_t *zio) if (zfs_nocacheflush) break; + /* + * We cannot safely call vfs_fsync() when PF_FSTRANS + * is set in the current context. Filesystems like + * XFS include sanity checks to verify it is not + * already set, see xfs_vm_writepage(). Therefore + * the sync must be dispatched to a different context. + */ + if (spl_fstrans_check()) { + VERIFY3U(taskq_dispatch(vdev_file_taskq, + vdev_file_io_fsync, zio, TQ_SLEEP), !=, 0); + return (ZIO_PIPELINE_STOP); + } + zio->io_error = VOP_FSYNC(vf->vf_vnode, FSYNC | FDSYNC, kcred, NULL); break; |