Whamcloud - gitweb
LU-5568 lnet: fix kernel crash when network failed to start
[fs/lustre-release.git] / config / lustre-build-ldiskfs.m4
1 #
2 # LDISKFS_LINUX_SERIES
3 #
4 AC_DEFUN([LDISKFS_LINUX_SERIES], [
5 LDISKFS_SERIES=
6 AC_MSG_CHECKING([which ldiskfs series to use])
7 AS_IF([test x$RHEL_KERNEL = xyes], [
8         case $RHEL_RELEASE_NO in
9         70)     LDISKFS_SERIES="3.10-rhel7.series"      ;;
10         66)     LDISKFS_SERIES="2.6-rhel6.6.series"     ;;
11         65)     LDISKFS_SERIES="2.6-rhel6.5.series"     ;;
12         64)     LDISKFS_SERIES="2.6-rhel6.4.series"     ;;
13         6[0-3]) LDISKFS_SERIES="2.6-rhel6.series"       ;;
14         esac
15 ], [test x$SUSE_KERNEL = xyes], [
16         AS_VERSION_COMPARE([$LINUXRELEASE],[3.0.0],[
17         AS_VERSION_COMPARE([$LINUXRELEASE],[2.6.32], [],
18         [LDISKFS_SERIES="2.6-sles11.series"],[LDISKFS_SERIES="2.6-sles11.series"])],
19         [LDISKFS_SERIES="3.0-sles11.series"],[
20                 PLEV=$(grep PATCHLEVEL /etc/SuSE-release | sed -e 's/.*= *//')
21                 case $PLEV in
22                 2) LDISKFS_SERIES="3.0-sles11.series"
23                         ;;
24                 3) LDISKFS_SERIES="3.0-sles11sp3.series"
25                         ;;
26                 esac
27         ])
28 ])
29 AS_IF([test -z "$LDISKFS_SERIES"],
30         [AC_MSG_WARN([Unknown kernel version $LDISKFS_VERSIONRELEASE])])
31 AC_MSG_RESULT([$LDISKFS_SERIES])
32 AC_SUBST(LDISKFS_SERIES)
33 ]) # LDISKFS_LINUX_SERIES
34
35 #
36 # LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD
37 #
38 # 2.6.32-rc7 ext4_free_blocks requires struct buffer_head
39 # Note that RHEL6 is pre 2.6.32-rc7 so this check is still needed.
40 #
41 AC_DEFUN([LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD], [
42 LB_CHECK_COMPILE([if 'ext4_free_blocks' needs 'struct buffer_head'],
43 ext4_free_blocks_with_buffer_head, [
44         #include <linux/fs.h>
45         #include "$EXT4_SRC_DIR/ext4.h"
46 ],[
47         ext4_free_blocks(NULL, NULL, NULL, 0, 0, 0);
48 ],[
49         AC_DEFINE(HAVE_EXT_FREE_BLOCK_WITH_BUFFER_HEAD, 1,
50                 [ext4_free_blocks do not require struct buffer_head])
51 ])
52 ]) # LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD
53
54 #
55 # LB_EXT_PBLOCK
56 #
57 # 2.6.35 renamed ext_pblock to ext4_ext_pblock(ex)
58 #
59 AC_DEFUN([LB_EXT_PBLOCK], [
60 LB_CHECK_COMPILE([if Linux kernel has 'ext_pblock'],
61 ext_pblock, [
62         #include <linux/fs.h>
63         #include "$EXT4_SRC_DIR/ext4_extents.h"
64 ],[
65         ext_pblock(NULL);
66 ],[
67         AC_DEFINE(HAVE_EXT_PBLOCK, 1, [Linux kernel has ext_pblock])
68 ])
69 ]) # LB_EXT_PBLOCK
70
71 #
72 # LB_EXT4_JOURNAL_START_3ARGS
73 #
74 # 3.9 added a type argument to ext4_journal_start and friends
75 #
76 AC_DEFUN([LB_EXT4_JOURNAL_START_3ARGS], [
77 LB_CHECK_COMPILE([if ext4_journal_start takes 3 arguments],
78 ext4_journal_start, [
79         #include <linux/fs.h>
80         #include "$EXT4_SRC_DIR/ext4_jbd2.h"
81 ],[
82         ext4_journal_start(NULL, 0, 0);
83 ],[
84         AC_DEFINE(JOURNAL_START_HAS_3ARGS, 1, [ext4_journal_start takes 3 arguments])
85 ])
86 ]) # LB_EXT4_JOURNAL_START_3ARGS
87
88 #
89 # LB_LDISKFS_MAP_BLOCKS
90 #
91 # Since 2.6.35 brought ext4_map_blocks() for IO.
92 # We just check this function whether existed.
93 # it must be exported by ldiskfs patches.
94 #
95 AC_DEFUN([LB_LDISKFS_MAP_BLOCKS], [
96 LB_CHECK_COMPILE([if kernel has ext4_map_blocks],
97 ext4_map_blocks, [
98         #include <linux/fs.h>
99         #include "$EXT4_SRC_DIR/ext4.h"
100 ],[
101         ext4_map_blocks(NULL, NULL, NULL, 0);
102 ],[
103         AC_DEFINE(HAVE_LDISKFS_MAP_BLOCKS, 1, [kernel has ext4_map_blocks])
104 ])
105 ])
106
107 #
108 # LDISKFS_AC_PATCH_PROGRAM
109 #
110 # Determine which program should be used to apply the patches to
111 # the ext4 source code to produce the ldiskfs source code.
112 #
113 AC_DEFUN([LDISKFS_AC_PATCH_PROGRAM], [
114         AC_ARG_ENABLE([quilt],
115                 [AC_HELP_STRING([--disable-quilt],
116                         [disable use of quilt for ldiskfs])],
117                 [AS_IF([test "x$enableval" = xno],
118                         [use_quilt=no],
119                         [use_quilt=maybe])],
120                 [use_quilt=maybe]
121         )
122
123         AS_IF([test x$use_quilt = xmaybe], [
124                 AC_PATH_PROG([quilt_avail], [quilt], [no])
125                 AS_IF([test x$quilt_avail = xno], [
126                         use_quilt=no
127                 ], [
128                         use_quilt=yes
129                 ])
130         ])
131
132         AS_IF([test x$use_quilt = xno], [
133                 AC_PATH_PROG([patch_avail], [patch], [no])
134                 AS_IF([test x$patch_avail = xno], [
135                         AC_MSG_ERROR([*** Need "quilt" or "patch" command])
136                 ])
137         ])
138 ]) # LDISKFS_AC_PATCH_PROGRAM
139
140 #
141 # LB_CONFIG_LDISKFS
142 #
143 AC_DEFUN([LB_CONFIG_LDISKFS], [
144 # --with-ldiskfs is deprecated now that ldiskfs is fully merged with lustre.
145 # However we continue to support this option through Lustre 2.5.
146 AC_ARG_WITH([ldiskfs],
147         [],
148         [AC_MSG_WARN([--with-ldiskfs is deprecated, please use --enable-ldiskfs])
149         AS_IF([test x$withval != xyes -a x$withval != xno],
150                 [AC_MSG_ERROR([
151
152 The ldiskfs option is deprecated,
153 and no longer supports paths to external ldiskfs source
154 ])])
155 ])
156
157 AC_ARG_ENABLE([ldiskfs],
158         [AS_HELP_STRING([--disable-ldiskfs],
159                 [disable ldiskfs osd (default is enable)])],
160         [AS_IF([test x$enable_ldiskfs != xyes -a x$enable_ldiskfs != xno],
161                 [AC_MSG_ERROR([ldiskfs valid options are "yes" or "no"])])],
162         [AS_IF([test "${with_ldiskfs+set}" = set],
163                 [enable_ldiskfs=$with_ldiskfs],
164                 [enable_ldiskfs=maybe])
165 ])
166
167 AS_IF([test x$enable_server = xno],
168         [AS_CASE([$enable_ldiskfs],
169                 [maybe], [enable_ldiskfs=no],
170                 [yes], [AC_MSG_ERROR([cannot build ldiskfs when servers are disabled])]
171         )])
172
173 AS_IF([test x$enable_ldiskfs != xno],[
174         # In the future, we chould change enable_ldiskfs from maybe to
175         # either yes or no based on additional tests, e.g.  whether a patch
176         # set is available for the detected kernel.  For now, we just always
177         # set it to "yes".
178         AS_IF([test x$enable_ldiskfs = xmaybe], [enable_ldiskfs=yes])
179
180         LDISKFS_LINUX_SERIES
181         LDISKFS_AC_PATCH_PROGRAM
182         LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD
183         LB_EXT_PBLOCK
184         LB_EXT4_JOURNAL_START_3ARGS
185         LB_LDISKFS_MAP_BLOCKS
186         AC_DEFINE(CONFIG_LDISKFS_FS_POSIX_ACL, 1, [posix acls for ldiskfs])
187         AC_DEFINE(CONFIG_LDISKFS_FS_SECURITY, 1, [fs security for ldiskfs])
188         AC_DEFINE(CONFIG_LDISKFS_FS_XATTR, 1, [extened attributes for ldiskfs])
189         AC_DEFINE(CONFIG_LDISKFS_FS_RW, 1, [enable rw access for ldiskfs])
190         AC_SUBST(LDISKFS_SUBDIR, ldiskfs)
191         AC_DEFINE(HAVE_LDISKFS_OSD, 1, Enable ldiskfs osd)
192 ])
193
194 AC_MSG_CHECKING([whether to build ldiskfs])
195 AC_MSG_RESULT([$enable_ldiskfs])
196
197 AM_CONDITIONAL([LDISKFS_ENABLED], [test x$enable_ldiskfs = xyes])
198 ]) # LB_CONFIG_LDISKFS
199
200 #
201 # LB_VALIDATE_EXT4_SRC_DIR
202 #
203 # Spot check the existance of several source files common to ext4.
204 # Detecting this at configure time allows us to avoid a potential build
205 # failure and provide a useful error message to explain what is wrong.
206 #
207 AC_DEFUN([LB_VALIDATE_EXT4_SRC_DIR], [
208 enable_ldiskfs_build="no"
209 AS_IF([test -n "$EXT4_SRC_DIR"], [
210         enable_ldiskfs_build="yes"
211         LB_CHECK_FILE([$EXT4_SRC_DIR/dir.c], [], [
212                 enable_ldiskfs_build="no"
213                 AC_MSG_WARN([ext4 must exist for ldiskfs build])
214         ])
215         LB_CHECK_FILE([$EXT4_SRC_DIR/file.c], [], [
216                 enable_ldiskfs_build="no"
217                 AC_MSG_WARN([ext4 must exist for ldiskfs build])
218         ])
219         LB_CHECK_FILE([$EXT4_SRC_DIR/inode.c], [], [
220                 enable_ldiskfs_build="no"
221                 AC_MSG_WARN([ext4 must exist for ldiskfs build])
222         ])
223         LB_CHECK_FILE([$EXT4_SRC_DIR/super.c], [], [
224                 enable_ldiskfs_build="no"
225                 AC_MSG_WARN([ext4 must exist for ldiskfs build])
226         ])
227 ])
228
229 AS_IF([test "x$enable_ldiskfs_build" = xno], [
230         enable_ldiskfs="no"
231
232         AC_MSG_WARN([
233
234 Disabling ldiskfs support because complete ext4 source does not exist.
235
236 If you are building using kernel-devel packages and require ldiskfs
237 server support then ensure that the matching kernel-debuginfo-common
238 and kernel-debuginfo-common-<arch> packages are installed.
239 ])
240 ])
241 ]) # LB_VALIDATE_EXT4_SRC_DIR
242
243 #
244 # LB_EXT4_SRC_DIR
245 #
246 # Determine the location of the ext4 source code.  It it required
247 # for several configure tests and to build ldiskfs.
248 #
249 AC_DEFUN([LB_EXT4_SRC_DIR], [
250 AC_MSG_CHECKING([ext4 source directory])
251 # Kernel ext source located with devel headers
252 linux_src=$LINUX
253 AS_IF([test -e "$linux_src/fs/ext4/super.c"], [
254         EXT4_SRC_DIR="$linux_src/fs/ext4"
255 ], [
256         # Kernel ext source provided by kernel-debuginfo-common package
257         linux_src=$(ls -1d /usr/src/debug/*/linux-$LINUXRELEASE \
258                 2>/dev/null | tail -1)
259         AS_IF([test -e "$linux_src/fs/ext4/super.c"],
260                 [EXT4_SRC_DIR="$linux_src/fs/ext4"],
261                 [EXT4_SRC_DIR=""])
262 ])
263 AC_MSG_RESULT([$EXT4_SRC_DIR])
264 AC_SUBST(EXT4_SRC_DIR)
265
266 LB_VALIDATE_EXT4_SRC_DIR
267 ]) # LB_EXT4_SRC_DIR
268
269 #
270 # LB_DEFINE_E2FSPROGS_NAMES
271 #
272 # Enable the use of alternate naming of ldiskfs-enabled e2fsprogs package.
273 #
274 AC_DEFUN([LB_DEFINE_E2FSPROGS_NAMES], [
275 AC_MSG_CHECKING([whether to use alternate names for e2fsprogs])
276 AC_ARG_WITH([ldiskfsprogs],
277         AC_HELP_STRING([--with-ldiskfsprogs],
278                 [use alternate names for ldiskfs-enabled e2fsprogs]),
279         [], [withval="no"])
280
281 AS_IF([test "x$withval" = xyes], [
282         AC_MSG_RESULT([enabled])
283         AC_DEFINE(HAVE_LDISKFSPROGS, 1, [enable use of ldiskfsprogs package])
284         E2FSPROGS="ldiskfsprogs"
285         MKE2FS="mkfs.ldiskfs"
286         DEBUGFS="debugfs.ldiskfs"
287         TUNE2FS="tunefs.ldiskfs"
288         E2LABEL="label.ldiskfs"
289         DUMPE2FS="dumpfs.ldiskfs"
290         E2FSCK="fsck.ldiskfs"
291         PFSCK="pfsck.ldiskfs"
292 ], [
293         AC_MSG_RESULT([disabled])
294         E2FSPROGS="e2fsprogs"
295         MKE2FS="mke2fs"
296         DEBUGFS="debugfs"
297         TUNE2FS="tune2fs"
298         E2LABEL="e2label"
299         DUMPE2FS="dumpe2fs"
300         E2FSCK="e2fsck"
301         PFSCK="fsck"
302 ])
303
304 AC_DEFINE_UNQUOTED(E2FSPROGS, "$E2FSPROGS", [name of ldiskfs e2fsprogs package])
305 AC_DEFINE_UNQUOTED(MKE2FS, "$MKE2FS", [name of ldiskfs mkfs program])
306 AC_DEFINE_UNQUOTED(DEBUGFS, "$DEBUGFS", [name of ldiskfs debug program])
307 AC_DEFINE_UNQUOTED(TUNE2FS, "$TUNE2FS", [name of ldiskfs tune program])
308 AC_DEFINE_UNQUOTED(E2LABEL, "$E2LABEL", [name of ldiskfs label program])
309 AC_DEFINE_UNQUOTED(DUMPE2FS,"$DUMPE2FS", [name of ldiskfs dump program])
310 AC_DEFINE_UNQUOTED(E2FSCK, "$E2FSCK", [name of ldiskfs fsck program])
311 AC_DEFINE_UNQUOTED(PFSCK, "$PFSCK", [name of parallel fsck program])
312
313 AC_SUBST([E2FSPROGS], [$E2FSPROGS])
314 AC_SUBST([MKE2FS], [$MKE2FS])
315 AC_SUBST([DEBUGFS], [$DEBUGFS])
316 AC_SUBST([TUNE2FS], [$TUNE2FS])
317 AC_SUBST([E2LABEL], [$E2LABEL])
318 AC_SUBST([DUMPE2FS], [$DUMPE2FS])
319 AC_SUBST([E2FSCK], [$E2FSCK])
320 AC_SUBST([PFSCK], [$PFSCK])
321 ]) # LB_DEFINE_E2FSPROGS_NAMES