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