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 77) LDISKFS_SERIES="3.10-rhel7.7.series" ;;
18 76) LDISKFS_SERIES="3.10-rhel7.6.series" ;;
19 75) LDISKFS_SERIES="3.10-rhel7.5.series" ;;
20 74) LDISKFS_SERIES="3.10-rhel7.4.series" ;;
21 73) LDISKFS_SERIES="3.10-rhel7.3.series" ;;
22 72) LDISKFS_SERIES="3.10-rhel7.2.series" ;;
23 71) LDISKFS_SERIES="3.10-rhel7.series" ;;
24 69) LDISKFS_SERIES="2.6-rhel6.9.series" ;;
25 68) LDISKFS_SERIES="2.6-rhel6.8.series" ;;
26 67) LDISKFS_SERIES="2.6-rhel6.7.series" ;;
27 66) LDISKFS_SERIES="2.6-rhel6.6.series" ;;
28 65) LDISKFS_SERIES="2.6-rhel6.5.series" ;;
29 64) LDISKFS_SERIES="2.6-rhel6.4.series" ;;
30 6[0-3]) LDISKFS_SERIES="2.6-rhel6.series" ;;
32 ], [test x$SUSE_KERNEL = xyes], [
33 AS_VERSION_COMPARE([$LINUXRELEASE],[4.4.82],[
34 AS_VERSION_COMPARE([$LINUXRELEASE],[4.4.0],[
35 AS_VERSION_COMPARE([$LINUXRELEASE],[3.12.0],[
36 AS_VERSION_COMPARE([$LINUXRELEASE],[3.0.0],[
37 AS_VERSION_COMPARE([$LINUXRELEASE],[2.6.32], [],
38 [LDISKFS_SERIES="2.6-sles11.series"],[LDISKFS_SERIES="2.6-sles11.series"])],
39 [LDISKFS_SERIES="3.0-sles11.series"],[
40 PLEV=$(grep PATCHLEVEL /etc/SuSE-release | sed -e 's/.*= *//')
42 2) LDISKFS_SERIES="3.0-sles11.series"
44 3) LDISKFS_SERIES="3.0-sles11sp3.series"
46 4) LDISKFS_SERIES="3.0-sles11sp4.series"
49 ])],[LDISKFS_SERIES="3.12-sles12.series"],[
50 PLEV=$(grep PATCHLEVEL /etc/SuSE-release | sed -e 's/.*= *//')
52 1) LDISKFS_SERIES="3.12-sles12sp1.series"
54 *) LDISKFS_SERIES="3.12-sles12.series"
57 ])],[LDISKFS_SERIES="4.4-sles12sp2.series"],
58 [LDISKFS_SERIES="4.4-sles12sp2.series"]
59 )], [LDISKFS_SERIES="4.4-sles12sp3.series"],
60 [LDISKFS_SERIES="4.4-sles12sp3.series"])
61 ], [test x$UBUNTU_KERNEL = xyes], [
62 AS_VERSION_COMPARE([$LINUXRELEASE],[5.0.0],[
63 AS_VERSION_COMPARE([$LINUXRELEASE],[4.15.0],[
64 AS_VERSION_COMPARE([$LINUXRELEASE],[4.4.0], [],
66 KPLEV=$(echo $LINUXRELEASE | sed -n 's/.*-\([0-9]\+\).*/\1/p')
69 AC_MSG_WARN([Failed to determine Kernel patch level. Assume latest.])
70 LDISKFS_SERIES="4.4.0-73-ubuntu14+16.series"
72 [test $KPLEV -ge 73], [LDISKFS_SERIES="4.4.0-73-ubuntu14+16.series"],
73 [test $KPLEV -ge 62], [LDISKFS_SERIES="4.4.0-62-ubuntu14+16.series"],
74 [test $KPLEV -ge 49], [LDISKFS_SERIES="4.4.0-49-ubuntu14+16.series"],
75 [LDISKFS_SERIES="4.4.0-45-ubuntu14+16.series"]
78 [LDISKFS_SERIES="4.4.0-73-ubuntu14+16.series"])],
80 KPLEV=$(echo $LINUXRELEASE | sed -n 's/.*-\([0-9]\+\).*/\1/p')
83 AC_MSG_WARN([Failed to determine Kernel patch level. Assume latest.])
84 LDISKFS_SERIES="4.15.0-24-ubuntu18.series"
86 [test $KPLEV -ge 24], [LDISKFS_SERIES="4.15.0-24-ubuntu18.series"],
87 [test $KPLEV -ge 20], [LDISKFS_SERIES="4.15.0-20-ubuntu18.series"]
90 [LDISKFS_SERIES="4.15.0-24-ubuntu18.series"])],
91 [LDISKFS_SERIES="5.0.0-13-ubuntu19.series"],
92 [LDISKFS_SERIES="5.0.0-13-ubuntu19.series"])
95 AS_IF([test -z "$LDISKFS_SERIES"],
96 [AC_MSG_RESULT([failed to identify series])],
97 [AC_MSG_RESULT([$LDISKFS_SERIES])])
98 AC_SUBST(LDISKFS_SERIES)
99 ]) # LDISKFS_LINUX_SERIES
102 # LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD
104 # 2.6.32-rc7 ext4_free_blocks requires struct buffer_head
105 # Note that RHEL6 is pre 2.6.32-rc7 so this check is still needed.
107 AC_DEFUN([LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD], [
108 LB_CHECK_COMPILE([if 'ext4_free_blocks' needs 'struct buffer_head'],
109 ext4_free_blocks_with_buffer_head, [
110 #include <linux/fs.h>
111 #include "$EXT4_SRC_DIR/ext4.h"
113 ext4_free_blocks(NULL, NULL, NULL, 0, 0, 0);
115 AC_DEFINE(HAVE_EXT_FREE_BLOCK_WITH_BUFFER_HEAD, 1,
116 [ext4_free_blocks do not require struct buffer_head])
118 ]) # LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD
121 # LB_EXT4_JOURNAL_START_3ARGS
123 # 3.9 added a type argument to ext4_journal_start and friends
125 AC_DEFUN([LB_EXT4_JOURNAL_START_3ARGS], [
126 LB_CHECK_COMPILE([if ext4_journal_start takes 3 arguments],
127 ext4_journal_start, [
128 #include <linux/fs.h>
129 #include "$EXT4_SRC_DIR/ext4_jbd2.h"
131 ext4_journal_start(NULL, 0, 0);
133 AC_DEFINE(JOURNAL_START_HAS_3ARGS, 1, [ext4_journal_start takes 3 arguments])
135 ]) # LB_EXT4_JOURNAL_START_3ARGS
138 # LB_EXT4_BREAD_4ARGS
140 # 3.18 ext4_bread has 4 arguments
142 AC_DEFUN([LB_EXT4_BREAD_4ARGS], [
143 LB_CHECK_COMPILE([if ext4_bread takes 4 arguments],
145 #include <linux/fs.h>
146 #include "$EXT4_SRC_DIR/ext4.h"
148 ext4_bread(NULL, NULL, 0, 0);
150 AC_DEFINE(HAVE_EXT4_BREAD_4ARGS, 1, [ext4_bread takes 4 arguments])
152 ]) # LB_EXT4_BREAD_4ARGS
155 # LB_EXT4_HAVE_INFO_DQUOT
157 # in linux 4.4 i_dqout is in ext4_inode_info, not in struct inode
159 AC_DEFUN([LB_EXT4_HAVE_INFO_DQUOT], [
160 LB_CHECK_COMPILE([if i_dquot is in ext4_inode_info],
162 #include <linux/fs.h>
163 #include <linux/quota.h>
164 #include "$EXT4_SRC_DIR/ext4.h"
166 struct ext4_inode_info in;
171 AC_DEFINE(HAVE_EXT4_INFO_DQUOT, 1, [i_dquot is in ext4_inode_info])
173 ]) # LB_EXT4_HAVE_INFO_DQUOT
176 # LB_EXT4_HAVE_I_CRYPT_INFO
178 # in linux 4.8 i_crypt_info moved from ext4_inode_info to struct inode
180 # Determine if we need to enable CONFIG_LDISKFS_FS_ENCRYPTION.
181 # If we have i_crypt_info in ext4_inode_info, the config option
182 # should be enabled to make the ldiskfs module compilation happy.
183 # Otherwise i_crypy_info is in struct inode, we need to check kernel
184 # config option to determine that.
186 AC_DEFUN([LB_EXT4_HAVE_I_CRYPT_INFO], [
187 LB_CHECK_COMPILE([if i_crypt_info is in ext4_inode_info],
189 #define CONFIG_EXT4_FS_ENCRYPTION 1
190 #include <linux/fs.h>
191 #include "$EXT4_SRC_DIR/ext4.h"
193 struct ext4_inode_info in;
195 in.i_crypt_info = NULL;
198 CONFIG_LDISKFS_FS_ENCRYPTION, 1,
199 [enable encryption for ldiskfs]
202 LB_CHECK_CONFIG([EXT4_FS_ENCRYPTION],[
204 CONFIG_LDISKFS_FS_ENCRYPTION, 1,
205 [enable encryption for ldiskfs]
209 ]) # LB_EXT4_HAVE_I_CRYPT_INFO
212 # LB_LDISKFS_IGET_HAS_FLAGS_ARG
214 # kernel 4.19 commit 8a363970d1dc38c4ec4ad575c862f776f468d057
215 # ext4_iget changed to a macro with 3 args was function with 2 args
217 AC_DEFUN([LB_LDISKFS_IGET_HAS_FLAGS_ARG], [
218 tmp_flags="$EXTRA_KCFLAGS"
219 EXTRA_KCFLAGS="-Werror"
220 LB_CHECK_COMPILE([if ldiskfs_iget takes a flags argument],
222 #include <linux/fs.h>
223 #include "$EXT4_SRC_DIR/ext4.h"
225 int f = EXT4_IGET_SPECIAL;
228 AC_DEFINE(HAVE_LDISKFS_IGET_WITH_FLAGS, 1,
229 [if ldiskfs_iget takes a flags argument])
231 EXTRA_KCFLAGS="$tmp_flags"
232 ]) # LB_LDISKFS_IGET_HAS_FLAGS_ARG
235 # LDISKFS_AC_PATCH_PROGRAM
237 # Determine which program should be used to apply the patches to
238 # the ext4 source code to produce the ldiskfs source code.
240 AC_DEFUN([LDISKFS_AC_PATCH_PROGRAM], [
241 AC_ARG_ENABLE([quilt],
242 [AC_HELP_STRING([--disable-quilt],
243 [disable use of quilt for ldiskfs])],
244 [AS_IF([test "x$enableval" = xno],
250 AS_IF([test x$use_quilt = xmaybe], [
251 AC_PATH_PROG([quilt_avail], [quilt], [no])
252 AS_IF([test x$quilt_avail = xno], [
259 AS_IF([test x$use_quilt = xno], [
260 AC_PATH_PROG([patch_avail], [patch], [no])
261 AS_IF([test x$patch_avail = xno], [
262 AC_MSG_ERROR([*** Need "quilt" or "patch" command])
265 ]) # LDISKFS_AC_PATCH_PROGRAM
268 # LB_HAVE_BVEC_ITER_ALL
270 # kernel 5.1 commit 6dc4f100c175dd0511ae8674786e7c9006cdfbfa
271 # block: allow bio_for_each_segment_all() to iterate over multi-page bvec
273 AC_DEFUN([LB_HAVE_BVEC_ITER_ALL], [
274 tmp_flags="$EXTRA_KCFLAGS"
275 EXTRA_KCFLAGS="-Werror"
276 LB_CHECK_COMPILE([if bvec_iter_all exists for multi-page bvec iternation],
278 #include <linux/bvec.h>
280 struct bvec_iter_all iter;
283 AC_DEFINE(HAVE_BVEC_ITER_ALL, 1,
284 [if bvec_iter_all exists for multi-page bvec iternation])
286 EXTRA_KCFLAGS="$tmp_flags"
287 ]) # LB_HAVE_BVEC_ITER_ALL
292 AC_DEFUN([LB_CONFIG_LDISKFS], [
293 # --with-ldiskfs is deprecated now that ldiskfs is fully merged with lustre.
294 # However we continue to support this option through Lustre 2.5.
295 AC_ARG_WITH([ldiskfs],
297 [AC_MSG_WARN([--with-ldiskfs is deprecated, please use --enable-ldiskfs])
298 AS_IF([test x$withval != xyes -a x$withval != xno],
301 The ldiskfs option is deprecated,
302 and no longer supports paths to external ldiskfs source
306 AC_ARG_ENABLE([ldiskfs],
307 [AS_HELP_STRING([--disable-ldiskfs],
308 [disable ldiskfs osd (default is enable)])],
309 [AS_IF([test x$enable_ldiskfs != xyes -a x$enable_ldiskfs != xno],
310 [AC_MSG_ERROR([ldiskfs valid options are "yes" or "no"])])],
311 [AS_IF([test "${with_ldiskfs+set}" = set],
312 [enable_ldiskfs=$with_ldiskfs],
313 [enable_ldiskfs=maybe])
316 AS_IF([test x$enable_server = xno],
317 [AS_CASE([$enable_ldiskfs],
318 [maybe], [enable_ldiskfs=no],
319 [yes], [AC_MSG_ERROR([cannot build ldiskfs when servers are disabled])]
322 AS_IF([test x$enable_ldiskfs != xno],[
323 # In the future, we chould change enable_ldiskfs from maybe to
324 # either yes or no based on additional tests, e.g. whether a patch
325 # set is available for the detected kernel. For now, we just always
327 AS_IF([test x$enable_ldiskfs = xmaybe], [enable_ldiskfs=yes])
328 AC_SUBST(ENABLE_LDISKFS, yes)
331 LDISKFS_AC_PATCH_PROGRAM
332 LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD
333 LB_EXT4_JOURNAL_START_3ARGS
335 LB_EXT4_HAVE_INFO_DQUOT
336 LB_EXT4_HAVE_I_CRYPT_INFO
337 LB_LDISKFS_IGET_HAS_FLAGS_ARG
338 LB_HAVE_BVEC_ITER_ALL
339 AC_DEFINE(CONFIG_LDISKFS_FS_POSIX_ACL, 1, [posix acls for ldiskfs])
340 AC_DEFINE(CONFIG_LDISKFS_FS_SECURITY, 1, [fs security for ldiskfs])
341 AC_DEFINE(CONFIG_LDISKFS_FS_XATTR, 1, [extened attributes for ldiskfs])
342 AC_DEFINE(CONFIG_LDISKFS_FS_RW, 1, [enable rw access for ldiskfs])
343 AC_SUBST(LDISKFS_SUBDIR, ldiskfs)
344 AC_DEFINE(HAVE_LDISKFS_OSD, 1, Enable ldiskfs osd)
346 AC_SUBST(ENABLE_LDISKFS, no)
349 AC_MSG_CHECKING([whether to build ldiskfs])
350 AC_MSG_RESULT([$enable_ldiskfs])
352 AM_CONDITIONAL([LDISKFS_ENABLED], [test x$enable_ldiskfs = xyes])
353 ]) # LB_CONFIG_LDISKFS
356 # LB_VALIDATE_EXT4_SRC_DIR
358 # Spot check the existence of several source files common to ext4.
359 # Detecting this at configure time allows us to avoid a potential build
360 # failure and provide a useful error message to explain what is wrong.
362 AC_DEFUN([LB_VALIDATE_EXT4_SRC_DIR], [
363 enable_ldiskfs_build="no"
364 AS_IF([test -n "$EXT4_SRC_DIR"], [
365 enable_ldiskfs_build="yes"
366 LB_CHECK_FILE([$EXT4_SRC_DIR/dir.c], [], [
367 enable_ldiskfs_build="no"
368 AC_MSG_WARN([ext4 must exist for ldiskfs build])
370 LB_CHECK_FILE([$EXT4_SRC_DIR/file.c], [], [
371 enable_ldiskfs_build="no"
372 AC_MSG_WARN([ext4 must exist for ldiskfs build])
374 LB_CHECK_FILE([$EXT4_SRC_DIR/inode.c], [], [
375 enable_ldiskfs_build="no"
376 AC_MSG_WARN([ext4 must exist for ldiskfs build])
378 LB_CHECK_FILE([$EXT4_SRC_DIR/super.c], [], [
379 enable_ldiskfs_build="no"
380 AC_MSG_WARN([ext4 must exist for ldiskfs build])
384 AS_IF([test "x$enable_ldiskfs_build" = xno], [
389 Disabling ldiskfs support because complete ext4 source does not exist.
391 If you are building using kernel-devel packages and require ldiskfs
392 server support then ensure that the matching kernel-debuginfo-common
393 and kernel-debuginfo-common-<arch> packages are installed.
396 ]) # LB_VALIDATE_EXT4_SRC_DIR
401 # Determine the location of the ext4 source code. It it required
402 # for several configure tests and to build ldiskfs.
404 AC_DEFUN([LB_EXT4_SRC_DIR], [
405 AC_MSG_CHECKING([ext4 source directory])
406 # Kernel ext source located with devel headers
408 AS_IF([test -e "$linux_src/fs/ext4/super.c"], [
409 EXT4_SRC_DIR="$linux_src/fs/ext4"
411 # Kernel ext source provided by kernel-debuginfo-common package
412 # that extracted to $LINUX
413 linux_src=$(ls -1d $linux_src/../../debug/*/linux-${LINUXRELEASE%.*}* \
414 2>/dev/null | tail -1)
415 AS_IF([test -e "$linux_src/fs/ext4/super.c"], [
416 EXT4_SRC_DIR="$linux_src/fs/ext4"
418 # Kernel ext source provided by kernel-debuginfo-common package
419 linux_src=$(ls -1d /usr/src/debug/*/linux-${LINUXRELEASE%.*}* \
420 2>/dev/null | tail -1)
421 AS_IF([test -e "$linux_src/fs/ext4/super.c"], [
422 EXT4_SRC_DIR="$linux_src/fs/ext4"
428 AC_MSG_RESULT([$EXT4_SRC_DIR])
429 AC_SUBST(EXT4_SRC_DIR)
431 LB_VALIDATE_EXT4_SRC_DIR
435 # LB_DEFINE_E2FSPROGS_NAMES
437 # Enable the use of alternate naming of ldiskfs-enabled e2fsprogs package.
439 AC_DEFUN([LB_DEFINE_E2FSPROGS_NAMES], [
440 AC_MSG_CHECKING([whether to use alternate names for e2fsprogs])
441 AC_ARG_WITH([ldiskfsprogs],
442 AC_HELP_STRING([--with-ldiskfsprogs],
443 [use alternate names for ldiskfs-enabled e2fsprogs]),
446 AS_IF([test "x$withval" = xyes], [
447 AC_MSG_RESULT([enabled])
448 AC_DEFINE(HAVE_LDISKFSPROGS, 1, [enable use of ldiskfsprogs package])
449 E2FSPROGS="ldiskfsprogs"
450 MKE2FS="mkfs.ldiskfs"
451 DEBUGFS="debugfs.ldiskfs"
452 TUNE2FS="tunefs.ldiskfs"
453 E2LABEL="label.ldiskfs"
454 DUMPE2FS="dumpfs.ldiskfs"
455 E2FSCK="fsck.ldiskfs"
456 PFSCK="pfsck.ldiskfs"
458 AC_MSG_RESULT([disabled])
459 E2FSPROGS="e2fsprogs"
469 AC_DEFINE_UNQUOTED(E2FSPROGS, "$E2FSPROGS", [name of ldiskfs e2fsprogs package])
470 AC_DEFINE_UNQUOTED(MKE2FS, "$MKE2FS", [name of ldiskfs mkfs program])
471 AC_DEFINE_UNQUOTED(DEBUGFS, "$DEBUGFS", [name of ldiskfs debug program])
472 AC_DEFINE_UNQUOTED(TUNE2FS, "$TUNE2FS", [name of ldiskfs tune program])
473 AC_DEFINE_UNQUOTED(E2LABEL, "$E2LABEL", [name of ldiskfs label program])
474 AC_DEFINE_UNQUOTED(DUMPE2FS,"$DUMPE2FS", [name of ldiskfs dump program])
475 AC_DEFINE_UNQUOTED(E2FSCK, "$E2FSCK", [name of ldiskfs fsck program])
476 AC_DEFINE_UNQUOTED(PFSCK, "$PFSCK", [name of parallel fsck program])
478 AC_SUBST([E2FSPROGS], [$E2FSPROGS])
479 AC_SUBST([MKE2FS], [$MKE2FS])
480 AC_SUBST([DEBUGFS], [$DEBUGFS])
481 AC_SUBST([TUNE2FS], [$TUNE2FS])
482 AC_SUBST([E2LABEL], [$E2LABEL])
483 AC_SUBST([DUMPE2FS], [$DUMPE2FS])
484 AC_SUBST([E2FSCK], [$E2FSCK])
485 AC_SUBST([PFSCK], [$PFSCK])
486 ]) # LB_DEFINE_E2FSPROGS_NAMES