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