Skip to content

Commit

Permalink
config: remove HAVE_GET_USER_PAGES_*
Browse files Browse the repository at this point in the history
get_user_pages_unlocked() had stabilised by 4.9.

Sponsored-by: https://despairlabs.com/sponsor/
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Tony Hutter <[email protected]>
Reviewed-by: Tino Reichardt <[email protected]>
Signed-off-by: Rob Norris <[email protected]>
Closes openzfs#16479
  • Loading branch information
robn authored and lundman committed Jan 22, 2025
1 parent b9d2c7b commit 23458ef
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 229 deletions.
179 changes: 0 additions & 179 deletions config/kernel-get-user-pages.m4

This file was deleted.

2 changes: 0 additions & 2 deletions config/kernel.m4
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [
ZFS_AC_KERNEL_SRC_VFS_FILEMAP_DIRTY_FOLIO
ZFS_AC_KERNEL_SRC_VFS_READ_FOLIO
ZFS_AC_KERNEL_SRC_VFS_FSYNC_2ARGS
ZFS_AC_KERNEL_SRC_GET_USER_PAGES
ZFS_AC_KERNEL_SRC_VFS_DIRECT_IO
ZFS_AC_KERNEL_SRC_VFS_READPAGES
ZFS_AC_KERNEL_SRC_VFS_SET_PAGE_DIRTY_NOBUFFERS
Expand Down Expand Up @@ -187,7 +186,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [
ZFS_AC_KERNEL_VFS_FILEMAP_DIRTY_FOLIO
ZFS_AC_KERNEL_VFS_READ_FOLIO
ZFS_AC_KERNEL_VFS_FSYNC_2ARGS
ZFS_AC_KERNEL_GET_USER_PAGES
ZFS_AC_KERNEL_VFS_DIRECT_IO
ZFS_AC_KERNEL_VFS_READPAGES
ZFS_AC_KERNEL_VFS_SET_PAGE_DIRTY_NOBUFFERS
Expand Down
45 changes: 0 additions & 45 deletions include/os/linux/kernel/linux/kmap_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,49 +48,4 @@
#define zfs_access_ok(type, addr, size) access_ok(addr, size)
#endif

/*
* read returning FOLL_WRITE is due to the fact that we are stating
* that the kernel will have write access to the user pages. So, when
* a Direct I/O read request is issued, the kernel must write to the user
* pages.
*
* get_user_pages_unlocked was not available to 4.0, so we also check
* for get_user_pages on older kernels.
*/
/* 4.9 API change - for and read flag is passed as gup flags */
#if defined(HAVE_GET_USER_PAGES_UNLOCKED_GUP_FLAGS)
#define zfs_get_user_pages(addr, numpages, read, pages) \
get_user_pages_unlocked(addr, numpages, pages, read ? FOLL_WRITE : 0)

/* 4.8 API change - no longer takes struct task_struct as arguement */
#elif defined(HAVE_GET_USER_PAGES_UNLOCKED_WRITE_FLAG)
#define zfs_get_user_pages(addr, numpages, read, pages) \
get_user_pages_unlocked(addr, numpages, read, 0, pages)

/* 4.0-4.3, 4.5-4.7 API */
#elif defined(HAVE_GET_USER_PAGES_UNLOCKED_TASK_STRUCT)
#define zfs_get_user_pages(addr, numpages, read, pages) \
get_user_pages_unlocked(current, current->mm, addr, numpages, read, 0, \
pages)

/* 4.4 API */
#elif defined(HAVE_GET_USER_PAGES_UNLOCKED_TASK_STRUCT_GUP_FLAGS)
#define zfs_get_user_pages(addr, numpages, read, pages) \
get_user_pages_unlocked(current, current->mm, addr, numpages, pages, \
read ? FOLL_WRITE : 0)

/* Using get_user_pages if kernel is < 4.0 */
#elif defined(HAVE_GET_USER_PAGES_TASK_STRUCT)
#define zfs_get_user_pages(addr, numpages, read, pages) \
get_user_pages(current, current->mm, addr, numpages, read, 0, pages, \
NULL)
#else
/*
* This case is unreachable. We must be able to use either
* get_user_pages_unlocked() or get_user_pages() to map user pages into
* the kernel.
*/
#error "Unknown Direct I/O interface"
#endif

#endif /* _ZFS_KMAP_H */
13 changes: 10 additions & 3 deletions module/os/linux/zfs/zfs_uio.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,9 +589,16 @@ zfs_uio_iov_step(struct iovec v, zfs_uio_rw_t rw, zfs_uio_t *uio,
size_t len = v.iov_len;
unsigned long n = DIV_ROUND_UP(len, PAGE_SIZE);

long res = zfs_get_user_pages(
P2ALIGN_TYPED(addr, PAGE_SIZE, unsigned long), n, rw == UIO_READ,
&uio->uio_dio.pages[uio->uio_dio.npages]);
/*
* read returning FOLL_WRITE is due to the fact that we are stating
* that the kernel will have write access to the user pages. So, when a
* Direct I/O read request is issued, the kernel must write to the user
* pages.
*/
long res = get_user_pages_unlocked(
P2ALIGN_TYPED(addr, PAGE_SIZE, unsigned long), n,
&uio->uio_dio.pages[uio->uio_dio.npages],
rw == UIO_READ ? FOLL_WRITE : 0);
if (res < 0) {
return (SET_ERROR(-res));
} else if (len != (res * PAGE_SIZE)) {
Expand Down

0 comments on commit 23458ef

Please sign in to comment.