From beb733c0f27c28d699700a5aabec41bf573712f8 Mon Sep 17 00:00:00 2001 From: Dmitry Eremin Date: Thu, 2 Mar 2017 22:39:37 +0300 Subject: [PATCH] LU-9183 libcfs: handle get_user_pages() with gup_flags In commit c8fe4609827aedc9c4b45de80e7cdc8ccfa8541b the arguments write/force for get_user_pages() were replaced with gup_flags. Change-Id: I64b3e69ee736d1f3be48f2c4c8fe1af1dc14e857 Signed-off-by: Dmitry Eremin Reviewed-on: https://review.whamcloud.com/25817 Reviewed-by: James Simmons Reviewed-by: Bob Glossman Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- libcfs/autoconf/lustre-libcfs.m4 | 19 +++++++++++++++++++ libcfs/libcfs/linux/linux-curproc.c | 4 +++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/libcfs/autoconf/lustre-libcfs.m4 b/libcfs/autoconf/lustre-libcfs.m4 index c7199f5..db240c21 100644 --- a/libcfs/autoconf/lustre-libcfs.m4 +++ b/libcfs/autoconf/lustre-libcfs.m4 @@ -555,6 +555,23 @@ stacktrace_ops, [ ]) # LIBCFS_STACKTRACE_OPS # +# Kernel version 4.9 commit 768ae309a96103ed02eb1e111e838c87854d8b51 +# mm: replace get_user_pages() write/force parameters with gup_flags +# +AC_DEFUN([LIBCFS_GET_USER_PAGES_GUP_FLAGS], [ +LB_CHECK_COMPILE([if 'get_user_pages()' takes gup_flags in arguments], +get_user_pages_gup_flags, [ + #include +],[ + int rc; + rc = get_user_pages(0, 0, FOLL_WRITE, NULL, NULL); +],[ + AC_DEFINE(HAVE_GET_USER_PAGES_GUP_FLAGS, 1, + [get_user_pages takes gup_flags in arguments]) +]) +]) # LIBCFS_GET_USER_PAGES_GUP_FLAGS + +# # LIBCFS_PROG_LINUX # # LibCFS linux kernel checks @@ -612,6 +629,8 @@ LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT LIBCFS_GET_USER_PAGES_6ARG # 4.8 LIBCFS_STACKTRACE_OPS +# 4.9 +LIBCFS_GET_USER_PAGES_GUP_FLAGS ]) # LIBCFS_PROG_LINUX # diff --git a/libcfs/libcfs/linux/linux-curproc.c b/libcfs/libcfs/linux/linux-curproc.c index b846627..7b2e46e 100644 --- a/libcfs/libcfs/linux/linux-curproc.c +++ b/libcfs/libcfs/linux/linux-curproc.c @@ -149,7 +149,9 @@ static int cfs_access_process_vm(struct task_struct *tsk, int bytes, rc, offset; void *maddr; -#ifdef HAVE_GET_USER_PAGES_6ARG +#if defined(HAVE_GET_USER_PAGES_GUP_FLAGS) + rc = get_user_pages(addr, 1, write ? FOLL_WRITE : 0, &page, &vma); +#elif defined(HAVE_GET_USER_PAGES_6ARG) rc = get_user_pages(addr, 1, write, 1, &page, &vma); #else rc = get_user_pages(tsk, mm, addr, 1, write, 1, &page, &vma); -- 1.8.3.1