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