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