From da318b17c78756d2e5a35f23d36c4ada1fa6dbd6 Mon Sep 17 00:00:00 2001 From: Ryusuke Konishi Date: Wed, 9 Jul 2014 03:09:17 +0900 Subject: [PATCH] Add kern_feature.h header file This file evens up kernel differences depending on versions and distributions. This initial version of kern_feature.h includes declaration of truncate_inode_pages_final() function which is added to kernel 3.15 and backported to RHEL 7 GA kernel. Signed-off-by: Ryusuke Konishi --- fs/nilfs2/inode.c | 1 + fs/nilfs2/kern_feature.h | 56 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 fs/nilfs2/kern_feature.h diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c index b1a5277..0104859 100644 --- a/fs/nilfs2/inode.c +++ b/fs/nilfs2/inode.c @@ -26,6 +26,7 @@ #include #include #include +#include "kern_feature.h" #include "nilfs.h" #include "btnode.h" #include "segment.h" diff --git a/fs/nilfs2/kern_feature.h b/fs/nilfs2/kern_feature.h new file mode 100644 index 0000000..97b137c --- /dev/null +++ b/fs/nilfs2/kern_feature.h @@ -0,0 +1,56 @@ +/* + * kern_feature.h - Kernel dependent features + * + * Licensed under GPLv2: the complete text of the GNU General Public + * License can be found in COPYING file of the nilfs-kmod package. + */ + +#ifndef NILFS_KERN_FEATURE_H +#define NILFS_KERN_FEATURE_H + +#include + +/* + * Please define as 0/1 here if you want to override + */ + +/* + * for Red Hat Enterprise Linux 7.x (and clones like CentOS or SL) + */ +#if defined(RHEL_MAJOR) && (RHEL_MAJOR == 7) +# define HAVE_TRUNCATE_INODE_PAGES_FINAL 1 +#endif + +/* + * defaults + */ + +/* + * defaults dependent to kernel versions + */ +#ifdef LINUX_VERSION_CODE +/* + * linux-3.15 and later kernels have truncate_inode_pages_final() + * and use it in ->evict_inode() implementation. + */ +#ifndef HAVE_TRUNCATE_INODE_PAGES_FINAL +# define HAVE_TRUNCATE_INODE_PAGES_FINAL \ + (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)) +#endif +#endif /* LINUX_VERSION_CODE */ + + +#include + +/* + * definitions dependent to above macros + */ +#if !HAVE_TRUNCATE_INODE_PAGES_FINAL +static inline void truncate_inode_pages_final(struct address_space *mapping) +{ + if (mapping->nrpages) + truncate_inode_pages(mapping, 0); +} +#endif + +#endif /* NILFS_KERN_FEATURE_H */