From f2b224a48cb00f885b9df2cc56e349dae5f27f9e Mon Sep 17 00:00:00 2001 From: Shaun Tancheff Date: Sun, 14 Jul 2019 07:43:14 -0500 Subject: [PATCH] LU-12400 llite: Use the new vm_fault_t type Linux 4.17 created the new vm_fault_t type Linux-commit: 1c8f422059ae5da07db7406ab916203f9417e396 Linux 5.1 changed the vm_fault_t type to bitwise unsigned int which changes the interfaces registered to struct vm_operations_struct Linux-commit: 3d3539018d2cbd12e5af4a132636ee7fd8d43ef0 Prefer to match the upstream API and fallback to 'int' where vm_fault_t is not available. Test-Parameters: trivial Cray-bug-id: LUS-7600 Signed-off-by: Shaun Tancheff Change-Id: I7122fb0d4af3ee9a19c1a5d0b77c4f13f6850181 Reviewed-on: https://review.whamcloud.com/35500 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-by: Petros Koutoupis --- lustre/autoconf/lustre-core.m4 | 20 ++++++++++++++++++++ lustre/include/lustre_compat.h | 4 ++++ lustre/llite/llite_mmap.c | 15 ++++++++------- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index 05b0d73..635563f 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -3157,6 +3157,25 @@ i_pages, [ ]) # LC_I_PAGES # +# LC_VM_FAULT_T +# +# kernel 4.17 commit 3d3539018d2cbd12e5af4a132636ee7fd8d43ef0 +# mm: create the new vm_fault_t type +# +AC_DEFUN([LC_VM_FAULT_T], [ +LB_CHECK_COMPILE([if vm_fault_t type exists], +vm_fault_t, [ + #include +],[ + vm_fault_t x = VM_FAULT_SIGBUS; + (void)x +],[ + AC_DEFINE(HAVE_VM_FAULT_T, 1, + [if vm_fault_t type exists]) +]) +]) # LC_VM_FAULT_T + +# # LC_INODE_TIMESPEC64 # # kernel 4.17-rc7 commit 8efd6894ff089adeeac7cb9f32125b85d963d1bc @@ -3440,6 +3459,7 @@ AC_DEFUN([LC_PROG_LINUX], [ LC_BI_BDEV # 4.17 + LC_VM_FAULT_T LC_I_PAGES # 4.18 diff --git a/lustre/include/lustre_compat.h b/lustre/include/lustre_compat.h index 8fb9131..4175c82 100644 --- a/lustre/include/lustre_compat.h +++ b/lustre/include/lustre_compat.h @@ -323,6 +323,10 @@ static inline void set_nlink(struct inode *inode, unsigned int nlink) # define ll_umode_t int #endif +#ifndef HAVE_VM_FAULT_T +#define vm_fault_t int +#endif + #include #ifndef HAVE_D_MAKE_ROOT static inline struct dentry *d_make_root(struct inode *root) diff --git a/lustre/llite/llite_mmap.c b/lustre/llite/llite_mmap.c index e9552ae..1009c70 100644 --- a/lustre/llite/llite_mmap.c +++ b/lustre/llite/llite_mmap.c @@ -261,7 +261,7 @@ static inline int to_fault_error(int result) * \retval VM_FAULT_ERROR on general error * \retval NOPAGE_OOM not have memory for allocate new page */ -static int ll_fault0(struct vm_area_struct *vma, struct vm_fault *vmf) +static vm_fault_t ll_fault0(struct vm_area_struct *vma, struct vm_fault *vmf) { struct lu_env *env; struct cl_io *io; @@ -340,17 +340,17 @@ out: } #ifdef HAVE_VM_OPS_USE_VM_FAULT_ONLY -static int ll_fault(struct vm_fault *vmf) +static vm_fault_t ll_fault(struct vm_fault *vmf) { struct vm_area_struct *vma = vmf->vma; #else -static int ll_fault(struct vm_area_struct *vma, struct vm_fault *vmf) +static vm_fault_t ll_fault(struct vm_area_struct *vma, struct vm_fault *vmf) { #endif int count = 0; bool printed = false; bool cached; - int result; + vm_fault_t result; sigset_t set; ll_stats_ops_tally(ll_i2sbi(file_inode(vma->vm_file)), @@ -398,18 +398,19 @@ restart: } #ifdef HAVE_VM_OPS_USE_VM_FAULT_ONLY -static int ll_page_mkwrite(struct vm_fault *vmf) +static vm_fault_t ll_page_mkwrite(struct vm_fault *vmf) { struct vm_area_struct *vma = vmf->vma; #else -static int ll_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) +static vm_fault_t ll_page_mkwrite(struct vm_area_struct *vma, + struct vm_fault *vmf) { #endif int count = 0; bool printed = false; bool retry; bool cached; - int result; + vm_fault_t result; ll_stats_ops_tally(ll_i2sbi(file_inode(vma->vm_file)), LPROC_LL_MKWRITE, 1); -- 1.8.3.1