From ea7a2a00c43002111b9a2277bc7c372d707522f5 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Tue, 25 Jun 2013 12:07:13 -0400 Subject: [PATCH] LU-2987 llite: rcu-free inode Since 2.6.38, inode.i_rcu was added and file system .destroy_inode should rcu-free inodes. Signed-off-by: Peng Tao Signed-off-by: James Simmons Change-Id: Idc12c94fd1bf9c99756c9bcb2d07f3061e6dad5a Reviewed-on: http://review.whamcloud.com/5763 Tested-by: Hudson Reviewed-by: Andreas Dilger Reviewed-by: Keith Mannthey Tested-by: Maloo Reviewed-by: Alexey Shvetsov --- lustre/autoconf/lustre-core.m4 | 21 +++++++++++++++++++++ lustre/llite/super25.c | 18 ++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index a362095..076c3c0 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -1639,6 +1639,26 @@ LB_LINUX_TRY_COMPILE([ ]) # +# 2.6.38 inode.i_rcu added. +# +AC_DEFUN([LC_INODE_I_RCU], +[AC_MSG_CHECKING([if inode.i_rcu exists]) +LB_LINUX_TRY_COMPILE([ + #include +],[ + struct inode ino; + struct rcu_head rcu = {}; + ino.i_rcu = rcu; +],[ + AC_DEFINE(HAVE_INODE_I_RCU, 1, + [inode.i_rcu exists]) + AC_MSG_RESULT([yes]) +],[ + AC_MSG_RESULT([no]) +]) +]) + +# # 2.6.38 export blkdev_get_by_dev # AC_DEFUN([LC_BLKDEV_GET_BY_DEV], @@ -2344,6 +2364,7 @@ AC_DEFUN([LC_PROG_LINUX], LC_GENERIC_PERMISSION LC_QUOTA_ON_USE_PATH LC_DCACHE_LOCK + LC_INODE_I_RCU LC_D_COMPARE_7ARGS LC_D_DELETE_CONST diff --git a/lustre/llite/super25.c b/lustre/llite/super25.c index 6567d07..a0feba9 100644 --- a/lustre/llite/super25.c +++ b/lustre/llite/super25.c @@ -61,11 +61,25 @@ static struct inode *ll_alloc_inode(struct super_block *sb) return &lli->lli_vfs_inode; } +#ifdef HAVE_INODE_I_RCU +static void ll_inode_destroy_callback(struct rcu_head *head) +{ + struct inode *inode = container_of(head, struct inode, i_rcu); + struct ll_inode_info *ptr = ll_i2info(inode); + OBD_SLAB_FREE_PTR(ptr, ll_inode_cachep); +} + +static void ll_destroy_inode(struct inode *inode) +{ + call_rcu(&inode->i_rcu, ll_inode_destroy_callback); +} +#else static void ll_destroy_inode(struct inode *inode) { - struct ll_inode_info *ptr = ll_i2info(inode); - OBD_SLAB_FREE_PTR(ptr, ll_inode_cachep); + struct ll_inode_info *ptr = ll_i2info(inode); + OBD_SLAB_FREE_PTR(ptr, ll_inode_cachep); } +#endif int ll_init_inodecache(void) { -- 1.8.3.1