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