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