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