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