Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <konishi.ryusuke@lab.ntt.co.jp>
- Loading branch information
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <linux/version.h> | ||
|
||
/* | ||
* 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 <linux/fs.h> | ||
|
||
/* | ||
* 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 */ |