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