diff options
author | Coleman Kane <ckane@colemankane.org> | 2021-12-02 23:25:08 -0500 |
---|---|---|
committer | Tony Hutter <hutter2@llnl.gov> | 2021-12-07 13:14:23 -0800 |
commit | 9519fe1ff83016fdbf2ad7bcad0c7a16a8e73acc (patch) | |
tree | a6d62d2814aecf6fa2895cdb2e17cfa72c88148b | |
parent | 0c40ff56f25037db817d00f09b1ff00b0c699ed3 (diff) |
Linux 5.16: type member of iov_iter renamed iter_type
The iov_iter->type member was renamed iov_iter->iter_type. However,
while looking into this, realized that in 2018 a iov_iter_type(*iov)
accessor function was introduced. So if that is present, use it,
otherwise fall back to trying the existing behavior of directly
accessing type from iov_iter.
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Coleman Kane <ckane@colemankane.org>
Closes #12819
-rw-r--r-- | config/kernel-vfs-iov_iter.m4 | 22 | ||||
-rw-r--r-- | module/os/linux/zfs/zpl_file.c | 6 |
2 files changed, 28 insertions, 0 deletions
diff --git a/config/kernel-vfs-iov_iter.m4 b/config/kernel-vfs-iov_iter.m4 index bee6d0be9..ecdda939f 100644 --- a/config/kernel-vfs-iov_iter.m4 +++ b/config/kernel-vfs-iov_iter.m4 @@ -74,6 +74,14 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_IOV_ITER], [ bytes = copy_from_iter((void *)&buf, size, &iter); ]) + + ZFS_LINUX_TEST_SRC([iov_iter_type], [ + #include <linux/fs.h> + #include <linux/uio.h> + ],[ + struct iov_iter iter = { 0 }; + __attribute__((unused)) enum iter_type i = iov_iter_type(&iter); + ]) ]) AC_DEFUN([ZFS_AC_KERNEL_VFS_IOV_ITER], [ @@ -150,6 +158,20 @@ AC_DEFUN([ZFS_AC_KERNEL_VFS_IOV_ITER], [ ]) dnl # + dnl # This checks for iov_iter_type() in linux/uio.h. It is not + dnl # required, however, and the module will compiled without it + dnl # using direct access of the member attribute + dnl # + AC_MSG_CHECKING([whether iov_iter_type() is available]) + ZFS_LINUX_TEST_RESULT([iov_iter_type], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_IOV_ITER_TYPE, 1, + [iov_iter_type() is available]) + ],[ + AC_MSG_RESULT(no) + ]) + + dnl # dnl # As of the 4.9 kernel support is provided for iovecs, kvecs, dnl # bvecs and pipes in the iov_iter structure. As long as the dnl # other support interfaces are all available the iov_iter can diff --git a/module/os/linux/zfs/zpl_file.c b/module/os/linux/zfs/zpl_file.c index 63002fe3b..7e88eae33 100644 --- a/module/os/linux/zfs/zpl_file.c +++ b/module/os/linux/zfs/zpl_file.c @@ -251,10 +251,16 @@ zpl_uio_init(zfs_uio_t *uio, struct kiocb *kiocb, struct iov_iter *to, #if defined(HAVE_VFS_IOV_ITER) zfs_uio_iov_iter_init(uio, to, pos, count, skip); #else +#ifdef HAVE_IOV_ITER_TYPE + zfs_uio_iovec_init(uio, to->iov, to->nr_segs, pos, + iov_iter_type(to) & ITER_KVEC ? UIO_SYSSPACE : UIO_USERSPACE, + count, skip); +#else zfs_uio_iovec_init(uio, to->iov, to->nr_segs, pos, to->type & ITER_KVEC ? UIO_SYSSPACE : UIO_USERSPACE, count, skip); #endif +#endif } static ssize_t |