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