Skip to content

Commit

Permalink
Add kern_feature.h header file
Browse files Browse the repository at this point in the history
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
konis committed Jul 8, 2014
1 parent 136f23b commit da318b1
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions fs/nilfs2/inode.c
Expand Up @@ -26,6 +26,7 @@
#include <linux/mpage.h>
#include <linux/writeback.h>
#include <linux/aio.h>
#include "kern_feature.h"
#include "nilfs.h"
#include "btnode.h"
#include "segment.h"
Expand Down
56 changes: 56 additions & 0 deletions 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 <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 */

0 comments on commit da318b1

Please sign in to comment.