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