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 77) LDISKFS_SERIES="3.10-rhel7.7.series" ;;
19 76) LDISKFS_SERIES="3.10-rhel7.6.series" ;;
21 ], [test x$SUSE_KERNEL = xyes], [
22 AS_VERSION_COMPARE([$LINUXRELEASE],[5.3.18],[
23 AS_VERSION_COMPARE([$LINUXRELEASE],[4.12.14],[
24 AS_VERSION_COMPARE([$LINUXRELEASE],[4.4.82],[
25 AS_VERSION_COMPARE([$LINUXRELEASE],[4.4.0],[
26 AS_VERSION_COMPARE([$LINUXRELEASE],[3.12.0],[],
27 [LDISKFS_SERIES="3.12-sles12.series"],[
28 PLEV=$(grep PATCHLEVEL /etc/SuSE-release | sed -e 's/.*= *//')
30 1) LDISKFS_SERIES="3.12-sles12sp1.series"
32 *) LDISKFS_SERIES="3.12-sles12.series"
35 ])],[LDISKFS_SERIES="4.4-sles12sp2.series"],
36 [LDISKFS_SERIES="4.4-sles12sp2.series"]
37 )], [LDISKFS_SERIES="4.4-sles12sp3.series"],
38 [LDISKFS_SERIES="4.4-sles12sp3.series"]
39 )], [LDISKFS_SERIES="4.12-sles15.series"],
40 [LDISKFS_SERIES="4.12-sles15.series"]
41 )], [LDISKFS_SERIES="5.4.0-ml.series"],
42 [LDISKFS_SERIES="5.4.0-ml.series"])
43 ], [test x$UBUNTU_KERNEL = xyes], [
44 AS_VERSION_COMPARE([$LINUXRELEASE],[5.3.0],[
45 AS_VERSION_COMPARE([$LINUXRELEASE],[5.0.0],[
46 AS_VERSION_COMPARE([$LINUXRELEASE],[4.15.0],[
47 AS_VERSION_COMPARE([$LINUXRELEASE],[4.4.0], [],
49 KPLEV=$(echo $LINUXRELEASE | sed -n 's/.*-\([0-9]\+\).*/\1/p')
52 AC_MSG_WARN([Failed to determine Kernel patch level. Assume latest.])
53 LDISKFS_SERIES="4.4.0-73-ubuntu14+16.series"
55 [test $KPLEV -ge 73], [LDISKFS_SERIES="4.4.0-73-ubuntu14+16.series"],
56 [test $KPLEV -ge 62], [LDISKFS_SERIES="4.4.0-62-ubuntu14+16.series"],
57 [test $KPLEV -ge 49], [LDISKFS_SERIES="4.4.0-49-ubuntu14+16.series"],
58 [LDISKFS_SERIES="4.4.0-45-ubuntu14+16.series"]
61 [LDISKFS_SERIES="4.4.0-73-ubuntu14+16.series"])],
63 KPLEV=$(echo $LINUXRELEASE | sed -n 's/.*-\([0-9]\+\).*/\1/p')
66 AC_MSG_WARN([Failed to determine Kernel patch level. Assume latest.])
67 LDISKFS_SERIES="4.15.0-24-ubuntu18.series"
69 [test $KPLEV -ge 24], [LDISKFS_SERIES="4.15.0-24-ubuntu18.series"],
70 [test $KPLEV -ge 20], [LDISKFS_SERIES="4.15.0-20-ubuntu18.series"]
73 [LDISKFS_SERIES="4.15.0-24-ubuntu18.series"])],
74 [LDISKFS_SERIES="5.0.0-13-ubuntu19.series"],
75 [LDISKFS_SERIES="5.0.0-13-ubuntu19.series"])],
76 [LDISKFS_SERIES="5.4.0-ml.series"],
77 [LDISKFS_SERIES="5.4.0-ml.series"])
80 # Not RHEL/SLES or Ubuntu .. probably mainline
81 AS_IF([test -z "$LDISKFS_SERIES"],
83 AS_VERSION_COMPARE([$LINUXRELEASE],[5.4.0],[],
84 [LDISKFS_SERIES="5.4.0-ml.series"],[
85 AS_VERSION_COMPARE([$LINUXRELEASE],[5.4.0],
86 [LDISKFS_SERIES="5.4.0-ml.series"], # lt
87 [LDISKFS_SERIES="5.4.0-ml.series"], # eq
88 [LDISKFS_SERIES="5.4.0-ml.series"] # gt
92 AS_IF([test -z "$LDISKFS_SERIES"],
93 [AC_MSG_RESULT([failed to identify series])],
94 [AC_MSG_RESULT([$LDISKFS_SERIES for $LINUXRELEASE])])
95 AC_SUBST(LDISKFS_SERIES)
96 ]) # LDISKFS_LINUX_SERIES
99 # LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD
101 # 2.6.32-rc7 ext4_free_blocks requires struct buffer_head
102 # Note that RHEL6 is pre 2.6.32-rc7 so this check is still needed.
104 AC_DEFUN([LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD], [
105 LB_CHECK_COMPILE([if 'ext4_free_blocks' needs 'struct buffer_head'],
106 ext4_free_blocks_with_buffer_head, [
107 #include <linux/fs.h>
108 #include "$EXT4_SRC_DIR/ext4.h"
110 ext4_free_blocks(NULL, NULL, NULL, 0, 0, 0);
112 AC_DEFINE(HAVE_EXT_FREE_BLOCK_WITH_BUFFER_HEAD, 1,
113 [ext4_free_blocks do not require struct buffer_head])
115 ]) # LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD
118 # LB_EXT4_JOURNAL_START_3ARGS
120 # 3.9 added a type argument to ext4_journal_start and friends
122 AC_DEFUN([LB_EXT4_JOURNAL_START_3ARGS], [
123 LB_CHECK_COMPILE([if ext4_journal_start takes 3 arguments],
124 ext4_journal_start, [
125 #include <linux/fs.h>
126 #include "$EXT4_SRC_DIR/ext4_jbd2.h"
128 ext4_journal_start(NULL, 0, 0);
130 AC_DEFINE(JOURNAL_START_HAS_3ARGS, 1, [ext4_journal_start takes 3 arguments])
132 ]) # LB_EXT4_JOURNAL_START_3ARGS
135 # LB_EXT4_BREAD_4ARGS
137 # 3.18 ext4_bread has 4 arguments
138 # NOTE: It may not be exported for modules, use a positive compiler test here.
140 AC_DEFUN([LB_EXT4_BREAD_4ARGS], [
141 LB_CHECK_COMPILE([if ext4_bread takes 4 arguments],
143 #include <linux/fs.h>
144 #include "$EXT4_SRC_DIR/ext4.h"
146 struct buffer_head *ext4_bread(handle_t *handle, struct inode *inode,
147 ext4_lblk_t block, int map_flags)
149 struct buffer_head *bh = NULL;
157 ext4_bread(NULL, NULL, 0, 0);
159 AC_DEFINE(HAVE_EXT4_BREAD_4ARGS, 1, [ext4_bread takes 4 arguments])
161 ]) # LB_EXT4_BREAD_4ARGS
164 # LB_EXT4_HAVE_INFO_DQUOT
166 # in linux 4.4 i_dqout is in ext4_inode_info, not in struct inode
168 AC_DEFUN([LB_EXT4_HAVE_INFO_DQUOT], [
169 LB_CHECK_COMPILE([if i_dquot is in ext4_inode_info],
171 #include <linux/fs.h>
172 #include <linux/quota.h>
173 #include "$EXT4_SRC_DIR/ext4.h"
175 struct ext4_inode_info in;
180 AC_DEFINE(HAVE_EXT4_INFO_DQUOT, 1, [i_dquot is in ext4_inode_info])
182 ]) # LB_EXT4_HAVE_INFO_DQUOT
185 # LB_EXT4_HAVE_I_CRYPT_INFO
187 # in linux 4.8 i_crypt_info moved from ext4_inode_info to struct inode
189 # Determine if we need to enable CONFIG_LDISKFS_FS_ENCRYPTION.
190 # If we have i_crypt_info in ext4_inode_info, the config option
191 # should be enabled to make the ldiskfs module compilation happy.
192 # Otherwise i_crypy_info is in struct inode, we need to check kernel
193 # config option to determine that.
195 AC_DEFUN([LB_EXT4_HAVE_I_CRYPT_INFO], [
196 LB_CHECK_COMPILE([if i_crypt_info is in ext4_inode_info],
198 #define CONFIG_EXT4_FS_ENCRYPTION 1
199 #include <linux/fs.h>
200 #include "$EXT4_SRC_DIR/ext4.h"
202 struct ext4_inode_info in;
204 in.i_crypt_info = NULL;
207 CONFIG_LDISKFS_FS_ENCRYPTION, 1,
208 [enable encryption for ldiskfs]
211 LB_CHECK_CONFIG([EXT4_FS_ENCRYPTION],[
213 CONFIG_LDISKFS_FS_ENCRYPTION, 1,
214 [enable encryption for ldiskfs]
218 ]) # LB_EXT4_HAVE_I_CRYPT_INFO
221 # LB_LDISKFS_IGET_HAS_FLAGS_ARG
223 # kernel 4.19 commit 8a363970d1dc38c4ec4ad575c862f776f468d057
224 # ext4_iget changed to a macro with 3 args was function with 2 args
226 AC_DEFUN([LB_LDISKFS_IGET_HAS_FLAGS_ARG], [
227 tmp_flags="$EXTRA_KCFLAGS"
228 EXTRA_KCFLAGS="-Werror"
229 LB_CHECK_COMPILE([if ldiskfs_iget takes a flags argument],
231 #include <linux/fs.h>
232 #include "$EXT4_SRC_DIR/ext4.h"
234 int f = EXT4_IGET_SPECIAL;
237 AC_DEFINE(HAVE_LDISKFS_IGET_WITH_FLAGS, 1,
238 [if ldiskfs_iget takes a flags argument])
240 EXTRA_KCFLAGS="$tmp_flags"
241 ]) # LB_LDISKFS_IGET_HAS_FLAGS_ARG
244 # LDISKFS_AC_PATCH_PROGRAM
246 # Determine which program should be used to apply the patches to
247 # the ext4 source code to produce the ldiskfs source code.
249 AC_DEFUN([LDISKFS_AC_PATCH_PROGRAM], [
250 AC_ARG_ENABLE([quilt],
251 [AC_HELP_STRING([--disable-quilt],
252 [disable use of quilt for ldiskfs])],
253 [AS_IF([test "x$enableval" = xno],
259 AS_IF([test x$use_quilt = xmaybe], [
260 AC_PATH_PROG([quilt_avail], [quilt], [no])
261 AS_IF([test x$quilt_avail = xno], [
268 AS_IF([test x$use_quilt = xno], [
269 AC_PATH_PROG([patch_avail], [patch], [no])
270 AS_IF([test x$patch_avail = xno], [
271 AC_MSG_ERROR([*** Need "quilt" or "patch" command])
274 ]) # LDISKFS_AC_PATCH_PROGRAM
277 # LB_HAVE_BVEC_ITER_ALL
279 # kernel 5.1 commit 6dc4f100c175dd0511ae8674786e7c9006cdfbfa
280 # block: allow bio_for_each_segment_all() to iterate over multi-page bvec
282 AC_DEFUN([LB_HAVE_BVEC_ITER_ALL], [
283 tmp_flags="$EXTRA_KCFLAGS"
284 EXTRA_KCFLAGS="-Werror"
285 LB_CHECK_COMPILE([if bvec_iter_all exists for multi-page bvec iternation],
287 #include <linux/bvec.h>
289 struct bvec_iter_all iter;
292 AC_DEFINE(HAVE_BVEC_ITER_ALL, 1,
293 [if bvec_iter_all exists for multi-page bvec iternation])
295 EXTRA_KCFLAGS="$tmp_flags"
296 ]) # LB_HAVE_BVEC_ITER_ALL
299 # LB_LDISKFS_FIND_ENTRY_LOCKED_EXISTS
301 # kernel 5.2 commit 8a363970d1dc38c4ec4ad575c862f776f468d057
302 # ext4: avoid declaring fs inconsistent due to invalid file handles
303 # __ext4_find_entry became a helper function for ext4_find_entry
304 # conflicting with previous ldiskfs patches.
305 # ldiskfs patches map ext4_find_entry to ldiskfs_find_entry_locked to
306 # avoid conflicting with __ext4_find_entry
308 # When the following check succeeds __ext4_find_entry helper is not
311 AC_DEFUN([LB_LDISKFS_FIND_ENTRY_LOCKED_EXISTS], [
312 tmp_flags="$EXTRA_KCFLAGS"
313 EXTRA_KCFLAGS="-Werror"
314 LB_CHECK_COMPILE([if __ldiskfs_find_entry is available],
315 ldiskfs_find_entry_locked, [
316 #include <linux/fs.h>
317 #include "$EXT4_SRC_DIR/ext4.h"
318 #include "$EXT4_SRC_DIR/namei.c"
320 static int __ext4_find_entry(void) { return 0; }
322 int x = __ext4_find_entry();
325 AC_DEFINE(HAVE___LDISKFS_FIND_ENTRY, 1,
326 [if __ldiskfs_find_entry is available])
328 EXTRA_KCFLAGS="$tmp_flags"
329 ]) # LB_LDISKFS_FIND_ENTRY_LOCKED_EXISTS
332 # LB_LDISKFSFS_DIRHASH_WANTS_DIR
334 # kernel 5.2 commit 8a363970d1dc38c4ec4ad575c862f776f468d057
335 # ext4fs_dirhash UNICODE support
337 AC_DEFUN([LB_LDISKFSFS_DIRHASH_WANTS_DIR], [
338 tmp_flags="$EXTRA_KCFLAGS"
339 EXTRA_KCFLAGS="-Werror"
340 LB_CHECK_COMPILE([if ldiskfsfs_dirhash takes an inode argument],
342 #include <linux/fs.h>
343 #include "$EXT4_SRC_DIR/ext4.h"
345 int ext4fs_dirhash(const struct inode *dir, const char *name, int len,
346 struct dx_hash_info *hinfo)
355 int f = ext4fs_dirhash(NULL, NULL, 0, NULL);
358 AC_DEFINE(HAVE_LDISKFSFS_GETHASH_INODE_ARG, 1,
359 [if ldiskfsfs_dirhash takes an inode argument])
361 EXTRA_KCFLAGS="$tmp_flags"
362 ]) # LB_LDISKFSFS_DIRHASH_WANTS_DIR
367 AC_DEFUN([LB_CONFIG_LDISKFS], [
368 # --with-ldiskfs is deprecated now that ldiskfs is fully merged with lustre.
369 # However we continue to support this option through Lustre 2.5.
370 AC_ARG_WITH([ldiskfs],
372 [AC_MSG_WARN([--with-ldiskfs is deprecated, please use --enable-ldiskfs])
373 AS_IF([test x$withval != xyes -a x$withval != xno],
376 The ldiskfs option is deprecated,
377 and no longer supports paths to external ldiskfs source
381 AC_ARG_ENABLE([ldiskfs],
382 [AS_HELP_STRING([--disable-ldiskfs],
383 [disable ldiskfs osd (default is enable)])],
384 [AS_IF([test x$enable_ldiskfs != xyes -a x$enable_ldiskfs != xno],
385 [AC_MSG_ERROR([ldiskfs valid options are "yes" or "no"])])],
386 [AS_IF([test "${with_ldiskfs+set}" = set],
387 [enable_ldiskfs=$with_ldiskfs],
388 [enable_ldiskfs=maybe])
391 AS_IF([test x$enable_server = xno],
392 [AS_CASE([$enable_ldiskfs],
393 [maybe], [enable_ldiskfs=no],
394 [yes], [AC_MSG_ERROR([cannot build ldiskfs when servers are disabled])]
397 AS_IF([test x$enable_ldiskfs != xno],[
398 # In the future, we chould change enable_ldiskfs from maybe to
399 # either yes or no based on additional tests, e.g. whether a patch
400 # set is available for the detected kernel. For now, we just always
402 AS_IF([test x$enable_ldiskfs = xmaybe], [enable_ldiskfs=yes])
403 AC_SUBST(ENABLE_LDISKFS, yes)
406 LDISKFS_AC_PATCH_PROGRAM
407 LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD
408 LB_EXT4_JOURNAL_START_3ARGS
410 LB_EXT4_HAVE_INFO_DQUOT
411 LB_EXT4_HAVE_I_CRYPT_INFO
412 LB_LDISKFS_IGET_HAS_FLAGS_ARG
413 LB_HAVE_BVEC_ITER_ALL
414 LB_LDISKFS_FIND_ENTRY_LOCKED_EXISTS
415 LB_LDISKFSFS_DIRHASH_WANTS_DIR
416 AC_DEFINE(CONFIG_LDISKFS_FS_POSIX_ACL, 1, [posix acls for ldiskfs])
417 AC_DEFINE(CONFIG_LDISKFS_FS_SECURITY, 1, [fs security for ldiskfs])
418 AC_DEFINE(CONFIG_LDISKFS_FS_XATTR, 1, [extened attributes for ldiskfs])
419 AC_DEFINE(CONFIG_LDISKFS_FS_RW, 1, [enable rw access for ldiskfs])
420 AC_SUBST(LDISKFS_SUBDIR, ldiskfs)
421 AC_DEFINE(HAVE_LDISKFS_OSD, 1, Enable ldiskfs osd)
423 AC_SUBST(ENABLE_LDISKFS, no)
426 AC_MSG_CHECKING([whether to build ldiskfs])
427 AC_MSG_RESULT([$enable_ldiskfs])
429 AM_CONDITIONAL([LDISKFS_ENABLED], [test x$enable_ldiskfs = xyes])
430 ]) # LB_CONFIG_LDISKFS
433 # LB_VALIDATE_EXT4_SRC_DIR
435 # Spot check the existence of several source files common to ext4.
436 # Detecting this at configure time allows us to avoid a potential build
437 # failure and provide a useful error message to explain what is wrong.
439 AC_DEFUN([LB_VALIDATE_EXT4_SRC_DIR], [
440 enable_ldiskfs_build="no"
441 AS_IF([test -n "$EXT4_SRC_DIR"], [
442 enable_ldiskfs_build="yes"
443 LB_CHECK_FILE([$EXT4_SRC_DIR/dir.c], [], [
444 enable_ldiskfs_build="no"
445 AC_MSG_WARN([ext4 must exist for ldiskfs build])
447 LB_CHECK_FILE([$EXT4_SRC_DIR/file.c], [], [
448 enable_ldiskfs_build="no"
449 AC_MSG_WARN([ext4 must exist for ldiskfs build])
451 LB_CHECK_FILE([$EXT4_SRC_DIR/inode.c], [], [
452 enable_ldiskfs_build="no"
453 AC_MSG_WARN([ext4 must exist for ldiskfs build])
455 LB_CHECK_FILE([$EXT4_SRC_DIR/super.c], [], [
456 enable_ldiskfs_build="no"
457 AC_MSG_WARN([ext4 must exist for ldiskfs build])
461 AS_IF([test "x$enable_ldiskfs_build" = xno], [
466 Disabling ldiskfs support because complete ext4 source does not exist.
468 If you are building using kernel-devel packages and require ldiskfs
469 server support then ensure that the matching kernel-debuginfo-common
470 and kernel-debuginfo-common-<arch> packages are installed.
473 ]) # LB_VALIDATE_EXT4_SRC_DIR
478 # Determine the location of the ext4 source code. It it required
479 # for several configure tests and to build ldiskfs.
481 AC_DEFUN([LB_EXT4_SRC_DIR], [
482 AC_MSG_CHECKING([ext4 source directory])
483 # Kernel ext source located with devel headers
485 AS_IF([test -e "$linux_src/fs/ext4/super.c"], [
486 EXT4_SRC_DIR="$linux_src/fs/ext4"
488 # Kernel ext source provided by kernel-debuginfo-common package
489 # that extracted to $LINUX
490 linux_src=$(ls -1d $linux_src/../../debug/*/linux-${LINUXRELEASE%.*}* \
491 2>/dev/null | tail -1)
492 AS_IF([test -e "$linux_src/fs/ext4/super.c"], [
493 EXT4_SRC_DIR="$linux_src/fs/ext4"
495 # Kernel ext source provided by kernel-debuginfo-common package
496 linux_src=$(ls -1d /usr/src/debug/*/linux-${LINUXRELEASE%.*}* \
497 2>/dev/null | tail -1)
498 AS_IF([test -e "$linux_src/fs/ext4/super.c"], [
499 EXT4_SRC_DIR="$linux_src/fs/ext4"
505 AC_MSG_RESULT([$EXT4_SRC_DIR])
506 AC_SUBST(EXT4_SRC_DIR)
508 LB_VALIDATE_EXT4_SRC_DIR
512 # LB_DEFINE_E2FSPROGS_NAMES
514 # Enable the use of alternate naming of ldiskfs-enabled e2fsprogs package.
516 AC_DEFUN([LB_DEFINE_E2FSPROGS_NAMES], [
517 AC_MSG_CHECKING([whether to use alternate names for e2fsprogs])
518 AC_ARG_WITH([ldiskfsprogs],
519 AC_HELP_STRING([--with-ldiskfsprogs],
520 [use alternate names for ldiskfs-enabled e2fsprogs]),
523 AS_IF([test "x$withval" = xyes], [
524 AC_MSG_RESULT([enabled])
525 AC_DEFINE(HAVE_LDISKFSPROGS, 1, [enable use of ldiskfsprogs package])
526 E2FSPROGS="ldiskfsprogs"
527 MKE2FS="mkfs.ldiskfs"
528 DEBUGFS="debugfs.ldiskfs"
529 TUNE2FS="tunefs.ldiskfs"
530 E2LABEL="label.ldiskfs"
531 DUMPE2FS="dumpfs.ldiskfs"
532 E2FSCK="fsck.ldiskfs"
533 PFSCK="pfsck.ldiskfs"
535 AC_MSG_RESULT([disabled])
536 E2FSPROGS="e2fsprogs"
546 AC_DEFINE_UNQUOTED(E2FSPROGS, "$E2FSPROGS", [name of ldiskfs e2fsprogs package])
547 AC_DEFINE_UNQUOTED(MKE2FS, "$MKE2FS", [name of ldiskfs mkfs program])
548 AC_DEFINE_UNQUOTED(DEBUGFS, "$DEBUGFS", [name of ldiskfs debug program])
549 AC_DEFINE_UNQUOTED(TUNE2FS, "$TUNE2FS", [name of ldiskfs tune program])
550 AC_DEFINE_UNQUOTED(E2LABEL, "$E2LABEL", [name of ldiskfs label program])
551 AC_DEFINE_UNQUOTED(DUMPE2FS,"$DUMPE2FS", [name of ldiskfs dump program])
552 AC_DEFINE_UNQUOTED(E2FSCK, "$E2FSCK", [name of ldiskfs fsck program])
553 AC_DEFINE_UNQUOTED(PFSCK, "$PFSCK", [name of parallel fsck program])
555 AC_SUBST([E2FSPROGS], [$E2FSPROGS])
556 AC_SUBST([MKE2FS], [$MKE2FS])
557 AC_SUBST([DEBUGFS], [$DEBUGFS])
558 AC_SUBST([TUNE2FS], [$TUNE2FS])
559 AC_SUBST([E2LABEL], [$E2LABEL])
560 AC_SUBST([DUMPE2FS], [$DUMPE2FS])
561 AC_SUBST([E2FSCK], [$E2FSCK])
562 AC_SUBST([PFSCK], [$PFSCK])
563 ]) # LB_DEFINE_E2FSPROGS_NAMES