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