diff --git a/module/spl/spl-vnode.c b/module/spl/spl-vnode.c index 80e4a0ffdb..a914e046c2 100644 --- a/module/spl/spl-vnode.c +++ b/module/spl/spl-vnode.c @@ -571,6 +571,9 @@ int vn_space(vnode_t *vp, int cmd, struct flock *bfp, int flag, offset_t offset, void *x6, void *x7) { int error = EOPNOTSUPP; +#ifdef FALLOC_FL_PUNCH_HOLE + int fstrans; +#endif if (cmd != F_FREESP || bfp->l_whence != 0) return (EOPNOTSUPP); @@ -580,6 +583,14 @@ int vn_space(vnode_t *vp, int cmd, struct flock *bfp, int flag, ASSERT(bfp->l_start >= 0 && bfp->l_len > 0); #ifdef FALLOC_FL_PUNCH_HOLE + /* + * May enter XFS which generates a warning when PF_FSTRANS is set. + * To avoid this the flag is cleared over vfs_sync() and then reset. + */ + fstrans = spl_fstrans_check(); + if (fstrans) + current->flags &= ~(PF_FSTRANS); + /* * When supported by the underlying file system preferentially * use the fallocate() callback to preallocate the space. @@ -587,6 +598,10 @@ int vn_space(vnode_t *vp, int cmd, struct flock *bfp, int flag, error = -spl_filp_fallocate(vp->v_file, FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE, bfp->l_start, bfp->l_len); + + if (fstrans) + current->flags |= PF_FSTRANS; + if (error == 0) return (0); #endif