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