summaryrefslogtreecommitdiffstats
path: root/module/zfs/zfs_vnops.c
diff options
context:
space:
mode:
Diffstat (limited to 'module/zfs/zfs_vnops.c')
-rw-r--r--module/zfs/zfs_vnops.c37
1 files changed, 27 insertions, 10 deletions
diff --git a/module/zfs/zfs_vnops.c b/module/zfs/zfs_vnops.c
index 5a9c96334..3c3e8db4b 100644
--- a/module/zfs/zfs_vnops.c
+++ b/module/zfs/zfs_vnops.c
@@ -240,15 +240,15 @@ zfs_close(struct inode *ip, int flag, cred_t *cr)
}
EXPORT_SYMBOL(zfs_close);
-#if 0
+#if defined(SEEK_HOLE) && defined(SEEK_DATA)
/*
- * Lseek support for finding holes (cmd == _FIO_SEEK_HOLE) and
- * data (cmd == _FIO_SEEK_DATA). "off" is an in/out parameter.
+ * Lseek support for finding holes (cmd == SEEK_HOLE) and
+ * data (cmd == SEEK_DATA). "off" is an in/out parameter.
*/
static int
-zfs_holey(vnode_t *vp, int cmd, offset_t *off)
+zfs_holey_common(struct inode *ip, int cmd, loff_t *off)
{
- znode_t *zp = VTOZ(vp);
+ znode_t *zp = ITOZ(ip);
uint64_t noff = (uint64_t)*off; /* new offset */
uint64_t file_sz;
int error;
@@ -256,15 +256,15 @@ zfs_holey(vnode_t *vp, int cmd, offset_t *off)
file_sz = zp->z_size;
if (noff >= file_sz) {
- return (SET_ERROR(ENXIO));
+ return (ENXIO);
}
- if (cmd == _FIO_SEEK_HOLE)
+ if (cmd == SEEK_HOLE)
hole = B_TRUE;
else
hole = B_FALSE;
- error = dmu_offset_next(zp->z_zfsvfs->z_os, zp->z_id, hole, &noff);
+ error = dmu_offset_next(ZTOZSB(zp)->z_os, zp->z_id, hole, &noff);
/* end of file? */
if ((error == ESRCH) || (noff > file_sz)) {
@@ -275,7 +275,7 @@ zfs_holey(vnode_t *vp, int cmd, offset_t *off)
*off = file_sz;
return (0);
}
- return (SET_ERROR(ENXIO));
+ return (ENXIO);
}
if (noff < *off)
@@ -283,7 +283,24 @@ zfs_holey(vnode_t *vp, int cmd, offset_t *off)
*off = noff;
return (error);
}
-#endif
+
+int
+zfs_holey(struct inode *ip, int cmd, loff_t *off)
+{
+ znode_t *zp = ITOZ(ip);
+ zfs_sb_t *zsb = ITOZSB(ip);
+ int error;
+
+ ZFS_ENTER(zsb);
+ ZFS_VERIFY_ZP(zp);
+
+ error = zfs_holey_common(ip, cmd, off);
+
+ ZFS_EXIT(zsb);
+ return (error);
+}
+EXPORT_SYMBOL(zfs_holey);
+#endif /* SEEK_HOLE && SEEK_DATA */
#if defined(_KERNEL)
/*