X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=module%2Fzfs%2Fzfs_vnops.c;h=876d44b3563dae38e3989c632c356d2b7b9637b1;hb=refs%2Fheads%2Frertzinger%2Ffeature-zpool-get--p;hp=5a9c96334672fe5c9bfd10b3014592d439b0aaee;hpb=cf91b2b6b2baaca1e56f23c985e3261cd98bd3f0;p=zfs.git diff --git a/module/zfs/zfs_vnops.c b/module/zfs/zfs_vnops.c index 5a9c963..876d44b 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) /* @@ -1980,8 +1997,7 @@ EXPORT_SYMBOL(zfs_rmdir); */ /* ARGSUSED */ int -zfs_readdir(struct inode *ip, void *dirent, filldir_t filldir, - loff_t *pos, cred_t *cr) +zfs_readdir(struct inode *ip, struct dir_context *ctx, cred_t *cr) { znode_t *zp = ITOZ(ip); zfs_sb_t *zsb = ITOZSB(ip); @@ -1993,6 +2009,7 @@ zfs_readdir(struct inode *ip, void *dirent, filldir_t filldir, uint8_t prefetch; int done = 0; uint64_t parent; + loff_t *pos = &(ctx->pos); ZFS_ENTER(zsb); ZFS_VERIFY_ZP(zp); @@ -2081,11 +2098,11 @@ zfs_readdir(struct inode *ip, void *dirent, filldir_t filldir, objnum = ZFS_DIRENT_OBJ(zap.za_first_integer); } - done = filldir(dirent, zap.za_name, strlen(zap.za_name), - zap_cursor_serialize(&zc), objnum, 0); - if (done) { + + done = !dir_emit(ctx, zap.za_name, strlen(zap.za_name), + objnum, ZFS_DIRENT_TYPE(zap.za_first_integer)); + if (done) break; - } /* Prefetch znode */ if (prefetch) {