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