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