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"]
41 suse_conf=$LINUX_OBJ/include/generated/uapi/linux/suse_version.h
42 suse_vers=$(awk '[$]2 == "SUSE_VERSION" {print [$]3 }' $suse_conf)
43 suse_patchlevel=$(awk '[$]2 == "SUSE_PATCHLEVEL" {print [$]3 }' $suse_conf)
44 echo "$suse_conf $suse_vers $suse_patchlevel ${suse_vers}sp$suse_patchlevel" >> /tmp/log-nb
45 case ${suse_vers}sp$suse_patchlevel in # (
46 15sp0 ) LDISKFS_SERIES="4.12-sles15.series"
47 if test ! -f $LINUX/arch/x86/kernel/cpu/hygon.c ; then
48 # This file was added shortly after -150.22 so
49 # this must be 150.22 or earlier
50 LDISKFS_SERIES="4.12-sles15-22.series"
53 15sp1 ) LDISKFS_SERIES="4.12-sles15sp1.series"
54 if test ! -f $LINUX/arch/x86/kernel/cpu/umwait.c ; then
55 # This file was added after -197.7 so
56 # this must be -197.7 or earlier
57 LDISKFS_SERIES="4.12-sles15sp1-7.series"
62 )], [LDISKFS_SERIES="5.4.0-ml.series"],
63 [LDISKFS_SERIES="5.4.0-ml.series"])
64 ], [test x$UBUNTU_KERNEL = xyes], [
65 AS_VERSION_COMPARE([$LINUXRELEASE],[5.3.0],[
66 AS_VERSION_COMPARE([$LINUXRELEASE],[5.0.0],[
67 AS_VERSION_COMPARE([$LINUXRELEASE],[4.15.0],[
68 AS_VERSION_COMPARE([$LINUXRELEASE],[4.4.0], [],
70 KPLEV=$(echo $LINUXRELEASE | sed -n 's/.*-\([0-9]\+\).*/\1/p')
73 AC_MSG_WARN([Failed to determine Kernel patch level. Assume latest.])
74 LDISKFS_SERIES="4.4.0-73-ubuntu14+16.series"
76 [test $KPLEV -ge 73], [LDISKFS_SERIES="4.4.0-73-ubuntu14+16.series"],
77 [test $KPLEV -ge 62], [LDISKFS_SERIES="4.4.0-62-ubuntu14+16.series"],
78 [test $KPLEV -ge 49], [LDISKFS_SERIES="4.4.0-49-ubuntu14+16.series"],
79 [LDISKFS_SERIES="4.4.0-45-ubuntu14+16.series"]
82 [LDISKFS_SERIES="4.4.0-73-ubuntu14+16.series"])],
84 KPLEV=$(echo $LINUXRELEASE | sed -n 's/.*-\([0-9]\+\).*/\1/p')
87 AC_MSG_WARN([Failed to determine Kernel patch level. Assume latest.])
88 LDISKFS_SERIES="4.15.0-24-ubuntu18.series"
90 [test $KPLEV -ge 24], [LDISKFS_SERIES="4.15.0-24-ubuntu18.series"],
91 [test $KPLEV -ge 20], [LDISKFS_SERIES="4.15.0-20-ubuntu18.series"]
94 [LDISKFS_SERIES="4.15.0-24-ubuntu18.series"])],
95 [LDISKFS_SERIES="5.0.0-13-ubuntu19.series"],
96 [LDISKFS_SERIES="5.0.0-13-ubuntu19.series"])],
97 [LDISKFS_SERIES="5.4.0-ml.series"],
98 [LDISKFS_SERIES="5.4.0-ml.series"])
101 # Not RHEL/SLES or Ubuntu .. probably mainline
102 AS_IF([test -z "$LDISKFS_SERIES"],
104 AS_VERSION_COMPARE([$LINUXRELEASE],[5.4.0],[],
105 [LDISKFS_SERIES="5.4.0-ml.series"],[
106 AS_VERSION_COMPARE([$LINUXRELEASE],[5.4.0],
107 [LDISKFS_SERIES="5.4.0-ml.series"], # lt
108 [LDISKFS_SERIES="5.4.0-ml.series"], # eq
109 [LDISKFS_SERIES="5.4.0-ml.series"] # gt
113 AS_IF([test -z "$LDISKFS_SERIES"],
114 [AC_MSG_RESULT([failed to identify series])],
115 [AC_MSG_RESULT([$LDISKFS_SERIES for $LINUXRELEASE])])
116 AC_SUBST(LDISKFS_SERIES)
117 ]) # LDISKFS_LINUX_SERIES
120 # LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD
122 # 2.6.32-rc7 ext4_free_blocks requires struct buffer_head
123 # Note that RHEL6 is pre 2.6.32-rc7 so this check is still needed.
125 AC_DEFUN([LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD], [
126 LB_CHECK_COMPILE([if 'ext4_free_blocks' needs 'struct buffer_head'],
127 ext4_free_blocks_with_buffer_head, [
128 #include <linux/fs.h>
129 #include "$EXT4_SRC_DIR/ext4.h"
131 ext4_free_blocks(NULL, NULL, NULL, 0, 0, 0);
133 AC_DEFINE(HAVE_EXT_FREE_BLOCK_WITH_BUFFER_HEAD, 1,
134 [ext4_free_blocks do not require struct buffer_head])
136 ]) # LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD
139 # LB_EXT4_JOURNAL_START_3ARGS
141 # 3.9 added a type argument to ext4_journal_start and friends
143 AC_DEFUN([LB_EXT4_JOURNAL_START_3ARGS], [
144 LB_CHECK_COMPILE([if ext4_journal_start takes 3 arguments],
145 ext4_journal_start, [
146 #include <linux/fs.h>
147 #include "$EXT4_SRC_DIR/ext4_jbd2.h"
149 ext4_journal_start(NULL, 0, 0);
151 AC_DEFINE(JOURNAL_START_HAS_3ARGS, 1, [ext4_journal_start takes 3 arguments])
153 ]) # LB_EXT4_JOURNAL_START_3ARGS
156 # LB_EXT4_BREAD_4ARGS
158 # 3.18 ext4_bread has 4 arguments
159 # NOTE: It may not be exported for modules, use a positive compiler test here.
161 AC_DEFUN([LB_EXT4_BREAD_4ARGS], [
162 LB_CHECK_COMPILE([if ext4_bread takes 4 arguments],
164 #include <linux/fs.h>
165 #include "$EXT4_SRC_DIR/ext4.h"
167 struct buffer_head *ext4_bread(handle_t *handle, struct inode *inode,
168 ext4_lblk_t block, int map_flags)
170 struct buffer_head *bh = NULL;
178 ext4_bread(NULL, NULL, 0, 0);
180 AC_DEFINE(HAVE_EXT4_BREAD_4ARGS, 1, [ext4_bread takes 4 arguments])
182 ]) # LB_EXT4_BREAD_4ARGS
185 # LB_EXT4_HAVE_INFO_DQUOT
187 # in linux 4.4 i_dqout is in ext4_inode_info, not in struct inode
189 AC_DEFUN([LB_EXT4_HAVE_INFO_DQUOT], [
190 LB_CHECK_COMPILE([if i_dquot is in ext4_inode_info],
192 #include <linux/fs.h>
193 #include <linux/quota.h>
194 #include "$EXT4_SRC_DIR/ext4.h"
196 struct ext4_inode_info in;
201 AC_DEFINE(HAVE_EXT4_INFO_DQUOT, 1, [i_dquot is in ext4_inode_info])
203 ]) # LB_EXT4_HAVE_INFO_DQUOT
206 # LB_EXT4_HAVE_I_CRYPT_INFO
208 # in linux 4.8 i_crypt_info moved from ext4_inode_info to struct inode
210 # Determine if we need to enable CONFIG_LDISKFS_FS_ENCRYPTION.
211 # If we have i_crypt_info in ext4_inode_info, the config option
212 # should be enabled to make the ldiskfs module compilation happy.
213 # Otherwise i_crypy_info is in struct inode, we need to check kernel
214 # config option to determine that.
216 AC_DEFUN([LB_EXT4_HAVE_I_CRYPT_INFO], [
217 LB_CHECK_COMPILE([if i_crypt_info is in ext4_inode_info],
219 #define CONFIG_EXT4_FS_ENCRYPTION 1
220 #include <linux/fs.h>
221 #include "$EXT4_SRC_DIR/ext4.h"
223 struct ext4_inode_info in;
225 in.i_crypt_info = NULL;
228 CONFIG_LDISKFS_FS_ENCRYPTION, 1,
229 [enable encryption for ldiskfs]
232 LB_CHECK_CONFIG([EXT4_FS_ENCRYPTION],[
234 CONFIG_LDISKFS_FS_ENCRYPTION, 1,
235 [enable encryption for ldiskfs]
239 ]) # LB_EXT4_HAVE_I_CRYPT_INFO
242 # LB_LDISKFS_IGET_HAS_FLAGS_ARG
244 # kernel 4.19 commit 8a363970d1dc38c4ec4ad575c862f776f468d057
245 # ext4_iget changed to a macro with 3 args was function with 2 args
247 AC_DEFUN([LB_LDISKFS_IGET_HAS_FLAGS_ARG], [
248 tmp_flags="$EXTRA_KCFLAGS"
249 EXTRA_KCFLAGS="-Werror"
250 LB_CHECK_COMPILE([if ldiskfs_iget takes a flags argument],
252 #include <linux/fs.h>
253 #include "$EXT4_SRC_DIR/ext4.h"
255 int f = EXT4_IGET_SPECIAL;
258 AC_DEFINE(HAVE_LDISKFS_IGET_WITH_FLAGS, 1,
259 [if ldiskfs_iget takes a flags argument])
261 EXTRA_KCFLAGS="$tmp_flags"
262 ]) # LB_LDISKFS_IGET_HAS_FLAGS_ARG
265 # LDISKFS_AC_PATCH_PROGRAM
267 # Determine which program should be used to apply the patches to
268 # the ext4 source code to produce the ldiskfs source code.
270 AC_DEFUN([LDISKFS_AC_PATCH_PROGRAM], [
271 AC_ARG_ENABLE([quilt],
272 [AC_HELP_STRING([--disable-quilt],
273 [disable use of quilt for ldiskfs])],
274 [AS_IF([test "x$enableval" = xno],
280 AS_IF([test x$use_quilt = xmaybe], [
281 AC_PATH_PROG([quilt_avail], [quilt], [no])
282 AS_IF([test x$quilt_avail = xno], [
289 AS_IF([test x$use_quilt = xno], [
290 AC_PATH_PROG([patch_avail], [patch], [no])
291 AS_IF([test x$patch_avail = xno], [
292 AC_MSG_ERROR([*** Need "quilt" or "patch" command])
295 ]) # LDISKFS_AC_PATCH_PROGRAM
298 # LB_LDISKFS_FIND_ENTRY_LOCKED_EXISTS
300 # kernel 5.2 commit 8a363970d1dc38c4ec4ad575c862f776f468d057
301 # ext4: avoid declaring fs inconsistent due to invalid file handles
302 # __ext4_find_entry became a helper function for ext4_find_entry
303 # conflicting with previous ldiskfs patches.
304 # ldiskfs patches map ext4_find_entry to ldiskfs_find_entry_locked to
305 # avoid conflicting with __ext4_find_entry
307 # When the following check succeeds __ext4_find_entry helper is not
310 AC_DEFUN([LB_LDISKFS_FIND_ENTRY_LOCKED_EXISTS], [
311 tmp_flags="$EXTRA_KCFLAGS"
312 EXTRA_KCFLAGS="-Werror"
313 LB_CHECK_COMPILE([if __ldiskfs_find_entry is available],
314 ldiskfs_find_entry_locked, [
315 #include <linux/fs.h>
316 #include "$EXT4_SRC_DIR/ext4.h"
317 #include "$EXT4_SRC_DIR/namei.c"
319 static int __ext4_find_entry(void) { return 0; }
321 int x = __ext4_find_entry();
324 AC_DEFINE(HAVE___LDISKFS_FIND_ENTRY, 1,
325 [if __ldiskfs_find_entry is available])
327 EXTRA_KCFLAGS="$tmp_flags"
328 ]) # LB_LDISKFS_FIND_ENTRY_LOCKED_EXISTS
331 # LB_LDISKFSFS_DIRHASH_WANTS_DIR
333 # kernel 5.2 commit 8a363970d1dc38c4ec4ad575c862f776f468d057
334 # ext4fs_dirhash UNICODE support
336 AC_DEFUN([LB_LDISKFSFS_DIRHASH_WANTS_DIR], [
337 tmp_flags="$EXTRA_KCFLAGS"
338 EXTRA_KCFLAGS="-Werror"
339 LB_CHECK_COMPILE([if ldiskfsfs_dirhash takes an inode argument],
341 #include <linux/fs.h>
342 #include "$EXT4_SRC_DIR/ext4.h"
344 int ext4fs_dirhash(const struct inode *dir, const char *name, int len,
345 struct dx_hash_info *hinfo)
354 int f = ext4fs_dirhash(NULL, NULL, 0, NULL);
357 AC_DEFINE(HAVE_LDISKFSFS_GETHASH_INODE_ARG, 1,
358 [if ldiskfsfs_dirhash takes an inode argument])
360 EXTRA_KCFLAGS="$tmp_flags"
361 ]) # LB_LDISKFSFS_DIRHASH_WANTS_DIR
366 AC_DEFUN([LB_CONFIG_LDISKFS], [
367 # --with-ldiskfs is deprecated now that ldiskfs is fully merged with lustre.
368 # However we continue to support this option through Lustre 2.5.
369 AC_ARG_WITH([ldiskfs],
371 [AC_MSG_WARN([--with-ldiskfs is deprecated, please use --enable-ldiskfs])
372 AS_IF([test x$withval != xyes -a x$withval != xno],
375 The ldiskfs option is deprecated,
376 and no longer supports paths to external ldiskfs source
380 AC_ARG_ENABLE([ldiskfs],
381 [AS_HELP_STRING([--disable-ldiskfs],
382 [disable ldiskfs osd (default is enable)])],
383 [AS_IF([test x$enable_ldiskfs != xyes -a x$enable_ldiskfs != xno],
384 [AC_MSG_ERROR([ldiskfs valid options are "yes" or "no"])])],
385 [AS_IF([test "${with_ldiskfs+set}" = set],
386 [enable_ldiskfs=$with_ldiskfs],
387 [enable_ldiskfs=maybe])
390 AS_IF([test x$enable_server = xno],
391 [AS_CASE([$enable_ldiskfs],
392 [maybe], [enable_ldiskfs=no],
393 [yes], [AC_MSG_ERROR([cannot build ldiskfs when servers are disabled])]
396 AS_IF([test x$enable_ldiskfs != xno],[
397 # In the future, we chould change enable_ldiskfs from maybe to
398 # either yes or no based on additional tests, e.g. whether a patch
399 # set is available for the detected kernel. For now, we just always
401 AS_IF([test x$enable_ldiskfs = xmaybe], [enable_ldiskfs=yes])
402 AC_SUBST(ENABLE_LDISKFS, yes)
405 LDISKFS_AC_PATCH_PROGRAM
406 LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD
407 LB_EXT4_JOURNAL_START_3ARGS
409 LB_EXT4_HAVE_INFO_DQUOT
410 LB_EXT4_HAVE_I_CRYPT_INFO
411 LB_LDISKFS_IGET_HAS_FLAGS_ARG
412 LB_LDISKFS_FIND_ENTRY_LOCKED_EXISTS
413 LB_LDISKFSFS_DIRHASH_WANTS_DIR
414 AC_DEFINE(CONFIG_LDISKFS_FS_POSIX_ACL, 1, [posix acls for ldiskfs])
415 AC_DEFINE(CONFIG_LDISKFS_FS_SECURITY, 1, [fs security for ldiskfs])
416 AC_DEFINE(CONFIG_LDISKFS_FS_XATTR, 1, [extened attributes for ldiskfs])
417 AC_DEFINE(CONFIG_LDISKFS_FS_RW, 1, [enable rw access for ldiskfs])
418 AC_SUBST(LDISKFS_SUBDIR, ldiskfs)
419 AC_DEFINE(HAVE_LDISKFS_OSD, 1, Enable ldiskfs osd)
421 AC_SUBST(ENABLE_LDISKFS, no)
424 AC_MSG_CHECKING([whether to build ldiskfs])
425 AC_MSG_RESULT([$enable_ldiskfs])
427 AM_CONDITIONAL([LDISKFS_ENABLED], [test x$enable_ldiskfs = xyes])
428 ]) # LB_CONFIG_LDISKFS
431 # LB_VALIDATE_EXT4_SRC_DIR
433 # Spot check the existence of several source files common to ext4.
434 # Detecting this at configure time allows us to avoid a potential build
435 # failure and provide a useful error message to explain what is wrong.
437 AC_DEFUN([LB_VALIDATE_EXT4_SRC_DIR], [
438 enable_ldiskfs_build="no"
439 AS_IF([test -n "$EXT4_SRC_DIR"], [
440 enable_ldiskfs_build="yes"
441 LB_CHECK_FILE([$EXT4_SRC_DIR/dir.c], [], [
442 enable_ldiskfs_build="no"
443 AC_MSG_WARN([ext4 must exist for ldiskfs build])
445 LB_CHECK_FILE([$EXT4_SRC_DIR/file.c], [], [
446 enable_ldiskfs_build="no"
447 AC_MSG_WARN([ext4 must exist for ldiskfs build])
449 LB_CHECK_FILE([$EXT4_SRC_DIR/inode.c], [], [
450 enable_ldiskfs_build="no"
451 AC_MSG_WARN([ext4 must exist for ldiskfs build])
453 LB_CHECK_FILE([$EXT4_SRC_DIR/super.c], [], [
454 enable_ldiskfs_build="no"
455 AC_MSG_WARN([ext4 must exist for ldiskfs build])
459 AS_IF([test "x$enable_ldiskfs_build" = xno], [
464 Disabling ldiskfs support because complete ext4 source does not exist.
466 If you are building using kernel-devel packages and require ldiskfs
467 server support then ensure that the matching kernel-debuginfo-common
468 and kernel-debuginfo-common-<arch> packages are installed.
471 ]) # LB_VALIDATE_EXT4_SRC_DIR
476 # Determine the location of the ext4 source code. It it required
477 # for several configure tests and to build ldiskfs.
479 AC_DEFUN([LB_EXT4_SRC_DIR], [
480 AC_MSG_CHECKING([ext4 source directory])
481 # Kernel ext source located with devel headers
483 AS_IF([test -e "$linux_src/fs/ext4/super.c"], [
484 EXT4_SRC_DIR="$linux_src/fs/ext4"
486 # Kernel ext source provided by kernel-debuginfo-common package
487 # that extracted to $LINUX
488 linux_src=$(ls -1d $linux_src/../../debug/*/linux-${LINUXRELEASE%.*}* \
489 2>/dev/null | tail -1)
490 AS_IF([test -e "$linux_src/fs/ext4/super.c"], [
491 EXT4_SRC_DIR="$linux_src/fs/ext4"
493 # Kernel ext source provided by kernel-debuginfo-common package
494 linux_src=$(ls -1d /usr/src/debug/*/linux-${LINUXRELEASE%.*}* \
495 2>/dev/null | tail -1)
496 AS_IF([test -e "$linux_src/fs/ext4/super.c"], [
497 EXT4_SRC_DIR="$linux_src/fs/ext4"
503 AC_MSG_RESULT([$EXT4_SRC_DIR])
504 AC_SUBST(EXT4_SRC_DIR)
506 LB_VALIDATE_EXT4_SRC_DIR
510 # LB_DEFINE_E2FSPROGS_NAMES
512 # Enable the use of alternate naming of ldiskfs-enabled e2fsprogs package.
514 AC_DEFUN([LB_DEFINE_E2FSPROGS_NAMES], [
515 AC_MSG_CHECKING([whether to use alternate names for e2fsprogs])
516 AC_ARG_WITH([ldiskfsprogs],
517 AC_HELP_STRING([--with-ldiskfsprogs],
518 [use alternate names for ldiskfs-enabled e2fsprogs]),
521 AS_IF([test "x$withval" = xyes], [
522 AC_MSG_RESULT([enabled])
523 AC_DEFINE(HAVE_LDISKFSPROGS, 1, [enable use of ldiskfsprogs package])
524 E2FSPROGS="ldiskfsprogs"
525 MKE2FS="mkfs.ldiskfs"
526 DEBUGFS="debugfs.ldiskfs"
527 TUNE2FS="tunefs.ldiskfs"
528 E2LABEL="label.ldiskfs"
529 DUMPE2FS="dumpfs.ldiskfs"
530 E2FSCK="fsck.ldiskfs"
531 PFSCK="pfsck.ldiskfs"
533 AC_MSG_RESULT([disabled])
534 E2FSPROGS="e2fsprogs"
544 AC_DEFINE_UNQUOTED(E2FSPROGS, "$E2FSPROGS", [name of ldiskfs e2fsprogs package])
545 AC_DEFINE_UNQUOTED(MKE2FS, "$MKE2FS", [name of ldiskfs mkfs program])
546 AC_DEFINE_UNQUOTED(DEBUGFS, "$DEBUGFS", [name of ldiskfs debug program])
547 AC_DEFINE_UNQUOTED(TUNE2FS, "$TUNE2FS", [name of ldiskfs tune program])
548 AC_DEFINE_UNQUOTED(E2LABEL, "$E2LABEL", [name of ldiskfs label program])
549 AC_DEFINE_UNQUOTED(DUMPE2FS,"$DUMPE2FS", [name of ldiskfs dump program])
550 AC_DEFINE_UNQUOTED(E2FSCK, "$E2FSCK", [name of ldiskfs fsck program])
551 AC_DEFINE_UNQUOTED(PFSCK, "$PFSCK", [name of parallel fsck program])
553 AC_SUBST([E2FSPROGS], [$E2FSPROGS])
554 AC_SUBST([MKE2FS], [$MKE2FS])
555 AC_SUBST([DEBUGFS], [$DEBUGFS])
556 AC_SUBST([TUNE2FS], [$TUNE2FS])
557 AC_SUBST([E2LABEL], [$E2LABEL])
558 AC_SUBST([DUMPE2FS], [$DUMPE2FS])
559 AC_SUBST([E2FSCK], [$E2FSCK])
560 AC_SUBST([PFSCK], [$PFSCK])
561 ]) # LB_DEFINE_E2FSPROGS_NAMES