Whamcloud - gitweb
LU-13839 ldiskfs: fix detecting ext4_journal_ensure_credits
[fs/lustre-release.git] / config / lustre-build-ldiskfs.m4
1 #
2 # LDISKFS_LINUX_SERIES
3 #
4 AC_DEFUN([LDISKFS_LINUX_SERIES], [
5 AC_MSG_CHECKING([which ldiskfs series to use])
6 case x$LDISKFS_SERIES in
7         x)                      # not set
8                 ;;
9         *.series)               # set externally
10                 ;;
11         *) LDISKFS_SERIES=
12 esac
13 AS_IF([test -z "$LDISKFS_SERIES"], [
14 AS_IF([test x$RHEL_KERNEL = xyes], [
15         case $RHEL_RELEASE_NO in
16         83)     LDISKFS_SERIES="4.18-rhel8.3.series"    ;;
17         82)     LDISKFS_SERIES="4.18-rhel8.2.series"    ;;
18         81)     LDISKFS_SERIES="4.18-rhel8.1.series"    ;;
19         80)     LDISKFS_SERIES="4.18-rhel8.series"      ;;
20         79)     LDISKFS_SERIES="3.10-rhel7.9.series"    ;;
21         78)     LDISKFS_SERIES="3.10-rhel7.8.series"    ;;
22         77)     LDISKFS_SERIES="3.10-rhel7.7.series"    ;;
23         76)     LDISKFS_SERIES="3.10-rhel7.6.series"    ;;
24         esac
25 ], [test x$SUSE_KERNEL = xyes], [
26         AS_VERSION_COMPARE([$LINUXRELEASE],[5.3.18],[
27         AS_VERSION_COMPARE([$LINUXRELEASE],[4.12.14],[], [], [
28                 suse_conf=$LINUX_OBJ/include/generated/uapi/linux/suse_version.h
29                 suse_vers=$(awk '[$]2 == "SUSE_VERSION" {print [$]3 }' $suse_conf)
30                 suse_patchlevel=$(awk '[$]2 == "SUSE_PATCHLEVEL" {print [$]3 }' $suse_conf)
31                 echo "$suse_conf $suse_vers $suse_patchlevel  ${suse_vers}sp$suse_patchlevel" >> /tmp/log-nb
32                 case ${suse_vers}sp$suse_patchlevel in # (
33                 15sp0 ) LDISKFS_SERIES="4.12-sles15.series"
34                         if test ! -f $LINUX/arch/x86/kernel/cpu/hygon.c ; then
35                                 # This file was added shortly after -150.22 so
36                                 # this must be 150.22 or earlier
37                                 LDISKFS_SERIES="4.12-sles15-22.series"
38                         fi
39                         ;; # (
40                 15sp1 ) LDISKFS_SERIES="4.12-sles15sp1.series"
41                         if test ! -f $LINUX/arch/x86/kernel/cpu/umwait.c ; then
42                                 # This file was added after -197.7 so
43                                 # this must be -197.7 or earlier
44                                 LDISKFS_SERIES="4.12-sles15sp1-7.series"
45                         fi
46                         ;;
47                 esac
48         ]
49         )], [LDISKFS_SERIES="5.4.21-ml.series"],
50             [LDISKFS_SERIES="5.4.21-ml.series"])
51 ], [test x$UBUNTU_KERNEL = xyes], [
52         AS_VERSION_COMPARE([$LINUXRELEASE],[5.4.0],[
53         AS_VERSION_COMPARE([$LINUXRELEASE],[5.0.0],[
54         AS_VERSION_COMPARE([$LINUXRELEASE],[4.15.0],[
55         AS_VERSION_COMPARE([$LINUXRELEASE],[4.4.0], [],
56         [
57                 KPLEV=$(echo $LINUXRELEASE | sed -n 's/.*-\([0-9]\+\).*/\1/p')
58                 AS_IF(
59                         [test -z "$KPLEV"], [
60                                 AC_MSG_WARN([Failed to determine Kernel patch level. Assume latest.])
61                                 LDISKFS_SERIES="4.4.0-73-ubuntu14+16.series"
62                         ],
63                         [test $KPLEV -ge 73], [LDISKFS_SERIES="4.4.0-73-ubuntu14+16.series"],
64                         [test $KPLEV -ge 62], [LDISKFS_SERIES="4.4.0-62-ubuntu14+16.series"],
65                         [test $KPLEV -ge 49], [LDISKFS_SERIES="4.4.0-49-ubuntu14+16.series"],
66                         [LDISKFS_SERIES="4.4.0-45-ubuntu14+16.series"]
67                 )
68         ],
69         [LDISKFS_SERIES="4.4.0-73-ubuntu14+16.series"])],
70         [
71                 KPLEV=$(echo $LINUXRELEASE | sed -n 's/.*-\([0-9]\+\).*/\1/p')
72                 AS_IF(
73                         [test -z "$KPLEV"], [
74                                 AC_MSG_WARN([Failed to determine Kernel patch level. Assume latest.])
75                                 LDISKFS_SERIES="4.15.0-24-ubuntu18.series"
76                         ],
77                         [test $KPLEV -ge 24], [LDISKFS_SERIES="4.15.0-24-ubuntu18.series"],
78                         [test $KPLEV -ge 20], [LDISKFS_SERIES="4.15.0-20-ubuntu18.series"]
79                 )
80         ],
81         [LDISKFS_SERIES="4.15.0-24-ubuntu18.series"])],
82         [LDISKFS_SERIES="5.0.0-13-ubuntu19.series"],
83         [LDISKFS_SERIES="5.0.0-13-ubuntu19.series"])],
84         [LDISKFS_SERIES="5.4.0-42-ubuntu20.series"],
85         [LDISKFS_SERIES="5.4.0-42-ubuntu20.series"],
86         [LDISKFS_SERIES="5.4.0-ml.series"])
87 ])
88 ])
89 # Not RHEL/SLES or Ubuntu .. probably mainline
90 AS_IF([test -z "$LDISKFS_SERIES"],
91         [
92         AS_VERSION_COMPARE([$LINUXRELEASE],[5.4.0],[],
93         [LDISKFS_SERIES="5.4.0-ml.series"],[
94         AS_VERSION_COMPARE([$LINUXRELEASE],[5.4.21],
95                 [LDISKFS_SERIES="5.4.0-ml.series"],  # lt
96                 [LDISKFS_SERIES="5.4.21-ml.series"], # eq
97                 [LDISKFS_SERIES="5.4.21-ml.series"]  # gt
98                 )])
99         ],
100 [])
101 AS_IF([test -z "$LDISKFS_SERIES"],
102         [AC_MSG_RESULT([failed to identify series])],
103         [AC_MSG_RESULT([$LDISKFS_SERIES for $LINUXRELEASE])])
104 AC_SUBST(LDISKFS_SERIES)
105 ]) # LDISKFS_LINUX_SERIES
106
107 #
108 # LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD
109 #
110 # 2.6.32-rc7 ext4_free_blocks requires struct buffer_head
111 # Note that RHEL6 is pre 2.6.32-rc7 so this check is still needed.
112 #
113 AC_DEFUN([LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD], [
114 LB_CHECK_COMPILE([if 'ext4_free_blocks' needs 'struct buffer_head'],
115 ext4_free_blocks_with_buffer_head, [
116         #include <linux/fs.h>
117         #include "$EXT4_SRC_DIR/ext4.h"
118 ],[
119         ext4_free_blocks(NULL, NULL, NULL, 0, 0, 0);
120 ],[
121         AC_DEFINE(HAVE_EXT_FREE_BLOCK_WITH_BUFFER_HEAD, 1,
122                 [ext4_free_blocks do not require struct buffer_head])
123 ])
124 ]) # LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD
125
126 #
127 # LB_EXT4_JOURNAL_START_3ARGS
128 #
129 # 3.9 added a type argument to ext4_journal_start and friends
130 #
131 AC_DEFUN([LB_EXT4_JOURNAL_START_3ARGS], [
132 LB_CHECK_COMPILE([if ext4_journal_start takes 3 arguments],
133 ext4_journal_start, [
134         #include <linux/fs.h>
135         #include "$EXT4_SRC_DIR/ext4_jbd2.h"
136 ],[
137         ext4_journal_start(NULL, 0, 0);
138 ],[
139         AC_DEFINE(JOURNAL_START_HAS_3ARGS, 1, [ext4_journal_start takes 3 arguments])
140 ])
141 ]) # LB_EXT4_JOURNAL_START_3ARGS
142
143 #
144 # LB_EXT4_BREAD_4ARGS
145 #
146 # 3.18 ext4_bread has 4 arguments
147 # NOTE: It may not be exported for modules, use a positive compiler test here.
148 #
149 AC_DEFUN([LB_EXT4_BREAD_4ARGS], [
150 LB_CHECK_COMPILE([if ext4_bread takes 4 arguments],
151 ext4_bread, [
152         #include <linux/fs.h>
153         #include "$EXT4_SRC_DIR/ext4.h"
154
155         struct buffer_head *ext4_bread(handle_t *handle, struct inode *inode,
156                                        ext4_lblk_t block, int map_flags)
157         {
158                 struct buffer_head *bh = NULL;
159                 (void)handle;
160                 (void)inode;
161                 (void)block;
162                 (void)map_flags;
163                 return bh;
164         }
165 ],[
166         ext4_bread(NULL, NULL, 0, 0);
167 ],[
168         AC_DEFINE(HAVE_EXT4_BREAD_4ARGS, 1, [ext4_bread takes 4 arguments])
169 ])
170 ]) # LB_EXT4_BREAD_4ARGS
171
172 #
173 # LB_EXT4_HAVE_INFO_DQUOT
174 #
175 # in linux 4.4 i_dqout is in ext4_inode_info, not in struct inode
176 #
177 AC_DEFUN([LB_EXT4_HAVE_INFO_DQUOT], [
178 LB_CHECK_COMPILE([if i_dquot is in ext4_inode_info],
179 ext4_info_dquot, [
180         #include <linux/fs.h>
181         #include <linux/quota.h>
182         #include "$EXT4_SRC_DIR/ext4.h"
183 ],[
184         struct ext4_inode_info in;
185         struct dquot *dq;
186
187         dq = in.i_dquot[0];
188 ],[
189         AC_DEFINE(HAVE_EXT4_INFO_DQUOT, 1, [i_dquot is in ext4_inode_info])
190 ])
191 ]) # LB_EXT4_HAVE_INFO_DQUOT
192
193 #
194 # LB_EXT4_HAVE_I_CRYPT_INFO
195 #
196 # in linux 4.8 i_crypt_info moved from ext4_inode_info to struct inode
197 #
198 # Determine if we need to enable CONFIG_LDISKFS_FS_ENCRYPTION.
199 # If we have i_crypt_info in ext4_inode_info, the config option
200 # should be enabled to make the ldiskfs module compilation happy.
201 # Otherwise i_crypy_info is in struct inode, we need to check kernel
202 # config option to determine that.
203 #
204 AC_DEFUN([LB_EXT4_HAVE_I_CRYPT_INFO], [
205 LB_CHECK_COMPILE([if i_crypt_info is in ext4_inode_info],
206 ext4_i_crypt_info, [
207         #define CONFIG_EXT4_FS_ENCRYPTION 1
208         #include <linux/fs.h>
209         #include "$EXT4_SRC_DIR/ext4.h"
210 ],[
211         struct ext4_inode_info in;
212
213         in.i_crypt_info = NULL;
214 ],[
215         AC_DEFINE(
216                 CONFIG_LDISKFS_FS_ENCRYPTION, 1,
217                 [enable encryption for ldiskfs]
218         )
219 ],[
220         LB_CHECK_CONFIG([EXT4_FS_ENCRYPTION],[
221                 AC_DEFINE(
222                         CONFIG_LDISKFS_FS_ENCRYPTION, 1,
223                         [enable encryption for ldiskfs]
224                 )
225         ])
226 ])
227 ]) # LB_EXT4_HAVE_I_CRYPT_INFO
228
229 #
230 # LB_LDISKFS_JOURNAL_ENSURE_CREDITS
231 #
232 # kernel 4.18.0-240.1.1.el8 and
233 # kernel 5.4 commit a413036791d040e33badcc634453a4d0c0705499
234 #
235 # ext4_journal_ensure_credits was introduced to ensure given handle
236 # has at least requested amount of credits available, and possibly
237 # restarting transaction if needed.
238 #
239 AC_DEFUN([LB_LDISKFS_JOURNAL_ENSURE_CREDITS], [
240 tmp_flags="$EXTRA_KCFLAGS"
241 EXTRA_KCFLAGS="-Werror"
242 LB_CHECK_COMPILE([if 'ext4_journal_ensure_credits' exists],
243 ext4_journal_ensure_credits, [
244         #include "$EXT4_SRC_DIR/ext4_jbd2.h"
245         int __ext4_journal_ensure_credits(handle_t *handle, int check_cred,
246                 int extend_cred, int revoke_cred) { return 0; }
247 ],[
248         ext4_journal_ensure_credits(NULL, 0, 0);
249 ],[
250         AC_DEFINE(HAVE_LDISKFS_JOURNAL_ENSURE_CREDITS, 1,
251                 ['ext4_journal_ensure_credits' exists])
252 ])
253 EXTRA_KCFLAGS="$tmp_flags"
254 ]) # LB_LDISKFS_JOURNAL_ENSURE_CREDITS
255
256 #
257 # LB_LDISKFS_IGET_HAS_FLAGS_ARG
258 #
259 # kernel 4.19 commit 8a363970d1dc38c4ec4ad575c862f776f468d057
260 # ext4_iget changed to a macro with 3 args was function with 2 args
261 #
262 AC_DEFUN([LB_LDISKFS_IGET_HAS_FLAGS_ARG], [
263 tmp_flags="$EXTRA_KCFLAGS"
264 EXTRA_KCFLAGS="-Werror"
265 LB_CHECK_COMPILE([if ldiskfs_iget takes a flags argument],
266 ext4_iget_3args, [
267         #include <linux/fs.h>
268         #include "$EXT4_SRC_DIR/ext4.h"
269 ],[
270         int f = EXT4_IGET_SPECIAL;
271         (void)f;
272 ],[
273         AC_DEFINE(HAVE_LDISKFS_IGET_WITH_FLAGS, 1,
274                 [if ldiskfs_iget takes a flags argument])
275 ])
276 EXTRA_KCFLAGS="$tmp_flags"
277 ]) # LB_LDISKFS_IGET_HAS_FLAGS_ARG
278
279 #
280 # LDISKFS_AC_PATCH_PROGRAM
281 #
282 # Determine which program should be used to apply the patches to
283 # the ext4 source code to produce the ldiskfs source code.
284 #
285 AC_DEFUN([LDISKFS_AC_PATCH_PROGRAM], [
286         AC_ARG_ENABLE([quilt],
287                 [AC_HELP_STRING([--disable-quilt],
288                         [disable use of quilt for ldiskfs])],
289                 [AS_IF([test "x$enableval" = xno],
290                         [use_quilt=no],
291                         [use_quilt=maybe])],
292                 [use_quilt=maybe]
293         )
294
295         AS_IF([test x$use_quilt = xmaybe], [
296                 AC_PATH_PROG([quilt_avail], [quilt], [no])
297                 AS_IF([test x$quilt_avail = xno], [
298                         use_quilt=no
299                 ], [
300                         use_quilt=yes
301                 ])
302         ])
303
304         AS_IF([test x$use_quilt = xno], [
305                 AC_PATH_PROG([patch_avail], [patch], [no])
306                 AS_IF([test x$patch_avail = xno], [
307                         AC_MSG_ERROR([*** Need "quilt" or "patch" command])
308                 ])
309         ])
310 ]) # LDISKFS_AC_PATCH_PROGRAM
311
312 #
313 # LB_LDISKFS_FIND_ENTRY_LOCKED_EXISTS
314 #
315 # kernel 5.2 commit 8a363970d1dc38c4ec4ad575c862f776f468d057
316 # ext4: avoid declaring fs inconsistent due to invalid file handles
317 # __ext4_find_entry became a helper function for ext4_find_entry
318 # conflicting with previous ldiskfs patches.
319 # ldiskfs patches map ext4_find_entry to ldiskfs_find_entry_locked to
320 # avoid conflicting with __ext4_find_entry
321 #
322 # When the following check succeeds __ext4_find_entry helper is not
323 # used.
324 #
325 AC_DEFUN([LB_LDISKFS_FIND_ENTRY_LOCKED_EXISTS], [
326 tmp_flags="$EXTRA_KCFLAGS"
327 EXTRA_KCFLAGS="-Werror"
328 LB_CHECK_COMPILE([if __ldiskfs_find_entry is available],
329 ldiskfs_find_entry_locked, [
330         #include <linux/fs.h>
331         #include "$EXT4_SRC_DIR/ext4.h"
332         #include "$EXT4_SRC_DIR/namei.c"
333
334         static int __ext4_find_entry(void) { return 0; }
335 ],[
336         int x = __ext4_find_entry();
337         (void)x;
338 ],[
339         AC_DEFINE(HAVE___LDISKFS_FIND_ENTRY, 1,
340                 [if __ldiskfs_find_entry is available])
341 ])
342 EXTRA_KCFLAGS="$tmp_flags"
343 ]) # LB_LDISKFS_FIND_ENTRY_LOCKED_EXISTS
344
345 #
346 # LB_LDISKFSFS_DIRHASH_WANTS_DIR
347 #
348 # kernel 5.2 commit 8a363970d1dc38c4ec4ad575c862f776f468d057
349 # ext4fs_dirhash UNICODE support
350 #
351 AC_DEFUN([LB_LDISKFSFS_DIRHASH_WANTS_DIR], [
352 tmp_flags="$EXTRA_KCFLAGS"
353 EXTRA_KCFLAGS="-Werror"
354 LB_CHECK_COMPILE([if ldiskfsfs_dirhash takes an inode argument],
355 ext4fs_dirhash, [
356         #include <linux/fs.h>
357         #include "$EXT4_SRC_DIR/ext4.h"
358
359         int ext4fs_dirhash(const struct inode *dir, const char *name, int len,
360                           struct dx_hash_info *hinfo)
361         {
362                 (void)dir;
363                 (void)name;
364                 (void)len;
365                 (void)hinfo;
366                 return 0;
367         }
368 ],[
369         int f = ext4fs_dirhash(NULL, NULL, 0, NULL);
370         (void)f;
371 ],[
372         AC_DEFINE(HAVE_LDISKFSFS_GETHASH_INODE_ARG, 1,
373                 [ldiskfsfs_dirhash takes an inode argument])
374 ])
375 EXTRA_KCFLAGS="$tmp_flags"
376 ]) # LB_LDISKFSFS_DIRHASH_WANTS_DIR
377
378 #
379 # LB_JBD2_H_TOTAL_CREDITS
380 #
381 # kernel 5.5 commit 933f1c1e0b75bbc29730eef07c9e196c6dfd37e5
382 # jbd2: Reserve space for revoke descriptor blocks
383 #
384 AC_DEFUN([LB_JBD2_H_TOTAL_CREDITS], [
385 tmp_flags="$EXTRA_KCFLAGS"
386 EXTRA_KCFLAGS="-Werror"
387 LB_CHECK_COMPILE([if struct jbd2_journal_handle has h_total_credits member],
388 handle_t_h_revoke_credits, [
389         #include <linux/jbd2.h>
390 ],[
391         int x = offsetof(struct jbd2_journal_handle, h_total_credits);
392         (void)x;
393 ],[
394         AC_DEFINE(HAVE_JOURNAL_TOTAL_CREDITS, 1,
395                 [struct jbd2_journal_handle has h_total_credits member])
396 ])
397 EXTRA_KCFLAGS="$tmp_flags"
398 ]) # LB_JBD2_H_TOTAL_CREDITS
399
400 #
401 # LB_CONFIG_LDISKFS
402 #
403 AC_DEFUN([LB_CONFIG_LDISKFS], [
404 # --with-ldiskfs is deprecated now that ldiskfs is fully merged with lustre.
405 # However we continue to support this option through Lustre 2.5.
406 AC_ARG_WITH([ldiskfs],
407         [],
408         [AC_MSG_WARN([--with-ldiskfs is deprecated, please use --enable-ldiskfs])
409         AS_IF([test x$withval != xyes -a x$withval != xno],
410                 [AC_MSG_ERROR([
411
412 The ldiskfs option is deprecated,
413 and no longer supports paths to external ldiskfs source
414 ])])
415 ])
416
417 AC_ARG_ENABLE([ldiskfs],
418         [AS_HELP_STRING([--disable-ldiskfs],
419                 [disable ldiskfs osd (default is enable)])],
420         [AS_IF([test x$enable_ldiskfs != xyes -a x$enable_ldiskfs != xno],
421                 [AC_MSG_ERROR([ldiskfs valid options are "yes" or "no"])])],
422         [AS_IF([test "${with_ldiskfs+set}" = set],
423                 [enable_ldiskfs=$with_ldiskfs],
424                 [enable_ldiskfs=maybe])
425 ])
426
427 AS_IF([test x$enable_server = xno],
428         [AS_CASE([$enable_ldiskfs],
429                 [maybe], [enable_ldiskfs=no],
430                 [yes], [AC_MSG_ERROR([cannot build ldiskfs when servers are disabled])]
431         )])
432
433 AS_IF([test x$enable_ldiskfs != xno],[
434         # In the future, we chould change enable_ldiskfs from maybe to
435         # either yes or no based on additional tests, e.g.  whether a patch
436         # set is available for the detected kernel.  For now, we just always
437         # set it to "yes".
438         AS_IF([test x$enable_ldiskfs = xmaybe], [enable_ldiskfs=yes])
439         AC_SUBST(ENABLE_LDISKFS, yes)
440
441         LDISKFS_LINUX_SERIES
442         LDISKFS_AC_PATCH_PROGRAM
443         LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD
444         LB_EXT4_JOURNAL_START_3ARGS
445         LB_EXT4_BREAD_4ARGS
446         LB_EXT4_HAVE_INFO_DQUOT
447         LB_EXT4_HAVE_I_CRYPT_INFO
448         LB_LDISKFS_JOURNAL_ENSURE_CREDITS
449         LB_LDISKFS_IGET_HAS_FLAGS_ARG
450         LB_LDISKFS_FIND_ENTRY_LOCKED_EXISTS
451         LB_LDISKFSFS_DIRHASH_WANTS_DIR
452         LB_JBD2_H_TOTAL_CREDITS
453         AC_DEFINE(CONFIG_LDISKFS_FS_POSIX_ACL, 1, [posix acls for ldiskfs])
454         AC_DEFINE(CONFIG_LDISKFS_FS_SECURITY, 1, [fs security for ldiskfs])
455         AC_DEFINE(CONFIG_LDISKFS_FS_XATTR, 1, [extened attributes for ldiskfs])
456         AC_DEFINE(CONFIG_LDISKFS_FS_RW, 1, [enable rw access for ldiskfs])
457         AC_SUBST(LDISKFS_SUBDIR, ldiskfs)
458         AC_DEFINE(HAVE_LDISKFS_OSD, 1, Enable ldiskfs osd)
459 ], [
460         AC_SUBST(ENABLE_LDISKFS, no)
461 ])
462
463 AC_MSG_CHECKING([whether to build ldiskfs])
464 AC_MSG_RESULT([$enable_ldiskfs])
465
466 AM_CONDITIONAL([LDISKFS_ENABLED], [test x$enable_ldiskfs = xyes])
467 ]) # LB_CONFIG_LDISKFS
468
469
470 AC_DEFUN([LB_EXT4_SRC_DIR_SRC], [])
471 AC_DEFUN([LB_EXT4_SRC_DIR_RESULTS], [])
472
473 #
474 # LB_VALIDATE_EXT4_SRC_DIR
475 #
476 # Spot check the existence of several source files common to ext4.
477 # Detecting this at configure time allows us to avoid a potential build
478 # failure and provide a useful error message to explain what is wrong.
479 #
480 AC_DEFUN([LB_VALIDATE_EXT4_SRC_DIR], [
481 enable_ldiskfs_build="no"
482 AS_IF([test -n "$EXT4_SRC_DIR"], [
483         enable_ldiskfs_build="yes"
484         LB_CHECK_FILE([$EXT4_SRC_DIR/dir.c], [], [
485                 enable_ldiskfs_build="no"
486                 AC_MSG_WARN([ext4 must exist for ldiskfs build])
487         ])
488         LB_CHECK_FILE([$EXT4_SRC_DIR/file.c], [], [
489                 enable_ldiskfs_build="no"
490                 AC_MSG_WARN([ext4 must exist for ldiskfs build])
491         ])
492         LB_CHECK_FILE([$EXT4_SRC_DIR/inode.c], [], [
493                 enable_ldiskfs_build="no"
494                 AC_MSG_WARN([ext4 must exist for ldiskfs build])
495         ])
496         LB_CHECK_FILE([$EXT4_SRC_DIR/super.c], [], [
497                 enable_ldiskfs_build="no"
498                 AC_MSG_WARN([ext4 must exist for ldiskfs build])
499         ])
500 ])
501
502 AS_IF([test "x$enable_ldiskfs_build" = xno], [
503         enable_ldiskfs="no"
504
505         AC_MSG_WARN([
506
507 Disabling ldiskfs support because complete ext4 source does not exist.
508
509 If you are building using kernel-devel packages and require ldiskfs
510 server support then ensure that the matching kernel-debuginfo-common
511 and kernel-debuginfo-common-<arch> packages are installed.
512 ])
513 ])
514 ]) # LB_VALIDATE_EXT4_SRC_DIR
515
516 #
517 # LB_EXT4_SRC_DIR
518 #
519 # Determine the location of the ext4 source code.  It it required
520 # for several configure tests and to build ldiskfs.
521 #
522 AC_DEFUN([LB_EXT4_SRC_DIR], [
523 AC_MSG_CHECKING([ext4 source directory])
524 # Kernel ext source located with devel headers
525 linux_src=$LINUX
526 AS_IF([test -e "$linux_src/fs/ext4/super.c"], [
527         EXT4_SRC_DIR="$linux_src/fs/ext4"
528 ], [
529         # Kernel ext source provided by kernel-debuginfo-common package
530         # that extracted to $LINUX
531         linux_src=$(ls -1d $linux_src/../../debug/*/linux-${LINUXRELEASE%.*}* \
532                 2>/dev/null | tail -1)
533         AS_IF([test -e "$linux_src/fs/ext4/super.c"], [
534                 EXT4_SRC_DIR="$linux_src/fs/ext4"
535         ], [
536                 # Kernel ext source provided by kernel-debuginfo-common package
537                 linux_src=$(ls -1d /usr/src/debug/*/linux-${LINUXRELEASE%.*}* \
538                         2>/dev/null | tail -1)
539                 AS_IF([test -e "$linux_src/fs/ext4/super.c"], [
540                         EXT4_SRC_DIR="$linux_src/fs/ext4"
541                 ], [
542                         EXT4_SRC_DIR=""
543                 ])
544         ])
545 ])
546 AC_MSG_RESULT([$EXT4_SRC_DIR])
547 AC_SUBST(EXT4_SRC_DIR)
548
549 LB_VALIDATE_EXT4_SRC_DIR
550 ]) # LB_EXT4_SRC_DIR
551
552 #
553 # LB_DEFINE_E2FSPROGS_NAMES
554 #
555 # Enable the use of alternate naming of ldiskfs-enabled e2fsprogs package.
556 #
557 AC_DEFUN([LB_DEFINE_E2FSPROGS_NAMES], [
558 AC_MSG_CHECKING([whether to use alternate names for e2fsprogs])
559 AC_ARG_WITH([ldiskfsprogs],
560         AC_HELP_STRING([--with-ldiskfsprogs],
561                 [use alternate names for ldiskfs-enabled e2fsprogs]),
562         [], [withval="no"])
563
564 AS_IF([test "x$withval" = xyes], [
565         AC_MSG_RESULT([enabled])
566         AC_DEFINE(HAVE_LDISKFSPROGS, 1, [enable use of ldiskfsprogs package])
567         E2FSPROGS="ldiskfsprogs"
568         MKE2FS="mkfs.ldiskfs"
569         DEBUGFS="debugfs.ldiskfs"
570         TUNE2FS="tunefs.ldiskfs"
571         E2LABEL="label.ldiskfs"
572         DUMPE2FS="dumpfs.ldiskfs"
573         E2FSCK="fsck.ldiskfs"
574         PFSCK="pfsck.ldiskfs"
575 ], [
576         AC_MSG_RESULT([disabled])
577         E2FSPROGS="e2fsprogs"
578         MKE2FS="mke2fs"
579         DEBUGFS="debugfs"
580         TUNE2FS="tune2fs"
581         E2LABEL="e2label"
582         DUMPE2FS="dumpe2fs"
583         E2FSCK="e2fsck"
584         PFSCK="fsck"
585 ])
586
587 AC_DEFINE_UNQUOTED(E2FSPROGS, "$E2FSPROGS", [name of ldiskfs e2fsprogs package])
588 AC_DEFINE_UNQUOTED(MKE2FS, "$MKE2FS", [name of ldiskfs mkfs program])
589 AC_DEFINE_UNQUOTED(DEBUGFS, "$DEBUGFS", [name of ldiskfs debug program])
590 AC_DEFINE_UNQUOTED(TUNE2FS, "$TUNE2FS", [name of ldiskfs tune program])
591 AC_DEFINE_UNQUOTED(E2LABEL, "$E2LABEL", [name of ldiskfs label program])
592 AC_DEFINE_UNQUOTED(DUMPE2FS,"$DUMPE2FS", [name of ldiskfs dump program])
593 AC_DEFINE_UNQUOTED(E2FSCK, "$E2FSCK", [name of ldiskfs fsck program])
594 AC_DEFINE_UNQUOTED(PFSCK, "$PFSCK", [name of parallel fsck program])
595
596 AC_SUBST([E2FSPROGS], [$E2FSPROGS])
597 AC_SUBST([MKE2FS], [$MKE2FS])
598 AC_SUBST([DEBUGFS], [$DEBUGFS])
599 AC_SUBST([TUNE2FS], [$TUNE2FS])
600 AC_SUBST([E2LABEL], [$E2LABEL])
601 AC_SUBST([DUMPE2FS], [$DUMPE2FS])
602 AC_SUBST([E2FSCK], [$E2FSCK])
603 AC_SUBST([PFSCK], [$PFSCK])
604 ]) # LB_DEFINE_E2FSPROGS_NAMES