Whamcloud - gitweb
d3dcc6c722893b0bf5f3a80ae7f2dbe39416e1b1
[fs/lustre-release.git] / libcfs / autoconf / lustre-libcfs.m4
1 #
2 # LIBCFS_CONFIG_CDEBUG
3 #
4 # whether to enable various libcfs debugs (CDEBUG, ENTRY/EXIT, LASSERT, etc.)
5 #
6 AC_DEFUN([LIBCFS_CONFIG_CDEBUG], [
7 AC_MSG_CHECKING([whether to enable CDEBUG, CWARN])
8 AC_ARG_ENABLE([libcfs_cdebug],
9         AC_HELP_STRING([--disable-libcfs-cdebug],
10                 [disable libcfs CDEBUG, CWARN]),
11         [], [enable_libcfs_cdebug="yes"])
12 AC_MSG_RESULT([$enable_libcfs_cdebug])
13 AS_IF([test "x$enable_libcfs_cdebug" = xyes],
14         [AC_DEFINE(CDEBUG_ENABLED, 1, [enable libcfs CDEBUG, CWARN])])
15
16 AC_MSG_CHECKING([whether to enable ENTRY/EXIT])
17 AC_ARG_ENABLE([libcfs_trace],
18         AC_HELP_STRING([--disable-libcfs-trace],
19                 [disable libcfs ENTRY/EXIT]),
20         [], [enable_libcfs_trace="yes"])
21 AC_MSG_RESULT([$enable_libcfs_trace])
22 AS_IF([test "x$enable_libcfs_trace" = xyes],
23         [AC_DEFINE(CDEBUG_ENTRY_EXIT, 1, [enable libcfs ENTRY/EXIT])])
24
25 AC_MSG_CHECKING([whether to enable LASSERT, LASSERTF])
26 AC_ARG_ENABLE([libcfs_assert],
27         AC_HELP_STRING([--disable-libcfs-assert],
28                 [disable libcfs LASSERT, LASSERTF]),
29         [], [enable_libcfs_assert="yes"])
30 AC_MSG_RESULT([$enable_libcfs_assert])
31 AS_IF([test x$enable_libcfs_assert = xyes],
32         [AC_DEFINE(LIBCFS_DEBUG, 1, [enable libcfs LASSERT, LASSERTF])])
33 ]) # LIBCFS_CONFIG_CDEBUG
34
35 #
36 # LIBCFS_CONFIG_PANIC_DUMPLOG
37 #
38 # check if tunable panic_dumplog is wanted
39 #
40 AC_DEFUN([LIBCFS_CONFIG_PANIC_DUMPLOG], [
41 AC_MSG_CHECKING([whether to use tunable 'panic_dumplog' support])
42 AC_ARG_ENABLE([panic_dumplog],
43         AC_HELP_STRING([--enable-panic_dumplog],
44                 [enable panic_dumplog]),
45         [], [enable_panic_dumplog="no"])
46 AC_MSG_RESULT([$enable_panic_dumplog])
47 AS_IF([test "x$enable_panic_dumplog" = xyes],
48         [AC_DEFINE(LNET_DUMP_ON_PANIC, 1, [use dumplog on panic])])
49 ]) # LIBCFS_CONFIG_PANIC_DUMPLOG
50
51 #
52 # Kernel version 3.11 introduced ktime_get_ts64
53 #
54 AC_DEFUN([LIBCFS_KTIME_GET_TS64],[
55 LB_CHECK_COMPILE([does function 'ktime_get_ts64' exist],
56 ktime_get_ts64, [
57         #include <linux/hrtimer.h>
58         #include <linux/ktime.h>
59 ],[
60         struct timespec64 *ts = NULL;
61
62         ktime_get_ts64(ts);
63 ],[
64         AC_DEFINE(HAVE_KTIME_GET_TS64, 1,
65                 ['ktime_get_ts64' is available])
66 ])
67 ]) # LIBCFS_KTIME_GET_TS64
68
69 #
70 # Kernel version 3.12-rc4 commit c2d816443ef30 added prepare_to_wait_event()
71 #
72 AC_DEFUN([LIBCFS_PREPARE_TO_WAIT_EVENT],[
73 LB_CHECK_COMPILE([does function 'prepare_to_wait_event' exist],
74 prepare_to_wait_event, [
75         #include <linux/wait.h>
76 ],[
77         prepare_to_wait_event(NULL, NULL, 0);
78 ],[
79         AC_DEFINE(HAVE_PREPARE_TO_WAIT_EVENT, 1,
80                 ['prepare_to_wait_event' is available])
81 ])
82 ]) # LIBCFS_PREPARE_TO_WAIT_EVENT
83
84 #
85 # Linux kernel 3.12 introduced struct kernel_param_ops
86 # This has been backported to all lustre supported
87 # clients except RHEL6. We have to handle the differences.
88 #
89 AC_DEFUN([LIBCFS_KERNEL_PARAM_OPS],[
90 LB_CHECK_COMPILE([does 'struct kernel_param_ops' exist],
91 kernel_param_ops, [
92         #include <linux/module.h>
93 ],[
94         struct kernel_param_ops ops;
95
96         ops.set = NULL;
97 ],[
98         AC_DEFINE(HAVE_KERNEL_PARAM_OPS, 1,
99                 ['struct kernel_param_ops' is available])
100 ])
101 ]) # LIBCFS_KERNEL_PARAM_OPS
102
103 #
104 # Kernel version 3.12 introduced ktime_add
105 #
106 AC_DEFUN([LIBCFS_KTIME_ADD],[
107 LB_CHECK_COMPILE([does function 'ktime_add' exist],
108 ktime_add, [
109         #include <linux/hrtimer.h>
110         #include <linux/ktime.h>
111 ],[
112         ktime_t start = ktime_set(0, 0);
113         ktime_t end = start;
114         ktime_t total;
115
116         total = ktime_add(start, end);
117 ],[
118         AC_DEFINE(HAVE_KTIME_ADD, 1,
119                 [ktime_add is available])
120 ])
121 ]) # LIBCFS_KTIME_ADD
122
123 #
124 # Kernel version 3.12 introduced ktime_after
125 #
126 AC_DEFUN([LIBCFS_KTIME_AFTER],[
127 LB_CHECK_COMPILE([does function 'ktime_after' exist],
128 ktime_after, [
129         #include <linux/hrtimer.h>
130         #include <linux/ktime.h>
131 ],[
132         ktime_t start = ktime_set(0, 0);
133         ktime_t end = start;
134
135         ktime_after(start, end);
136 ],[
137         AC_DEFINE(HAVE_KTIME_AFTER, 1,
138                 [ktime_after is available])
139 ])
140 ]) # LIBCFS_KTIME_AFTER
141
142 #
143 # Kernel version 3.12 introduced ktime_before
144 # See linux commit 67cb9366ff5f99868100198efba5ca88aaa6ad25
145 #
146 AC_DEFUN([LIBCFS_KTIME_BEFORE],[
147 LB_CHECK_COMPILE([does function 'ktime_before' exist],
148 ktime_before, [
149         #include <linux/hrtimer.h>
150         #include <linux/ktime.h>
151 ],[
152         ktime_t start = ktime_set(0, 0);
153         ktime_t end = start;
154
155         ktime_before(start, end);
156 ],[
157         AC_DEFINE(HAVE_KTIME_BEFORE, 1,
158                 [ktime_before is available])
159 ])
160 ]) # LIBCFS_KTIME_BEFORE
161
162 #
163 # Kernel version 3.12 introduced ktime_compare
164 #
165 AC_DEFUN([LIBCFS_KTIME_COMPARE],[
166 LB_CHECK_COMPILE([does function 'ktime_compare' exist],
167 ktime_compare, [
168         #include <linux/hrtimer.h>
169         #include <linux/ktime.h>
170 ],[
171         ktime_t start = ktime_set(0, 0);
172         ktime_t end = start;
173
174         ktime_compare(start, end);
175 ],[
176         AC_DEFINE(HAVE_KTIME_COMPARE, 1,
177                 [ktime_compare is available])
178 ])
179 ]) # LIBCFS_KTIME_COMPARE
180
181 #
182 # FC19 3.12 kernel struct shrinker change
183 #
184 AC_DEFUN([LIBCFS_SHRINKER_COUNT],[
185 LB_CHECK_COMPILE([shrinker has 'count_objects'],
186 shrinker_count_objects, [
187         #include <linux/mmzone.h>
188         #include <linux/shrinker.h>
189 ],[
190         struct shrinker shrinker;
191
192         shrinker.count_objects = NULL;
193 ],[
194         AC_DEFINE(HAVE_SHRINKER_COUNT, 1,
195                 [shrinker has count_objects member])
196 ])
197 ]) # LIBCFS_SHRINKER_COUNT
198
199 #
200 # LIBCFS_IOV_ITER_HAS_TYPE
201 #
202 # kernel 3.15-rc4 commit 71d8e532b1549a478e6a6a8a44f309d050294d00
203 # start adding the tag to iov_iter
204 #
205 AC_DEFUN([LIBCFS_IOV_ITER_HAS_TYPE], [
206 tmp_flags="$EXTRA_KCFLAGS"
207 EXTRA_KCFLAGS="-Werror"
208 LB_CHECK_COMPILE([if iov_iter has member type],
209 iov_iter_has_type_member, [
210         #include <linux/uio.h>
211 ],[
212         struct iov_iter iter = { .type = ITER_KVEC };
213         (void)iter;
214 ],[
215         AC_DEFINE(HAVE_IOV_ITER_HAS_TYPE_MEMBER, 1,
216                 [if iov_iter has member type])
217 ])
218 EXTRA_KCFLAGS="$tmp_flags"
219 ]) # LIBCFS_IOV_ITER_HAS_TYPE
220
221 #
222 # LIBCFS_HAVE_NS_TO_TIMESPEC64
223 #
224 # Kernel version 4.16-rc3 commit a84d1169164b274f13b97a23ff235c000efe3b49
225 # introduced struct __kernel_old_timeval
226 #
227 AC_DEFUN([LIBCFS_HAVE_NS_TO_TIMESPEC64],[
228 LB_CHECK_COMPILE([does 'ns_to_timespec64()' exist],
229 kernel_old_timeval, [
230         #include <linux/time.h>
231 ],[
232         struct timespec64 kts;
233
234         kts = ns_to_timespec64(0);
235 ],[
236         AC_DEFINE(HAVE_NS_TO_TIMESPEC64, 1,
237                 [ns_to_timespec64() is available])
238 ])
239 ]) # LIBCFS_HAVE_NS_TO_TIMESPEC64
240
241 #
242 # Kernel version 3.17 changed hlist_add_after to
243 # hlist_add_behind
244 #
245 AC_DEFUN([LIBCFS_HLIST_ADD_AFTER],[
246 LB_CHECK_COMPILE([does function 'hlist_add_after' exist],
247 hlist_add_after, [
248         #include <linux/list.h>
249 ],[
250         hlist_add_after(NULL, NULL);
251 ],[
252         AC_DEFINE(HAVE_HLIST_ADD_AFTER, 1,
253                 [hlist_add_after is available])
254 ])
255 ]) # LIBCFS_HLIST_ADD_AFTER
256
257 #
258 # Kernel version 3.17 introduced struct timespec64
259 #
260 AC_DEFUN([LIBCFS_TIMESPEC64],[
261 LB_CHECK_COMPILE([does 'struct timespec64' exist],
262 timespec64, [
263         #include <linux/time.h>
264 ],[
265         struct timespec64 ts;
266
267         ts.tv_sec = 0;
268         ts.tv_nsec = 0;
269 ],[
270         AC_DEFINE(HAVE_TIMESPEC64, 1,
271                 ['struct timespec64' is available])
272 ])
273 ]) # LIBCFS_TIMESPEC64
274
275 #
276 # Kernel version 3.17 introduced ktime_get_real_ts64
277 #
278 AC_DEFUN([LIBCFS_KTIME_GET_REAL_TS64],[
279 LB_CHECK_COMPILE([does function 'ktime_get_real_ts64' exist],
280 ktime_get_real_ts64, [
281         #include <linux/ktime.h>
282 ],[
283         struct timespec64 *ts = NULL;
284
285         ktime_get_real_ts64(ts);
286 ],[
287         AC_DEFINE(HAVE_KTIME_GET_REAL_TS64, 1,
288                 ['ktime_get_real_ts64' is available])
289 ])
290 ]) # LIBCFS_KTIME_GET_REAL_TS64
291
292 #
293 # Kernel version 3.17 introduced ktime_get_real_seconds
294 #
295 AC_DEFUN([LIBCFS_KTIME_GET_REAL_SECONDS],[
296 LB_CHECK_COMPILE([does function 'ktime_get_real_seconds' exist],
297 ktime_get_real_seconds, [
298         #include <linux/hrtimer.h>
299         #include <linux/ktime.h>
300 ],[
301         time64_t now;
302
303         now = ktime_get_real_seconds();
304 ],[
305         AC_DEFINE(HAVE_KTIME_GET_REAL_SECONDS, 1,
306                 ['ktime_get_real_seconds' is available])
307 ])
308 ]) # LIBCFS_KTIME_GET_REAL_SECONDS
309
310 #
311 # Kernel version 3.17 created ktime_get_ns wrapper
312 #
313 AC_DEFUN([LIBCFS_KTIME_GET_NS],[
314 LB_CHECK_COMPILE([does function 'ktime_get_ns' exist],
315 ktime_get_ns, [
316         #include <linux/hrtimer.h>
317         #include <linux/ktime.h>
318 ],[
319         u64 nanoseconds;
320
321         nanoseconds = ktime_get_ns();
322 ],[],[
323         AC_DEFINE(NEED_KTIME_GET_NS, 1,
324                 ['ktime_get_ns' is not available])
325 ])
326 ]) # LIBCFS_KTIME_GET_NS
327
328 #
329 # Kernel version 3.17 created ktime_get_real_ns wrapper
330 #
331 AC_DEFUN([LIBCFS_KTIME_GET_REAL_NS],[
332 LB_CHECK_COMPILE([does function 'ktime_get_real_ns' exist],
333 ktime_get_real_ns, [
334         #include <linux/hrtimer.h>
335         #include <linux/ktime.h>
336 ],[
337         u64 nanoseconds;
338
339         nanoseconds = ktime_get_real_ns();
340 ],[],[
341         AC_DEFINE(NEED_KTIME_GET_REAL_NS, 1,
342                 ['ktime_get_real_ns' is not available])
343 ])
344 ]) # LIBCFS_KTIME_GET_REAL_NS
345
346 #
347 # Kernel version 3.17 introduced ktime_to_timespec64
348 #
349 AC_DEFUN([LIBCFS_KTIME_TO_TIMESPEC64],[
350 LB_CHECK_COMPILE([does function 'ktime_to_timespec64' exist],
351 ktime_to_timespec64, [
352         #include <linux/hrtimer.h>
353         #include <linux/ktime.h>
354 ],[
355         ktime_t now = ktime_set(0, 0);
356         struct timespec64 ts;
357
358         ts = ktime_to_timespec64(now);
359 ],[
360         AC_DEFINE(HAVE_KTIME_TO_TIMESPEC64, 1,
361                 ['ktime_to_timespec64' is available])
362 ])
363 ]) # LIBCFS_KTIME_TO_TIMESPEC64
364
365 #
366 # Kernel version 3.17 introduced timespec64_sub
367 #
368 AC_DEFUN([LIBCFS_TIMESPEC64_SUB],[
369 LB_CHECK_COMPILE([does function 'timespec64_sub' exist],
370 timespec64_sub, [
371         #include <linux/time.h>
372 ],[
373         struct timespec64 later = { }, earlier = { }, diff;
374
375         diff = timespec64_sub(later, earlier);
376 ],[
377         AC_DEFINE(HAVE_TIMESPEC64_SUB, 1,
378                 ['timespec64_sub' is available])
379 ])
380 ]) # LIBCFS_TIMESPEC64_SUB
381
382 #
383 # Kernel version 3.17 introduced timespec64_to_ktime
384 #
385 AC_DEFUN([LIBCFS_TIMESPEC64_TO_KTIME],[
386 LB_CHECK_COMPILE([does function 'timespec64_to_ktime' exist],
387 timespec64_to_ktime, [
388         #include <linux/ktime.h>
389 ],[
390         struct timespec64 ts;
391         ktime_t now;
392
393         now = timespec64_to_ktime(ts);
394 ],[
395         AC_DEFINE(HAVE_TIMESPEC64_TO_KTIME, 1,
396                 ['timespec64_to_ktime' is available])
397 ])
398 ]) # LIBCFS_TIMESPEC64_TO_KTIME
399
400 #
401 # Kernel version 3.19 introduced ktime_get_seconds
402 #
403 AC_DEFUN([LIBCFS_KTIME_GET_SECONDS],[
404 LB_CHECK_COMPILE([does function 'ktime_get_seconds' exist],
405 ktime_get_seconds, [
406         #include <linux/ktime.h>
407 ],[
408         time64_t now;
409
410         now = ktime_get_seconds();
411 ],[
412         AC_DEFINE(HAVE_KTIME_GET_SECONDS, 1,
413                 ['ktime_get_seconds' is available])
414 ])
415 ]) # LIBCFS_KTIME_GET_SECONDS
416
417 #
418 # Kernel version 4.0 commit 41fbf3b39d5eca01527338b4d0ee15ee1ae1023c
419 # introduced the helper function ktime_ms_delta.
420 #
421 AC_DEFUN([LIBCFS_KTIME_MS_DELTA],[
422 LB_CHECK_COMPILE([does function 'ktime_ms_delta' exist],
423 ktime_ms_delta, [
424         #include <linux/ktime.h>
425 ],[
426         ktime_t start = ktime_set(0, 0);
427         ktime_t end = start;
428
429         ktime_ms_delta(start, end);
430 ],[
431         AC_DEFINE(HAVE_KTIME_MS_DELTA, 1,
432                 ['ktime_ms_delta' is available])
433 ])
434 ]) # LIBCFS_KTIME_MS_DELTA
435
436 #
437 # Kernel version 4.1 commit b51d23e4e9fea6f264d39535c2a62d1f51e7ccc3
438 # create per module locks which added kernel_param_[un]lock(). Older
439 # kernels you have to use __kernel_param_[un]lock(). In that case its
440 # a global lock for all modules but that is okay since its a rare event.
441 #
442 AC_DEFUN([LIBCFS_KERNEL_PARAM_LOCK],[
443 LB_CHECK_COMPILE([does function 'kernel_param_[un]lock' exist],
444 kernel_param_lock, [
445         #include <linux/moduleparam.h>
446 ],[
447         kernel_param_lock(NULL);
448         kernel_param_unlock(NULL);
449 ],[
450         AC_DEFINE(HAVE_KERNEL_PARAM_LOCK, 1,
451                 ['kernel_param_[un]lock' is available])
452 ])
453 ]) # LIBCFS_KERNEL_PARAM_LOCK
454
455 #
456 # Kernel version 4.2 changed topology_thread_cpumask
457 # to topology_sibling_cpumask
458 #
459 AC_DEFUN([LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK],[
460 LB_CHECK_COMPILE([does function 'topology_sibling_cpumask' exist],
461 topology_sibling_cpumask, [
462         #include <linux/topology.h>
463 ],[
464         const struct cpumask *mask;
465
466         mask = topology_sibling_cpumask(0);
467 ],[
468         AC_DEFINE(HAVE_TOPOLOGY_SIBLING_CPUMASK, 1,
469                 [topology_sibling_cpumask is available])
470 ])
471 ]) # LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK
472
473 #
474 # Kernel version 4.4 commit ef951599074ba4fad2d0efa0a977129b41e6d203
475 # introduced kstrtobool and kstrtobool_from_user.
476 #
477 AC_DEFUN([LIBCFS_KSTRTOBOOL_FROM_USER], [
478 LB_CHECK_COMPILE([if Linux kernel has 'kstrtobool_from_user'],
479 kstrtobool_from_user, [
480         #include <linux/kernel.h>
481 ],[
482         bool result;
483         return kstrtobool_from_user(NULL, 0, &result);
484 ],[
485         AC_DEFINE(HAVE_KSTRTOBOOL_FROM_USER, 1,
486                 [kernel has kstrtobool_from_user])
487 ])
488 ]) # LIBCFS_KSTRTOBOOL_FROM_USER
489
490 #
491 # Kernel version 4.5-rc1 commit d12481bc58fba89427565f8592e88446ec084a24
492 # added crypto hash helpers
493 #
494 AC_DEFUN([LIBCFS_CRYPTO_HASH_HELPERS], [
495 LB_CHECK_COMPILE([does crypto hash helper functions exist],
496 crypto_hash_helpers, [
497         #include <crypto/hash.h>
498 ],[
499         crypto_ahash_alg_name(NULL);
500         crypto_ahash_driver_name(NULL);
501 ],[
502         AC_DEFINE(HAVE_CRYPTO_HASH_HELPERS, 1,
503                 [crypto hash helper functions are available])
504 ])
505 ]) # LIBCFS_CRYPTO_HASH_HELPERS
506
507 #
508 # Kernel version 4.5-rc1 commit 3502cad73c4bbf8f6365d539e814159275252c59
509 # introduced rhashtable_replace_fast
510 #
511 AC_DEFUN([LIBCFS_RHASHTABLE_REPLACE], [
512 LB_CHECK_COMPILE([if 'rhashtable_replace_fast' exists],
513 rhashtable_replace_fast, [
514         #include <linux/rhashtable.h>
515 ],[
516         const struct rhashtable_params params = { 0 };
517
518         rhashtable_replace_fast(NULL, NULL, NULL, params);
519 ],[
520         AC_DEFINE(HAVE_RHASHTABLE_REPLACE, 1,
521                 [rhashtable_replace_fast() is available])
522 ])
523 ]) # LIBCFS_RHASHTABLE_REPLACE
524
525 #
526 # Kernel version 4.5-rc3 commit 2fe829aca9d7bed5fd6b49c6a1452e5e486b6cc3dd
527 # made kset_find_obj() exportable to modules
528 #
529 AC_DEFUN([LIBCFS_EXPORT_KSET_FIND_OBJ], [
530 LB_CHECK_EXPORT([kset_find_obj], [lib/kobject.c],
531         [AC_DEFINE(HAVE_KSET_FIND_OBJ, 1,
532                 [kset_find_obj is exported by the kernel])])
533 ]) # LIBCFS_EXPORT_KSET_FIND_OBJ
534
535 #
536 # Kernel version 4.6+ commit ef703f49a6c5b909a85149bb6625c4ed0d697186
537 # fixed the brokenness of hash_64(). The fix removed GOLDEN_RATIO_PRIME_64
538 # since it was a poor prime value.
539 #
540 AC_DEFUN([LIBCFS_BROKEN_HASH_64], [
541 LB_CHECK_COMPILE([kernel has fixed hash_64()],
542 broken_hash_64, [
543         #include <linux/hash.h>
544 ],[
545         int tmp = GOLDEN_RATIO_PRIME_64;
546 ],[
547         AC_DEFINE(HAVE_BROKEN_HASH_64, 1, [kernel hash_64() is broken])
548 ])
549 ]) # LIBCFS_BROKEN_HASH_64
550
551 #
552 # LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
553 #
554 # linux 4.6 kernel changed stacktrace_ops address to return an int
555 #
556 AC_DEFUN([LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT], [
557 LB_CHECK_COMPILE([if 'struct stacktrace_ops' address function returns an int],
558 stacktrace_ops_address_return_int, [
559         #include <asm/stacktrace.h>
560 ],[
561         int rc;
562
563         rc = ((struct stacktrace_ops *)0)->address(NULL, 0, 0);
564 ],[
565         AC_DEFINE(STACKTRACE_OPS_ADDRESS_RETURN_INT, 1,
566                 ['struct stacktrace_ops' address function returns an int])
567 ])
568 ]) # LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
569
570 #
571 # Kernel version 4.6 removed both struct task_struct and struct mm_struct
572 # arguments to get_user_pages
573 #
574 AC_DEFUN([LIBCFS_GET_USER_PAGES_6ARG], [
575 LB_CHECK_COMPILE([if 'get_user_pages()' takes 6 arguments],
576 get_user_pages_6arg, [
577         #include <linux/mm.h>
578 ],[
579         int rc;
580
581         rc = get_user_pages(0, 0, 0, 0, NULL, NULL);
582 ],[
583         AC_DEFINE(HAVE_GET_USER_PAGES_6ARG, 1,
584                 [get_user_pages takes 6 arguments])
585 ])
586 ]) # LIBCFS_GET_USER_PAGES_6ARG
587
588 #
589 # LIBCFS_STRINGHASH
590 #
591 # 4.6 kernel created stringhash.h which moved stuff out of dcache.h
592 # commit f4bcbe792b8f434e32487cff9d9e30ab45a3ce02
593 #
594 AC_DEFUN([LIBCFS_STRINGHASH], [
595 LB_CHECK_LINUX_HEADER([linux/stringhash.h], [
596         AC_DEFINE(HAVE_STRINGHASH, 1,
597                 [stringhash.h is present])])
598 ]) # LIBCFS_STRINGHASH
599
600 #
601 # LIBCFS_RHASHTABLE_INSERT_FAST
602 #
603 # 4.7+ kernel commit 5ca8cc5bf11faed257c762018aea9106d529232f
604 # changed __rhashtable_insert_fast to support the new function
605 # rhashtable_lookup_get_insert_key().
606 #
607 AC_DEFUN([LIBCFS_RHASHTABLE_INSERT_FAST], [
608 tmp_flags="$EXTRA_KCFLAGS"
609 EXTRA_KCFLAGS="-Werror"
610 LB_CHECK_COMPILE([if internal '__rhashtable_insert_fast()' returns int],
611 rhashtable_insert_fast, [
612         #include <linux/rhashtable.h>
613 ],[
614         const struct rhashtable_params params = { 0 };
615         int rc;
616
617         rc = __rhashtable_insert_fast(NULL, NULL, NULL, params);
618 ],[
619         AC_DEFINE(HAVE_HASHTABLE_INSERT_FAST_RETURN_INT, 1,
620                   ['__rhashtable_insert_fast()' returns int])
621 ])
622 EXTRA_KCFLAGS="$tmp_flags"
623 ]) # LIBCFS_RHASHTABLE_INSERT_FAST
624
625 #
626 # Kernel version 4.7-rc1 commit 8f6fd83c6c5ec66a4a70c728535ddcdfef4f3697
627 # added 3rd arg to rhashtable_walk_init
628 #
629 AC_DEFUN([LIBCFS_RHASHTABLE_WALK_INIT_3ARG], [
630 LB_CHECK_COMPILE([if 'rhashtable_walk_init' has 3 args],
631 rhashtable_walk_init, [
632         #include <linux/gfp.h>
633         #include <linux/rhashtable.h>
634 ],[
635         rhashtable_walk_init(NULL, NULL, GFP_KERNEL);
636 ],[
637         AC_DEFINE(HAVE_3ARG_RHASHTABLE_WALK_INIT, 1,
638                 [rhashtable_walk_init() has 3 args])
639 ])
640 ]) # LIBCFS_RHASHTABLE_REPLACE
641
642 #
643 # Kernel version 4.8-rc6 commit ca26893f05e86497a86732768ec53cd38c0819ca
644 # introduced rhashtable_lookup
645 #
646 AC_DEFUN([LIBCFS_RHASHTABLE_LOOKUP], [
647 LB_CHECK_COMPILE([if 'rhashtable_lookup' exist],
648 rhashtable_lookup, [
649         #include <linux/rhashtable.h>
650 ],[
651         const struct rhashtable_params params = { 0 };
652         void *ret;
653
654         ret = rhashtable_lookup(NULL, NULL, params);
655 ],[
656         AC_DEFINE(HAVE_RHASHTABLE_LOOKUP, 1,
657                 [rhashtable_lookup() is available])
658 ])
659 ]) # LIBCFS_RHASHTABLE_LOOKUP
660
661 #
662 # LIBCFS_RHLTABLE
663 # Kernel version 4.8-rc6 commit ca26893f05e86497a86732768ec53cd38c0819ca
664 # created the rhlist interface to allow inserting duplicate objects
665 # into the same table.
666 #
667 AC_DEFUN([LIBCFS_RHLTABLE], [
668 LB_CHECK_COMPILE([does 'struct rhltable' exist],
669 rhtable, [
670         #include <linux/rhashtable.h>
671 ],[
672         struct rhltable *hlt;
673
674         rhltable_destroy(hlt);
675 ],[
676         AC_DEFINE(HAVE_RHLTABLE, 1,
677                   [struct rhltable exist])
678 ])
679 ]) # LIBCFS_RHLTABLE
680
681 #
682 # LIBCFS_STACKTRACE_OPS
683 #
684 # Kernel version 4.8 commit c8fe4609827aedc9c4b45de80e7cdc8ccfa8541b
685 # removed both struct stacktrace_ops and dump_trace() function
686 #
687 AC_DEFUN([LIBCFS_STACKTRACE_OPS], [
688 LB_CHECK_COMPILE([if 'struct stacktrace_ops' exists],
689 stacktrace_ops, [
690         struct task_struct;
691         struct pt_regs;
692         #include <asm/stacktrace.h>
693 ],[
694         struct stacktrace_ops ops;
695         ops.stack = NULL;
696 ],[
697         AC_DEFINE(HAVE_STACKTRACE_OPS, 1,
698                 [struct stacktrace_ops exists])
699 ])
700 ]) # LIBCFS_STACKTRACE_OPS
701
702 #
703 # Kernel version 4.9-rc1 commit 246779dd090bd1b74d2652b3a6ca7759f593b27a
704 # introduced rhashtable_walk_enter
705 #
706 AC_DEFUN([LIBCFS_RHASHTABLE_WALK_ENTER], [
707 LB_CHECK_COMPILE([if 'rhashtable_walk_enter' exists],
708 rhashtable_walk_enter, [
709         #include <linux/rhashtable.h>
710 ],[
711         rhashtable_walk_enter(NULL, NULL);
712 ],[
713         AC_DEFINE(HAVE_RHASHTABLE_WALK_ENTER, 1,
714                 [rhashtable_walk_enter() is available])
715 ])
716 ]) # LIBCFS_RHASHTABLE_REPLACE
717
718 #
719 # Kernel version 4.9 commit 768ae309a96103ed02eb1e111e838c87854d8b51
720 # mm: replace get_user_pages() write/force parameters with gup_flags
721 #
722 AC_DEFUN([LIBCFS_GET_USER_PAGES_GUP_FLAGS], [
723 LB_CHECK_COMPILE([if 'get_user_pages()' takes gup_flags in arguments],
724 get_user_pages_gup_flags, [
725         #include <linux/mm.h>
726 ],[
727         int rc;
728         rc = get_user_pages(0, 0, FOLL_WRITE, NULL, NULL);
729 ],[
730         AC_DEFINE(HAVE_GET_USER_PAGES_GUP_FLAGS, 1,
731                 [get_user_pages takes gup_flags in arguments])
732 ])
733 ]) # LIBCFS_GET_USER_PAGES_GUP_FLAGS
734
735 #
736 # Kernel version 4.10 commit 7b737965b33188bd3dbb44e938535c4006d97fbb
737 # libcfs: Convert to hotplug state machine
738 #
739 AC_DEFUN([LIBCFS_HOTPLUG_STATE_MACHINE], [
740 LB_CHECK_COMPILE([if libcfs supports CPU hotplug state machine],
741 cpu_hotplug_state_machine, [
742         #include <linux/cpuhotplug.h>
743 ],[
744         cpuhp_remove_state(CPUHP_LUSTRE_CFS_DEAD);
745 ],[
746         AC_DEFINE(HAVE_HOTPLUG_STATE_MACHINE, 1,
747                 [hotplug state machine is supported])
748 ])
749 ]) # LIBCFS_HOTPLUG_STATE_MACHINE
750
751 #
752 # Kernel version 4.10-rc3 commit f405df5de3170c00e5c54f8b7cf4766044a032ba
753 # introduced refcount_t which is atomic_t plus over flow guards.
754 #
755 AC_DEFUN([LIBCFS_REFCOUNT_T], [
756 tmp_flags="$EXTRA_KCFLAGS"
757 EXTRA_KCFLAGS="-Werror"
758 LB_CHECK_LINUX_HEADER([linux/refcount.h], [
759         AC_DEFINE(HAVE_REFCOUNT_T, 1,
760                 [refcount_t is supported])
761 ])
762 EXTRA_KCFLAGS="$tmp_flags"
763 ]) # LIBCFS_REFCOUNT_T
764
765 #
766 # Kernel version 4.12 commit 499118e966f1d2150bd66647c8932343c4e9a0b8
767 # introduce memalloc_noreclaim_{save,restore}
768 #
769 AC_DEFUN([LIBCFS_MEMALLOC_NORECLAIM], [
770 LB_CHECK_COMPILE([if memalloc_noreclaim_{save,restore} exist],
771 memalloc_noreclaim, [
772         #include <linux/sched/mm.h>
773 ],[
774         int flag = memalloc_noreclaim_save();
775         memalloc_noreclaim_restore(flag);
776 ],[
777         AC_DEFINE(HAVE_MEMALLOC_RECLAIM, 1,
778                 [memalloc_noreclaim_{save,restore}() is supported])
779 ])
780 ]) # LIBCFS_MEMALLOC_NORECLAIM
781
782 #
783 # LIBCFS_SCHED_HEADERS
784 #
785 # 4.11 has broken up sched.h into more headers.
786 #
787 AC_DEFUN([LIBCFS_SCHED_HEADERS], [
788 LB_CHECK_LINUX_HEADER([linux/sched/signal.h], [
789         AC_DEFINE(HAVE_SCHED_HEADERS, 1,
790                 [linux/sched header directory exist])])
791 ]) # LIBCFS_SCHED_HEADERS
792
793 #
794 # Kernel version 4.11-rc1 commit 2c935bc57221cc2edc787c72ea0e2d30cdcd3d5e
795 # introduce kref_read
796 #
797 AC_DEFUN([LIBCFS_KREF_READ], [
798 LB_CHECK_COMPILE([if 'kref_read' exists],
799 kref_read, [
800         #include <linux/kref.h>
801 ],[
802         kref_read(NULL);
803 ],[
804         AC_DEFINE(HAVE_KREF_READ, 1,
805                 [kref_read() is available])
806 ])
807 ]) LIBCFS_KREF_READ
808
809 #
810 # Kernel version 4.11-rc1 commit da20420f83ea0fbcf3d03afda08d971ea1d8a356
811 # introduced rht_bucket_var
812 #
813 AC_DEFUN([LIBCFS_RHT_BUCKET_VAR], [
814 LB_CHECK_COMPILE([if 'rht_bucket_var' exists],
815 rht_bucket_var, [
816         #include <linux/rhashtable.h>
817 ],[
818
819         rht_bucket_var(NULL, 0);
820 ],[
821         AC_DEFINE(HAVE_RHT_BUCKET_VAR, 1,
822                 [rht_bucket_var() is available])
823 ])
824 ]) # LIBCFS_RHT_BUCKET_VAR
825
826 #
827 # Kernel version 4.11 commit f9fe1c12d126f9887441fa5bb165046f30ddd4b5
828 # introduced rhashtable_lookup_get_insert_fast
829 #
830 AC_DEFUN([LIBCFS_RHASHTABLE_LOOKUP_GET_INSERT_FAST], [
831 LB_CHECK_COMPILE([if 'rhashtable_lookup_get_insert_fast' exist],
832 rhashtable_lookup_get_insert_fast, [
833         #include <linux/rhashtable.h>
834 ],[
835         const struct rhashtable_params params = { 0 };
836         void *ret;
837
838         ret = rhashtable_lookup_get_insert_fast(NULL, NULL, params);
839 ],[
840         AC_DEFINE(HAVE_RHASHTABLE_LOOKUP_GET_INSERT_FAST, 1,
841                 [rhashtable_lookup_get_insert_fast() is available])
842 ])
843 ]) # LIBCFS_RHASHTABLE_LOOKUP_GET_INSERT_FAST
844
845 #
846 # Kernel version 4.12-rc2 8f553c498e1772cccb39a114da4a498d22992758
847 # provide proper CPU hotplug locking
848 #
849 AC_DEFUN([LIBCFS_CPUS_READ_LOCK], [
850 LB_CHECK_COMPILE([if 'cpus_read_[un]lock' exist],
851 cpu_read_lock, [
852         #include <linux/cpu.h>
853 ],[
854         cpus_read_lock();
855         cpus_read_unlock();
856 ],[
857         AC_DEFINE(HAVE_CPUS_READ_LOCK, 1, ['cpus_read_lock' exist])
858 ])
859 ]) # LIBCFS_CPUS_READ_LOCK
860
861 #
862 # Kernel version 4.12-rc3 f9727a17db9bab71ddae91f74f11a8a2f9a0ece6
863 # renamed uuid_be to uuid_t
864 #
865 AC_DEFUN([LIBCFS_UUID_T], [
866 LB_CHECK_COMPILE([if 'uuid_t' exist],
867 uuid_t, [
868         #include <linux/uuid.h>
869 ],[
870         uuid_t uuid;
871
872         memset(uuid.b, 0, 16);
873 ],[
874         AC_DEFINE(HAVE_UUID_T, 1, ['uuid_t' exist])
875 ])
876 ]) # LIBCFS_UUID_T
877
878 #
879 # Kernel version 4.12-rc3 commit fd851a3cdc196bfc1d229b5f22369069af532bf8
880 # introduce processor.h
881 #
882 AC_DEFUN([LIBCFS_HAVE_PROCESSOR_HEADER], [
883 tmp_flags="$EXTRA_KCFLAGS"
884 EXTRA_KCFLAGS="-Werror"
885 LB_CHECK_LINUX_HEADER([linux/processor.h], [
886         AC_DEFINE(HAVE_PROCESSOR_H, 1,
887                 [processor.h is present])
888 ])
889 EXTRA_KCFLAGS="$tmp_flags"
890 ]) # LIBCFS_HAVE_PROCESSOR_HEADER
891
892 #
893 # Kernel verison 4.12-rc6 commit 5dd43ce2f69d42a71dcacdb13d17d8c0ac1fe8f7
894 # created wait_bit.h
895 #
896 AC_DEFUN([LIBCFS_HAVE_WAIT_BIT_HEADER], [
897 LB_CHECK_LINUX_HEADER([linux/wait_bit.h], [
898         AC_DEFINE(HAVE_WAIT_BIT_HEADER_H, 1,
899                 [wait_bit.h is present])])
900 ]) # LIBCFS_HAVE_WAIT_BIT_HEADER
901
902 #
903 # Kernel version 4.12-rc6 commmit 2055da97389a605c8a00d163d40903afbe413921
904 # changed:
905 #       struct wait_queue_head::task_list       => ::head
906 #       struct wait_queue_entry::task_list      => ::entry
907 #
908 AC_DEFUN([LIBCFS_WAIT_QUEUE_TASK_LIST_RENAME], [
909 LB_CHECK_COMPILE([if linux wait_queue_head list_head is named head],
910 wait_queue_task_list, [
911         #include <linux/wait.h>
912 ],[
913         wait_queue_head_t e;
914
915         INIT_LIST_HEAD(&e.head);
916 ],[
917         AC_DEFINE(HAVE_WAIT_QUEUE_ENTRY_LIST, 1,
918                 [linux wait_queue_head_t list_head is name head])
919 ])
920 ]) # LIBCFS_WAIT_QUEUE_TASK_LIST_RENAME
921
922 #
923 # LIBCFS_WAIT_QUEUE_ENTRY
924 #
925 # Kernel version 4.13 ac6424b981bce1c4bc55675c6ce11bfe1bbfa64f
926 # Rename wait_queue_t => wait_queue_entry_t
927 #
928 AC_DEFUN([LIBCFS_WAIT_QUEUE_ENTRY], [
929 LB_CHECK_COMPILE([if 'wait_queue_entry_t' exists],
930 wait_queue_entry, [
931         #include <linux/wait.h>
932 ],[
933         wait_queue_entry_t e;
934
935         e.flags = 0;
936 ],[
937         AC_DEFINE(HAVE_WAIT_QUEUE_ENTRY, 1,
938                 ['wait_queue_entry_t' is available])
939 ])
940 ]) # LIBCFS_WAIT_QUEUE_ENTRY
941
942 #
943 # LIBCFS_NEW_KERNEL_WRITE
944 #
945 # Kernel version 4.14 e13ec939e96b13e664bb6cee361cc976a0ee621a
946 # changed kernel_write prototype to make is plug compatible
947 # with the unexported vfs_write()
948 #
949 AC_DEFUN([LIBCFS_NEW_KERNEL_WRITE], [
950 tmp_flags="$EXTRA_KCFLAGS"
951 EXTRA_KCFLAGS="-Werror"
952 LB_CHECK_COMPILE([if 'kernel_write' matches other read/write helpers],
953 kernel_write_match, [
954         #include <linux/fs.h>
955 ],[
956         const void *buf = NULL;
957         loff_t pos = 0;
958         return kernel_write(NULL, buf, 0, &pos);
959 ],[
960         AC_DEFINE(HAVE_NEW_KERNEL_WRITE, 1,
961                 ['kernel_write' aligns with read/write helpers])
962 ])
963 EXTRA_KCFLAGS="$tmp_flags"
964 ]) # LIBCFS_NEW_KERNEL_WRITE
965
966 #
967 # LIBCFS_MM_TOTALRAM_PAGES_FUNC
968 #
969 # kernel 5.0 commit ca79b0c211af63fa3276f0e3fd7dd9ada2439839
970 # mm: convert totalram_pages and totalhigh_pages variables to atomic
971 #
972 AC_DEFUN([LIBCFS_MM_TOTALRAM_PAGES_FUNC], [
973 tmp_flags="$EXTRA_KCFLAGS"
974 EXTRA_KCFLAGS="-Werror"
975 LB_CHECK_COMPILE([if totalram_pages is a function],
976 totalram_pages, [
977         #include <linux/mm.h>
978 ],[
979         totalram_pages_inc();
980 ],[
981         AC_DEFINE(HAVE_TOTALRAM_PAGES_AS_FUNC, 1,
982                 [if totalram_pages is a function])
983 ])
984 EXTRA_KCFLAGS="$tmp_flags"
985 ]) # LIBCFS_MM_TOTALRAM_PAGES_FUNC
986
987 #
988 # LIBCFS_NEW_KERNEL_WRITE
989 #
990 # 4.14 commit bdd1d2d3d251c65b74ac4493e08db18971c09240 changed
991 # the signature of kernel_read to match other read/write helpers
992 # and place offset last.
993 #
994 AC_DEFUN([LIBCFS_NEW_KERNEL_READ], [
995 tmp_flags="$EXTRA_KCFLAGS"
996 EXTRA_KCFLAGS="-Werror"
997 LB_CHECK_COMPILE([if 'kernel_read()' has loff_t *pos as last parameter],
998 kernel_read, [
999         #include <linux/fs.h>
1000         ],[
1001         loff_t pos = 0;
1002         kernel_read(NULL, NULL, 0, &pos);
1003 ],[
1004         AC_DEFINE(HAVE_KERNEL_READ_LAST_POSP, 1,
1005                 [kernel_read() signature ends with loff_t *pos])
1006 ])
1007 EXTRA_KCFLAGS="$tmp_flags"
1008 ]) # LIBCFS_NEW_KERNEL_READ
1009
1010 #
1011 # LIBCFS_DEFINE_TIMER
1012 #
1013 # Kernel version 4.14 commit 1d27e3e2252ba9d949ca82fbdb73cde102cb2067
1014 # remove expires and data arguments from DEFINE_TIMER. Also the callback
1015 # when from using unsigned long argument to using struct timer_list pointer.
1016 #
1017 AC_DEFUN([LIBCFS_DEFINE_TIMER], [
1018 LB_CHECK_COMPILE([if DEFINE_TIMER takes only 2 arguments],
1019 define_timer, [
1020         #include <linux/timer.h>
1021 ],[
1022         static DEFINE_TIMER(my_timer, NULL);
1023 ],[
1024         AC_DEFINE(HAVE_NEW_DEFINE_TIMER, 1,
1025                 [DEFINE_TIMER uses only 2 arguements])
1026 ])
1027 ]) # LIBCFS_DEFINE_TIMER
1028
1029 #
1030 # LIBCFS_EXPORT_SAVE_STACK_TRACE_TSK
1031 #
1032 # Kernel 2.6.27 commit 8594698ebddeef5443b7da8258ae33b3eaca61d5
1033 # exported save_stack_trace_tsk for x86.
1034 # Kernel 2.6.27 commit 01f4b8b8b8db09b88be7df7e51192e4e678b69d3
1035 # exported save_stack_trace_tsk for powerpc
1036 # Kernel 4.13 commit e27c7fa015d61c8be6a2c32b2144aad2ae6ec975
1037 # exported save_stack_trace_tsk for arm64
1038 # Kernel 4.14 commit 9a3dc3186fc3795e076a4122da9e0258651a9631
1039 # exported save_stack_trace_tsk for arm
1040 #
1041 AC_DEFUN([LIBCFS_EXPORT_SAVE_STACK_TRACE_TSK], [
1042 LB_CHECK_EXPORT([save_stack_trace_tsk], [arch/$SUBARCH/kernel/stacktrace.c],
1043         [AC_DEFINE(HAVE_SAVE_STACK_TRACE_TSK, 1,
1044                 [save_stack_trace_tsk is exported])])
1045 ]) # LIBCFS_EXPORT_SAVE_STACK_TRACE_TSK
1046
1047 #
1048 # LIBCFS_LOCKDEP_IS_HELD
1049 #
1050 # Kernel v4.15-rc8-106-g08f36ff64234
1051 # lockdep: Make lockdep checking constant
1052 #
1053 AC_DEFUN([LIBCFS_LOCKDEP_IS_HELD], [
1054 tmp_flags="$EXTRA_KCFLAGS"
1055 EXTRA_KCFLAGS="-Werror"
1056 LB_CHECK_COMPILE([if 'lockdep_is_held()' uses const argument],
1057 lockdep_is_held, [
1058         #include <linux/lockdep.h>
1059 ],[
1060 #ifdef CONFIG_LOCKDEP
1061         const struct spinlock *lock = NULL;
1062
1063         lockdep_is_held(lock);
1064 #endif
1065 ],[],[
1066         AC_DEFINE(NEED_LOCKDEP_IS_HELD_DISCARD_CONST, 1,
1067                 [lockdep_is_held() argument is const])
1068 ])
1069 EXTRA_KCFLAGS="$tmp_flags"
1070 ]) # LIBCFS_LOCKDEP_IS_HELD
1071
1072 #
1073 # LIBCFS_TIMER_SETUP
1074 #
1075 # Kernel version 4.15 commit e99e88a9d2b067465adaa9c111ada99a041bef9a
1076 # setup_timer() was replaced by timer_setup(), where the callback
1077 # argument is the structure already holding the struct timer_list.
1078 #
1079 AC_DEFUN([LIBCFS_TIMER_SETUP], [
1080 LB_CHECK_COMPILE([if setup_timer has been replaced with timer_setup],
1081 timer_setup, [
1082         #include <linux/timer.h>
1083 ],[
1084         timer_setup(NULL, NULL, 0);
1085 ],[
1086         AC_DEFINE(HAVE_TIMER_SETUP, 1,
1087                 [timer_setup has replaced setup_timer])
1088 ])
1089 ]) # LIBCFS_TIMER_SETUP
1090
1091 #
1092 # LIBCFS_WAIT_VAR_EVENT
1093 #
1094 # Kernel version 4.16-rc4 commit 6b2bb7265f0b62605e8caee3613449ed0db270b9
1095 # added wait_var_event()
1096 #
1097 AC_DEFUN([LIBCFS_WAIT_VAR_EVENT], [
1098 LB_CHECK_COMPILE([if 'wait_var_event' exist],
1099 wait_var_event, [
1100         #ifdef HAVE_WAIT_BIT_HEADER_H
1101         #include <linux/wait_bit.h>
1102         #endif
1103         #include <linux/wait.h>
1104 ],[
1105         wake_up_var(NULL);
1106 ],[
1107         AC_DEFINE(HAVE_WAIT_VAR_EVENT, 1,
1108                 ['wait_var_event' is available])
1109 ])
1110 ]) # LIBCFS_WAIT_VAR_EVENT
1111
1112 #
1113 # LIBCFS_BITMAP_ALLOC
1114 #
1115 # Kernel version 4.17 commit c42b65e363ce97a828f81b59033c3558f8fa7f70
1116 # added bitmap memory allocation handling.
1117 #
1118 AC_DEFUN([LIBCFS_BITMAP_ALLOC], [
1119 LB_CHECK_COMPILE([if Linux bitmap memory management exist],
1120 bitmap_alloc, [
1121         #include <linux/bitmap.h>
1122 ],[
1123         unsigned long *map = bitmap_alloc(1, GFP_KERNEL);
1124 ],[
1125         AC_DEFINE(HAVE_BITMAP_ALLOC, 1,
1126                 [Linux bitmap can be allocated])
1127 ])
1128 ]) # LIBCFS_BITMAP_ALLOC
1129
1130 #
1131 # LIBCFS_CLEAR_AND_WAKE_UP_BIT
1132 #
1133 # Kernel version 4.17-rc2 commit 8236b0ae31c837d2b3a2565c5f8d77f637e824cc
1134 # added clear_and_wake_up_bit()
1135 #
1136 AC_DEFUN([LIBCFS_CLEAR_AND_WAKE_UP_BIT], [
1137 LB_CHECK_COMPILE([if 'clear_and_wake_up_bit' exist],
1138 clear_and_wake_up_bit, [
1139         #ifdef HAVE_WAIT_BIT_HEADER_H
1140         #include <linux/wait_bit.h>
1141         #endif
1142         #include <linux/wait.h>
1143 ],[
1144         clear_and_wake_up_bit(0, NULL);
1145 ],[
1146         AC_DEFINE(HAVE_CLEAR_AND_WAKE_UP_BIT, 1,
1147                 ['clear_and_wake_up_bit' is available])
1148 ])
1149 ]) # LIBCFS_CLEAR_AND_WAKE_UP_BIT
1150
1151 #
1152 # LIBCFS_XARRAY_SUPPORT
1153 #
1154 # 4.19-rc5 kernel commit 3159f943aafdbacb2f94c38fdaadabf2bbde2a14
1155 # replaced the radix tree implementation with Xarrays. This change
1156 # introduced functionaly needed for general Xarray support
1157 #
1158 AC_DEFUN([LIBCFS_XARRAY_SUPPORT], [
1159 tmp_flags="$EXTRA_KCFLAGS"
1160 EXTRA_KCFLAGS="-Werror"
1161 LB_CHECK_COMPILE([if page cache uses Xarray],
1162 xarray_support, [
1163         #include <linux/xarray.h>
1164 ],[
1165         xa_is_value(NULL);
1166 ],[
1167         AC_DEFINE(HAVE_XARRAY_SUPPORT, 1,
1168                 [kernel Xarray implementation lacks 'xa_is_value'])
1169 ])
1170 EXTRA_KCFLAGS="$tmp_flags"
1171 ]) # LIBCFS_XARRAY_SUPPORT
1172
1173 #
1174 # LIBCFS_HAVE_IOV_ITER_TYPE
1175 #
1176 # kernel 4.20 commit 00e23707442a75b404392cef1405ab4fd498de6b
1177 # iov_iter: Use accessor functions to access an iterator's type and direction.
1178 #
1179 AC_DEFUN([LIBCFS_HAVE_IOV_ITER_TYPE], [
1180 tmp_flags="$EXTRA_KCFLAGS"
1181 EXTRA_KCFLAGS="-Werror"
1182 LB_CHECK_COMPILE([if iov_iter_type exists],
1183 macro_iov_iter_type_exists, [
1184         #include <linux/uio.h>
1185 ],[
1186         struct iov_iter iter = { .type = ITER_KVEC };
1187         enum iter_type type = iov_iter_type(&iter);
1188         (void)type;
1189 ],[
1190         AC_DEFINE(HAVE_IOV_ITER_TYPE, 1,
1191                 [if iov_iter_type exists])
1192 ])
1193 EXTRA_KCFLAGS="$tmp_flags"
1194 ]) # LIBCFS_HAVE_IOV_ITER_TYPE
1195
1196 #
1197 # LIBCFS_GET_REQUEST_KEY_AUTH
1198 #
1199 # kernel 5.0 commit 822ad64d7e46a8e2c8b8a796738d7b657cbb146d
1200 # keys: Fix dependency loop between construction record and auth key
1201 #
1202 # Added <keys/request_key_auth-type.h> and get_request_key_auth()
1203 # which was propagated to stable
1204 #
1205 AC_DEFUN([LIBCFS_GET_REQUEST_KEY_AUTH], [
1206 tmp_flags="$EXTRA_KCFLAGS"
1207 EXTRA_KCFLAGS="-Werror"
1208 LB_CHECK_COMPILE([if get_request_key_auth() is available],
1209 get_request_key_auth_exported, [
1210         #include <linux/key.h>
1211         #include <linux/keyctl.h>
1212         #include <keys/request_key_auth-type.h>
1213 ],[
1214         struct key *ring;
1215         const struct key *key = NULL;
1216         struct request_key_auth *rka = get_request_key_auth(key);
1217
1218         ring = key_get(rka->dest_keyring);
1219 ],[
1220         AC_DEFINE(HAVE_GET_REQUEST_KEY_AUTH, 1,
1221                 [get_request_key_auth() is available])
1222 ])
1223 EXTRA_KCFLAGS="$tmp_flags"
1224 ]) # LIBCFS_GET_REQUEST_KEY_AUTH
1225
1226 #
1227 # LIBCFS_LOOKUP_USER_KEY
1228 #
1229 # kernel 5.3 commit 3cf5d076fb4d48979f382bc9452765bf8b79e740
1230 # signal: Remove task parameter from force_sig
1231 #
1232 AC_DEFUN([LIBCFS_LOOKUP_USER_KEY], [
1233 tmp_flags="$EXTRA_KCFLAGS"
1234 EXTRA_KCFLAGS="-Werror"
1235 LB_CHECK_COMPILE([if lookup_user_key() is available],
1236 lookup_user_key_exported, [
1237         #include <linux/key.h>
1238         #include <linux/keyctl.h>
1239 ],[
1240         lookup_user_key(KEY_SPEC_USER_KEYRING, 0, 0);
1241 ],[
1242         AC_DEFINE(HAVE_LOOKUP_USER_KEY, 1,
1243                 [lookup_user_key() is available])
1244 ])
1245 EXTRA_KCFLAGS="$tmp_flags"
1246 ]) # LIBCFS_LOOKUP_USER_KEY
1247
1248 #
1249 # LIBCFS_FORCE_SIG_WITH_TASK
1250 #
1251 # kernel 5.3 commit 3cf5d076fb4d48979f382bc9452765bf8b79e740
1252 # signal: Remove task parameter from force_sig
1253 #
1254 AC_DEFUN([LIBCFS_FORCE_SIG_WITH_TASK], [
1255 tmp_flags="$EXTRA_KCFLAGS"
1256 EXTRA_KCFLAGS="-Werror"
1257 LB_CHECK_COMPILE([if force_sig has task parameter],
1258 force_sig_with_task, [
1259         #include <linux/sched/signal.h>
1260 ],[
1261         force_sig(SIGINT, NULL);
1262 ],[
1263         AC_DEFINE(HAVE_FORCE_SIG_WITH_TASK, 1,
1264                 [force_sig() has task parameter])
1265 ])
1266 EXTRA_KCFLAGS="$tmp_flags"
1267 ]) # LIBCFS_FORCE_SIG_WITH_TASK
1268
1269 #
1270 # LIBCFS_CACHE_DETAIL_WRITERS
1271 #
1272 # kernel v5.3-rc2-1-g64a38e840ce5
1273 # SUNRPC: Track writers of the 'channel' file to improve cache_listeners_exist
1274 #
1275 AC_DEFUN([LIBCFS_CACHE_DETAIL_WRITERS], [
1276 tmp_flags="$EXTRA_KCFLAGS"
1277 EXTRA_KCFLAGS="-Werror"
1278 LB_CHECK_COMPILE([if struct cache_detail has writers],
1279 cache_detail_writers_atomic, [
1280         #include <linux/sunrpc/cache.h>
1281
1282         static struct cache_detail rsi_cache;
1283 ],[
1284         atomic_set(&rsi_cache.writers, 0);
1285 ],[
1286         AC_DEFINE(HAVE_CACHE_DETAIL_WRITERS, 1,
1287                 [struct cache_detail has writers])
1288 ])
1289 EXTRA_KCFLAGS="$tmp_flags"
1290 ]) # LIBCFS_CACHE_DETAIL_WRITERS
1291
1292 #
1293 # LIBCFS_KALLSYMS_LOOKUP
1294 #
1295 # kernel v5.6-11591-g0bd476e6c671
1296 # kallsyms: unexport kallsyms_lookup_name() and kallsyms_on_each_symbol()
1297 AC_DEFUN([LIBCFS_KALLSYMS_LOOKUP], [
1298 LB_CHECK_EXPORT([kallsyms_lookup_name], [kernel/kallsyms.c],
1299         [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1300                 [kallsyms_lookup_name is exported by kernel])])
1301 ]) # LIBCFS_KALLSYMS_LOOKUP
1302
1303 #
1304 # LIBCFS_VMALLOC_2ARGS
1305 #
1306 # kernel v5.8-rc1~201^2~19
1307 # mm: remove the pgprot argument to __vmalloc
1308 AC_DEFUN([LIBCFS_VMALLOC_2ARGS], [
1309 LB_CHECK_COMPILE([if __vmalloc has 2 args],
1310 vmalloc_2args, [
1311         #include <linux/vmalloc.h>
1312 ],[
1313         __vmalloc(0, 0);
1314 ],[
1315         AC_DEFINE(HAVE_VMALLOC_2ARGS, 1,
1316                 [__vmalloc only takes 2 args.])
1317 ])
1318 ]) # LIBCFS_VMALLOC_2ARGS
1319
1320 #
1321 # LIBCFS_HAVE_NR_UNSTABLE_NFS
1322 #
1323 # kernel v5.8-rc1~201^2~75
1324 # mm/writeback: discard NR_UNSTABLE_NFS, use NR_WRITEBACK instead
1325 #
1326 AC_DEFUN([LIBCFS_HAVE_NR_UNSTABLE_NFS], [
1327 tmp_flags="$EXTRA_KCFLAGS"
1328 EXTRA_KCFLAGS="-Werror"
1329 LB_CHECK_COMPILE([if NR_UNSTABLE_NFS still in use],
1330 nr_unstable_nfs_exists, [
1331         #include <linux/mm.h>
1332
1333         int i;
1334 ],[
1335         i = NR_UNSTABLE_NFS;
1336 ],[
1337         AC_DEFINE(HAVE_NR_UNSTABLE_NFS, 1,
1338                 [NR_UNSTABLE_NFS is still in use.])
1339 ])
1340 EXTRA_KCFLAGS="$tmp_flags"
1341 ]) # LIBCFS_HAVE_NR_UNSTABLE_NFS
1342
1343 #
1344 # LIBCFS_HAVE_MMAP_LOCK
1345 #
1346 # kernel v5.8-rc1~83^2~24
1347 # mmap locking API: rename mmap_sem to mmap_lock
1348 #
1349 AC_DEFUN([LIBCFS_HAVE_MMAP_LOCK], [
1350 LB_CHECK_COMPILE([if mmap_lock API is available],
1351 mmap_write_lock, [
1352         #include <linux/mm.h>
1353 ],[
1354         mmap_write_lock(NULL);
1355 ],[
1356         AC_DEFINE(HAVE_MMAP_LOCK, 1,
1357                 [mmap_lock API is available.])
1358 ])
1359 ]) # LIBCFS_HAVE_MMAP_LOCK
1360
1361 #
1362 # LIBCFS_KERNEL_SETSOCKOPT
1363 #
1364 # kernel v5.8-rc1~165^2~59^2
1365 # net: remove kernel_setsockopt
1366 AC_DEFUN([LIBCFS_KERNEL_SETSOCKOPT], [
1367 tmp_flags="$EXTRA_KCFLAGS"
1368 EXTRA_KCFLAGS="-Werror"
1369 LB_CHECK_COMPILE([if kernel_setsockopt still in use],
1370 kernel_setsockopt_exists, [
1371         #include <linux/net.h>
1372 ],[
1373         kernel_setsockopt(NULL, 0, 0, NULL, 0);
1374 ],[
1375         AC_DEFINE(HAVE_KERNEL_SETSOCKOPT, 1,
1376                 [kernel_setsockopt still in use])
1377 ])
1378 EXTRA_KCFLAGS="$tmp_flags"
1379 ]) # LIBCFS_KERNEL_SETSOCKOPT
1380
1381 AC_DEFUN([LIBCFS_PROG_LINUX_SRC], [] )
1382 AC_DEFUN([LIBCFS_PROG_LINUX_RESULTS], [])
1383
1384 #
1385 # LIBCFS_PROG_LINUX
1386 #
1387 # LibCFS linux kernel checks
1388 #
1389 AC_DEFUN([LIBCFS_PROG_LINUX], [
1390 AC_MSG_NOTICE([LibCFS kernel checks
1391 ==============================================================================])
1392 LIBCFS_CONFIG_PANIC_DUMPLOG
1393
1394 # 3.11
1395 LIBCFS_KTIME_GET_TS64
1396 # 3.12
1397 LIBCFS_PREPARE_TO_WAIT_EVENT
1398 LIBCFS_KERNEL_PARAM_OPS
1399 LIBCFS_KTIME_ADD
1400 LIBCFS_KTIME_AFTER
1401 LIBCFS_KTIME_BEFORE
1402 LIBCFS_KTIME_COMPARE
1403 LIBCFS_SHRINKER_COUNT
1404 # 3.15
1405 LIBCFS_IOV_ITER_HAS_TYPE
1406 # 3.16
1407 LIBCFS_HAVE_NS_TO_TIMESPEC64
1408 # 3.17
1409 LIBCFS_HLIST_ADD_AFTER
1410 LIBCFS_TIMESPEC64
1411 LIBCFS_KTIME_GET_NS
1412 LIBCFS_KTIME_GET_REAL_TS64
1413 LIBCFS_KTIME_GET_REAL_SECONDS
1414 LIBCFS_KTIME_GET_REAL_NS
1415 LIBCFS_KTIME_TO_TIMESPEC64
1416 LIBCFS_TIMESPEC64_SUB
1417 LIBCFS_TIMESPEC64_TO_KTIME
1418 # 3.19
1419 LIBCFS_KTIME_GET_SECONDS
1420 # 4.0
1421 LIBCFS_KTIME_MS_DELTA
1422 # 4.1
1423 LIBCFS_KERNEL_PARAM_LOCK
1424 # 4.2
1425 LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK
1426 # 4.4
1427 LIBCFS_KSTRTOBOOL_FROM_USER
1428 # 4.5
1429 LIBCFS_CRYPTO_HASH_HELPERS
1430 LIBCFS_EXPORT_KSET_FIND_OBJ
1431 LIBCFS_RHASHTABLE_REPLACE
1432 # 4.6
1433 LIBCFS_BROKEN_HASH_64
1434 LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
1435 LIBCFS_GET_USER_PAGES_6ARG
1436 LIBCFS_STRINGHASH
1437 # 4.7
1438 LIBCFS_RHASHTABLE_INSERT_FAST
1439 LIBCFS_RHASHTABLE_WALK_INIT_3ARG
1440 # 4.8
1441 LIBCFS_RHASHTABLE_LOOKUP
1442 LIBCFS_RHLTABLE
1443 LIBCFS_STACKTRACE_OPS
1444 # 4.9
1445 LIBCFS_GET_USER_PAGES_GUP_FLAGS
1446 LIBCFS_RHASHTABLE_WALK_ENTER
1447 # 4.10
1448 LIBCFS_HOTPLUG_STATE_MACHINE
1449 LIBCFS_REFCOUNT_T
1450 # 4.11
1451 LIBCFS_RHASHTABLE_LOOKUP_GET_INSERT_FAST
1452 LIBCFS_SCHED_HEADERS
1453 LIBCFS_KREF_READ
1454 LIBCFS_RHT_BUCKET_VAR
1455 # 4.12
1456 LIBCFS_HAVE_PROCESSOR_HEADER
1457 LIBCFS_HAVE_WAIT_BIT_HEADER
1458 LIBCFS_MEMALLOC_NORECLAIM
1459 LIBCFS_WAIT_QUEUE_TASK_LIST_RENAME
1460 LIBCFS_CPUS_READ_LOCK
1461 LIBCFS_UUID_T
1462 # 4.13
1463 LIBCFS_WAIT_QUEUE_ENTRY
1464 # 4.14
1465 LIBCFS_DEFINE_TIMER
1466 LIBCFS_NEW_KERNEL_WRITE
1467 LIBCFS_NEW_KERNEL_READ
1468 LIBCFS_EXPORT_SAVE_STACK_TRACE_TSK
1469 # 4.15
1470 LIBCFS_LOCKDEP_IS_HELD
1471 LIBCFS_TIMER_SETUP
1472 # 4.16
1473 LIBCFS_WAIT_VAR_EVENT
1474 # 4.17
1475 LIBCFS_BITMAP_ALLOC
1476 LIBCFS_CLEAR_AND_WAKE_UP_BIT
1477 # 4.19
1478 LIBCFS_XARRAY_SUPPORT
1479 # 4.20
1480 LIBCFS_HAVE_IOV_ITER_TYPE
1481 # 5.0
1482 LIBCFS_MM_TOTALRAM_PAGES_FUNC
1483 LIBCFS_GET_REQUEST_KEY_AUTH
1484 # 5.3
1485 LIBCFS_LOOKUP_USER_KEY
1486 LIBCFS_FORCE_SIG_WITH_TASK
1487 LIBCFS_CACHE_DETAIL_WRITERS
1488 LIBCFS_HAVE_NR_UNSTABLE_NFS
1489 # 5.7
1490 LIBCFS_KALLSYMS_LOOKUP
1491 # 5.8
1492 LIBCFS_HAVE_MMAP_LOCK
1493 LIBCFS_KERNEL_SETSOCKOPT
1494 LIBCFS_VMALLOC_2ARGS
1495 ]) # LIBCFS_PROG_LINUX
1496
1497 #
1498 # LIBCFS_PATH_DEFAULTS
1499 #
1500 # default paths for installed files
1501 #
1502 AC_DEFUN([LIBCFS_PATH_DEFAULTS], [
1503 ]) # LIBCFS_PATH_DEFAULTS
1504
1505 #
1506 # LIBCFS_CONFIGURE
1507 #
1508 # other configure checks
1509 #
1510 AC_DEFUN([LIBCFS_CONFIGURE], [
1511 AC_MSG_NOTICE([LibCFS core checks
1512 ==============================================================================])
1513
1514 # libcfs/libcfs/util/nidstrings.c
1515 AC_CHECK_HEADERS([netdb.h asm/types.h endian.h])
1516 AC_CHECK_FUNCS([gethostbyname])
1517
1518 # --------  Check for required packages  --------------
1519
1520 AC_MSG_NOTICE([LibCFS required packages checks
1521 ==============================================================================])
1522
1523 AC_MSG_CHECKING([whether to enable readline support])
1524 AC_ARG_ENABLE(readline,
1525         AC_HELP_STRING([--disable-readline],
1526                 [disable readline support]),
1527         [], [enable_readline="yes"])
1528 AC_MSG_RESULT([$enable_readline])
1529
1530 LIBREADLINE=""
1531 AS_IF([test "x$enable_readline" = xyes], [
1532         AC_CHECK_LIB([readline], [readline], [
1533                 LIBREADLINE="-lreadline"
1534                 AC_DEFINE(HAVE_LIBREADLINE, 1,
1535                         [readline library is available])
1536         ])
1537 ])
1538 AC_SUBST(LIBREADLINE)
1539
1540 AC_MSG_CHECKING([whether to use libpthread for libcfs library])
1541 AC_ARG_ENABLE([libpthread],
1542         AC_HELP_STRING([--disable-libpthread],
1543                 [disable libpthread]),
1544         [], [enable_libpthread="yes"])
1545 AC_MSG_RESULT([$enable_libpthread])
1546
1547 PTHREAD_LIBS=""
1548 AS_IF([test "x$enable_libpthread" = xyes], [
1549         AC_CHECK_LIB([pthread], [pthread_create], [
1550                 PTHREAD_LIBS="-lpthread"
1551                 AC_DEFINE([HAVE_LIBPTHREAD], 1,
1552                         [use libpthread for libcfs library])
1553         ])
1554 ], [
1555         AC_MSG_WARN([Using libpthread for libcfs library is disabled explicitly])
1556 ])
1557 AC_SUBST(PTHREAD_LIBS)
1558 ]) # LIBCFS_CONFIGURE
1559
1560 #
1561 # LIBCFS_CONFIG_FILES
1562 #
1563 # files that should be generated with AC_OUTPUT
1564 #
1565 AC_DEFUN([LIBCFS_CONFIG_FILES], [
1566 AC_CONFIG_FILES([
1567 libcfs/Makefile
1568 libcfs/autoMakefile
1569 libcfs/autoconf/Makefile
1570 libcfs/include/Makefile
1571 libcfs/include/libcfs/Makefile
1572 libcfs/include/uapi/Makefile
1573 libcfs/include/libcfs/linux/Makefile
1574 libcfs/include/libcfs/util/Makefile
1575 libcfs/include/libcfs/crypto/Makefile
1576 libcfs/include/uapi/linux/Makefile
1577 libcfs/libcfs/Makefile
1578 libcfs/libcfs/autoMakefile
1579 libcfs/libcfs/linux/Makefile
1580 libcfs/libcfs/util/Makefile
1581 libcfs/libcfs/crypto/Makefile
1582 ])
1583 ]) # LIBCFS_CONFIG_FILES