Whamcloud - gitweb
LU-1337 llite: kernel 3.4 converts d_alloc_root to d_make_root
authorLiu Xuezhao <xuezhao.liu@emc.com>
Tue, 30 Oct 2012 09:14:02 +0000 (17:14 +0800)
committerOleg Drokin <green@whamcloud.com>
Wed, 5 Dec 2012 14:28:24 +0000 (09:28 -0500)
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 <xuezhao.liu@emc.com>
Change-Id: I7ff1f0eff25495b655e650997016377ca0a200aa
Reviewed-on: http://review.whamcloud.com/3580
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Peng Tao <bergwolf@gmail.com>
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/autoconf/lustre-core.m4
lustre/include/linux/lustre_compat25.h
lustre/llite/llite_lib.c
lustre/obdclass/obd_mount.c

index f4ec1c5..5163de2 100644 (file)
@@ -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 <linux/fs.h>
+],[
+       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
 ])
 
 #
index df109a8..600fa73 100644 (file)
@@ -728,4 +728,17 @@ static inline void set_nlink(struct inode *inode, unsigned int nlink)
 # define ll_umode_t    int
 #endif
 
+#include <linux/dcache.h>
+#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 */
index 5813a29..b25c913 100644 (file)
@@ -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
index be886ad..578492e 100644 (file)
@@ -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)