From 5467ad53134bf0f064030a3b709ccafb7b8d0b79 Mon Sep 17 00:00:00 2001 From: Liu Xuezhao Date: Tue, 30 Oct 2012 17:14:02 +0800 Subject: [PATCH] LU-1337 llite: kernel 3.4 converts d_alloc_root to d_make_root kernel 3.4 converts d_alloc_root to d_make_root. (kernel commit 32991ab305ace7017c62f8eecbe5eb36dc32e13b) Add LC_HAVE_D_MAKE_ROOT/HAVE_D_MAKE_ROOT to ckeck it. Signed-off-by: Liu Xuezhao Change-Id: I7ff1f0eff25495b655e650997016377ca0a200aa Reviewed-on: http://review.whamcloud.com/3580 Reviewed-by: Andreas Dilger Reviewed-by: Peng Tao Tested-by: Hudson Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/autoconf/lustre-core.m4 | 38 ++++++++++++++++++++++++++-------- lustre/include/linux/lustre_compat25.h | 13 ++++++++++++ lustre/llite/llite_lib.c | 8 ++++++- lustre/obdclass/obd_mount.c | 23 ++++++++++---------- 4 files changed, 60 insertions(+), 22 deletions(-) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index f4ec1c5..5163de2 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -2029,6 +2029,25 @@ LB_LINUX_TRY_COMPILE([ ]) # +# 3.4 converts d_alloc_root to d_make_root +# see kernel commit 32991ab305ace7017c62f8eecbe5eb36dc32e13b +# +AC_DEFUN([LC_HAVE_D_MAKE_ROOT], +[AC_MSG_CHECKING([if have d_make_root]) +LB_LINUX_TRY_COMPILE([ + #include +],[ + d_make_root((struct inode *)NULL); +],[ + AC_DEFINE(HAVE_D_MAKE_ROOT, 1, + [have d_make_root]) + AC_MSG_RESULT([yes]) +],[ + AC_MSG_RESULT([no]) +]) +]) + +# # LC_PROG_LINUX # # Lustre linux kernel checks @@ -2190,15 +2209,16 @@ AC_DEFUN([LC_PROG_LINUX], # 3.4 LC_TOUCH_ATIME_1ARG - - # - if test x$enable_server = xyes ; then - AC_DEFINE(HAVE_SERVER_SUPPORT, 1, [support server]) - LC_FUNC_DEV_SET_RDONLY - LC_STACK_SIZE - LC_QUOTA64 - LC_QUOTA_CONFIG - fi + LC_HAVE_D_MAKE_ROOT + + # + if test x$enable_server = xyes ; then + AC_DEFINE(HAVE_SERVER_SUPPORT, 1, [support server]) + LC_FUNC_DEV_SET_RDONLY + LC_STACK_SIZE + LC_QUOTA64 + LC_QUOTA_CONFIG + fi ]) # diff --git a/lustre/include/linux/lustre_compat25.h b/lustre/include/linux/lustre_compat25.h index df109a8..600fa73 100644 --- a/lustre/include/linux/lustre_compat25.h +++ b/lustre/include/linux/lustre_compat25.h @@ -728,4 +728,17 @@ static inline void set_nlink(struct inode *inode, unsigned int nlink) # define ll_umode_t int #endif +#include +#ifndef HAVE_D_MAKE_ROOT +static inline struct dentry *d_make_root(struct inode *root) +{ + struct dentry *res = d_alloc_root(root); + + if (res == NULL && root) + iput(root); + + return res; +} +#endif + #endif /* _COMPAT25_H */ diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 5813a29..b25c913 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -555,7 +555,13 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, KEY_CACHE_SET, sizeof(sbi->ll_cache), &sbi->ll_cache, NULL); - sb->s_root = d_alloc_root(root); + sb->s_root = d_make_root(root); + if (sb->s_root == NULL) { + CERROR("%s: can't make root dentry\n", + ll_get_fsname(sb, NULL, 0)); + GOTO(out_lock_cn_cb, err = -ENOMEM); + } + #ifdef HAVE_DCACHE_LOCK sb->s_root->d_op = &ll_d_root_ops; #else diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index be886ad..578492e 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -2277,19 +2277,18 @@ static int server_fill_super_common(struct super_block *sb) RETURN(-EIO); } - /* returns -EIO for every operation */ - /* make_bad_inode(root); -- badness - can't umount */ - /* apparently we need to be a directory for the mount to finish */ - root->i_mode = S_IFDIR; - - sb->s_root = d_alloc_root(root); - if (!sb->s_root) { - CERROR("Can't make root dentry\n"); - iput(root); - RETURN(-EIO); - } + /* returns -EIO for every operation */ + /* make_bad_inode(root); -- badness - can't umount */ + /* apparently we need to be a directory for the mount to finish */ + root->i_mode = S_IFDIR; + + sb->s_root = d_make_root(root); + if (!sb->s_root) { + CERROR("%s: can't make root dentry\n", sb->s_id); + RETURN(-EIO); + } - RETURN(0); + RETURN(0); } static int osd_start(struct lustre_sb_info *lsi, unsigned long mflags) -- 1.8.3.1