Whamcloud - gitweb
LU-14787 libcfs: Proved an abstraction for AS_EXITING 70/44070/6
authorShaun Tancheff <shaun.tancheff@hpe.com>
Thu, 22 Jul 2021 07:31:30 +0000 (02:31 -0500)
committerOleg Drokin <green@whamcloud.com>
Wed, 18 Aug 2021 01:59:24 +0000 (01:59 +0000)
Linux kernel v3.14-7405-g91b0abe36a7b added AS_EXITING flag
AS_EXITING flag is set while address_space mapping is exiting.

Provide an abstraction mapping_clear_exiting() to clear
the AS_EXITING flag. This balances the kernel mapping_set_existing()
and is used for older kernels when enum mapping_flags does
not include AS_EXITING.

HPE-bug-id: LUS-9977
Signed-off-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Change-Id: Ib3101b7e3eb8a7fcfd0012ac27367f1e65537f5d
Reviewed-on: https://review.whamcloud.com/44070
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Tested-by: Maloo <maloo@whamcloud.com>
libcfs/autoconf/lustre-libcfs.m4
libcfs/include/libcfs/linux/linux-fs.h
lustre/llite/vvp_object.c

index d58062e..6407f53 100644 (file)
@@ -197,6 +197,29 @@ shrinker_count_objects, [
 ]) # LIBCFS_SHRINKER_COUNT
 
 #
+# LIBCFS_HAVE_MAPPING_AS_EXITING_FLAG
+#
+# v3.14-7405-g91b0abe36a7b added AS_EXITING flag with
+# mapping_exiting() and mapping_set_exiting()
+#
+AC_DEFUN([LIBCFS_HAVE_MAPPING_AS_EXITING_FLAG], [
+m4_pattern_allow([AS_EXITING])
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_CHECK_COMPILE([if enum mapping_flags has AS_EXITING flag],
+mapping_exiting_exists, [
+       #include <linux/pagemap.h>
+],[
+       enum mapping_flags flag = AS_EXITING;
+       (void)flag;
+],[
+       AC_DEFINE(HAVE_MAPPING_AS_EXITING_FLAG, 1,
+               [enum mapping_flags has AS_EXITING flag])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+]) # LIBCFS_HAVE_MAPPING_AS_EXITING_FLAG
+
+#
 # LIBCFS_IOV_ITER_HAS_TYPE
 #
 # kernel 3.15-rc4 commit 71d8e532b1549a478e6a6a8a44f309d050294d00
@@ -1660,6 +1683,7 @@ LIBCFS_KTIME_BEFORE
 LIBCFS_KTIME_COMPARE
 LIBCFS_SHRINKER_COUNT
 # 3.15
+LIBCFS_HAVE_MAPPING_AS_EXITING_FLAG
 LIBCFS_IOV_ITER_HAS_TYPE
 # 3.16
 LIBCFS_HAVE_NS_TO_TIMESPEC64
index e830368..6ef6b07 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/stat.h>
 #include <linux/mount.h>
 #include <linux/backing-dev.h>
+#include <linux/pagemap.h>
 
 #ifndef HAVE_FILE_DENTRY
 static inline struct dentry *file_dentry(const struct file *file)
@@ -76,4 +77,11 @@ static inline struct dentry *file_dentry(const struct file *file)
 #define proc_get_unmapped_area         get_unmapped_area
 #endif
 
+static inline void mapping_clear_exiting(struct address_space *mapping)
+{
+#ifdef HAVE_MAPPING_AS_EXITING_FLAG
+       clear_bit(AS_EXITING, &mapping->flags);
+#endif
+}
+
 #endif
index 8fac513..2413da9 100644 (file)
@@ -167,7 +167,7 @@ static int vvp_prune(const struct lu_env *env, struct cl_object *obj)
        }
 
        ll_truncate_inode_pages_final(inode);
-       clear_bit(AS_EXITING, &inode->i_mapping->flags);
+       mapping_clear_exiting(inode->i_mapping);
 
        RETURN(0);
 }