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 81) LDISKFS_SERIES="4.18-rhel8.1.series" ;;
17 80) LDISKFS_SERIES="4.18-rhel8.series" ;;
18 78) LDISKFS_SERIES="3.10-rhel7.8.series" ;;
19 77) LDISKFS_SERIES="3.10-rhel7.7.series" ;;
20 76) LDISKFS_SERIES="3.10-rhel7.6.series" ;;
22 ], [test x$SUSE_KERNEL = xyes], [
23 AS_VERSION_COMPARE([$LINUXRELEASE],[5.3.18],[
24 AS_VERSION_COMPARE([$LINUXRELEASE],[4.12.14],[
25 AS_VERSION_COMPARE([$LINUXRELEASE],[4.4.82],[
26 AS_VERSION_COMPARE([$LINUXRELEASE],[4.4.0],[
27 AS_VERSION_COMPARE([$LINUXRELEASE],[3.12.0],[],
28 [LDISKFS_SERIES="3.12-sles12.series"],[
29 PLEV=$(grep PATCHLEVEL /etc/SuSE-release | sed -e 's/.*= *//')
31 1) LDISKFS_SERIES="3.12-sles12sp1.series"
33 *) LDISKFS_SERIES="3.12-sles12.series"
36 ])],[LDISKFS_SERIES="4.4-sles12sp2.series"],
37 [LDISKFS_SERIES="4.4-sles12sp2.series"]
38 )], [LDISKFS_SERIES="4.4-sles12sp3.series"],
39 [LDISKFS_SERIES="4.4-sles12sp3.series"]
40 )], [LDISKFS_SERIES="4.12-sles15.series"],
41 [LDISKFS_SERIES="4.12-sles15.series"]
42 )], [LDISKFS_SERIES="5.4.0-ml.series"],
43 [LDISKFS_SERIES="5.4.0-ml.series"])
44 ], [test x$UBUNTU_KERNEL = xyes], [
45 AS_VERSION_COMPARE([$LINUXRELEASE],[5.3.0],[
46 AS_VERSION_COMPARE([$LINUXRELEASE],[5.0.0],[
47 AS_VERSION_COMPARE([$LINUXRELEASE],[4.15.0],[
48 AS_VERSION_COMPARE([$LINUXRELEASE],[4.4.0], [],
50 KPLEV=$(echo $LINUXRELEASE | sed -n 's/.*-\([0-9]\+\).*/\1/p')
53 AC_MSG_WARN([Failed to determine Kernel patch level. Assume latest.])
54 LDISKFS_SERIES="4.4.0-73-ubuntu14+16.series"
56 [test $KPLEV -ge 73], [LDISKFS_SERIES="4.4.0-73-ubuntu14+16.series"],
57 [test $KPLEV -ge 62], [LDISKFS_SERIES="4.4.0-62-ubuntu14+16.series"],
58 [test $KPLEV -ge 49], [LDISKFS_SERIES="4.4.0-49-ubuntu14+16.series"],
59 [LDISKFS_SERIES="4.4.0-45-ubuntu14+16.series"]
62 [LDISKFS_SERIES="4.4.0-73-ubuntu14+16.series"])],
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.15.0-24-ubuntu18.series"
70 [test $KPLEV -ge 24], [LDISKFS_SERIES="4.15.0-24-ubuntu18.series"],
71 [test $KPLEV -ge 20], [LDISKFS_SERIES="4.15.0-20-ubuntu18.series"]
74 [LDISKFS_SERIES="4.15.0-24-ubuntu18.series"])],
75 [LDISKFS_SERIES="5.0.0-13-ubuntu19.series"],
76 [LDISKFS_SERIES="5.0.0-13-ubuntu19.series"])],
77 [LDISKFS_SERIES="5.4.0-ml.series"],
78 [LDISKFS_SERIES="5.4.0-ml.series"])
81 # Not RHEL/SLES or Ubuntu .. probably mainline
82 AS_IF([test -z "$LDISKFS_SERIES"],
84 AS_VERSION_COMPARE([$LINUXRELEASE],[5.4.0],[],
85 [LDISKFS_SERIES="5.4.0-ml.series"],[
86 AS_VERSION_COMPARE([$LINUXRELEASE],[5.4.0],
87 [LDISKFS_SERIES="5.4.0-ml.series"], # lt
88 [LDISKFS_SERIES="5.4.0-ml.series"], # eq
89 [LDISKFS_SERIES="5.4.0-ml.series"] # gt
93 AS_IF([test -z "$LDISKFS_SERIES"],
94 [AC_MSG_RESULT([failed to identify series])],
95 [AC_MSG_RESULT([$LDISKFS_SERIES for $LINUXRELEASE])])
96 AC_SUBST(LDISKFS_SERIES)
97 ]) # LDISKFS_LINUX_SERIES
100 # LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD
102 # 2.6.32-rc7 ext4_free_blocks requires struct buffer_head
103 # Note that RHEL6 is pre 2.6.32-rc7 so this check is still needed.
105 AC_DEFUN([LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD], [
106 LB_CHECK_COMPILE([if 'ext4_free_blocks' needs 'struct buffer_head'],
107 ext4_free_blocks_with_buffer_head, [
108 #include <linux/fs.h>
109 #include "$EXT4_SRC_DIR/ext4.h"
111 ext4_free_blocks(NULL, NULL, NULL, 0, 0, 0);
113 AC_DEFINE(HAVE_EXT_FREE_BLOCK_WITH_BUFFER_HEAD, 1,
114 [ext4_free_blocks do not require struct buffer_head])
116 ]) # LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD
119 # LB_EXT4_JOURNAL_START_3ARGS
121 # 3.9 added a type argument to ext4_journal_start and friends
123 AC_DEFUN([LB_EXT4_JOURNAL_START_3ARGS], [
124 LB_CHECK_COMPILE([if ext4_journal_start takes 3 arguments],
125 ext4_journal_start, [
126 #include <linux/fs.h>
127 #include "$EXT4_SRC_DIR/ext4_jbd2.h"
129 ext4_journal_start(NULL, 0, 0);
131 AC_DEFINE(JOURNAL_START_HAS_3ARGS, 1, [ext4_journal_start takes 3 arguments])
133 ]) # LB_EXT4_JOURNAL_START_3ARGS
136 # LB_EXT4_BREAD_4ARGS
138 # 3.18 ext4_bread has 4 arguments
139 # NOTE: It may not be exported for modules, use a positive compiler test here.
141 AC_DEFUN([LB_EXT4_BREAD_4ARGS], [
142 LB_CHECK_COMPILE([if ext4_bread takes 4 arguments],
144 #include <linux/fs.h>
145 #include "$EXT4_SRC_DIR/ext4.h"
147 struct buffer_head *ext4_bread(handle_t *handle, struct inode *inode,
148 ext4_lblk_t block, int map_flags)
150 struct buffer_head *bh = NULL;
158 ext4_bread(NULL, NULL, 0, 0);
160 AC_DEFINE(HAVE_EXT4_BREAD_4ARGS, 1, [ext4_bread takes 4 arguments])
162 ]) # LB_EXT4_BREAD_4ARGS
165 # LB_EXT4_HAVE_INFO_DQUOT
167 # in linux 4.4 i_dqout is in ext4_inode_info, not in struct inode
169 AC_DEFUN([LB_EXT4_HAVE_INFO_DQUOT], [
170 LB_CHECK_COMPILE([if i_dquot is in ext4_inode_info],
172 #include <linux/fs.h>
173 #include <linux/quota.h>
174 #include "$EXT4_SRC_DIR/ext4.h"
176 struct ext4_inode_info in;
181 AC_DEFINE(HAVE_EXT4_INFO_DQUOT, 1, [i_dquot is in ext4_inode_info])
183 ]) # LB_EXT4_HAVE_INFO_DQUOT
186 # LB_EXT4_HAVE_I_CRYPT_INFO
188 # in linux 4.8 i_crypt_info moved from ext4_inode_info to struct inode
190 # Determine if we need to enable CONFIG_LDISKFS_FS_ENCRYPTION.
191 # If we have i_crypt_info in ext4_inode_info, the config option
192 # should be enabled to make the ldiskfs module compilation happy.
193 # Otherwise i_crypy_info is in struct inode, we need to check kernel
194 # config option to determine that.
196 AC_DEFUN([LB_EXT4_HAVE_I_CRYPT_INFO], [
197 LB_CHECK_COMPILE([if i_crypt_info is in ext4_inode_info],
199 #define CONFIG_EXT4_FS_ENCRYPTION 1
200 #include <linux/fs.h>
201 #include "$EXT4_SRC_DIR/ext4.h"
203 struct ext4_inode_info in;
205 in.i_crypt_info = NULL;
208 CONFIG_LDISKFS_FS_ENCRYPTION, 1,
209 [enable encryption for ldiskfs]
212 LB_CHECK_CONFIG([EXT4_FS_ENCRYPTION],[
214 CONFIG_LDISKFS_FS_ENCRYPTION, 1,
215 [enable encryption for ldiskfs]
219 ]) # LB_EXT4_HAVE_I_CRYPT_INFO
222 # LB_LDISKFS_IGET_HAS_FLAGS_ARG
224 # kernel 4.19 commit 8a363970d1dc38c4ec4ad575c862f776f468d057
225 # ext4_iget changed to a macro with 3 args was function with 2 args
227 AC_DEFUN([LB_LDISKFS_IGET_HAS_FLAGS_ARG], [
228 tmp_flags="$EXTRA_KCFLAGS"
229 EXTRA_KCFLAGS="-Werror"
230 LB_CHECK_COMPILE([if ldiskfs_iget takes a flags argument],
232 #include <linux/fs.h>
233 #include "$EXT4_SRC_DIR/ext4.h"
235 int f = EXT4_IGET_SPECIAL;
238 AC_DEFINE(HAVE_LDISKFS_IGET_WITH_FLAGS, 1,
239 [if ldiskfs_iget takes a flags argument])
241 EXTRA_KCFLAGS="$tmp_flags"
242 ]) # LB_LDISKFS_IGET_HAS_FLAGS_ARG
245 # LDISKFS_AC_PATCH_PROGRAM
247 # Determine which program should be used to apply the patches to
248 # the ext4 source code to produce the ldiskfs source code.
250 AC_DEFUN([LDISKFS_AC_PATCH_PROGRAM], [
251 AC_ARG_ENABLE([quilt],
252 [AC_HELP_STRING([--disable-quilt],
253 [disable use of quilt for ldiskfs])],
254 [AS_IF([test "x$enableval" = xno],
260 AS_IF([test x$use_quilt = xmaybe], [
261 AC_PATH_PROG([quilt_avail], [quilt], [no])
262 AS_IF([test x$quilt_avail = xno], [
269 AS_IF([test x$use_quilt = xno], [
270 AC_PATH_PROG([patch_avail], [patch], [no])
271 AS_IF([test x$patch_avail = xno], [
272 AC_MSG_ERROR([*** Need "quilt" or "patch" command])
275 ]) # LDISKFS_AC_PATCH_PROGRAM
278 # LB_HAVE_BVEC_ITER_ALL
280 # kernel 5.1 commit 6dc4f100c175dd0511ae8674786e7c9006cdfbfa
281 # block: allow bio_for_each_segment_all() to iterate over multi-page bvec
283 AC_DEFUN([LB_HAVE_BVEC_ITER_ALL], [
284 tmp_flags="$EXTRA_KCFLAGS"
285 EXTRA_KCFLAGS="-Werror"
286 LB_CHECK_COMPILE([if bvec_iter_all exists for multi-page bvec iternation],
288 #include <linux/bvec.h>
290 struct bvec_iter_all iter;
293 AC_DEFINE(HAVE_BVEC_ITER_ALL, 1,
294 [if bvec_iter_all exists for multi-page bvec iternation])
296 EXTRA_KCFLAGS="$tmp_flags"
297 ]) # LB_HAVE_BVEC_ITER_ALL
300 # LB_LDISKFS_FIND_ENTRY_LOCKED_EXISTS
302 # kernel 5.2 commit 8a363970d1dc38c4ec4ad575c862f776f468d057
303 # ext4: avoid declaring fs inconsistent due to invalid file handles
304 # __ext4_find_entry became a helper function for ext4_find_entry
305 # conflicting with previous ldiskfs patches.
306 # ldiskfs patches map ext4_find_entry to ldiskfs_find_entry_locked to
307 # avoid conflicting with __ext4_find_entry
309 # When the following check succeeds __ext4_find_entry helper is not
312 AC_DEFUN([LB_LDISKFS_FIND_ENTRY_LOCKED_EXISTS], [
313 tmp_flags="$EXTRA_KCFLAGS"
314 EXTRA_KCFLAGS="-Werror"
315 LB_CHECK_COMPILE([if __ldiskfs_find_entry is available],
316 ldiskfs_find_entry_locked, [
317 #include <linux/fs.h>
318 #include "$EXT4_SRC_DIR/ext4.h"
319 #include "$EXT4_SRC_DIR/namei.c"
321 static int __ext4_find_entry(void) { return 0; }
323 int x = __ext4_find_entry();
326 AC_DEFINE(HAVE___LDISKFS_FIND_ENTRY, 1,
327 [if __ldiskfs_find_entry is available])
329 EXTRA_KCFLAGS="$tmp_flags"
330 ]) # LB_LDISKFS_FIND_ENTRY_LOCKED_EXISTS
333 # LB_LDISKFSFS_DIRHASH_WANTS_DIR
335 # kernel 5.2 commit 8a363970d1dc38c4ec4ad575c862f776f468d057
336 # ext4fs_dirhash UNICODE support
338 AC_DEFUN([LB_LDISKFSFS_DIRHASH_WANTS_DIR], [
339 tmp_flags="$EXTRA_KCFLAGS"
340 EXTRA_KCFLAGS="-Werror"
341 LB_CHECK_COMPILE([if ldiskfsfs_dirhash takes an inode argument],
343 #include <linux/fs.h>
344 #include "$EXT4_SRC_DIR/ext4.h"
346 int ext4fs_dirhash(const struct inode *dir, const char *name, int len,
347 struct dx_hash_info *hinfo)
356 int f = ext4fs_dirhash(NULL, NULL, 0, NULL);
359 AC_DEFINE(HAVE_LDISKFSFS_GETHASH_INODE_ARG, 1,
360 [if ldiskfsfs_dirhash takes an inode argument])
362 EXTRA_KCFLAGS="$tmp_flags"
363 ]) # LB_LDISKFSFS_DIRHASH_WANTS_DIR
368 AC_DEFUN([LB_CONFIG_LDISKFS], [
369 # --with-ldiskfs is deprecated now that ldiskfs is fully merged with lustre.
370 # However we continue to support this option through Lustre 2.5.
371 AC_ARG_WITH([ldiskfs],
373 [AC_MSG_WARN([--with-ldiskfs is deprecated, please use --enable-ldiskfs])
374 AS_IF([test x$withval != xyes -a x$withval != xno],
377 The ldiskfs option is deprecated,
378 and no longer supports paths to external ldiskfs source
382 AC_ARG_ENABLE([ldiskfs],
383 [AS_HELP_STRING([--disable-ldiskfs],
384 [disable ldiskfs osd (default is enable)])],
385 [AS_IF([test x$enable_ldiskfs != xyes -a x$enable_ldiskfs != xno],
386 [AC_MSG_ERROR([ldiskfs valid options are "yes" or "no"])])],
387 [AS_IF([test "${with_ldiskfs+set}" = set],
388 [enable_ldiskfs=$with_ldiskfs],
389 [enable_ldiskfs=maybe])
392 AS_IF([test x$enable_server = xno],
393 [AS_CASE([$enable_ldiskfs],
394 [maybe], [enable_ldiskfs=no],
395 [yes], [AC_MSG_ERROR([cannot build ldiskfs when servers are disabled])]
398 AS_IF([test x$enable_ldiskfs != xno],[
399 # In the future, we chould change enable_ldiskfs from maybe to
400 # either yes or no based on additional tests, e.g. whether a patch
401 # set is available for the detected kernel. For now, we just always
403 AS_IF([test x$enable_ldiskfs = xmaybe], [enable_ldiskfs=yes])
404 AC_SUBST(ENABLE_LDISKFS, yes)
407 LDISKFS_AC_PATCH_PROGRAM
408 LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD
409 LB_EXT4_JOURNAL_START_3ARGS
411 LB_EXT4_HAVE_INFO_DQUOT
412 LB_EXT4_HAVE_I_CRYPT_INFO
413 LB_LDISKFS_IGET_HAS_FLAGS_ARG
414 LB_HAVE_BVEC_ITER_ALL
415 LB_LDISKFS_FIND_ENTRY_LOCKED_EXISTS
416 LB_LDISKFSFS_DIRHASH_WANTS_DIR
417 AC_DEFINE(CONFIG_LDISKFS_FS_POSIX_ACL, 1, [posix acls for ldiskfs])
418 AC_DEFINE(CONFIG_LDISKFS_FS_SECURITY, 1, [fs security for ldiskfs])
419 AC_DEFINE(CONFIG_LDISKFS_FS_XATTR, 1, [extened attributes for ldiskfs])
420 AC_DEFINE(CONFIG_LDISKFS_FS_RW, 1, [enable rw access for ldiskfs])
421 AC_SUBST(LDISKFS_SUBDIR, ldiskfs)
422 AC_DEFINE(HAVE_LDISKFS_OSD, 1, Enable ldiskfs osd)
424 AC_SUBST(ENABLE_LDISKFS, no)
427 AC_MSG_CHECKING([whether to build ldiskfs])
428 AC_MSG_RESULT([$enable_ldiskfs])
430 AM_CONDITIONAL([LDISKFS_ENABLED], [test x$enable_ldiskfs = xyes])
431 ]) # LB_CONFIG_LDISKFS
434 # LB_VALIDATE_EXT4_SRC_DIR
436 # Spot check the existence of several source files common to ext4.
437 # Detecting this at configure time allows us to avoid a potential build
438 # failure and provide a useful error message to explain what is wrong.
440 AC_DEFUN([LB_VALIDATE_EXT4_SRC_DIR], [
441 enable_ldiskfs_build="no"
442 AS_IF([test -n "$EXT4_SRC_DIR"], [
443 enable_ldiskfs_build="yes"
444 LB_CHECK_FILE([$EXT4_SRC_DIR/dir.c], [], [
445 enable_ldiskfs_build="no"
446 AC_MSG_WARN([ext4 must exist for ldiskfs build])
448 LB_CHECK_FILE([$EXT4_SRC_DIR/file.c], [], [
449 enable_ldiskfs_build="no"
450 AC_MSG_WARN([ext4 must exist for ldiskfs build])
452 LB_CHECK_FILE([$EXT4_SRC_DIR/inode.c], [], [
453 enable_ldiskfs_build="no"
454 AC_MSG_WARN([ext4 must exist for ldiskfs build])
456 LB_CHECK_FILE([$EXT4_SRC_DIR/super.c], [], [
457 enable_ldiskfs_build="no"
458 AC_MSG_WARN([ext4 must exist for ldiskfs build])
462 AS_IF([test "x$enable_ldiskfs_build" = xno], [
467 Disabling ldiskfs support because complete ext4 source does not exist.
469 If you are building using kernel-devel packages and require ldiskfs
470 server support then ensure that the matching kernel-debuginfo-common
471 and kernel-debuginfo-common-<arch> packages are installed.
474 ]) # LB_VALIDATE_EXT4_SRC_DIR
479 # Determine the location of the ext4 source code. It it required
480 # for several configure tests and to build ldiskfs.
482 AC_DEFUN([LB_EXT4_SRC_DIR], [
483 AC_MSG_CHECKING([ext4 source directory])
484 # Kernel ext source located with devel headers
486 AS_IF([test -e "$linux_src/fs/ext4/super.c"], [
487 EXT4_SRC_DIR="$linux_src/fs/ext4"
489 # Kernel ext source provided by kernel-debuginfo-common package
490 # that extracted to $LINUX
491 linux_src=$(ls -1d $linux_src/../../debug/*/linux-${LINUXRELEASE%.*}* \
492 2>/dev/null | tail -1)
493 AS_IF([test -e "$linux_src/fs/ext4/super.c"], [
494 EXT4_SRC_DIR="$linux_src/fs/ext4"
496 # Kernel ext source provided by kernel-debuginfo-common package
497 linux_src=$(ls -1d /usr/src/debug/*/linux-${LINUXRELEASE%.*}* \
498 2>/dev/null | tail -1)
499 AS_IF([test -e "$linux_src/fs/ext4/super.c"], [
500 EXT4_SRC_DIR="$linux_src/fs/ext4"
506 AC_MSG_RESULT([$EXT4_SRC_DIR])
507 AC_SUBST(EXT4_SRC_DIR)
509 LB_VALIDATE_EXT4_SRC_DIR
513 # LB_DEFINE_E2FSPROGS_NAMES
515 # Enable the use of alternate naming of ldiskfs-enabled e2fsprogs package.
517 AC_DEFUN([LB_DEFINE_E2FSPROGS_NAMES], [
518 AC_MSG_CHECKING([whether to use alternate names for e2fsprogs])
519 AC_ARG_WITH([ldiskfsprogs],
520 AC_HELP_STRING([--with-ldiskfsprogs],
521 [use alternate names for ldiskfs-enabled e2fsprogs]),
524 AS_IF([test "x$withval" = xyes], [
525 AC_MSG_RESULT([enabled])
526 AC_DEFINE(HAVE_LDISKFSPROGS, 1, [enable use of ldiskfsprogs package])
527 E2FSPROGS="ldiskfsprogs"
528 MKE2FS="mkfs.ldiskfs"
529 DEBUGFS="debugfs.ldiskfs"
530 TUNE2FS="tunefs.ldiskfs"
531 E2LABEL="label.ldiskfs"
532 DUMPE2FS="dumpfs.ldiskfs"
533 E2FSCK="fsck.ldiskfs"
534 PFSCK="pfsck.ldiskfs"
536 AC_MSG_RESULT([disabled])
537 E2FSPROGS="e2fsprogs"
547 AC_DEFINE_UNQUOTED(E2FSPROGS, "$E2FSPROGS", [name of ldiskfs e2fsprogs package])
548 AC_DEFINE_UNQUOTED(MKE2FS, "$MKE2FS", [name of ldiskfs mkfs program])
549 AC_DEFINE_UNQUOTED(DEBUGFS, "$DEBUGFS", [name of ldiskfs debug program])
550 AC_DEFINE_UNQUOTED(TUNE2FS, "$TUNE2FS", [name of ldiskfs tune program])
551 AC_DEFINE_UNQUOTED(E2LABEL, "$E2LABEL", [name of ldiskfs label program])
552 AC_DEFINE_UNQUOTED(DUMPE2FS,"$DUMPE2FS", [name of ldiskfs dump program])
553 AC_DEFINE_UNQUOTED(E2FSCK, "$E2FSCK", [name of ldiskfs fsck program])
554 AC_DEFINE_UNQUOTED(PFSCK, "$PFSCK", [name of parallel fsck program])
556 AC_SUBST([E2FSPROGS], [$E2FSPROGS])
557 AC_SUBST([MKE2FS], [$MKE2FS])
558 AC_SUBST([DEBUGFS], [$DEBUGFS])
559 AC_SUBST([TUNE2FS], [$TUNE2FS])
560 AC_SUBST([E2LABEL], [$E2LABEL])
561 AC_SUBST([DUMPE2FS], [$DUMPE2FS])
562 AC_SUBST([E2FSCK], [$E2FSCK])
563 AC_SUBST([PFSCK], [$PFSCK])
564 ]) # LB_DEFINE_E2FSPROGS_NAMES