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