4 AC_DEFUN([LDISKFS_LINUX_SERIES], [
5 AC_MSG_CHECKING([which ldiskfs series to use])
6 case x$LDISKFS_SERIES in
9 *.series) # set externally
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" ;;
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/.*= *//')
41 2) LDISKFS_SERIES="3.0-sles11.series"
43 3) LDISKFS_SERIES="3.0-sles11sp3.series"
45 4) LDISKFS_SERIES="3.0-sles11sp4.series"
48 ])],[LDISKFS_SERIES="3.12-sles12.series"],[
49 PLEV=$(grep PATCHLEVEL /etc/SuSE-release | sed -e 's/.*= *//')
51 1) LDISKFS_SERIES="3.12-sles12sp1.series"
53 *) LDISKFS_SERIES="3.12-sles12.series"
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], [],
64 KPLEV=$(echo $LINUXRELEASE | sed -n 's/.*-\([0-9]\+\).*/\1/p')
67 AC_MSG_WARN([Failed to determine Kernel patch level. Assume latest.])
68 LDISKFS_SERIES="4.4.0-73-ubuntu14+16.series"
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"]
76 [LDISKFS_SERIES="4.4.0-73-ubuntu14+16.series"])],
78 KPLEV=$(echo $LINUXRELEASE | sed -n 's/.*-\([0-9]\+\).*/\1/p')
81 AC_MSG_WARN([Failed to determine Kernel patch level. Assume latest.])
82 LDISKFS_SERIES="4.15.0-24-ubuntu18.series"
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"]
88 [LDISKFS_SERIES="4.15.0-24-ubuntu18.series"])
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
98 # LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD
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.
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"
109 ext4_free_blocks(NULL, NULL, NULL, 0, 0, 0);
111 AC_DEFINE(HAVE_EXT_FREE_BLOCK_WITH_BUFFER_HEAD, 1,
112 [ext4_free_blocks do not require struct buffer_head])
114 ]) # LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD
119 # 2.6.35 renamed ext_pblock to ext4_ext_pblock(ex)
121 AC_DEFUN([LB_EXT_PBLOCK], [
122 LB_CHECK_COMPILE([if Linux kernel has 'ext_pblock'],
124 #include <linux/fs.h>
125 #include "$EXT4_SRC_DIR/ext4_extents.h"
129 AC_DEFINE(HAVE_EXT_PBLOCK, 1, [Linux kernel has ext_pblock])
134 # LB_EXT4_JOURNAL_START_3ARGS
136 # 3.9 added a type argument to ext4_journal_start and friends
138 AC_DEFUN([LB_EXT4_JOURNAL_START_3ARGS], [
139 LB_CHECK_COMPILE([if ext4_journal_start takes 3 arguments],
140 ext4_journal_start, [
141 #include <linux/fs.h>
142 #include "$EXT4_SRC_DIR/ext4_jbd2.h"
144 ext4_journal_start(NULL, 0, 0);
146 AC_DEFINE(JOURNAL_START_HAS_3ARGS, 1, [ext4_journal_start takes 3 arguments])
148 ]) # LB_EXT4_JOURNAL_START_3ARGS
151 # LB_LDISKFS_MAP_BLOCKS
153 # Since 2.6.35 brought ext4_map_blocks() for IO.
154 # We just check this function whether existed.
155 # it must be exported by ldiskfs patches.
157 AC_DEFUN([LB_LDISKFS_MAP_BLOCKS], [
158 LB_CHECK_COMPILE([if kernel has ext4_map_blocks],
160 #include <linux/fs.h>
161 #include "$EXT4_SRC_DIR/ext4.h"
163 ext4_map_blocks(NULL, NULL, NULL, 0);
165 AC_DEFINE(HAVE_LDISKFS_MAP_BLOCKS, 1, [kernel has ext4_map_blocks])
170 # LB_EXT4_BREAD_4ARGS
172 # 3.18 ext4_bread has 4 arguments
174 AC_DEFUN([LB_EXT4_BREAD_4ARGS], [
175 LB_CHECK_COMPILE([if ext4_bread takes 4 arguments],
177 #include <linux/fs.h>
178 #include "$EXT4_SRC_DIR/ext4.h"
180 ext4_bread(NULL, NULL, 0, 0);
182 AC_DEFINE(HAVE_EXT4_BREAD_4ARGS, 1, [ext4_bread takes 4 arguments])
184 ]) # LB_EXT4_BREAD_4ARGS
187 # LB_EXT4_HAVE_INFO_DQUOT
189 # in linux 4.4 i_dqout is in ext4_inode_info, not in struct inode
191 AC_DEFUN([LB_EXT4_HAVE_INFO_DQUOT], [
192 LB_CHECK_COMPILE([if i_dquot is in ext4_inode_info],
194 #include <linux/fs.h>
195 #include <linux/quota.h>
196 #include "$EXT4_SRC_DIR/ext4.h"
198 struct ext4_inode_info in;
203 AC_DEFINE(HAVE_EXT4_INFO_DQUOT, 1, [i_dquot is in ext4_inode_info])
205 ]) # LB_EXT4_HAVE_INFO_DQUOT
208 # LB_EXT4_HAVE_I_CRYPT_INFO
210 # in linux 4.8 i_crypt_info moved from ext4_inode_info to struct inode
212 # Determine if we need to enable CONFIG_LDISKFS_FS_ENCRYPTION.
213 # If we have i_crypt_info in ext4_inode_info, the config option
214 # should be enabled to make the ldiskfs module compilation happy.
215 # Otherwise i_crypy_info is in struct inode, we need to check kernel
216 # config option to determine that.
218 AC_DEFUN([LB_EXT4_HAVE_I_CRYPT_INFO], [
219 LB_CHECK_COMPILE([if i_crypt_info is in ext4_inode_info],
221 #define CONFIG_EXT4_FS_ENCRYPTION 1
222 #include <linux/fs.h>
223 #include "$EXT4_SRC_DIR/ext4.h"
225 struct ext4_inode_info in;
227 in.i_crypt_info = NULL;
230 CONFIG_LDISKFS_FS_ENCRYPTION, 1,
231 [enable encryption for ldiskfs]
234 LB_CHECK_CONFIG([EXT4_FS_ENCRYPTION],[
236 CONFIG_LDISKFS_FS_ENCRYPTION, 1,
237 [enable encryption for ldiskfs]
241 ]) # LB_EXT4_HAVE_I_CRYPT_INFO
244 # LB_LDISKFS_IGET_HAS_FLAGS_ARG
246 # kernel 4.19 commit 8a363970d1dc38c4ec4ad575c862f776f468d057
247 # ext4_iget changed to a macro with 3 args was function with 2 args
249 AC_DEFUN([LB_LDISKFS_IGET_HAS_FLAGS_ARG], [
250 tmp_flags="$EXTRA_KCFLAGS"
251 EXTRA_KCFLAGS="-Werror"
252 LB_CHECK_COMPILE([if ldiskfs_iget takes a flags argument],
254 #include <linux/fs.h>
255 #include "$EXT4_SRC_DIR/ext4.h"
257 int f = EXT4_IGET_SPECIAL;
260 AC_DEFINE(HAVE_LDISKFS_IGET_WITH_FLAGS, 1,
261 [if ldiskfs_iget takes a flags argument])
263 EXTRA_KCFLAGS="$tmp_flags"
264 ]) # LB_LDISKFS_IGET_HAS_FLAGS_ARG
267 # LDISKFS_AC_PATCH_PROGRAM
269 # Determine which program should be used to apply the patches to
270 # the ext4 source code to produce the ldiskfs source code.
272 AC_DEFUN([LDISKFS_AC_PATCH_PROGRAM], [
273 AC_ARG_ENABLE([quilt],
274 [AC_HELP_STRING([--disable-quilt],
275 [disable use of quilt for ldiskfs])],
276 [AS_IF([test "x$enableval" = xno],
282 AS_IF([test x$use_quilt = xmaybe], [
283 AC_PATH_PROG([quilt_avail], [quilt], [no])
284 AS_IF([test x$quilt_avail = xno], [
291 AS_IF([test x$use_quilt = xno], [
292 AC_PATH_PROG([patch_avail], [patch], [no])
293 AS_IF([test x$patch_avail = xno], [
294 AC_MSG_ERROR([*** Need "quilt" or "patch" command])
297 ]) # LDISKFS_AC_PATCH_PROGRAM
302 AC_DEFUN([LB_CONFIG_LDISKFS], [
303 # --with-ldiskfs is deprecated now that ldiskfs is fully merged with lustre.
304 # However we continue to support this option through Lustre 2.5.
305 AC_ARG_WITH([ldiskfs],
307 [AC_MSG_WARN([--with-ldiskfs is deprecated, please use --enable-ldiskfs])
308 AS_IF([test x$withval != xyes -a x$withval != xno],
311 The ldiskfs option is deprecated,
312 and no longer supports paths to external ldiskfs source
316 AC_ARG_ENABLE([ldiskfs],
317 [AS_HELP_STRING([--disable-ldiskfs],
318 [disable ldiskfs osd (default is enable)])],
319 [AS_IF([test x$enable_ldiskfs != xyes -a x$enable_ldiskfs != xno],
320 [AC_MSG_ERROR([ldiskfs valid options are "yes" or "no"])])],
321 [AS_IF([test "${with_ldiskfs+set}" = set],
322 [enable_ldiskfs=$with_ldiskfs],
323 [enable_ldiskfs=maybe])
326 AS_IF([test x$enable_server = xno],
327 [AS_CASE([$enable_ldiskfs],
328 [maybe], [enable_ldiskfs=no],
329 [yes], [AC_MSG_ERROR([cannot build ldiskfs when servers are disabled])]
332 AS_IF([test x$enable_ldiskfs != xno],[
333 # In the future, we chould change enable_ldiskfs from maybe to
334 # either yes or no based on additional tests, e.g. whether a patch
335 # set is available for the detected kernel. For now, we just always
337 AS_IF([test x$enable_ldiskfs = xmaybe], [enable_ldiskfs=yes])
338 AC_SUBST(ENABLE_LDISKFS, yes)
341 LDISKFS_AC_PATCH_PROGRAM
342 LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD
344 LB_EXT4_JOURNAL_START_3ARGS
345 LB_LDISKFS_MAP_BLOCKS
347 LB_EXT4_HAVE_INFO_DQUOT
348 LB_EXT4_HAVE_I_CRYPT_INFO
349 LB_LDISKFS_IGET_HAS_FLAGS_ARG
350 AC_DEFINE(CONFIG_LDISKFS_FS_POSIX_ACL, 1, [posix acls for ldiskfs])
351 AC_DEFINE(CONFIG_LDISKFS_FS_SECURITY, 1, [fs security for ldiskfs])
352 AC_DEFINE(CONFIG_LDISKFS_FS_XATTR, 1, [extened attributes for ldiskfs])
353 AC_DEFINE(CONFIG_LDISKFS_FS_RW, 1, [enable rw access for ldiskfs])
354 AC_SUBST(LDISKFS_SUBDIR, ldiskfs)
355 AC_DEFINE(HAVE_LDISKFS_OSD, 1, Enable ldiskfs osd)
357 AC_SUBST(ENABLE_LDISKFS, no)
360 AC_MSG_CHECKING([whether to build ldiskfs])
361 AC_MSG_RESULT([$enable_ldiskfs])
363 AM_CONDITIONAL([LDISKFS_ENABLED], [test x$enable_ldiskfs = xyes])
364 ]) # LB_CONFIG_LDISKFS
367 # LB_VALIDATE_EXT4_SRC_DIR
369 # Spot check the existence of several source files common to ext4.
370 # Detecting this at configure time allows us to avoid a potential build
371 # failure and provide a useful error message to explain what is wrong.
373 AC_DEFUN([LB_VALIDATE_EXT4_SRC_DIR], [
374 enable_ldiskfs_build="no"
375 AS_IF([test -n "$EXT4_SRC_DIR"], [
376 enable_ldiskfs_build="yes"
377 LB_CHECK_FILE([$EXT4_SRC_DIR/dir.c], [], [
378 enable_ldiskfs_build="no"
379 AC_MSG_WARN([ext4 must exist for ldiskfs build])
381 LB_CHECK_FILE([$EXT4_SRC_DIR/file.c], [], [
382 enable_ldiskfs_build="no"
383 AC_MSG_WARN([ext4 must exist for ldiskfs build])
385 LB_CHECK_FILE([$EXT4_SRC_DIR/inode.c], [], [
386 enable_ldiskfs_build="no"
387 AC_MSG_WARN([ext4 must exist for ldiskfs build])
389 LB_CHECK_FILE([$EXT4_SRC_DIR/super.c], [], [
390 enable_ldiskfs_build="no"
391 AC_MSG_WARN([ext4 must exist for ldiskfs build])
395 AS_IF([test "x$enable_ldiskfs_build" = xno], [
400 Disabling ldiskfs support because complete ext4 source does not exist.
402 If you are building using kernel-devel packages and require ldiskfs
403 server support then ensure that the matching kernel-debuginfo-common
404 and kernel-debuginfo-common-<arch> packages are installed.
407 ]) # LB_VALIDATE_EXT4_SRC_DIR
412 # Determine the location of the ext4 source code. It it required
413 # for several configure tests and to build ldiskfs.
415 AC_DEFUN([LB_EXT4_SRC_DIR], [
416 AC_MSG_CHECKING([ext4 source directory])
417 # Kernel ext source located with devel headers
419 AS_IF([test -e "$linux_src/fs/ext4/super.c"], [
420 EXT4_SRC_DIR="$linux_src/fs/ext4"
422 # Kernel ext source provided by kernel-debuginfo-common package
423 # that extracted to $LINUX
424 linux_src=$(ls -1d $linux_src/../../debug/*/linux-${LINUXRELEASE%.*}* \
425 2>/dev/null | tail -1)
426 AS_IF([test -e "$linux_src/fs/ext4/super.c"], [
427 EXT4_SRC_DIR="$linux_src/fs/ext4"
429 # Kernel ext source provided by kernel-debuginfo-common package
430 linux_src=$(ls -1d /usr/src/debug/*/linux-${LINUXRELEASE%.*}* \
431 2>/dev/null | tail -1)
432 AS_IF([test -e "$linux_src/fs/ext4/super.c"], [
433 EXT4_SRC_DIR="$linux_src/fs/ext4"
439 AC_MSG_RESULT([$EXT4_SRC_DIR])
440 AC_SUBST(EXT4_SRC_DIR)
442 LB_VALIDATE_EXT4_SRC_DIR
446 # LB_DEFINE_E2FSPROGS_NAMES
448 # Enable the use of alternate naming of ldiskfs-enabled e2fsprogs package.
450 AC_DEFUN([LB_DEFINE_E2FSPROGS_NAMES], [
451 AC_MSG_CHECKING([whether to use alternate names for e2fsprogs])
452 AC_ARG_WITH([ldiskfsprogs],
453 AC_HELP_STRING([--with-ldiskfsprogs],
454 [use alternate names for ldiskfs-enabled e2fsprogs]),
457 AS_IF([test "x$withval" = xyes], [
458 AC_MSG_RESULT([enabled])
459 AC_DEFINE(HAVE_LDISKFSPROGS, 1, [enable use of ldiskfsprogs package])
460 E2FSPROGS="ldiskfsprogs"
461 MKE2FS="mkfs.ldiskfs"
462 DEBUGFS="debugfs.ldiskfs"
463 TUNE2FS="tunefs.ldiskfs"
464 E2LABEL="label.ldiskfs"
465 DUMPE2FS="dumpfs.ldiskfs"
466 E2FSCK="fsck.ldiskfs"
467 PFSCK="pfsck.ldiskfs"
469 AC_MSG_RESULT([disabled])
470 E2FSPROGS="e2fsprogs"
480 AC_DEFINE_UNQUOTED(E2FSPROGS, "$E2FSPROGS", [name of ldiskfs e2fsprogs package])
481 AC_DEFINE_UNQUOTED(MKE2FS, "$MKE2FS", [name of ldiskfs mkfs program])
482 AC_DEFINE_UNQUOTED(DEBUGFS, "$DEBUGFS", [name of ldiskfs debug program])
483 AC_DEFINE_UNQUOTED(TUNE2FS, "$TUNE2FS", [name of ldiskfs tune program])
484 AC_DEFINE_UNQUOTED(E2LABEL, "$E2LABEL", [name of ldiskfs label program])
485 AC_DEFINE_UNQUOTED(DUMPE2FS,"$DUMPE2FS", [name of ldiskfs dump program])
486 AC_DEFINE_UNQUOTED(E2FSCK, "$E2FSCK", [name of ldiskfs fsck program])
487 AC_DEFINE_UNQUOTED(PFSCK, "$PFSCK", [name of parallel fsck program])
489 AC_SUBST([E2FSPROGS], [$E2FSPROGS])
490 AC_SUBST([MKE2FS], [$MKE2FS])
491 AC_SUBST([DEBUGFS], [$DEBUGFS])
492 AC_SUBST([TUNE2FS], [$TUNE2FS])
493 AC_SUBST([E2LABEL], [$E2LABEL])
494 AC_SUBST([DUMPE2FS], [$DUMPE2FS])
495 AC_SUBST([E2FSCK], [$E2FSCK])
496 AC_SUBST([PFSCK], [$PFSCK])
497 ]) # LB_DEFINE_E2FSPROGS_NAMES