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