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