Whamcloud - gitweb
LU-9859 libcfs: handle missing refcount.h
[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 # Kernel version 3.17 changed hlist_add_after to
223 # hlist_add_behind
224 #
225 AC_DEFUN([LIBCFS_HLIST_ADD_AFTER],[
226 LB_CHECK_COMPILE([does function 'hlist_add_after' exist],
227 hlist_add_after, [
228         #include <linux/list.h>
229 ],[
230         hlist_add_after(NULL, NULL);
231 ],[
232         AC_DEFINE(HAVE_HLIST_ADD_AFTER, 1,
233                 [hlist_add_after is available])
234 ])
235 ]) # LIBCFS_HLIST_ADD_AFTER
236
237 #
238 # Kernel version 3.17 introduced struct timespec64
239 #
240 AC_DEFUN([LIBCFS_TIMESPEC64],[
241 LB_CHECK_COMPILE([does 'struct timespec64' exist],
242 timespec64, [
243         #include <linux/time.h>
244 ],[
245         struct timespec64 ts;
246
247         ts.tv_sec = 0;
248         ts.tv_nsec = 0;
249 ],[
250         AC_DEFINE(HAVE_TIMESPEC64, 1,
251                 ['struct timespec64' is available])
252 ])
253 ]) # LIBCFS_TIMESPEC64
254
255 #
256 # Kernel version 3.17 introduced ktime_get_real_ts64
257 #
258 AC_DEFUN([LIBCFS_KTIME_GET_REAL_TS64],[
259 LB_CHECK_COMPILE([does function 'ktime_get_real_ts64' exist],
260 ktime_get_real_ts64, [
261         #include <linux/ktime.h>
262 ],[
263         struct timespec64 *ts = NULL;
264
265         ktime_get_real_ts64(ts);
266 ],[
267         AC_DEFINE(HAVE_KTIME_GET_REAL_TS64, 1,
268                 ['ktime_get_real_ts64' is available])
269 ])
270 ]) # LIBCFS_KTIME_GET_REAL_TS64
271
272 #
273 # Kernel version 3.17 introduced ktime_get_real_seconds
274 #
275 AC_DEFUN([LIBCFS_KTIME_GET_REAL_SECONDS],[
276 LB_CHECK_COMPILE([does function 'ktime_get_real_seconds' exist],
277 ktime_get_real_seconds, [
278         #include <linux/hrtimer.h>
279         #include <linux/ktime.h>
280 ],[
281         time64_t now;
282
283         now = ktime_get_real_seconds();
284 ],[
285         AC_DEFINE(HAVE_KTIME_GET_REAL_SECONDS, 1,
286                 ['ktime_get_real_seconds' is available])
287 ])
288 ]) # LIBCFS_KTIME_GET_REAL_SECONDS
289
290 #
291 # Kernel version 3.17 created ktime_get_ns wrapper
292 #
293 AC_DEFUN([LIBCFS_KTIME_GET_NS],[
294 LB_CHECK_COMPILE([does function 'ktime_get_ns' exist],
295 ktime_get_ns, [
296         #include <linux/hrtimer.h>
297         #include <linux/ktime.h>
298 ],[
299         u64 nanoseconds;
300
301         nanoseconds = ktime_get_ns();
302 ],[],[
303         AC_DEFINE(NEED_KTIME_GET_NS, 1,
304                 ['ktime_get_ns' is not available])
305 ])
306 ]) # LIBCFS_KTIME_GET_NS
307
308 #
309 # Kernel version 3.17 created ktime_get_real_ns wrapper
310 #
311 AC_DEFUN([LIBCFS_KTIME_GET_REAL_NS],[
312 LB_CHECK_COMPILE([does function 'ktime_get_real_ns' exist],
313 ktime_get_real_ns, [
314         #include <linux/hrtimer.h>
315         #include <linux/ktime.h>
316 ],[
317         u64 nanoseconds;
318
319         nanoseconds = ktime_get_real_ns();
320 ],[],[
321         AC_DEFINE(NEED_KTIME_GET_REAL_NS, 1,
322                 ['ktime_get_real_ns' is not available])
323 ])
324 ]) # LIBCFS_KTIME_GET_REAL_NS
325
326 #
327 # Kernel version 3.17 introduced ktime_to_timespec64
328 #
329 AC_DEFUN([LIBCFS_KTIME_TO_TIMESPEC64],[
330 LB_CHECK_COMPILE([does function 'ktime_to_timespec64' exist],
331 ktime_to_timespec64, [
332         #include <linux/hrtimer.h>
333         #include <linux/ktime.h>
334 ],[
335         ktime_t now = ktime_set(0, 0);
336         struct timespec64 ts;
337
338         ts = ktime_to_timespec64(now);
339 ],[
340         AC_DEFINE(HAVE_KTIME_TO_TIMESPEC64, 1,
341                 ['ktime_to_timespec64' is available])
342 ])
343 ]) # LIBCFS_KTIME_TO_TIMESPEC64
344
345 #
346 # Kernel version 3.17 introduced timespec64_sub
347 #
348 AC_DEFUN([LIBCFS_TIMESPEC64_SUB],[
349 LB_CHECK_COMPILE([does function 'timespec64_sub' exist],
350 timespec64_sub, [
351         #include <linux/time.h>
352 ],[
353         struct timespec64 later = { }, earlier = { }, diff;
354
355         diff = timespec64_sub(later, earlier);
356 ],[
357         AC_DEFINE(HAVE_TIMESPEC64_SUB, 1,
358                 ['timespec64_sub' is available])
359 ])
360 ]) # LIBCFS_TIMESPEC64_SUB
361
362 #
363 # Kernel version 3.17 introduced timespec64_to_ktime
364 #
365 AC_DEFUN([LIBCFS_TIMESPEC64_TO_KTIME],[
366 LB_CHECK_COMPILE([does function 'timespec64_to_ktime' exist],
367 timespec64_to_ktime, [
368         #include <linux/ktime.h>
369 ],[
370         struct timespec64 ts;
371         ktime_t now;
372
373         now = timespec64_to_ktime(ts);
374 ],[
375         AC_DEFINE(HAVE_TIMESPEC64_TO_KTIME, 1,
376                 ['timespec64_to_ktime' is available])
377 ])
378 ]) # LIBCFS_TIMESPEC64_TO_KTIME
379
380 #
381 # Kernel version 3.19 introduced ktime_get_seconds
382 #
383 AC_DEFUN([LIBCFS_KTIME_GET_SECONDS],[
384 LB_CHECK_COMPILE([does function 'ktime_get_seconds' exist],
385 ktime_get_seconds, [
386         #include <linux/ktime.h>
387 ],[
388         time64_t now;
389
390         now = ktime_get_seconds();
391 ],[
392         AC_DEFINE(HAVE_KTIME_GET_SECONDS, 1,
393                 ['ktime_get_seconds' is available])
394 ])
395 ]) # LIBCFS_KTIME_GET_SECONDS
396
397 #
398 # Kernel version 4.0 commit 41fbf3b39d5eca01527338b4d0ee15ee1ae1023c
399 # introduced the helper function ktime_ms_delta.
400 #
401 AC_DEFUN([LIBCFS_KTIME_MS_DELTA],[
402 LB_CHECK_COMPILE([does function 'ktime_ms_delta' exist],
403 ktime_ms_delta, [
404         #include <linux/ktime.h>
405 ],[
406         ktime_t start = ktime_set(0, 0);
407         ktime_t end = start;
408
409         ktime_ms_delta(start, end);
410 ],[
411         AC_DEFINE(HAVE_KTIME_MS_DELTA, 1,
412                 ['ktime_ms_delta' is available])
413 ])
414 ]) # LIBCFS_KTIME_MS_DELTA
415
416 #
417 # Kernel version 4.1 commit b51d23e4e9fea6f264d39535c2a62d1f51e7ccc3
418 # create per module locks which added kernel_param_[un]lock(). Older
419 # kernels you have to use __kernel_param_[un]lock(). In that case its
420 # a global lock for all modules but that is okay since its a rare event.
421 #
422 AC_DEFUN([LIBCFS_KERNEL_PARAM_LOCK],[
423 LB_CHECK_COMPILE([does function 'kernel_param_[un]lock' exist],
424 kernel_param_lock, [
425         #include <linux/moduleparam.h>
426 ],[
427         kernel_param_lock(NULL);
428         kernel_param_unlock(NULL);
429 ],[
430         AC_DEFINE(HAVE_KERNEL_PARAM_LOCK, 1,
431                 ['kernel_param_[un]lock' is available])
432 ])
433 ]) # LIBCFS_KERNEL_PARAM_LOCK
434
435 #
436 # Kernel version 4.2 changed topology_thread_cpumask
437 # to topology_sibling_cpumask
438 #
439 AC_DEFUN([LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK],[
440 LB_CHECK_COMPILE([does function 'topology_sibling_cpumask' exist],
441 topology_sibling_cpumask, [
442         #include <linux/topology.h>
443 ],[
444         const struct cpumask *mask;
445
446         mask = topology_sibling_cpumask(0);
447 ],[
448         AC_DEFINE(HAVE_TOPOLOGY_SIBLING_CPUMASK, 1,
449                 [topology_sibling_cpumask is available])
450 ])
451 ]) # LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK
452
453 #
454 # Kernel version 4.4 commit ef951599074ba4fad2d0efa0a977129b41e6d203
455 # introduced kstrtobool and kstrtobool_from_user.
456 #
457 AC_DEFUN([LIBCFS_KSTRTOBOOL_FROM_USER], [
458 LB_CHECK_COMPILE([if Linux kernel has 'kstrtobool_from_user'],
459 kstrtobool_from_user, [
460         #include <linux/kernel.h>
461 ],[
462         bool result;
463         return kstrtobool_from_user(NULL, 0, &result);
464 ],[
465         AC_DEFINE(HAVE_KSTRTOBOOL_FROM_USER, 1,
466                 [kernel has kstrtobool_from_user])
467 ])
468 ]) # LIBCFS_KSTRTOBOOL_FROM_USER
469
470 #
471 # Kernel version 4.5-rc1 commit d12481bc58fba89427565f8592e88446ec084a24
472 # added crypto hash helpers
473 #
474 AC_DEFUN([LIBCFS_CRYPTO_HASH_HELPERS], [
475 LB_CHECK_COMPILE([does crypto hash helper functions exist],
476 crypto_hash_helpers, [
477         #include <crypto/hash.h>
478 ],[
479         crypto_ahash_alg_name(NULL);
480         crypto_ahash_driver_name(NULL);
481 ],[
482         AC_DEFINE(HAVE_CRYPTO_HASH_HELPERS, 1,
483                 [crypto hash helper functions are available])
484 ])
485 ]) # LIBCFS_CRYPTO_HASH_HELPERS
486
487 #
488 # Kernel version 4.5-rc1 commit 3502cad73c4bbf8f6365d539e814159275252c59
489 # introduced rhashtable_replace_fast
490 #
491 AC_DEFUN([LIBCFS_RHASHTABLE_REPLACE], [
492 LB_CHECK_COMPILE([if 'rhashtable_replace_fast' exists],
493 rhashtable_replace_fast, [
494         #include <linux/rhashtable.h>
495 ],[
496         const struct rhashtable_params params = { 0 };
497
498         rhashtable_replace_fast(NULL, NULL, NULL, params);
499 ],[
500         AC_DEFINE(HAVE_RHASHTABLE_REPLACE, 1,
501                 [rhashtable_replace_fast() is available])
502 ])
503 ]) # LIBCFS_RHASHTABLE_REPLACE
504
505 #
506 # Kernel version 4.5-rc3 commit 2fe829aca9d7bed5fd6b49c6a1452e5e486b6cc3dd
507 # made kset_find_obj() exportable to modules
508 #
509 AC_DEFUN([LIBCFS_EXPORT_KSET_FIND_OBJ], [
510 LB_CHECK_EXPORT([kset_find_obj], [lib/kobject.c],
511         [AC_DEFINE(HAVE_KSET_FIND_OBJ, 1,
512                 [kset_find_obj is exported by the kernel])])
513 ]) # LIBCFS_EXPORT_KSET_FIND_OBJ
514
515 #
516 # Kernel version 4.6+ commit ef703f49a6c5b909a85149bb6625c4ed0d697186
517 # fixed the brokenness of hash_64(). The fix removed GOLDEN_RATIO_PRIME_64
518 # since it was a poor prime value.
519 #
520 AC_DEFUN([LIBCFS_BROKEN_HASH_64], [
521 LB_CHECK_COMPILE([kernel has fixed hash_64()],
522 broken_hash_64, [
523         #include <linux/hash.h>
524 ],[
525         int tmp = GOLDEN_RATIO_PRIME_64;
526 ],[
527         AC_DEFINE(HAVE_BROKEN_HASH_64, 1, [kernel hash_64() is broken])
528 ])
529 ]) # LIBCFS_BROKEN_HASH_64
530
531 #
532 # LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
533 #
534 # linux 4.6 kernel changed stacktrace_ops address to return an int
535 #
536 AC_DEFUN([LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT], [
537 LB_CHECK_COMPILE([if 'struct stacktrace_ops' address function returns an int],
538 stacktrace_ops_address_return_int, [
539         #include <asm/stacktrace.h>
540 ],[
541         int rc;
542
543         rc = ((struct stacktrace_ops *)0)->address(NULL, 0, 0);
544 ],[
545         AC_DEFINE(STACKTRACE_OPS_ADDRESS_RETURN_INT, 1,
546                 ['struct stacktrace_ops' address function returns an int])
547 ])
548 ]) # LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
549
550 #
551 # Kernel version 4.6 removed both struct task_struct and struct mm_struct
552 # arguments to get_user_pages
553 #
554 AC_DEFUN([LIBCFS_GET_USER_PAGES_6ARG], [
555 LB_CHECK_COMPILE([if 'get_user_pages()' takes 6 arguments],
556 get_user_pages_6arg, [
557         #include <linux/mm.h>
558 ],[
559         int rc;
560
561         rc = get_user_pages(0, 0, 0, 0, NULL, NULL);
562 ],[
563         AC_DEFINE(HAVE_GET_USER_PAGES_6ARG, 1,
564                 [get_user_pages takes 6 arguments])
565 ])
566 ]) # LIBCFS_GET_USER_PAGES_6ARG
567
568 #
569 # LIBCFS_STRINGHASH
570 #
571 # 4.6 kernel created stringhash.h which moved stuff out of dcache.h
572 # commit f4bcbe792b8f434e32487cff9d9e30ab45a3ce02
573 #
574 AC_DEFUN([LIBCFS_STRINGHASH], [
575 LB_CHECK_LINUX_HEADER([linux/stringhash.h], [
576         AC_DEFINE(HAVE_STRINGHASH, 1,
577                 [stringhash.h is present])])
578 ]) # LIBCFS_STRINGHASH
579
580 #
581 # LIBCFS_RHASHTABLE_INSERT_FAST
582 #
583 # 4.7+ kernel commit 5ca8cc5bf11faed257c762018aea9106d529232f
584 # changed __rhashtable_insert_fast to support the new function
585 # rhashtable_lookup_get_insert_key().
586 #
587 AC_DEFUN([LIBCFS_RHASHTABLE_INSERT_FAST], [
588 tmp_flags="$EXTRA_KCFLAGS"
589 EXTRA_KCFLAGS="-Werror"
590 LB_CHECK_COMPILE([if internal '__rhashtable_insert_fast()' returns int],
591 rhashtable_insert_fast, [
592         #include <linux/rhashtable.h>
593 ],[
594         const struct rhashtable_params params = { 0 };
595         int rc;
596
597         rc = __rhashtable_insert_fast(NULL, NULL, NULL, params);
598 ],[
599         AC_DEFINE(HAVE_HASHTABLE_INSERT_FAST_RETURN_INT, 1,
600                   ['__rhashtable_insert_fast()' returns int])
601 ])
602 EXTRA_KCFLAGS="$tmp_flags"
603 ]) # LIBCFS_RHASHTABLE_INSERT_FAST
604
605 #
606 # Kernel version 4.7-rc1 commit 8f6fd83c6c5ec66a4a70c728535ddcdfef4f3697
607 # added 3rd arg to rhashtable_walk_init
608 #
609 AC_DEFUN([LIBCFS_RHASHTABLE_WALK_INIT_3ARG], [
610 LB_CHECK_COMPILE([if 'rhashtable_walk_init' has 3 args],
611 rhashtable_walk_init, [
612         #include <linux/gfp.h>
613         #include <linux/rhashtable.h>
614 ],[
615         rhashtable_walk_init(NULL, NULL, GFP_KERNEL);
616 ],[
617         AC_DEFINE(HAVE_3ARG_RHASHTABLE_WALK_INIT, 1,
618                 [rhashtable_walk_init() has 3 args])
619 ])
620 ]) # LIBCFS_RHASHTABLE_REPLACE
621
622 #
623 # Kernel version 4.8-rc6 commit ca26893f05e86497a86732768ec53cd38c0819ca
624 # introduced rhashtable_lookup
625 #
626 AC_DEFUN([LIBCFS_RHASHTABLE_LOOKUP], [
627 LB_CHECK_COMPILE([if 'rhashtable_lookup' exist],
628 rhashtable_lookup, [
629         #include <linux/rhashtable.h>
630 ],[
631         const struct rhashtable_params params = { 0 };
632         void *ret;
633
634         ret = rhashtable_lookup(NULL, NULL, params);
635 ],[
636         AC_DEFINE(HAVE_RHASHTABLE_LOOKUP, 1,
637                 [rhashtable_lookup() is available])
638 ])
639 ]) # LIBCFS_RHASHTABLE_LOOKUP
640
641 #
642 # LIBCFS_RHLTABLE
643 # Kernel version 4.8-rc6 commit ca26893f05e86497a86732768ec53cd38c0819ca
644 # created the rhlist interface to allow inserting duplicate objects
645 # into the same table.
646 #
647 AC_DEFUN([LIBCFS_RHLTABLE], [
648 LB_CHECK_COMPILE([does 'struct rhltable' exist],
649 rhtable, [
650         #include <linux/rhashtable.h>
651 ],[
652         struct rhltable *hlt;
653
654         rhltable_destroy(hlt);
655 ],[
656         AC_DEFINE(HAVE_RHLTABLE, 1,
657                   [struct rhltable exist])
658 ])
659 ]) # LIBCFS_RHLTABLE
660
661 #
662 # LIBCFS_STACKTRACE_OPS
663 #
664 # Kernel version 4.8 commit c8fe4609827aedc9c4b45de80e7cdc8ccfa8541b
665 # removed both struct stacktrace_ops and dump_trace() function
666 #
667 AC_DEFUN([LIBCFS_STACKTRACE_OPS], [
668 LB_CHECK_COMPILE([if 'struct stacktrace_ops' exists],
669 stacktrace_ops, [
670         struct task_struct;
671         struct pt_regs;
672         #include <asm/stacktrace.h>
673 ],[
674         struct stacktrace_ops ops;
675         ops.stack = NULL;
676 ],[
677         AC_DEFINE(HAVE_STACKTRACE_OPS, 1,
678                 [struct stacktrace_ops exists])
679 ])
680 ]) # LIBCFS_STACKTRACE_OPS
681
682 #
683 # Kernel version 4.9-rc1 commit 246779dd090bd1b74d2652b3a6ca7759f593b27a
684 # introduced rhashtable_walk_enter
685 #
686 AC_DEFUN([LIBCFS_RHASHTABLE_WALK_ENTER], [
687 LB_CHECK_COMPILE([if 'rhashtable_walk_enter' exists],
688 rhashtable_walk_enter, [
689         #include <linux/rhashtable.h>
690 ],[
691         rhashtable_walk_enter(NULL, NULL);
692 ],[
693         AC_DEFINE(HAVE_RHASHTABLE_WALK_ENTER, 1,
694                 [rhashtable_walk_enter() is available])
695 ])
696 ]) # LIBCFS_RHASHTABLE_REPLACE
697
698 #
699 # Kernel version 4.9 commit 768ae309a96103ed02eb1e111e838c87854d8b51
700 # mm: replace get_user_pages() write/force parameters with gup_flags
701 #
702 AC_DEFUN([LIBCFS_GET_USER_PAGES_GUP_FLAGS], [
703 LB_CHECK_COMPILE([if 'get_user_pages()' takes gup_flags in arguments],
704 get_user_pages_gup_flags, [
705         #include <linux/mm.h>
706 ],[
707         int rc;
708         rc = get_user_pages(0, 0, FOLL_WRITE, NULL, NULL);
709 ],[
710         AC_DEFINE(HAVE_GET_USER_PAGES_GUP_FLAGS, 1,
711                 [get_user_pages takes gup_flags in arguments])
712 ])
713 ]) # LIBCFS_GET_USER_PAGES_GUP_FLAGS
714
715 #
716 # Kernel version 4.10 commit 7b737965b33188bd3dbb44e938535c4006d97fbb
717 # libcfs: Convert to hotplug state machine
718 #
719 AC_DEFUN([LIBCFS_HOTPLUG_STATE_MACHINE], [
720 LB_CHECK_COMPILE([if libcfs supports CPU hotplug state machine],
721 cpu_hotplug_state_machine, [
722         #include <linux/cpuhotplug.h>
723 ],[
724         cpuhp_remove_state(CPUHP_LUSTRE_CFS_DEAD);
725 ],[
726         AC_DEFINE(HAVE_HOTPLUG_STATE_MACHINE, 1,
727                 [hotplug state machine is supported])
728 ])
729 ]) # LIBCFS_HOTPLUG_STATE_MACHINE
730
731 #
732 # Kernel version 4.10-rc3 commit f405df5de3170c00e5c54f8b7cf4766044a032ba
733 # introduced refcount_t which is atomic_t plus over flow guards.
734 #
735 AC_DEFUN([LIBCFS_REFCOUNT_T], [
736 tmp_flags="$EXTRA_KCFLAGS"
737 EXTRA_KCFLAGS="-Werror"
738 LB_CHECK_LINUX_HEADER([linux/refcount.h], [
739         AC_DEFINE(HAVE_REFCOUNT_T, 1,
740                 [refcount_t is supported])
741 ])
742 EXTRA_KCFLAGS="$tmp_flags"
743 ]) # LIBCFS_REFCOUNT_T
744
745 #
746 # LIBCFS_SCHED_HEADERS
747 #
748 # 4.11 has broken up sched.h into more headers.
749 #
750 AC_DEFUN([LIBCFS_SCHED_HEADERS], [
751 LB_CHECK_LINUX_HEADER([linux/sched/signal.h], [
752         AC_DEFINE(HAVE_SCHED_HEADERS, 1,
753                 [linux/sched header directory exist])])
754 ]) # LIBCFS_SCHED_HEADERS
755
756 #
757 # Kernel version 4.11-rc1 commit 2c935bc57221cc2edc787c72ea0e2d30cdcd3d5e
758 # introduce kref_read
759 #
760 AC_DEFUN([LIBCFS_KREF_READ], [
761 LB_CHECK_COMPILE([if 'kref_read' exists],
762 kref_read, [
763         #include <linux/kref.h>
764 ],[
765         kref_read(NULL);
766 ],[
767         AC_DEFINE(HAVE_KREF_READ, 1,
768                 [kref_read() is available])
769 ])
770 ]) LIBCFS_KREF_READ
771
772 #
773 # Kernel version 4.11-rc1 commit da20420f83ea0fbcf3d03afda08d971ea1d8a356
774 # introduced rht_bucket_var
775 #
776 AC_DEFUN([LIBCFS_RHT_BUCKET_VAR], [
777 LB_CHECK_COMPILE([if 'rht_bucket_var' exists],
778 rht_bucket_var, [
779         #include <linux/rhashtable.h>
780 ],[
781
782         rht_bucket_var(NULL, 0);
783 ],[
784         AC_DEFINE(HAVE_RHT_BUCKET_VAR, 1,
785                 [rht_bucket_var() is available])
786 ])
787 ]) # LIBCFS_RHT_BUCKET_VAR
788
789 #
790 # Kernel version 4.11 commit f9fe1c12d126f9887441fa5bb165046f30ddd4b5
791 # introduced rhashtable_lookup_get_insert_fast
792 #
793 AC_DEFUN([LIBCFS_RHASHTABLE_LOOKUP_GET_INSERT_FAST], [
794 LB_CHECK_COMPILE([if 'rhashtable_lookup_get_insert_fast' exist],
795 rhashtable_lookup_get_insert_fast, [
796         #include <linux/rhashtable.h>
797 ],[
798         const struct rhashtable_params params = { 0 };
799         void *ret;
800
801         ret = rhashtable_lookup_get_insert_fast(NULL, NULL, params);
802 ],[
803         AC_DEFINE(HAVE_RHASHTABLE_LOOKUP_GET_INSERT_FAST, 1,
804                 [rhashtable_lookup_get_insert_fast() is available])
805 ])
806 ]) # LIBCFS_RHASHTABLE_LOOKUP_GET_INSERT_FAST
807
808 #
809 # Kernel version 4.12-rc2 8f553c498e1772cccb39a114da4a498d22992758
810 # provide proper CPU hotplug locking
811 #
812 AC_DEFUN([LIBCFS_CPUS_READ_LOCK], [
813 LB_CHECK_COMPILE([if 'cpus_read_[un]lock' exist],
814 cpu_read_lock, [
815         #include <linux/cpu.h>
816 ],[
817         cpus_read_lock();
818         cpus_read_unlock();
819 ],[
820         AC_DEFINE(HAVE_CPUS_READ_LOCK, 1, ['cpus_read_lock' exist])
821 ])
822 ]) # LIBCFS_CPUS_READ_LOCK
823
824 #
825 # Kernel version 4.12-rc3 f9727a17db9bab71ddae91f74f11a8a2f9a0ece6
826 # renamed uuid_be to uuid_t
827 #
828 AC_DEFUN([LIBCFS_UUID_T], [
829 LB_CHECK_COMPILE([if 'uuid_t' exist],
830 uuid_t, [
831         #include <linux/uuid.h>
832 ],[
833         uuid_t uuid;
834
835         memset(uuid.b, 0, 16);
836 ],[
837         AC_DEFINE(HAVE_UUID_T, 1, ['uuid_t' exist])
838 ])
839 ]) # LIBCFS_UUID_T
840
841 #
842 # Kernel version 4.12-rc3 commit fd851a3cdc196bfc1d229b5f22369069af532bf8
843 # introduce processor.h
844 #
845 AC_DEFUN([LIBCFS_HAVE_PROCESSOR_HEADER], [
846 tmp_flags="$EXTRA_KCFLAGS"
847 EXTRA_KCFLAGS="-Werror"
848 LB_CHECK_LINUX_HEADER([linux/processor.h], [
849         AC_DEFINE(HAVE_PROCESSOR_H, 1,
850                 [processor.h is present])
851 ])
852 EXTRA_KCFLAGS="$tmp_flags"
853 ]) # LIBCFS_HAVE_PROCESSOR_HEADER
854
855 #
856 # Kernel verison 4.12-rc6 commit 5dd43ce2f69d42a71dcacdb13d17d8c0ac1fe8f7
857 # created wait_bit.h
858 #
859 AC_DEFUN([LIBCFS_HAVE_WAIT_BIT_HEADER], [
860 LB_CHECK_LINUX_HEADER([linux/wait_bit.h], [
861         AC_DEFINE(HAVE_WAIT_BIT_HEADER_H, 1,
862                 [wait_bit.h is present])])
863 ]) # LIBCFS_HAVE_WAIT_BIT_HEADER
864
865 #
866 # Kernel version 4.12-rc6 commmit 2055da97389a605c8a00d163d40903afbe413921
867 # changed:
868 #       struct wait_queue_head::task_list       => ::head
869 #       struct wait_queue_entry::task_list      => ::entry
870 #
871 AC_DEFUN([LIBCFS_WAIT_QUEUE_TASK_LIST_RENAME], [
872 LB_CHECK_COMPILE([if linux wait_queue_head list_head is named head],
873 wait_queue_task_list, [
874         #include <linux/wait.h>
875 ],[
876         wait_queue_head_t e;
877
878         INIT_LIST_HEAD(&e.head);
879 ],[
880         AC_DEFINE(HAVE_WAIT_QUEUE_ENTRY_LIST, 1,
881                 [linux wait_queue_head_t list_head is name head])
882 ])
883 ]) # LIBCFS_WAIT_QUEUE_TASK_LIST_RENAME
884
885 #
886 # LIBCFS_WAIT_QUEUE_ENTRY
887 #
888 # Kernel version 4.13 ac6424b981bce1c4bc55675c6ce11bfe1bbfa64f
889 # Rename wait_queue_t => wait_queue_entry_t
890 #
891 AC_DEFUN([LIBCFS_WAIT_QUEUE_ENTRY], [
892 LB_CHECK_COMPILE([if 'wait_queue_entry_t' exists],
893 wait_queue_entry, [
894         #include <linux/wait.h>
895 ],[
896         wait_queue_entry_t e;
897
898         e.flags = 0;
899 ],[
900         AC_DEFINE(HAVE_WAIT_QUEUE_ENTRY, 1,
901                 ['wait_queue_entry_t' is available])
902 ])
903 ]) # LIBCFS_WAIT_QUEUE_ENTRY
904
905 #
906 # LIBCFS_NEW_KERNEL_WRITE
907 #
908 # Kernel version 4.14 e13ec939e96b13e664bb6cee361cc976a0ee621a
909 # changed kernel_write prototype to make is plug compatible
910 # with the unexported vfs_write()
911 #
912 AC_DEFUN([LIBCFS_NEW_KERNEL_WRITE], [
913 tmp_flags="$EXTRA_KCFLAGS"
914 EXTRA_KCFLAGS="-Werror"
915 LB_CHECK_COMPILE([if 'kernel_write' matches other read/write helpers],
916 kernel_write_match, [
917         #include <linux/fs.h>
918 ],[
919         const void *buf = NULL;
920         loff_t pos = 0;
921         return kernel_write(NULL, buf, 0, &pos);
922 ],[
923         AC_DEFINE(HAVE_NEW_KERNEL_WRITE, 1,
924                 ['kernel_write' aligns with read/write helpers])
925 ])
926 EXTRA_KCFLAGS="$tmp_flags"
927 ]) # LIBCFS_NEW_KERNEL_WRITE
928
929 #
930 # LIBCFS_MM_TOTALRAM_PAGES_FUNC
931 #
932 # kernel 5.0 commit ca79b0c211af63fa3276f0e3fd7dd9ada2439839
933 # mm: convert totalram_pages and totalhigh_pages variables to atomic
934 #
935 AC_DEFUN([LIBCFS_MM_TOTALRAM_PAGES_FUNC], [
936 tmp_flags="$EXTRA_KCFLAGS"
937 EXTRA_KCFLAGS="-Werror"
938 LB_CHECK_COMPILE([if totalram_pages is a function],
939 totalram_pages, [
940         #include <linux/mm.h>
941 ],[
942         totalram_pages_inc();
943 ],[
944         AC_DEFINE(HAVE_TOTALRAM_PAGES_AS_FUNC, 1,
945                 [if totalram_pages is a function])
946 ])
947 EXTRA_KCFLAGS="$tmp_flags"
948 ]) # LIBCFS_MM_TOTALRAM_PAGES_FUNC
949
950 #
951 # LIBCFS_NEW_KERNEL_WRITE
952 #
953 # 4.14 commit bdd1d2d3d251c65b74ac4493e08db18971c09240 changed
954 # the signature of kernel_read to match other read/write helpers
955 # and place offset last.
956 #
957 AC_DEFUN([LIBCFS_NEW_KERNEL_READ], [
958 tmp_flags="$EXTRA_KCFLAGS"
959 EXTRA_KCFLAGS="-Werror"
960 LB_CHECK_COMPILE([if 'kernel_read()' has loff_t *pos as last parameter],
961 kernel_read, [
962         #include <linux/fs.h>
963         ],[
964         loff_t pos = 0;
965         kernel_read(NULL, NULL, 0, &pos);
966 ],[
967         AC_DEFINE(HAVE_KERNEL_READ_LAST_POSP, 1,
968                 [kernel_read() signature ends with loff_t *pos])
969 ])
970 EXTRA_KCFLAGS="$tmp_flags"
971 ]) # LIBCFS_NEW_KERNEL_READ
972
973 #
974 # LIBCFS_DEFINE_TIMER
975 #
976 # Kernel version 4.14 commit 1d27e3e2252ba9d949ca82fbdb73cde102cb2067
977 # remove expires and data arguments from DEFINE_TIMER. Also the callback
978 # when from using unsigned long argument to using struct timer_list pointer.
979 #
980 AC_DEFUN([LIBCFS_DEFINE_TIMER], [
981 LB_CHECK_COMPILE([if DEFINE_TIMER takes only 2 arguments],
982 define_timer, [
983         #include <linux/timer.h>
984 ],[
985         static DEFINE_TIMER(my_timer, NULL);
986 ],[
987         AC_DEFINE(HAVE_NEW_DEFINE_TIMER, 1,
988                 [DEFINE_TIMER uses only 2 arguements])
989 ])
990 ]) # LIBCFS_DEFINE_TIMER
991
992 #
993 # LIBCFS_EXPORT_SAVE_STACK_TRACE_TSK
994 #
995 # Kernel 2.6.27 commit 8594698ebddeef5443b7da8258ae33b3eaca61d5
996 # exported save_stack_trace_tsk for x86.
997 # Kernel 2.6.27 commit 01f4b8b8b8db09b88be7df7e51192e4e678b69d3
998 # exported save_stack_trace_tsk for powerpc
999 # Kernel 4.13 commit e27c7fa015d61c8be6a2c32b2144aad2ae6ec975
1000 # exported save_stack_trace_tsk for arm64
1001 # Kernel 4.14 commit 9a3dc3186fc3795e076a4122da9e0258651a9631
1002 # exported save_stack_trace_tsk for arm
1003 #
1004 AC_DEFUN([LIBCFS_EXPORT_SAVE_STACK_TRACE_TSK], [
1005 LB_CHECK_EXPORT([save_stack_trace_tsk], [arch/$SUBARCH/kernel/stacktrace.c],
1006         [AC_DEFINE(HAVE_SAVE_STACK_TRACE_TSK, 1,
1007                 [save_stack_trace_tsk is exported])])
1008 ]) # LIBCFS_EXPORT_SAVE_STACK_TRACE_TSK
1009
1010 #
1011 # LIBCFS_TIMER_SETUP
1012 #
1013 # Kernel version 4.15 commit e99e88a9d2b067465adaa9c111ada99a041bef9a
1014 # setup_timer() was replaced by timer_setup(), where the callback
1015 # argument is the structure already holding the struct timer_list.
1016 #
1017 AC_DEFUN([LIBCFS_TIMER_SETUP], [
1018 LB_CHECK_COMPILE([if setup_timer has been replaced with timer_setup],
1019 timer_setup, [
1020         #include <linux/timer.h>
1021 ],[
1022         timer_setup(NULL, NULL, 0);
1023 ],[
1024         AC_DEFINE(HAVE_TIMER_SETUP, 1,
1025                 [timer_setup has replaced setup_timer])
1026 ])
1027 ]) # LIBCFS_TIMER_SETUP
1028
1029 #
1030 # LIBCFS_WAIT_VAR_EVENT
1031 #
1032 # Kernel version 4.16-rc4 commit 6b2bb7265f0b62605e8caee3613449ed0db270b9
1033 # added wait_var_event()
1034 #
1035 AC_DEFUN([LIBCFS_WAIT_VAR_EVENT], [
1036 LB_CHECK_COMPILE([if 'wait_var_event' exist],
1037 wait_var_event, [
1038         #ifdef HAVE_WAIT_BIT_HEADER_H
1039         #include <linux/wait_bit.h>
1040         #endif
1041         #include <linux/wait.h>
1042 ],[
1043         wake_up_var(NULL);
1044 ],[
1045         AC_DEFINE(HAVE_WAIT_VAR_EVENT, 1,
1046                 ['wait_var_event' is available])
1047 ])
1048 ]) # LIBCFS_WAIT_VAR_EVENT
1049
1050 #
1051 # LIBCFS_CLEAR_AND_WAKE_UP_BIT
1052 #
1053 # Kernel version 4.17-rc2 commit 8236b0ae31c837d2b3a2565c5f8d77f637e824cc
1054 # added clear_and_wake_up_bit()
1055 #
1056 AC_DEFUN([LIBCFS_CLEAR_AND_WAKE_UP_BIT], [
1057 LB_CHECK_COMPILE([if 'clear_and_wake_up_bit' exist],
1058 clear_and_wake_up_bit, [
1059         #ifdef HAVE_WAIT_BIT_HEADER_H
1060         #include <linux/wait_bit.h>
1061         #endif
1062         #include <linux/wait.h>
1063 ],[
1064         clear_and_wake_up_bit(0, NULL);
1065 ],[
1066         AC_DEFINE(HAVE_CLEAR_AND_WAKE_UP_BIT, 1,
1067                 ['clear_and_wake_up_bit' is available])
1068 ])
1069 ]) # LIBCFS_CLEAR_AND_WAKE_UP_BIT
1070
1071 #
1072 # LIBCFS_HAVE_IOV_ITER_TYPE
1073 #
1074 # kernel 4.20 commit 00e23707442a75b404392cef1405ab4fd498de6b
1075 # iov_iter: Use accessor functions to access an iterator's type and direction.
1076 #
1077 AC_DEFUN([LIBCFS_HAVE_IOV_ITER_TYPE], [
1078 tmp_flags="$EXTRA_KCFLAGS"
1079 EXTRA_KCFLAGS="-Werror"
1080 LB_CHECK_COMPILE([if iov_iter_type exists],
1081 macro_iov_iter_type_exists, [
1082         #include <linux/uio.h>
1083 ],[
1084         struct iov_iter iter = { .type = ITER_KVEC };
1085         enum iter_type type = iov_iter_type(&iter);
1086         (void)type;
1087 ],[
1088         AC_DEFINE(HAVE_IOV_ITER_TYPE, 1,
1089                 [if iov_iter_type exists])
1090 ])
1091 EXTRA_KCFLAGS="$tmp_flags"
1092 ]) # LIBCFS_HAVE_IOV_ITER_TYPE
1093
1094 #
1095 # LIBCFS_GET_REQUEST_KEY_AUTH
1096 #
1097 # kernel 5.0 commit 822ad64d7e46a8e2c8b8a796738d7b657cbb146d
1098 # keys: Fix dependency loop between construction record and auth key
1099 #
1100 # Added <keys/request_key_auth-type.h> and get_request_key_auth()
1101 # which was propagated to stable
1102 #
1103 AC_DEFUN([LIBCFS_GET_REQUEST_KEY_AUTH], [
1104 tmp_flags="$EXTRA_KCFLAGS"
1105 EXTRA_KCFLAGS="-Werror"
1106 LB_CHECK_COMPILE([if get_request_key_auth() is available],
1107 get_request_key_auth_exported, [
1108         #include <linux/key.h>
1109         #include <linux/keyctl.h>
1110         #include <keys/request_key_auth-type.h>
1111 ],[
1112         struct key *ring;
1113         const struct key *key = NULL;
1114         struct request_key_auth *rka = get_request_key_auth(key);
1115
1116         ring = key_get(rka->dest_keyring);
1117 ],[
1118         AC_DEFINE(HAVE_GET_REQUEST_KEY_AUTH, 1,
1119                 [get_request_key_auth() is available])
1120 ])
1121 EXTRA_KCFLAGS="$tmp_flags"
1122 ]) # LIBCFS_GET_REQUEST_KEY_AUTH
1123
1124 #
1125 # LIBCFS_LOOKUP_USER_KEY
1126 #
1127 # kernel 5.3 commit 3cf5d076fb4d48979f382bc9452765bf8b79e740
1128 # signal: Remove task parameter from force_sig
1129 #
1130 AC_DEFUN([LIBCFS_LOOKUP_USER_KEY], [
1131 tmp_flags="$EXTRA_KCFLAGS"
1132 EXTRA_KCFLAGS="-Werror"
1133 LB_CHECK_COMPILE([if lookup_user_key() is available],
1134 lookup_user_key_exported, [
1135         #include <linux/key.h>
1136         #include <linux/keyctl.h>
1137 ],[
1138         lookup_user_key(KEY_SPEC_USER_KEYRING, 0, 0);
1139 ],[
1140         AC_DEFINE(HAVE_LOOKUP_USER_KEY, 1,
1141                 [lookup_user_key() is available])
1142 ])
1143 EXTRA_KCFLAGS="$tmp_flags"
1144 ]) # LIBCFS_LOOKUP_USER_KEY
1145
1146 #
1147 # LIBCFS_FORCE_SIG_WITH_TASK
1148 #
1149 # kernel 5.3 commit 3cf5d076fb4d48979f382bc9452765bf8b79e740
1150 # signal: Remove task parameter from force_sig
1151 #
1152 AC_DEFUN([LIBCFS_FORCE_SIG_WITH_TASK], [
1153 tmp_flags="$EXTRA_KCFLAGS"
1154 EXTRA_KCFLAGS="-Werror"
1155 LB_CHECK_COMPILE([if force_sig has task parameter],
1156 force_sig_with_task, [
1157         #include <linux/sched/signal.h>
1158 ],[
1159         force_sig(SIGINT, NULL);
1160 ],[
1161         AC_DEFINE(HAVE_FORCE_SIG_WITH_TASK, 1,
1162                 [force_sig() has task parameter])
1163 ])
1164 EXTRA_KCFLAGS="$tmp_flags"
1165 ]) # LIBCFS_FORCE_SIG_WITH_TASK
1166
1167 #
1168 # LIBCFS_CACHE_DETAIL_WRITERS
1169 #
1170 # kernel v5.3-rc2-1-g64a38e840ce5
1171 # SUNRPC: Track writers of the 'channel' file to improve cache_listeners_exist
1172 #
1173 AC_DEFUN([LIBCFS_CACHE_DETAIL_WRITERS], [
1174 tmp_flags="$EXTRA_KCFLAGS"
1175 EXTRA_KCFLAGS="-Werror"
1176 LB_CHECK_COMPILE([if struct cache_detail has writers],
1177 cache_detail_writers_atomic, [
1178         #include <linux/sunrpc/cache.h>
1179
1180         static struct cache_detail rsi_cache;
1181 ],[
1182         atomic_set(&rsi_cache.writers, 0);
1183 ],[
1184         AC_DEFINE(HAVE_CACHE_DETAIL_WRITERS, 1,
1185                 [struct cache_detail has writers])
1186 ])
1187 EXTRA_KCFLAGS="$tmp_flags"
1188 ]) # LIBCFS_CACHE_DETAIL_WRITERS
1189
1190 #
1191 # LIBCFS_CONFIG_CRYPTO_CRC32
1192 #
1193 # The kernel must support CONFIG_CRYPTO_CRC32 to RPC checksumming
1194 #
1195 AC_DEFUN([LIBCFS_CONFIG_CRYPTO_CRC32], [
1196 LB_CHECK_CONFIG_IM([CRYPTO_CRC32], [],
1197         [AC_MSG_ERROR([
1198
1199 Lustre requires that CONFIG_CRYPTO_CRC32 is enabled in your kernel.
1200 ])])
1201 ]) # LIBCFS_CONFIG_CRYPTO_CRC32
1202
1203
1204 #
1205 # LIBCFS_PROG_LINUX
1206 #
1207 # LibCFS linux kernel checks
1208 #
1209 AC_DEFUN([LIBCFS_PROG_LINUX], [
1210 AC_MSG_NOTICE([LibCFS kernel checks
1211 ==============================================================================])
1212 LIBCFS_CONFIG_PANIC_DUMPLOG
1213 LIBCFS_CONFIG_CRYPTO_CRC32
1214
1215 # 3.11
1216 LIBCFS_KTIME_GET_TS64
1217 # 3.12
1218 LIBCFS_PREPARE_TO_WAIT_EVENT
1219 LIBCFS_KERNEL_PARAM_OPS
1220 LIBCFS_KTIME_ADD
1221 LIBCFS_KTIME_AFTER
1222 LIBCFS_KTIME_BEFORE
1223 LIBCFS_KTIME_COMPARE
1224 LIBCFS_SHRINKER_COUNT
1225 # 3.15
1226 LIBCFS_IOV_ITER_HAS_TYPE
1227 # 3.17
1228 LIBCFS_HLIST_ADD_AFTER
1229 LIBCFS_TIMESPEC64
1230 LIBCFS_KTIME_GET_NS
1231 LIBCFS_KTIME_GET_REAL_TS64
1232 LIBCFS_KTIME_GET_REAL_SECONDS
1233 LIBCFS_KTIME_GET_REAL_NS
1234 LIBCFS_KTIME_TO_TIMESPEC64
1235 LIBCFS_TIMESPEC64_SUB
1236 LIBCFS_TIMESPEC64_TO_KTIME
1237 # 3.19
1238 LIBCFS_KTIME_GET_SECONDS
1239 # 4.0
1240 LIBCFS_KTIME_MS_DELTA
1241 # 4.1
1242 LIBCFS_KERNEL_PARAM_LOCK
1243 # 4.2
1244 LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK
1245 # 4.4
1246 LIBCFS_KSTRTOBOOL_FROM_USER
1247 # 4.5
1248 LIBCFS_CRYPTO_HASH_HELPERS
1249 LIBCFS_EXPORT_KSET_FIND_OBJ
1250 LIBCFS_RHASHTABLE_REPLACE
1251 # 4.6
1252 LIBCFS_BROKEN_HASH_64
1253 LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
1254 LIBCFS_GET_USER_PAGES_6ARG
1255 LIBCFS_STRINGHASH
1256 # 4.7
1257 LIBCFS_RHASHTABLE_INSERT_FAST
1258 LIBCFS_RHASHTABLE_WALK_INIT_3ARG
1259 # 4.8
1260 LIBCFS_RHASHTABLE_LOOKUP
1261 LIBCFS_RHLTABLE
1262 LIBCFS_STACKTRACE_OPS
1263 # 4.9
1264 LIBCFS_GET_USER_PAGES_GUP_FLAGS
1265 LIBCFS_RHASHTABLE_WALK_ENTER
1266 # 4.10
1267 LIBCFS_HOTPLUG_STATE_MACHINE
1268 LIBCFS_REFCOUNT_T
1269 # 4.11
1270 LIBCFS_RHASHTABLE_LOOKUP_GET_INSERT_FAST
1271 LIBCFS_SCHED_HEADERS
1272 LIBCFS_KREF_READ
1273 LIBCFS_RHT_BUCKET_VAR
1274 # 4.12
1275 LIBCFS_HAVE_PROCESSOR_HEADER
1276 LIBCFS_HAVE_WAIT_BIT_HEADER
1277 LIBCFS_WAIT_QUEUE_TASK_LIST_RENAME
1278 LIBCFS_CPUS_READ_LOCK
1279 LIBCFS_UUID_T
1280 # 4.13
1281 LIBCFS_WAIT_QUEUE_ENTRY
1282 # 4.14
1283 LIBCFS_DEFINE_TIMER
1284 LIBCFS_NEW_KERNEL_WRITE
1285 LIBCFS_NEW_KERNEL_READ
1286 LIBCFS_EXPORT_SAVE_STACK_TRACE_TSK
1287 # 4.15
1288 LIBCFS_TIMER_SETUP
1289 # 4.16
1290 LIBCFS_WAIT_VAR_EVENT
1291 # 4.17
1292 LIBCFS_CLEAR_AND_WAKE_UP_BIT
1293 # 4.20
1294 LIBCFS_HAVE_IOV_ITER_TYPE
1295 # 5.0
1296 LIBCFS_MM_TOTALRAM_PAGES_FUNC
1297 LIBCFS_GET_REQUEST_KEY_AUTH
1298 # 5.3
1299 LIBCFS_LOOKUP_USER_KEY
1300 LIBCFS_FORCE_SIG_WITH_TASK
1301 LIBCFS_CACHE_DETAIL_WRITERS
1302 ]) # LIBCFS_PROG_LINUX
1303
1304 #
1305 # LIBCFS_PATH_DEFAULTS
1306 #
1307 # default paths for installed files
1308 #
1309 AC_DEFUN([LIBCFS_PATH_DEFAULTS], [
1310 ]) # LIBCFS_PATH_DEFAULTS
1311
1312 #
1313 # LIBCFS_CONFIGURE
1314 #
1315 # other configure checks
1316 #
1317 AC_DEFUN([LIBCFS_CONFIGURE], [
1318 AC_MSG_NOTICE([LibCFS core checks
1319 ==============================================================================])
1320
1321 # libcfs/libcfs/util/nidstrings.c
1322 AC_CHECK_HEADERS([netdb.h asm/types.h endian.h])
1323 AC_CHECK_FUNCS([gethostbyname])
1324
1325 # --------  Check for required packages  --------------
1326
1327 AC_MSG_NOTICE([LibCFS required packages checks
1328 ==============================================================================])
1329
1330 AC_MSG_CHECKING([whether to enable readline support])
1331 AC_ARG_ENABLE(readline,
1332         AC_HELP_STRING([--disable-readline],
1333                 [disable readline support]),
1334         [], [enable_readline="yes"])
1335 AC_MSG_RESULT([$enable_readline])
1336
1337 LIBREADLINE=""
1338 AS_IF([test "x$enable_readline" = xyes], [
1339         AC_CHECK_LIB([readline], [readline], [
1340                 LIBREADLINE="-lreadline"
1341                 AC_DEFINE(HAVE_LIBREADLINE, 1,
1342                         [readline library is available])
1343         ])
1344 ])
1345 AC_SUBST(LIBREADLINE)
1346
1347 AC_MSG_CHECKING([whether to use libpthread for libcfs library])
1348 AC_ARG_ENABLE([libpthread],
1349         AC_HELP_STRING([--disable-libpthread],
1350                 [disable libpthread]),
1351         [], [enable_libpthread="yes"])
1352 AC_MSG_RESULT([$enable_libpthread])
1353
1354 PTHREAD_LIBS=""
1355 AS_IF([test "x$enable_libpthread" = xyes], [
1356         AC_CHECK_LIB([pthread], [pthread_create], [
1357                 PTHREAD_LIBS="-lpthread"
1358                 AC_DEFINE([HAVE_LIBPTHREAD], 1,
1359                         [use libpthread for libcfs library])
1360         ])
1361 ], [
1362         AC_MSG_WARN([Using libpthread for libcfs library is disabled explicitly])
1363 ])
1364 AC_SUBST(PTHREAD_LIBS)
1365 ]) # LIBCFS_CONFIGURE
1366
1367 #
1368 # LIBCFS_CONFIG_FILES
1369 #
1370 # files that should be generated with AC_OUTPUT
1371 #
1372 AC_DEFUN([LIBCFS_CONFIG_FILES], [
1373 AC_CONFIG_FILES([
1374 libcfs/Makefile
1375 libcfs/autoMakefile
1376 libcfs/autoconf/Makefile
1377 libcfs/include/Makefile
1378 libcfs/include/libcfs/Makefile
1379 libcfs/include/uapi/Makefile
1380 libcfs/include/libcfs/linux/Makefile
1381 libcfs/include/libcfs/util/Makefile
1382 libcfs/include/libcfs/crypto/Makefile
1383 libcfs/include/uapi/linux/Makefile
1384 libcfs/libcfs/Makefile
1385 libcfs/libcfs/autoMakefile
1386 libcfs/libcfs/linux/Makefile
1387 libcfs/libcfs/util/Makefile
1388 libcfs/libcfs/crypto/Makefile
1389 ])
1390 ]) # LIBCFS_CONFIG_FILES