mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-11-18 18:31:00 +03:00
58bc86c5cb
As of the 5.10 kernel the generic splice compatibility code has been removed. All filesystems are now responsible for registering a ->splice_read and ->splice_write callback to support this operation. The good news is the VFS provided generic_file_splice_read() and iter_file_splice_write() callbacks can be used provided the ->iter_read and ->iter_write callback support pipes. However, this is currently not the case and only iovecs and bvecs (not pipes) are ever attached to the uio structure. This commit changes that by allowing full iov_iter structures to be attached to uios. Ever since the 4.9 kernel the iov_iter structure has supported iovecs, kvecs, bvevs, and pipes so it's desirable to pass the entire thing when possible. In conjunction with this the uio helper functions (i.e uiomove(), uiocopy(), etc) have been updated to understand the new UIO_ITER type. Note that using the kernel provided uio_iter interfaces allowed the existing Linux specific uio handling code to be simplified. When there's no longer a need to support kernel's older than 4.9, then it will be possible to remove the iovec and bvec members from the uio structure and always use a uio_iter. Until then we need to maintain all of the existing types for older kernels. Some additional refactoring and cleanup was included in this change: - Added checks to configure to detect available iov_iter interfaces. Some are available all the way back to the 3.10 kernel and are used when available. In particular, uio_prefaultpages() now always uses iov_iter_fault_in_readable() which is available for all supported kernels. - The unused UIO_USERISPACE type has been removed. It is no longer needed now that the uio_seg enum is platform specific. - Moved zfs_uio.c from the zcommon.ko module to the Linux specific platform code for the zfs.ko module. This gets it out of libzfs where it was never needed and keeps this Linux specific code out of the common sources. - Removed unnecessary O_APPEND handling from zfs_iter_write(), this is redundant and O_APPEND is already handled in zfs_write(); NOTE: Cleanly applying this kernel compatibility change required applying the following commits. This makes the change larger than it absolutely needs to be, but the resulting code matches what's in the branch branch. This is both more tested and makes it easier to apply any future backports in this area.7cf4cd824
Remove incorrect assertion783be694f
Reduce confusion in zfs_writeaf5626ac2
Return EFAULT at the end of zfs_write() when setcc1f85be8
Simplify offset and length limit in zfs_write9585538d0
Const some unchanging variables in zfs_write86e74dc16
Remove redundant oid parameter to update_pagesb3d723fb0
Factor uid, gid, and projid out of loop in zfs_write3d40b6554
Share zfs_fsync, zfs_read, zfs_write, et al between Linux and FreeBSD Reviewed-by: Colin Ian King <colin.king@canonical.com> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #11351
207 lines
5.0 KiB
Plaintext
207 lines
5.0 KiB
Plaintext
dnl #
|
|
dnl # Check for available iov_iter functionality.
|
|
dnl #
|
|
AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_IOV_ITER], [
|
|
ZFS_LINUX_TEST_SRC([iov_iter_types], [
|
|
#include <linux/fs.h>
|
|
#include <linux/uio.h>
|
|
],[
|
|
int type __attribute__ ((unused)) =
|
|
ITER_IOVEC | ITER_KVEC | ITER_BVEC | ITER_PIPE;
|
|
])
|
|
|
|
ZFS_LINUX_TEST_SRC([iov_iter_init], [
|
|
#include <linux/fs.h>
|
|
#include <linux/uio.h>
|
|
],[
|
|
struct iov_iter iter = { 0 };
|
|
struct iovec iov;
|
|
unsigned long nr_segs = 1;
|
|
size_t count = 1024;
|
|
|
|
iov_iter_init(&iter, WRITE, &iov, nr_segs, count);
|
|
])
|
|
|
|
ZFS_LINUX_TEST_SRC([iov_iter_init_legacy], [
|
|
#include <linux/fs.h>
|
|
#include <linux/uio.h>
|
|
],[
|
|
struct iov_iter iter = { 0 };
|
|
struct iovec iov;
|
|
unsigned long nr_segs = 1;
|
|
size_t count = 1024;
|
|
size_t written = 0;
|
|
|
|
iov_iter_init(&iter, &iov, nr_segs, count, written);
|
|
])
|
|
|
|
ZFS_LINUX_TEST_SRC([iov_iter_advance], [
|
|
#include <linux/fs.h>
|
|
#include <linux/uio.h>
|
|
],[
|
|
struct iov_iter iter = { 0 };
|
|
size_t advance = 512;
|
|
|
|
iov_iter_advance(&iter, advance);
|
|
])
|
|
|
|
ZFS_LINUX_TEST_SRC([iov_iter_revert], [
|
|
#include <linux/fs.h>
|
|
#include <linux/uio.h>
|
|
],[
|
|
struct iov_iter iter = { 0 };
|
|
size_t revert = 512;
|
|
|
|
iov_iter_revert(&iter, revert);
|
|
])
|
|
|
|
ZFS_LINUX_TEST_SRC([iov_iter_fault_in_readable], [
|
|
#include <linux/fs.h>
|
|
#include <linux/uio.h>
|
|
],[
|
|
struct iov_iter iter = { 0 };
|
|
size_t size = 512;
|
|
int error __attribute__ ((unused));
|
|
|
|
error = iov_iter_fault_in_readable(&iter, size);
|
|
])
|
|
|
|
ZFS_LINUX_TEST_SRC([iov_iter_count], [
|
|
#include <linux/fs.h>
|
|
#include <linux/uio.h>
|
|
],[
|
|
struct iov_iter iter = { 0 };
|
|
size_t bytes __attribute__ ((unused));
|
|
|
|
bytes = iov_iter_count(&iter);
|
|
])
|
|
|
|
ZFS_LINUX_TEST_SRC([copy_to_iter], [
|
|
#include <linux/fs.h>
|
|
#include <linux/uio.h>
|
|
],[
|
|
struct iov_iter iter = { 0 };
|
|
char buf[512] = { 0 };
|
|
size_t size = 512;
|
|
size_t bytes __attribute__ ((unused));
|
|
|
|
bytes = copy_to_iter((const void *)&buf, size, &iter);
|
|
])
|
|
|
|
ZFS_LINUX_TEST_SRC([copy_from_iter], [
|
|
#include <linux/fs.h>
|
|
#include <linux/uio.h>
|
|
],[
|
|
struct iov_iter iter = { 0 };
|
|
char buf[512] = { 0 };
|
|
size_t size = 512;
|
|
size_t bytes __attribute__ ((unused));
|
|
|
|
bytes = copy_from_iter((void *)&buf, size, &iter);
|
|
])
|
|
])
|
|
|
|
AC_DEFUN([ZFS_AC_KERNEL_VFS_IOV_ITER], [
|
|
enable_vfs_iov_iter="yes"
|
|
|
|
AC_MSG_CHECKING([whether iov_iter types are available])
|
|
ZFS_LINUX_TEST_RESULT([iov_iter_types], [
|
|
AC_MSG_RESULT(yes)
|
|
AC_DEFINE(HAVE_IOV_ITER_TYPES, 1,
|
|
[iov_iter types are available])
|
|
],[
|
|
AC_MSG_RESULT(no)
|
|
enable_vfs_iov_iter="no"
|
|
])
|
|
|
|
dnl #
|
|
dnl # 'iov_iter_init' available in Linux 3.16 and newer.
|
|
dnl # 'iov_iter_init_legacy' available in Linux 3.15 and older.
|
|
dnl #
|
|
AC_MSG_CHECKING([whether iov_iter_init() is available])
|
|
ZFS_LINUX_TEST_RESULT([iov_iter_init], [
|
|
AC_MSG_RESULT(yes)
|
|
AC_DEFINE(HAVE_IOV_ITER_INIT, 1,
|
|
[iov_iter_init() is available])
|
|
],[
|
|
ZFS_LINUX_TEST_RESULT([iov_iter_init_legacy], [
|
|
AC_MSG_RESULT(yes)
|
|
AC_DEFINE(HAVE_IOV_ITER_INIT_LEGACY, 1,
|
|
[iov_iter_init() is available])
|
|
],[
|
|
ZFS_LINUX_TEST_ERROR([iov_iter_init()])
|
|
])
|
|
])
|
|
|
|
AC_MSG_CHECKING([whether iov_iter_advance() is available])
|
|
ZFS_LINUX_TEST_RESULT([iov_iter_advance], [
|
|
AC_MSG_RESULT(yes)
|
|
AC_DEFINE(HAVE_IOV_ITER_ADVANCE, 1,
|
|
[iov_iter_advance() is available])
|
|
],[
|
|
AC_MSG_RESULT(no)
|
|
enable_vfs_iov_iter="no"
|
|
])
|
|
|
|
AC_MSG_CHECKING([whether iov_iter_revert() is available])
|
|
ZFS_LINUX_TEST_RESULT([iov_iter_revert], [
|
|
AC_MSG_RESULT(yes)
|
|
AC_DEFINE(HAVE_IOV_ITER_REVERT, 1,
|
|
[iov_iter_revert() is available])
|
|
],[
|
|
AC_MSG_RESULT(no)
|
|
enable_vfs_iov_iter="no"
|
|
])
|
|
|
|
AC_MSG_CHECKING([whether iov_iter_fault_in_readable() is available])
|
|
ZFS_LINUX_TEST_RESULT([iov_iter_fault_in_readable], [
|
|
AC_MSG_RESULT(yes)
|
|
AC_DEFINE(HAVE_IOV_ITER_FAULT_IN_READABLE, 1,
|
|
[iov_iter_fault_in_readable() is available])
|
|
],[
|
|
AC_MSG_RESULT(no)
|
|
enable_vfs_iov_iter="no"
|
|
])
|
|
|
|
AC_MSG_CHECKING([whether iov_iter_count() is available])
|
|
ZFS_LINUX_TEST_RESULT([iov_iter_count], [
|
|
AC_MSG_RESULT(yes)
|
|
AC_DEFINE(HAVE_IOV_ITER_COUNT, 1,
|
|
[iov_iter_count() is available])
|
|
],[
|
|
AC_MSG_RESULT(no)
|
|
enable_vfs_iov_iter="no"
|
|
])
|
|
|
|
AC_MSG_CHECKING([whether copy_to_iter() is available])
|
|
ZFS_LINUX_TEST_RESULT([copy_to_iter], [
|
|
AC_MSG_RESULT(yes)
|
|
AC_DEFINE(HAVE_COPY_TO_ITER, 1,
|
|
[copy_to_iter() is available])
|
|
],[
|
|
AC_MSG_RESULT(no)
|
|
enable_vfs_iov_iter="no"
|
|
])
|
|
|
|
AC_MSG_CHECKING([whether copy_from_iter() is available])
|
|
ZFS_LINUX_TEST_RESULT([copy_from_iter], [
|
|
AC_MSG_RESULT(yes)
|
|
AC_DEFINE(HAVE_COPY_FROM_ITER, 1,
|
|
[copy_from_iter() is available])
|
|
],[
|
|
AC_MSG_RESULT(no)
|
|
enable_vfs_iov_iter="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
|
|
dnl # be correctly used in the uio structure.
|
|
dnl #
|
|
AS_IF([test "x$enable_vfs_iov_iter" = "xyes"], [
|
|
AC_DEFINE(HAVE_VFS_IOV_ITER, 1,
|
|
[All required iov_iter interfaces are available])
|
|
])
|
|
])
|