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