From 0c9d8d75ad60e4f93f884bc18d3021a0f37599c6 Mon Sep 17 00:00:00 2001 From: Lai Siyao Date: Mon, 23 May 2011 19:19:53 -0700 Subject: [PATCH] LU-339 use new aops for kernel >= RHEL5.4 Kernel in RHEL5 >= 5.4 supports both old and new aops interface, and a flag MS_HAS_NEW_AOPS is used to mark whether a filesystem supports new aops. Lustre has implemented the new aops, but not enabled. And with new aops a single thread I/O can gain 5% perf increase. Signed-off-by: Lai Siyao Change-Id: I23bbfcd105c1ffd7f6c942342f9c1fb29a1cffe4 Reviewed-on: http://review.whamcloud.com/592 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Oleg Drokin Reviewed-by: Johann Lombardi --- lustre/llite/dir.c | 6 ++++++ lustre/llite/llite_lib.c | 12 ++++++++++-- lustre/llite/rw26.c | 24 +++++++++++++++++++++++- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index 6f26358..84e93e4 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -193,9 +193,15 @@ static int ll_dir_readpage(struct file *file, struct page *page) return rc; } +#ifndef MS_HAS_NEW_AOPS struct address_space_operations ll_dir_aops = { .readpage = ll_dir_readpage, }; +#else +struct address_space_operations_ext ll_dir_aops = { + .orig_aops.readpage = ll_dir_readpage, +}; +#endif static void ll_check_page(struct inode *dir, struct page *page) { diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 3e4c4eb..a67031e 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -61,8 +61,13 @@ cfs_mem_cache_t *ll_file_data_slab; CFS_LIST_HEAD(ll_super_blocks); cfs_spinlock_t ll_sb_lock = CFS_SPIN_LOCK_UNLOCKED; +#ifndef MS_HAS_NEW_AOPS extern struct address_space_operations ll_aops; extern struct address_space_operations ll_dir_aops; +#else +extern struct address_space_operations_ext ll_aops; +extern struct address_space_operations_ext ll_dir_aops; +#endif #ifndef log2 #define log2(n) cfs_ffz(~(n)) @@ -221,6 +226,9 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt) /* force vfs to use lustre handler for flock() calls - bug 10743 */ sb->s_flags |= MS_FLOCK_LOCK; #endif +#ifdef MS_HAS_NEW_AOPS + sb->s_flags |= MS_HAS_NEW_AOPS; +#endif if (sbi->ll_flags & LL_SBI_FLOCK) sbi->ll_fop = &ll_file_operations_flock; @@ -1688,12 +1696,12 @@ void ll_read_inode2(struct inode *inode, void *opaque) struct ll_sb_info *sbi = ll_i2sbi(inode); inode->i_op = &ll_file_inode_operations; inode->i_fop = sbi->ll_fop; - inode->i_mapping->a_ops = &ll_aops; + inode->i_mapping->a_ops = (struct address_space_operations *)&ll_aops; EXIT; } else if (S_ISDIR(inode->i_mode)) { inode->i_op = &ll_dir_inode_operations; inode->i_fop = &ll_dir_operations; - inode->i_mapping->a_ops = &ll_dir_aops; + inode->i_mapping->a_ops = (struct address_space_operations *)&ll_dir_aops; EXIT; } else if (S_ISLNK(inode->i_mode)) { inode->i_op = &ll_fast_symlink_inode_operations; diff --git a/lustre/llite/rw26.c b/lustre/llite/rw26.c index 25ade0e..aba93e5 100644 --- a/lustre/llite/rw26.c +++ b/lustre/llite/rw26.c @@ -472,7 +472,7 @@ out: RETURN(tot_bytes ? : result); } -#ifdef HAVE_KERNEL_WRITE_BEGIN_END +#if defined(HAVE_KERNEL_WRITE_BEGIN_END) || defined(MS_HAS_NEW_AOPS) static int ll_write_begin(struct file *file, struct address_space *mapping, loff_t pos, unsigned len, unsigned flags, struct page **pagep, void **fsdata) @@ -520,6 +520,7 @@ int ll_migratepage(struct address_space *mapping, } #endif +#ifndef MS_HAS_NEW_AOPS struct address_space_operations ll_aops = { .readpage = ll_readpage, // .readpages = ll_readpages, @@ -542,3 +543,24 @@ struct address_space_operations ll_aops = { #endif .bmap = NULL }; +#else +struct address_space_operations_ext ll_aops = { + .orig_aops.readpage = ll_readpage, +// .orig_aops.readpages = ll_readpages, + .orig_aops.direct_IO = ll_direct_IO_26, + .orig_aops.writepage = ll_writepage, + .orig_aops.writepages = generic_writepages, + .orig_aops.set_page_dirty = ll_set_page_dirty, + .orig_aops.sync_page = NULL, + .orig_aops.prepare_write = ll_prepare_write, + .orig_aops.commit_write = ll_commit_write, + .orig_aops.invalidatepage = ll_invalidatepage, + .orig_aops.releasepage = ll_releasepage, +#ifdef CONFIG_MIGRATION + .orig_aops.migratepage = ll_migratepage, +#endif + .orig_aops.bmap = NULL, + .write_begin = ll_write_begin, + .write_end = ll_write_end +}; +#endif -- 1.8.3.1