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