Skip to content

Commit

Permalink
SQUASH
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Atkinson <[email protected]>
  • Loading branch information
bwatkinson committed Jan 28, 2025
1 parent 0fffeba commit cd9adf6
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
27 changes: 27 additions & 0 deletions config/kernel-vfs-iov_iter.m4
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_IOV_ITER], [
__attribute__((unused)) enum iter_type i = iov_iter_type(&iter);
])
ZFS_LINUX_TEST_SRC([iov_iter_get_pages2], [
#include <linux/uio.h>
],[
struct iov_iter iter = { 0 };
struct page **pages = NULL;
size_t maxsize = 4096;
unsigned maxpages = 1;
size_t start;
size_t ret __attribute__ ((unused));
ret = iov_iter_get_pages2(&iter, pages, maxsize, maxpages,
&start);
])
ZFS_LINUX_TEST_SRC([iter_is_ubuf], [
#include <linux/uio.h>
],[
Expand Down Expand Up @@ -64,6 +78,19 @@ AC_DEFUN([ZFS_AC_KERNEL_VFS_IOV_ITER], [
AC_MSG_RESULT(no)
])
dnl #
dnl # Kernel 6.0 changed iov_iter_get_pages() to iov_iter_get_pages2().
dnl #
AC_MSG_CHECKING([whether iov_iter_get_pages2() is available])
ZFS_LINUX_TEST_RESULT([iov_iter_get_pages2], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_IOV_ITER_GET_PAGES2, 1,
[iov_iter_get_pages2() is available])
],[
AC_MSG_RESULT(no)
])
dnl #
dnl # Kernel 6.0 introduced the ITER_UBUF iov_iter type. iter_is_ubuf()
dnl # was also added to determine if the iov_iter is an ITER_UBUF.
Expand Down
6 changes: 3 additions & 3 deletions include/os/linux/spl/sys/uio.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ zfs_uio_iov_iter_init(zfs_uio_t *uio, struct iov_iter *iter, offset_t offset,
#endif

#if defined(HAVE_ITER_IS_UBUF)
#define zfs_user_backed_iov_ter(iter) \
(zfs_uio_iov_iter_type((iter)) == iter_is_ubuf((iter))) || \
(zfs_uio_iov_iter_type((iter)) == ITER_IOVEC)
#define zfs_user_backed_iov_iter(iter) \
(iter_is_ubuf((iter)) || \
(zfs_uio_iov_iter_type((iter)) == ITER_IOVEC))
#else
#define zfs_user_backed_iov_iter(iter) \
(zfs_uio_iov_iter_type((iter)) == ITER_IOVEC)
Expand Down
11 changes: 11 additions & 0 deletions module/os/linux/zfs/zfs_uio.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,9 +584,15 @@ zfs_uio_get_dio_pages_iov_iter(zfs_uio_t *uio, zfs_uio_rw_t rw)
unsigned maxpages = DIV_ROUND_UP(wanted, PAGE_SIZE);

while (wanted) {
#if defined(HAVE_IOV_ITER_GET_PAGES2)
cnt = iov_iter_get_pages2(uio->uio_iter,
&uio->uio_dio.pages[uio->uio_dio.npages],
wanted, maxpages, &start);
#else
cnt = iov_iter_get_pages(uio->uio_iter,
&uio->uio_dio.pages[uio->uio_dio.npages],
wanted, maxpages, &start);
#endif
if (cnt < 0) {
iov_iter_revert(uio->uio_iter, rollback);
return (SET_ERROR(-cnt));
Expand All @@ -598,7 +604,12 @@ zfs_uio_get_dio_pages_iov_iter(zfs_uio_t *uio, zfs_uio_rw_t rw)
uio->uio_dio.npages += DIV_ROUND_UP(cnt, PAGE_SIZE);
rollback += cnt;
wanted -= cnt;
#if !defined(HAVE_IOV_ITER_GET_PAGES2)
/*
* iov_iter_get_pages2() advances the iov_iter on success.
*/
iov_iter_advance(uio->uio_iter, cnt);
#endif

}
ASSERT3U(rollback, ==, uio->uio_resid - uio->uio_skip);
Expand Down

0 comments on commit cd9adf6

Please sign in to comment.