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