Whamcloud - gitweb
LU-339 use new aops for kernel >= RHEL5.4
authorLai Siyao <laisiyao@whamcloud.com>
Tue, 24 May 2011 02:19:53 +0000 (19:19 -0700)
committerOleg Drokin <green@whamcloud.com>
Thu, 26 May 2011 22:43:45 +0000 (15:43 -0700)
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 <laisiyao@whamcloud.com>
Change-Id: I23bbfcd105c1ffd7f6c942342f9c1fb29a1cffe4
Reviewed-on: http://review.whamcloud.com/592
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Johann Lombardi <johann@whamcloud.com>
lustre/llite/dir.c
lustre/llite/llite_lib.c
lustre/llite/rw26.c

index 6f26358..84e93e4 100644 (file)
@@ -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)
 {
index 3e4c4eb..a67031e 100644 (file)
@@ -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;
index 25ade0e..aba93e5 100644 (file)
@@ -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