Cleaning up uio headers

Making uio_impl.h the common header interface between Linux and FreeBSD
so both OS's can share a common header file. This also helps reduce code
duplication for zfs_uio_t for each OS.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Brian Atkinson <batkinson@lanl.gov>
Closes #11622
This commit is contained in:
Brian Atkinson 2021-02-20 21:16:50 -07:00 committed by Tony Hutter
parent 0b1e6fcc3e
commit d10c35b640
9 changed files with 40 additions and 63 deletions

View File

@ -55,38 +55,12 @@ typedef struct zfs_uio {
#define zfs_uio_fault_disable(u, set) #define zfs_uio_fault_disable(u, set)
#define zfs_uio_prefaultpages(size, u) (0) #define zfs_uio_prefaultpages(size, u) (0)
static inline void
static __inline void
zfs_uio_init(zfs_uio_t *uio, struct uio *uio_s)
{
GET_UIO_STRUCT(uio) = uio_s;
}
static __inline void
zfs_uio_setoffset(zfs_uio_t *uio, offset_t off) zfs_uio_setoffset(zfs_uio_t *uio, offset_t off)
{ {
zfs_uio_offset(uio) = off; zfs_uio_offset(uio) = off;
} }
static __inline int
zfs_uiomove(void *cp, size_t n, zfs_uio_rw_t dir, zfs_uio_t *uio)
{
ASSERT(zfs_uio_rw(uio) == dir);
return (uiomove(cp, (int)n, GET_UIO_STRUCT(uio)));
}
int zfs_uiocopy(void *p, size_t n, zfs_uio_rw_t rw, zfs_uio_t *uio,
size_t *cbytes);
void zfs_uioskip(zfs_uio_t *uiop, size_t n);
int zfs_uio_fault_move(void *p, size_t n, zfs_uio_rw_t dir, zfs_uio_t *uio);
static inline void
zfs_uio_iov_at_index(zfs_uio_t *uio, uint_t idx, void **base, uint64_t *len)
{
*base = zfs_uio_iovbase(uio, idx);
*len = zfs_uio_iovlen(uio, idx);
}
static inline void static inline void
zfs_uio_advance(zfs_uio_t *uio, size_t size) zfs_uio_advance(zfs_uio_t *uio, size_t size)
{ {
@ -94,19 +68,14 @@ zfs_uio_advance(zfs_uio_t *uio, size_t size)
zfs_uio_offset(uio) += size; zfs_uio_offset(uio) += size;
} }
static inline offset_t static __inline void
zfs_uio_index_at_offset(zfs_uio_t *uio, offset_t off, uint_t *vec_idx) zfs_uio_init(zfs_uio_t *uio, struct uio *uio_s)
{ {
*vec_idx = 0; GET_UIO_STRUCT(uio) = uio_s;
while (*vec_idx < zfs_uio_iovcnt(uio) &&
off >= zfs_uio_iovlen(uio, *vec_idx)) {
off -= zfs_uio_iovlen(uio, *vec_idx);
(*vec_idx)++;
}
return (off);
} }
int zfs_uio_fault_move(void *p, size_t n, zfs_uio_rw_t dir, zfs_uio_t *uio);
#endif /* !_STANDALONE */ #endif /* !_STANDALONE */
#endif /* !_OPENSOLARIS_SYS_UIO_H_ */ #endif /* !_OPENSOLARIS_SYS_UIO_H_ */

View File

@ -78,19 +78,14 @@ typedef struct zfs_uio {
#define zfs_uio_rlimit_fsize(z, u) (0) #define zfs_uio_rlimit_fsize(z, u) (0)
#define zfs_uio_fault_move(p, n, rw, u) zfs_uiomove((p), (n), (rw), (u)) #define zfs_uio_fault_move(p, n, rw, u) zfs_uiomove((p), (n), (rw), (u))
extern int zfs_uio_prefaultpages(ssize_t, zfs_uio_t *);
static inline void static inline void
zfs_uio_setoffset(zfs_uio_t *uio, offset_t off) zfs_uio_setoffset(zfs_uio_t *uio, offset_t off)
{ {
uio->uio_loffset = off; uio->uio_loffset = off;
} }
static inline void
zfs_uio_iov_at_index(zfs_uio_t *uio, uint_t idx, void **base, uint64_t *len)
{
*base = zfs_uio_iovbase(uio, idx);
*len = zfs_uio_iovlen(uio, idx);
}
static inline void static inline void
zfs_uio_advance(zfs_uio_t *uio, size_t size) zfs_uio_advance(zfs_uio_t *uio, size_t size)
{ {
@ -98,19 +93,6 @@ zfs_uio_advance(zfs_uio_t *uio, size_t size)
uio->uio_loffset += size; uio->uio_loffset += size;
} }
static inline offset_t
zfs_uio_index_at_offset(zfs_uio_t *uio, offset_t off, uint_t *vec_idx)
{
*vec_idx = 0;
while (*vec_idx < zfs_uio_iovcnt(uio) &&
off >= zfs_uio_iovlen(uio, *vec_idx)) {
off -= zfs_uio_iovlen(uio, *vec_idx);
(*vec_idx)++;
}
return (off);
}
static inline void static inline void
iov_iter_init_compat(struct iov_iter *iter, unsigned int dir, iov_iter_init_compat(struct iov_iter *iter, unsigned int dir,
const struct iovec *iov, unsigned long nr_segs, size_t count) const struct iovec *iov, unsigned long nr_segs, size_t count)

View File

@ -23,7 +23,6 @@
#ifndef ZFS_CONTEXT_OS_H #ifndef ZFS_CONTEXT_OS_H
#define ZFS_CONTEXT_OS_H #define ZFS_CONTEXT_OS_H
#include <sys/uio_impl.h>
#include <linux/dcache_compat.h> #include <linux/dcache_compat.h>
#include <linux/utsname_compat.h> #include <linux/utsname_compat.h>
#include <linux/compiler_compat.h> #include <linux/compiler_compat.h>

View File

@ -42,8 +42,27 @@
#include <sys/uio.h> #include <sys/uio.h>
extern int zfs_uiomove(void *, size_t, zfs_uio_rw_t, zfs_uio_t *); extern int zfs_uiomove(void *, size_t, zfs_uio_rw_t, zfs_uio_t *);
extern int zfs_uio_prefaultpages(ssize_t, zfs_uio_t *);
extern int zfs_uiocopy(void *, size_t, zfs_uio_rw_t, zfs_uio_t *, size_t *); extern int zfs_uiocopy(void *, size_t, zfs_uio_rw_t, zfs_uio_t *, size_t *);
extern void zfs_uioskip(zfs_uio_t *, size_t); extern void zfs_uioskip(zfs_uio_t *, size_t);
static inline void
zfs_uio_iov_at_index(zfs_uio_t *uio, uint_t idx, void **base, uint64_t *len)
{
*base = zfs_uio_iovbase(uio, idx);
*len = zfs_uio_iovlen(uio, idx);
}
static inline offset_t
zfs_uio_index_at_offset(zfs_uio_t *uio, offset_t off, uint_t *vec_idx)
{
*vec_idx = 0;
while (*vec_idx < zfs_uio_iovcnt(uio) &&
off >= zfs_uio_iovlen(uio, *vec_idx)) {
off -= zfs_uio_iovlen(uio, *vec_idx);
(*vec_idx)++;
}
return (off);
}
#endif /* _SYS_UIO_IMPL_H */ #endif /* _SYS_UIO_IMPL_H */

View File

@ -72,6 +72,7 @@ extern "C" {
#include <sys/trace.h> #include <sys/trace.h>
#include <sys/procfs_list.h> #include <sys/procfs_list.h>
#include <sys/mod.h> #include <sys/mod.h>
#include <sys/uio_impl.h>
#include <sys/zfs_context_os.h> #include <sys/zfs_context_os.h>
#else /* _KERNEL || _STANDALONE */ #else /* _KERNEL || _STANDALONE */

View File

@ -41,10 +41,17 @@
*/ */
#include <sys/param.h> #include <sys/param.h>
#include <sys/uio.h> #include <sys/uio_impl.h>
#include <sys/vnode.h> #include <sys/vnode.h>
#include <sys/zfs_znode.h> #include <sys/zfs_znode.h>
int
zfs_uiomove(void *cp, size_t n, zfs_uio_rw_t dir, zfs_uio_t *uio)
{
ASSERT(zfs_uio_rw(uio) == dir);
return (uiomove(cp, (int)n, GET_UIO_STRUCT(uio)));
}
/* /*
* same as zfs_uiomove() but doesn't modify uio structure. * same as zfs_uiomove() but doesn't modify uio structure.
* return in cbytes how many bytes were copied. * return in cbytes how many bytes were copied.

View File

@ -31,7 +31,6 @@
#include <sys/fm/fs/zfs.h> #include <sys/fm/fs/zfs.h>
#include <sys/spa_impl.h> #include <sys/spa_impl.h>
#include <sys/nvpair.h> #include <sys/nvpair.h>
#include <sys/uio.h>
#include <sys/fs/zfs.h> #include <sys/fs/zfs.h>
#include <sys/vdev_impl.h> #include <sys/vdev_impl.h>
#include <sys/zfs_ioctl.h> #include <sys/zfs_ioctl.h>
@ -39,6 +38,7 @@
#include <sys/sunddi.h> #include <sys/sunddi.h>
#include <sys/zfeature.h> #include <sys/zfeature.h>
#include <sys/zfs_file.h> #include <sys/zfs_file.h>
#include <sys/zfs_context.h>
#ifdef _KERNEL #ifdef _KERNEL
#include <sys/zone.h> #include <sys/zone.h>
#endif #endif

View File

@ -159,7 +159,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/errno.h> #include <sys/errno.h>
#include <sys/uio.h> #include <sys/uio_impl.h>
#include <sys/file.h> #include <sys/file.h>
#include <sys/kmem.h> #include <sys/kmem.h>
#include <sys/cmn_err.h> #include <sys/cmn_err.h>

View File

@ -34,7 +34,7 @@
#include <sys/time.h> #include <sys/time.h>
#include <sys/sysmacros.h> #include <sys/sysmacros.h>
#include <sys/vfs.h> #include <sys/vfs.h>
#include <sys/uio.h> #include <sys/uio_impl.h>
#include <sys/file.h> #include <sys/file.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/kmem.h> #include <sys/kmem.h>