1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
From c9240c44062908b87b9f9af94da5ea5afa0ec46f Mon Sep 17 00:00:00 2001
From: Liu Xuezhao <xuezhao.liu@emc.com>
Date: Mon, 16 Jul 2012 17:05:04 +0800
Subject: [PATCH 10/13] LU-1337 vfs: 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 <xuezhao.liu@emc.com>
Change-Id: I7ff1f0eff25495b655e650997016377ca0a200aa
---
lustre/autoconf/lustre-core.m4 | 20 ++++++++++++++++++++
lustre/include/linux/lustre_compat25.h | 14 ++++++++++++++
lustre/llite/llite_lib.c | 7 ++++++-
lustre/obdclass/obd_mount.c | 13 ++++++-------
4 files changed, 46 insertions(+), 8 deletions(-)
diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4
index 9ff79f4..e563921 100644
--- a/lustre/autoconf/lustre-core.m4
+++ b/lustre/autoconf/lustre-core.m4
@@ -2012,6 +2012,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
@@ -2172,6 +2191,7 @@ AC_DEFUN([LC_PROG_LINUX],
# 3.4
LC_TOUCH_ATIME_1ARG
+ LC_HAVE_D_MAKE_ROOT
#
if test x$enable_server = xyes ; then
diff --git a/lustre/include/linux/lustre_compat25.h b/lustre/include/linux/lustre_compat25.h
index 87f611b..321892a 100644
--- a/lustre/include/linux/lustre_compat25.h
+++ b/lustre/include/linux/lustre_compat25.h
@@ -803,5 +803,19 @@ 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_inode)
+{
+ struct dentry *res;
+
+ res = d_alloc_root(root_inode);
+ if (res == NULL)
+ iput(root_inode);
+
+ return res;
+}
+#endif
+
#endif /* __KERNEL__ */
#endif /* _COMPAT25_H */
diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c
index ab3fe64..1db4903 100644
--- a/lustre/llite/llite_lib.c
+++ b/lustre/llite/llite_lib.c
@@ -543,7 +543,12 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
NULL);
cl_sb_init(sb);
- sb->s_root = d_alloc_root(root);
+ sb->s_root = d_make_root(root);
+ if (sb->s_root == NULL) {
+ CERROR("Can't make root dentry\n");
+ 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 4c82860..7277709 100644
--- a/lustre/obdclass/obd_mount.c
+++ b/lustre/obdclass/obd_mount.c
@@ -2276,14 +2276,13 @@ static int server_fill_super_common(struct super_block *sb)
/* 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);
- }
+ sb->s_root = d_make_root(root);
+ if (!sb->s_root) {
+ CERROR("Can't make root dentry\n");
+ RETURN(-EIO);
+ }
- RETURN(0);
+ RETURN(0);
}
static int osd_start(struct lustre_sb_info *lsi, unsigned long mflags)
--
1.7.12
|