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_LDISKFS_FIND_ENTRY_LOCKED_EXISTS
280 # kernel 5.2 commit 8a363970d1dc38c4ec4ad575c862f776f468d057
281 # ext4: avoid declaring fs inconsistent due to invalid file handles
282 # __ext4_find_entry became a helper function for ext4_find_entry
283 # conflicting with previous ldiskfs patches.
284 # ldiskfs patches map ext4_find_entry to ldiskfs_find_entry_locked to
285 # avoid conflicting with __ext4_find_entry
287 # When the following check succeeds __ext4_find_entry helper is not
290 AC_DEFUN([LB_LDISKFS_FIND_ENTRY_LOCKED_EXISTS], [
291 tmp_flags="$EXTRA_KCFLAGS"
292 EXTRA_KCFLAGS="-Werror"
293 LB_CHECK_COMPILE([if __ldiskfs_find_entry is available],
294 ldiskfs_find_entry_locked, [
295 #include <linux/fs.h>
296 #include "$EXT4_SRC_DIR/ext4.h"
297 #include "$EXT4_SRC_DIR/namei.c"
299 static int __ext4_find_entry(void) { return 0; }
301 int x = __ext4_find_entry();
304 AC_DEFINE(HAVE___LDISKFS_FIND_ENTRY, 1,
305 [if __ldiskfs_find_entry is available])
307 EXTRA_KCFLAGS="$tmp_flags"
308 ]) # LB_LDISKFS_FIND_ENTRY_LOCKED_EXISTS
311 # LB_LDISKFSFS_DIRHASH_WANTS_DIR
313 # kernel 5.2 commit 8a363970d1dc38c4ec4ad575c862f776f468d057
314 # ext4fs_dirhash UNICODE support
316 AC_DEFUN([LB_LDISKFSFS_DIRHASH_WANTS_DIR], [
317 tmp_flags="$EXTRA_KCFLAGS"
318 EXTRA_KCFLAGS="-Werror"
319 LB_CHECK_COMPILE([if ldiskfsfs_dirhash takes an inode argument],
321 #include <linux/fs.h>
322 #include "$EXT4_SRC_DIR/ext4.h"
324 int ext4fs_dirhash(const struct inode *dir, const char *name, int len,
325 struct dx_hash_info *hinfo)
334 int f = ext4fs_dirhash(NULL, NULL, 0, NULL);
337 AC_DEFINE(HAVE_LDISKFSFS_GETHASH_INODE_ARG, 1,
338 [if ldiskfsfs_dirhash takes an inode argument])
340 EXTRA_KCFLAGS="$tmp_flags"
341 ]) # LB_LDISKFSFS_DIRHASH_WANTS_DIR
346 AC_DEFUN([LB_CONFIG_LDISKFS], [
347 # --with-ldiskfs is deprecated now that ldiskfs is fully merged with lustre.
348 # However we continue to support this option through Lustre 2.5.
349 AC_ARG_WITH([ldiskfs],
351 [AC_MSG_WARN([--with-ldiskfs is deprecated, please use --enable-ldiskfs])
352 AS_IF([test x$withval != xyes -a x$withval != xno],
355 The ldiskfs option is deprecated,
356 and no longer supports paths to external ldiskfs source
360 AC_ARG_ENABLE([ldiskfs],
361 [AS_HELP_STRING([--disable-ldiskfs],
362 [disable ldiskfs osd (default is enable)])],
363 [AS_IF([test x$enable_ldiskfs != xyes -a x$enable_ldiskfs != xno],
364 [AC_MSG_ERROR([ldiskfs valid options are "yes" or "no"])])],
365 [AS_IF([test "${with_ldiskfs+set}" = set],
366 [enable_ldiskfs=$with_ldiskfs],
367 [enable_ldiskfs=maybe])
370 AS_IF([test x$enable_server = xno],
371 [AS_CASE([$enable_ldiskfs],
372 [maybe], [enable_ldiskfs=no],
373 [yes], [AC_MSG_ERROR([cannot build ldiskfs when servers are disabled])]
376 AS_IF([test x$enable_ldiskfs != xno],[
377 # In the future, we chould change enable_ldiskfs from maybe to
378 # either yes or no based on additional tests, e.g. whether a patch
379 # set is available for the detected kernel. For now, we just always
381 AS_IF([test x$enable_ldiskfs = xmaybe], [enable_ldiskfs=yes])
382 AC_SUBST(ENABLE_LDISKFS, yes)
385 LDISKFS_AC_PATCH_PROGRAM
386 LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD
387 LB_EXT4_JOURNAL_START_3ARGS
389 LB_EXT4_HAVE_INFO_DQUOT
390 LB_EXT4_HAVE_I_CRYPT_INFO
391 LB_LDISKFS_IGET_HAS_FLAGS_ARG
392 LB_LDISKFS_FIND_ENTRY_LOCKED_EXISTS
393 LB_LDISKFSFS_DIRHASH_WANTS_DIR
394 AC_DEFINE(CONFIG_LDISKFS_FS_POSIX_ACL, 1, [posix acls for ldiskfs])
395 AC_DEFINE(CONFIG_LDISKFS_FS_SECURITY, 1, [fs security for ldiskfs])
396 AC_DEFINE(CONFIG_LDISKFS_FS_XATTR, 1, [extened attributes for ldiskfs])
397 AC_DEFINE(CONFIG_LDISKFS_FS_RW, 1, [enable rw access for ldiskfs])
398 AC_SUBST(LDISKFS_SUBDIR, ldiskfs)
399 AC_DEFINE(HAVE_LDISKFS_OSD, 1, Enable ldiskfs osd)
401 AC_SUBST(ENABLE_LDISKFS, no)
404 AC_MSG_CHECKING([whether to build ldiskfs])
405 AC_MSG_RESULT([$enable_ldiskfs])
407 AM_CONDITIONAL([LDISKFS_ENABLED], [test x$enable_ldiskfs = xyes])
408 ]) # LB_CONFIG_LDISKFS
411 # LB_VALIDATE_EXT4_SRC_DIR
413 # Spot check the existence of several source files common to ext4.
414 # Detecting this at configure time allows us to avoid a potential build
415 # failure and provide a useful error message to explain what is wrong.
417 AC_DEFUN([LB_VALIDATE_EXT4_SRC_DIR], [
418 enable_ldiskfs_build="no"
419 AS_IF([test -n "$EXT4_SRC_DIR"], [
420 enable_ldiskfs_build="yes"
421 LB_CHECK_FILE([$EXT4_SRC_DIR/dir.c], [], [
422 enable_ldiskfs_build="no"
423 AC_MSG_WARN([ext4 must exist for ldiskfs build])
425 LB_CHECK_FILE([$EXT4_SRC_DIR/file.c], [], [
426 enable_ldiskfs_build="no"
427 AC_MSG_WARN([ext4 must exist for ldiskfs build])
429 LB_CHECK_FILE([$EXT4_SRC_DIR/inode.c], [], [
430 enable_ldiskfs_build="no"
431 AC_MSG_WARN([ext4 must exist for ldiskfs build])
433 LB_CHECK_FILE([$EXT4_SRC_DIR/super.c], [], [
434 enable_ldiskfs_build="no"
435 AC_MSG_WARN([ext4 must exist for ldiskfs build])
439 AS_IF([test "x$enable_ldiskfs_build" = xno], [
444 Disabling ldiskfs support because complete ext4 source does not exist.
446 If you are building using kernel-devel packages and require ldiskfs
447 server support then ensure that the matching kernel-debuginfo-common
448 and kernel-debuginfo-common-<arch> packages are installed.
451 ]) # LB_VALIDATE_EXT4_SRC_DIR
456 # Determine the location of the ext4 source code. It it required
457 # for several configure tests and to build ldiskfs.
459 AC_DEFUN([LB_EXT4_SRC_DIR], [
460 AC_MSG_CHECKING([ext4 source directory])
461 # Kernel ext source located with devel headers
463 AS_IF([test -e "$linux_src/fs/ext4/super.c"], [
464 EXT4_SRC_DIR="$linux_src/fs/ext4"
466 # Kernel ext source provided by kernel-debuginfo-common package
467 # that extracted to $LINUX
468 linux_src=$(ls -1d $linux_src/../../debug/*/linux-${LINUXRELEASE%.*}* \
469 2>/dev/null | tail -1)
470 AS_IF([test -e "$linux_src/fs/ext4/super.c"], [
471 EXT4_SRC_DIR="$linux_src/fs/ext4"
473 # Kernel ext source provided by kernel-debuginfo-common package
474 linux_src=$(ls -1d /usr/src/debug/*/linux-${LINUXRELEASE%.*}* \
475 2>/dev/null | tail -1)
476 AS_IF([test -e "$linux_src/fs/ext4/super.c"], [
477 EXT4_SRC_DIR="$linux_src/fs/ext4"
483 AC_MSG_RESULT([$EXT4_SRC_DIR])
484 AC_SUBST(EXT4_SRC_DIR)
486 LB_VALIDATE_EXT4_SRC_DIR
490 # LB_DEFINE_E2FSPROGS_NAMES
492 # Enable the use of alternate naming of ldiskfs-enabled e2fsprogs package.
494 AC_DEFUN([LB_DEFINE_E2FSPROGS_NAMES], [
495 AC_MSG_CHECKING([whether to use alternate names for e2fsprogs])
496 AC_ARG_WITH([ldiskfsprogs],
497 AC_HELP_STRING([--with-ldiskfsprogs],
498 [use alternate names for ldiskfs-enabled e2fsprogs]),
501 AS_IF([test "x$withval" = xyes], [
502 AC_MSG_RESULT([enabled])
503 AC_DEFINE(HAVE_LDISKFSPROGS, 1, [enable use of ldiskfsprogs package])
504 E2FSPROGS="ldiskfsprogs"
505 MKE2FS="mkfs.ldiskfs"
506 DEBUGFS="debugfs.ldiskfs"
507 TUNE2FS="tunefs.ldiskfs"
508 E2LABEL="label.ldiskfs"
509 DUMPE2FS="dumpfs.ldiskfs"
510 E2FSCK="fsck.ldiskfs"
511 PFSCK="pfsck.ldiskfs"
513 AC_MSG_RESULT([disabled])
514 E2FSPROGS="e2fsprogs"
524 AC_DEFINE_UNQUOTED(E2FSPROGS, "$E2FSPROGS", [name of ldiskfs e2fsprogs package])
525 AC_DEFINE_UNQUOTED(MKE2FS, "$MKE2FS", [name of ldiskfs mkfs program])
526 AC_DEFINE_UNQUOTED(DEBUGFS, "$DEBUGFS", [name of ldiskfs debug program])
527 AC_DEFINE_UNQUOTED(TUNE2FS, "$TUNE2FS", [name of ldiskfs tune program])
528 AC_DEFINE_UNQUOTED(E2LABEL, "$E2LABEL", [name of ldiskfs label program])
529 AC_DEFINE_UNQUOTED(DUMPE2FS,"$DUMPE2FS", [name of ldiskfs dump program])
530 AC_DEFINE_UNQUOTED(E2FSCK, "$E2FSCK", [name of ldiskfs fsck program])
531 AC_DEFINE_UNQUOTED(PFSCK, "$PFSCK", [name of parallel fsck program])
533 AC_SUBST([E2FSPROGS], [$E2FSPROGS])
534 AC_SUBST([MKE2FS], [$MKE2FS])
535 AC_SUBST([DEBUGFS], [$DEBUGFS])
536 AC_SUBST([TUNE2FS], [$TUNE2FS])
537 AC_SUBST([E2LABEL], [$E2LABEL])
538 AC_SUBST([DUMPE2FS], [$DUMPE2FS])
539 AC_SUBST([E2FSCK], [$E2FSCK])
540 AC_SUBST([PFSCK], [$PFSCK])
541 ]) # LB_DEFINE_E2FSPROGS_NAMES