From e9f1f5348685c5a19e21027b14e745266f256e1b Mon Sep 17 00:00:00 2001 From: Lai Siyao Date: Wed, 18 May 2011 20:25:20 -0700 Subject: [PATCH] LU-339 use new aops for kernel >= RHEL5.4 for RHEL5 kernel, from >= 5.4 both old and new aops interface are supported, and a flag MS_HAS_NEW_AOPS is used to mark wheather a filesystem supports it. Enable it for lustre by default, and this will increase single thread IO perf > 5% due to kernel implementation. Signed-off-by: Lai Siyao Change-Id: I8f0bfb1c4eea39275cb22c52e30310dcad41db14 Reviewed-on: http://review.whamcloud.com/570 Tested-by: Hudson Reviewed-by: Johann Lombardi Reviewed-by: Yang Sheng --- lustre/llite/dir.c | 6 ++++++ lustre/llite/llite_lib.c | 12 ++++++++++-- lustre/llite/rw26.c | 23 +++++++++++++++++++++-- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index 0f32502..576f880 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -106,9 +106,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 inline unsigned ll_dir_page_mask(struct inode *inode) { diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 7a47ce1..393eef4 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -60,8 +60,13 @@ cfs_mem_cache_t *ll_file_data_slab; LIST_HEAD(ll_super_blocks); struct rw_semaphore ll_sb_sem; +#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) ffz(~(n)) @@ -303,6 +308,9 @@ static int client_common_fill_super(struct super_block *sb, /* 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; @@ -2047,12 +2055,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 baf6ade..589dfa9 100644 --- a/lustre/llite/rw26.c +++ b/lustre/llite/rw26.c @@ -369,7 +369,7 @@ static ssize_t ll_direct_IO_26(int rw, struct kiocb *kiocb, return ll_direct_IO(rw, kiocb->ki_filp, iov, file_offset, nr_segs, 1); } -#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) @@ -385,7 +385,7 @@ static int ll_write_begin(struct file *file, struct address_space *mapping, RETURN(-ENOMEM); *pagep = page; - + rc = ll_prepare_write(file, page, from, from + len); if (rc) { unlock_page(page); @@ -408,6 +408,7 @@ static int ll_write_end(struct file *file, struct address_space *mapping, } #endif +#ifndef MS_HAS_NEW_AOPS struct address_space_operations ll_aops = { .readpage = ll_readpage, // .readpages = ll_readpages, @@ -427,3 +428,21 @@ struct address_space_operations ll_aops = { .releasepage = ll_releasepage, .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_26, + .orig_aops.writepages = generic_writepages, + .orig_aops.set_page_dirty = __set_page_dirty_nobuffers, + .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, + .orig_aops.bmap = NULL, + .write_begin = ll_write_begin, + .write_end = ll_write_end +}; +#endif -- 1.8.3.1