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