From a206d1ef12806cebc6c8d0aa010aa915114e8213 Mon Sep 17 00:00:00 2001 From: Shaun Tancheff Date: Fri, 22 May 2020 10:49:45 -0700 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. This patch is back-ported from the following one: Lustre-commit: f2b224a48cb00f885b9df2cc56e349dae5f27f9e Lustre-change: https://review.whamcloud.com/35500 Test-Parameters: trivial Cray-bug-id: LUS-7600 Signed-off-by: Shaun Tancheff Change-Id: I7122fb0d4af3ee9a19c1a5d0b77c4f13f6850181 Reviewed-on: https://review.whamcloud.com/38478 Reviewed-by: Petros Koutoupis Tested-by: jenkins Reviewed-by: James Simmons Tested-by: Maloo Reviewed-by: Oleg Drokin --- 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 b01d423..d803bf0 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -3073,6 +3073,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.18 commit 95582b00838837fc07e042979320caf917ce3fe6 @@ -3338,6 +3357,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 516cad4..58b123a 100644 --- a/lustre/include/lustre_compat.h +++ b/lustre/include/lustre_compat.h @@ -320,6 +320,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 e8f7c75..897c423 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,16 +340,16 @@ 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; - int result; + vm_fault_t result; sigset_t set; /* Only SIGKILL and SIGTERM is allowed for fault/nopage/mkwrite @@ -396,17 +396,18 @@ 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; - 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