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