Whamcloud - gitweb
LU-12559 ptlrpc: Hold imp lock for idle reconnect
[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         80)     LDISKFS_SERIES="4.18-rhel8.series"      ;;
17         77)     LDISKFS_SERIES="3.10-rhel7.7.series"    ;;
18         76)     LDISKFS_SERIES="3.10-rhel7.6.series"    ;;
19         75)     LDISKFS_SERIES="3.10-rhel7.5.series"    ;;
20         74)     LDISKFS_SERIES="3.10-rhel7.4.series"    ;;
21         73)     LDISKFS_SERIES="3.10-rhel7.3.series"    ;;
22         72)     LDISKFS_SERIES="3.10-rhel7.2.series"    ;;
23         71)     LDISKFS_SERIES="3.10-rhel7.series"      ;;
24         69)     LDISKFS_SERIES="2.6-rhel6.9.series"     ;;
25         68)     LDISKFS_SERIES="2.6-rhel6.8.series"     ;;
26         67)     LDISKFS_SERIES="2.6-rhel6.7.series"     ;;
27         66)     LDISKFS_SERIES="2.6-rhel6.6.series"     ;;
28         65)     LDISKFS_SERIES="2.6-rhel6.5.series"     ;;
29         64)     LDISKFS_SERIES="2.6-rhel6.4.series"     ;;
30         6[0-3]) LDISKFS_SERIES="2.6-rhel6.series"       ;;
31         esac
32 ], [test x$SUSE_KERNEL = xyes], [
33         AS_VERSION_COMPARE([$LINUXRELEASE],[4.4.82],[
34         AS_VERSION_COMPARE([$LINUXRELEASE],[4.4.0],[
35         AS_VERSION_COMPARE([$LINUXRELEASE],[3.12.0],[
36         AS_VERSION_COMPARE([$LINUXRELEASE],[3.0.0],[
37         AS_VERSION_COMPARE([$LINUXRELEASE],[2.6.32], [],
38         [LDISKFS_SERIES="2.6-sles11.series"],[LDISKFS_SERIES="2.6-sles11.series"])],
39         [LDISKFS_SERIES="3.0-sles11.series"],[
40                 PLEV=$(grep PATCHLEVEL /etc/SuSE-release | sed -e 's/.*= *//')
41                 case $PLEV in
42                 2) LDISKFS_SERIES="3.0-sles11.series"
43                         ;;
44                 3) LDISKFS_SERIES="3.0-sles11sp3.series"
45                         ;;
46                 4) LDISKFS_SERIES="3.0-sles11sp4.series"
47                         ;;
48                 esac
49         ])],[LDISKFS_SERIES="3.12-sles12.series"],[
50                 PLEV=$(grep PATCHLEVEL /etc/SuSE-release | sed -e 's/.*= *//')
51                 case $PLEV in
52                 1) LDISKFS_SERIES="3.12-sles12sp1.series"
53                         ;;
54                 *) LDISKFS_SERIES="3.12-sles12.series"
55                         ;;
56                 esac
57         ])],[LDISKFS_SERIES="4.4-sles12sp2.series"],
58             [LDISKFS_SERIES="4.4-sles12sp2.series"]
59         )], [LDISKFS_SERIES="4.4-sles12sp3.series"],
60             [LDISKFS_SERIES="4.4-sles12sp3.series"])
61 ], [test x$UBUNTU_KERNEL = xyes], [
62         AS_VERSION_COMPARE([$LINUXRELEASE],[4.15.0],[
63         AS_VERSION_COMPARE([$LINUXRELEASE],[4.4.0], [],
64         [
65                 KPLEV=$(echo $LINUXRELEASE | sed -n 's/.*-\([0-9]\+\).*/\1/p')
66                 AS_IF(
67                         [test -z "$KPLEV"], [
68                                 AC_MSG_WARN([Failed to determine Kernel patch level. Assume latest.])
69                                 LDISKFS_SERIES="4.4.0-73-ubuntu14+16.series"
70                         ],
71                         [test $KPLEV -ge 73], [LDISKFS_SERIES="4.4.0-73-ubuntu14+16.series"],
72                         [test $KPLEV -ge 62], [LDISKFS_SERIES="4.4.0-62-ubuntu14+16.series"],
73                         [test $KPLEV -ge 49], [LDISKFS_SERIES="4.4.0-49-ubuntu14+16.series"],
74                         [LDISKFS_SERIES="4.4.0-45-ubuntu14+16.series"]
75                 )
76         ],
77         [LDISKFS_SERIES="4.4.0-73-ubuntu14+16.series"])],
78         [
79                 KPLEV=$(echo $LINUXRELEASE | sed -n 's/.*-\([0-9]\+\).*/\1/p')
80                 AS_IF(
81                         [test -z "$KPLEV"], [
82                                 AC_MSG_WARN([Failed to determine Kernel patch level. Assume latest.])
83                                 LDISKFS_SERIES="4.15.0-24-ubuntu18.series"
84                         ],
85                         [test $KPLEV -ge 24], [LDISKFS_SERIES="4.15.0-24-ubuntu18.series"],
86                         [test $KPLEV -ge 20], [LDISKFS_SERIES="4.15.0-20-ubuntu18.series"]
87                 )
88         ],
89         [LDISKFS_SERIES="4.15.0-24-ubuntu18.series"])
90 ])
91 ])
92 AS_IF([test -z "$LDISKFS_SERIES"],
93         [AC_MSG_RESULT([failed to identify series])],
94         [AC_MSG_RESULT([$LDISKFS_SERIES])])
95 AC_SUBST(LDISKFS_SERIES)
96 ]) # LDISKFS_LINUX_SERIES
97
98 #
99 # LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD
100 #
101 # 2.6.32-rc7 ext4_free_blocks requires struct buffer_head
102 # Note that RHEL6 is pre 2.6.32-rc7 so this check is still needed.
103 #
104 AC_DEFUN([LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD], [
105 LB_CHECK_COMPILE([if 'ext4_free_blocks' needs 'struct buffer_head'],
106 ext4_free_blocks_with_buffer_head, [
107         #include <linux/fs.h>
108         #include "$EXT4_SRC_DIR/ext4.h"
109 ],[
110         ext4_free_blocks(NULL, NULL, NULL, 0, 0, 0);
111 ],[
112         AC_DEFINE(HAVE_EXT_FREE_BLOCK_WITH_BUFFER_HEAD, 1,
113                 [ext4_free_blocks do not require struct buffer_head])
114 ])
115 ]) # LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD
116
117 #
118 # LB_EXT4_JOURNAL_START_3ARGS
119 #
120 # 3.9 added a type argument to ext4_journal_start and friends
121 #
122 AC_DEFUN([LB_EXT4_JOURNAL_START_3ARGS], [
123 LB_CHECK_COMPILE([if ext4_journal_start takes 3 arguments],
124 ext4_journal_start, [
125         #include <linux/fs.h>
126         #include "$EXT4_SRC_DIR/ext4_jbd2.h"
127 ],[
128         ext4_journal_start(NULL, 0, 0);
129 ],[
130         AC_DEFINE(JOURNAL_START_HAS_3ARGS, 1, [ext4_journal_start takes 3 arguments])
131 ])
132 ]) # LB_EXT4_JOURNAL_START_3ARGS
133
134 #
135 # LB_EXT4_BREAD_4ARGS
136 #
137 # 3.18 ext4_bread has 4 arguments
138 #
139 AC_DEFUN([LB_EXT4_BREAD_4ARGS], [
140 LB_CHECK_COMPILE([if ext4_bread takes 4 arguments],
141 ext4_bread, [
142         #include <linux/fs.h>
143         #include "$EXT4_SRC_DIR/ext4.h"
144 ],[
145         ext4_bread(NULL, NULL, 0, 0);
146 ],[
147         AC_DEFINE(HAVE_EXT4_BREAD_4ARGS, 1, [ext4_bread takes 4 arguments])
148 ])
149 ]) # LB_EXT4_BREAD_4ARGS
150
151 #
152 # LB_EXT4_HAVE_INFO_DQUOT
153 #
154 # in linux 4.4 i_dqout is in ext4_inode_info, not in struct inode
155 #
156 AC_DEFUN([LB_EXT4_HAVE_INFO_DQUOT], [
157 LB_CHECK_COMPILE([if i_dquot is in ext4_inode_info],
158 ext4_info_dquot, [
159         #include <linux/fs.h>
160         #include <linux/quota.h>
161         #include "$EXT4_SRC_DIR/ext4.h"
162 ],[
163         struct ext4_inode_info in;
164         struct dquot *dq;
165
166         dq = in.i_dquot[0];
167 ],[
168         AC_DEFINE(HAVE_EXT4_INFO_DQUOT, 1, [i_dquot is in ext4_inode_info])
169 ])
170 ]) # LB_EXT4_HAVE_INFO_DQUOT
171
172 #
173 # LB_EXT4_HAVE_I_CRYPT_INFO
174 #
175 # in linux 4.8 i_crypt_info moved from ext4_inode_info to struct inode
176 #
177 # Determine if we need to enable CONFIG_LDISKFS_FS_ENCRYPTION.
178 # If we have i_crypt_info in ext4_inode_info, the config option
179 # should be enabled to make the ldiskfs module compilation happy.
180 # Otherwise i_crypy_info is in struct inode, we need to check kernel
181 # config option to determine that.
182 #
183 AC_DEFUN([LB_EXT4_HAVE_I_CRYPT_INFO], [
184 LB_CHECK_COMPILE([if i_crypt_info is in ext4_inode_info],
185 ext4_i_crypt_info, [
186         #define CONFIG_EXT4_FS_ENCRYPTION 1
187         #include <linux/fs.h>
188         #include "$EXT4_SRC_DIR/ext4.h"
189 ],[
190         struct ext4_inode_info in;
191
192         in.i_crypt_info = NULL;
193 ],[
194         AC_DEFINE(
195                 CONFIG_LDISKFS_FS_ENCRYPTION, 1,
196                 [enable encryption for ldiskfs]
197         )
198 ],[
199         LB_CHECK_CONFIG([EXT4_FS_ENCRYPTION],[
200                 AC_DEFINE(
201                         CONFIG_LDISKFS_FS_ENCRYPTION, 1,
202                         [enable encryption for ldiskfs]
203                 )
204         ])
205 ])
206 ]) # LB_EXT4_HAVE_I_CRYPT_INFO
207
208 #
209 # LB_LDISKFS_IGET_HAS_FLAGS_ARG
210 #
211 # kernel 4.19 commit 8a363970d1dc38c4ec4ad575c862f776f468d057
212 # ext4_iget changed to a macro with 3 args was function with 2 args
213 #
214 AC_DEFUN([LB_LDISKFS_IGET_HAS_FLAGS_ARG], [
215 tmp_flags="$EXTRA_KCFLAGS"
216 EXTRA_KCFLAGS="-Werror"
217 LB_CHECK_COMPILE([if ldiskfs_iget takes a flags argument],
218 ext4_iget_3args, [
219         #include <linux/fs.h>
220         #include "$EXT4_SRC_DIR/ext4.h"
221 ],[
222         int f = EXT4_IGET_SPECIAL;
223         (void)f;
224 ],[
225         AC_DEFINE(HAVE_LDISKFS_IGET_WITH_FLAGS, 1,
226                 [if ldiskfs_iget takes a flags argument])
227 ])
228 EXTRA_KCFLAGS="$tmp_flags"
229 ]) # LB_LDISKFS_IGET_HAS_FLAGS_ARG
230
231 #
232 # LDISKFS_AC_PATCH_PROGRAM
233 #
234 # Determine which program should be used to apply the patches to
235 # the ext4 source code to produce the ldiskfs source code.
236 #
237 AC_DEFUN([LDISKFS_AC_PATCH_PROGRAM], [
238         AC_ARG_ENABLE([quilt],
239                 [AC_HELP_STRING([--disable-quilt],
240                         [disable use of quilt for ldiskfs])],
241                 [AS_IF([test "x$enableval" = xno],
242                         [use_quilt=no],
243                         [use_quilt=maybe])],
244                 [use_quilt=maybe]
245         )
246
247         AS_IF([test x$use_quilt = xmaybe], [
248                 AC_PATH_PROG([quilt_avail], [quilt], [no])
249                 AS_IF([test x$quilt_avail = xno], [
250                         use_quilt=no
251                 ], [
252                         use_quilt=yes
253                 ])
254         ])
255
256         AS_IF([test x$use_quilt = xno], [
257                 AC_PATH_PROG([patch_avail], [patch], [no])
258                 AS_IF([test x$patch_avail = xno], [
259                         AC_MSG_ERROR([*** Need "quilt" or "patch" command])
260                 ])
261         ])
262 ]) # LDISKFS_AC_PATCH_PROGRAM
263
264 #
265 # LB_HAVE_BVEC_ITER_ALL
266 #
267 # kernel 5.1 commit 6dc4f100c175dd0511ae8674786e7c9006cdfbfa
268 # block: allow bio_for_each_segment_all() to iterate over multi-page bvec
269 #
270 AC_DEFUN([LB_HAVE_BVEC_ITER_ALL], [
271 tmp_flags="$EXTRA_KCFLAGS"
272 EXTRA_KCFLAGS="-Werror"
273 LB_CHECK_COMPILE([if bvec_iter_all exists for multi-page bvec iternation],
274 ext4fs_dirhash, [
275         #include <linux/bvec.h>
276 ],[
277         struct bvec_iter_all iter;
278         (void)iter;
279 ],[
280         AC_DEFINE(HAVE_BVEC_ITER_ALL, 1,
281                 [if bvec_iter_all exists for multi-page bvec iternation])
282 ])
283 EXTRA_KCFLAGS="$tmp_flags"
284 ]) # LB_HAVE_BVEC_ITER_ALL
285
286 #
287 # LB_CONFIG_LDISKFS
288 #
289 AC_DEFUN([LB_CONFIG_LDISKFS], [
290 # --with-ldiskfs is deprecated now that ldiskfs is fully merged with lustre.
291 # However we continue to support this option through Lustre 2.5.
292 AC_ARG_WITH([ldiskfs],
293         [],
294         [AC_MSG_WARN([--with-ldiskfs is deprecated, please use --enable-ldiskfs])
295         AS_IF([test x$withval != xyes -a x$withval != xno],
296                 [AC_MSG_ERROR([
297
298 The ldiskfs option is deprecated,
299 and no longer supports paths to external ldiskfs source
300 ])])
301 ])
302
303 AC_ARG_ENABLE([ldiskfs],
304         [AS_HELP_STRING([--disable-ldiskfs],
305                 [disable ldiskfs osd (default is enable)])],
306         [AS_IF([test x$enable_ldiskfs != xyes -a x$enable_ldiskfs != xno],
307                 [AC_MSG_ERROR([ldiskfs valid options are "yes" or "no"])])],
308         [AS_IF([test "${with_ldiskfs+set}" = set],
309                 [enable_ldiskfs=$with_ldiskfs],
310                 [enable_ldiskfs=maybe])
311 ])
312
313 AS_IF([test x$enable_server = xno],
314         [AS_CASE([$enable_ldiskfs],
315                 [maybe], [enable_ldiskfs=no],
316                 [yes], [AC_MSG_ERROR([cannot build ldiskfs when servers are disabled])]
317         )])
318
319 AS_IF([test x$enable_ldiskfs != xno],[
320         # In the future, we chould change enable_ldiskfs from maybe to
321         # either yes or no based on additional tests, e.g.  whether a patch
322         # set is available for the detected kernel.  For now, we just always
323         # set it to "yes".
324         AS_IF([test x$enable_ldiskfs = xmaybe], [enable_ldiskfs=yes])
325         AC_SUBST(ENABLE_LDISKFS, yes)
326
327         LDISKFS_LINUX_SERIES
328         LDISKFS_AC_PATCH_PROGRAM
329         LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD
330         LB_EXT4_JOURNAL_START_3ARGS
331         LB_EXT4_BREAD_4ARGS
332         LB_EXT4_HAVE_INFO_DQUOT
333         LB_EXT4_HAVE_I_CRYPT_INFO
334         LB_LDISKFS_IGET_HAS_FLAGS_ARG
335         LB_HAVE_BVEC_ITER_ALL
336         AC_DEFINE(CONFIG_LDISKFS_FS_POSIX_ACL, 1, [posix acls for ldiskfs])
337         AC_DEFINE(CONFIG_LDISKFS_FS_SECURITY, 1, [fs security for ldiskfs])
338         AC_DEFINE(CONFIG_LDISKFS_FS_XATTR, 1, [extened attributes for ldiskfs])
339         AC_DEFINE(CONFIG_LDISKFS_FS_RW, 1, [enable rw access for ldiskfs])
340         AC_SUBST(LDISKFS_SUBDIR, ldiskfs)
341         AC_DEFINE(HAVE_LDISKFS_OSD, 1, Enable ldiskfs osd)
342 ], [
343         AC_SUBST(ENABLE_LDISKFS, no)
344 ])
345
346 AC_MSG_CHECKING([whether to build ldiskfs])
347 AC_MSG_RESULT([$enable_ldiskfs])
348
349 AM_CONDITIONAL([LDISKFS_ENABLED], [test x$enable_ldiskfs = xyes])
350 ]) # LB_CONFIG_LDISKFS
351
352 #
353 # LB_VALIDATE_EXT4_SRC_DIR
354 #
355 # Spot check the existence of several source files common to ext4.
356 # Detecting this at configure time allows us to avoid a potential build
357 # failure and provide a useful error message to explain what is wrong.
358 #
359 AC_DEFUN([LB_VALIDATE_EXT4_SRC_DIR], [
360 enable_ldiskfs_build="no"
361 AS_IF([test -n "$EXT4_SRC_DIR"], [
362         enable_ldiskfs_build="yes"
363         LB_CHECK_FILE([$EXT4_SRC_DIR/dir.c], [], [
364                 enable_ldiskfs_build="no"
365                 AC_MSG_WARN([ext4 must exist for ldiskfs build])
366         ])
367         LB_CHECK_FILE([$EXT4_SRC_DIR/file.c], [], [
368                 enable_ldiskfs_build="no"
369                 AC_MSG_WARN([ext4 must exist for ldiskfs build])
370         ])
371         LB_CHECK_FILE([$EXT4_SRC_DIR/inode.c], [], [
372                 enable_ldiskfs_build="no"
373                 AC_MSG_WARN([ext4 must exist for ldiskfs build])
374         ])
375         LB_CHECK_FILE([$EXT4_SRC_DIR/super.c], [], [
376                 enable_ldiskfs_build="no"
377                 AC_MSG_WARN([ext4 must exist for ldiskfs build])
378         ])
379 ])
380
381 AS_IF([test "x$enable_ldiskfs_build" = xno], [
382         enable_ldiskfs="no"
383
384         AC_MSG_WARN([
385
386 Disabling ldiskfs support because complete ext4 source does not exist.
387
388 If you are building using kernel-devel packages and require ldiskfs
389 server support then ensure that the matching kernel-debuginfo-common
390 and kernel-debuginfo-common-<arch> packages are installed.
391 ])
392 ])
393 ]) # LB_VALIDATE_EXT4_SRC_DIR
394
395 #
396 # LB_EXT4_SRC_DIR
397 #
398 # Determine the location of the ext4 source code.  It it required
399 # for several configure tests and to build ldiskfs.
400 #
401 AC_DEFUN([LB_EXT4_SRC_DIR], [
402 AC_MSG_CHECKING([ext4 source directory])
403 # Kernel ext source located with devel headers
404 linux_src=$LINUX
405 AS_IF([test -e "$linux_src/fs/ext4/super.c"], [
406         EXT4_SRC_DIR="$linux_src/fs/ext4"
407 ], [
408         # Kernel ext source provided by kernel-debuginfo-common package
409         # that extracted to $LINUX
410         linux_src=$(ls -1d $linux_src/../../debug/*/linux-${LINUXRELEASE%.*}* \
411                 2>/dev/null | tail -1)
412         AS_IF([test -e "$linux_src/fs/ext4/super.c"], [
413                 EXT4_SRC_DIR="$linux_src/fs/ext4"
414         ], [
415                 # Kernel ext source provided by kernel-debuginfo-common package
416                 linux_src=$(ls -1d /usr/src/debug/*/linux-${LINUXRELEASE%.*}* \
417                         2>/dev/null | tail -1)
418                 AS_IF([test -e "$linux_src/fs/ext4/super.c"], [
419                         EXT4_SRC_DIR="$linux_src/fs/ext4"
420                 ], [
421                         EXT4_SRC_DIR=""
422                 ])
423         ])
424 ])
425 AC_MSG_RESULT([$EXT4_SRC_DIR])
426 AC_SUBST(EXT4_SRC_DIR)
427
428 LB_VALIDATE_EXT4_SRC_DIR
429 ]) # LB_EXT4_SRC_DIR
430
431 #
432 # LB_DEFINE_E2FSPROGS_NAMES
433 #
434 # Enable the use of alternate naming of ldiskfs-enabled e2fsprogs package.
435 #
436 AC_DEFUN([LB_DEFINE_E2FSPROGS_NAMES], [
437 AC_MSG_CHECKING([whether to use alternate names for e2fsprogs])
438 AC_ARG_WITH([ldiskfsprogs],
439         AC_HELP_STRING([--with-ldiskfsprogs],
440                 [use alternate names for ldiskfs-enabled e2fsprogs]),
441         [], [withval="no"])
442
443 AS_IF([test "x$withval" = xyes], [
444         AC_MSG_RESULT([enabled])
445         AC_DEFINE(HAVE_LDISKFSPROGS, 1, [enable use of ldiskfsprogs package])
446         E2FSPROGS="ldiskfsprogs"
447         MKE2FS="mkfs.ldiskfs"
448         DEBUGFS="debugfs.ldiskfs"
449         TUNE2FS="tunefs.ldiskfs"
450         E2LABEL="label.ldiskfs"
451         DUMPE2FS="dumpfs.ldiskfs"
452         E2FSCK="fsck.ldiskfs"
453         PFSCK="pfsck.ldiskfs"
454 ], [
455         AC_MSG_RESULT([disabled])
456         E2FSPROGS="e2fsprogs"
457         MKE2FS="mke2fs"
458         DEBUGFS="debugfs"
459         TUNE2FS="tune2fs"
460         E2LABEL="e2label"
461         DUMPE2FS="dumpe2fs"
462         E2FSCK="e2fsck"
463         PFSCK="fsck"
464 ])
465
466 AC_DEFINE_UNQUOTED(E2FSPROGS, "$E2FSPROGS", [name of ldiskfs e2fsprogs package])
467 AC_DEFINE_UNQUOTED(MKE2FS, "$MKE2FS", [name of ldiskfs mkfs program])
468 AC_DEFINE_UNQUOTED(DEBUGFS, "$DEBUGFS", [name of ldiskfs debug program])
469 AC_DEFINE_UNQUOTED(TUNE2FS, "$TUNE2FS", [name of ldiskfs tune program])
470 AC_DEFINE_UNQUOTED(E2LABEL, "$E2LABEL", [name of ldiskfs label program])
471 AC_DEFINE_UNQUOTED(DUMPE2FS,"$DUMPE2FS", [name of ldiskfs dump program])
472 AC_DEFINE_UNQUOTED(E2FSCK, "$E2FSCK", [name of ldiskfs fsck program])
473 AC_DEFINE_UNQUOTED(PFSCK, "$PFSCK", [name of parallel fsck program])
474
475 AC_SUBST([E2FSPROGS], [$E2FSPROGS])
476 AC_SUBST([MKE2FS], [$MKE2FS])
477 AC_SUBST([DEBUGFS], [$DEBUGFS])
478 AC_SUBST([TUNE2FS], [$TUNE2FS])
479 AC_SUBST([E2LABEL], [$E2LABEL])
480 AC_SUBST([DUMPE2FS], [$DUMPE2FS])
481 AC_SUBST([E2FSCK], [$E2FSCK])
482 AC_SUBST([PFSCK], [$PFSCK])
483 ]) # LB_DEFINE_E2FSPROGS_NAMES