Whamcloud - gitweb
LU-16045 enc: force use of new enc xattr on new servers
[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         AS_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         AS_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         AS_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         AS_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 # Kernel version 3.13 commit aace05097a0fd467230e39acb148be0fdaa90068
201 # add match_wildcard() function.
202 #
203 AC_DEFUN([LIBCFS_MATCH_WILDCARD],[
204 LB_CHECK_COMPILE([does function 'match_wildcard' exist],
205 match_wildcard, [
206         #include <linux/parser.h>
207 ],[
208         bool match;
209
210         match = match_wildcard(NULL, NULL);
211 ],[
212         AC_DEFINE(HAVE_MATCH_WILDCARD, 1,
213                 [match_wildcard() is available])
214 ])
215 ]) # LIBCFS_MATCH_WILDCARD
216
217 #
218 # LIBCFS_HAVE_MAPPING_AS_EXITING_FLAG
219 #
220 # v3.14-7405-g91b0abe36a7b added AS_EXITING flag with
221 # mapping_exiting() and mapping_set_exiting()
222 #
223 AC_DEFUN([LIBCFS_HAVE_MAPPING_AS_EXITING_FLAG], [
224 m4_pattern_allow([AS_EXITING])
225 tmp_flags="$EXTRA_KCFLAGS"
226 EXTRA_KCFLAGS="-Werror"
227 LB_CHECK_COMPILE([if enum mapping_flags has AS_EXITING flag],
228 mapping_exiting_exists, [
229         #include <linux/pagemap.h>
230 ],[
231         enum mapping_flags flag = AS_EXITING;
232         (void)flag;
233 ],[
234         AC_DEFINE(HAVE_MAPPING_AS_EXITING_FLAG, 1,
235                 [enum mapping_flags has AS_EXITING flag])
236 ])
237 EXTRA_KCFLAGS="$tmp_flags"
238 ]) # LIBCFS_HAVE_MAPPING_AS_EXITING_FLAG
239
240 #
241 # LIBCFS_IOV_ITER_HAS_TYPE
242 #
243 # kernel 3.15-rc4 commit 71d8e532b1549a478e6a6a8a44f309d050294d00
244 # start adding the tag to iov_iter
245 # kernel 5.13 commit 8cd54c1c848031a87820e58d772166ffdf8c08c0 change
246 # ->type to ->iter_type
247 #
248 AC_DEFUN([LIBCFS_IOV_ITER_HAS_TYPE], [
249 tmp_flags="$EXTRA_KCFLAGS"
250 EXTRA_KCFLAGS="-Werror"
251 iter_type_member=no
252 LB_CHECK_COMPILE([if iov_iter has member type],
253 iov_iter_has_type_member, [
254         #include <linux/uio.h>
255 ],[
256         struct iov_iter iter = { .type = ITER_KVEC };
257         (void)iter;
258 ],[
259         AC_DEFINE(HAVE_IOV_ITER_HAS_TYPE_MEMBER, 1,
260                 [if iov_iter has member type])
261         iter_type_member=yes
262 ])
263 if test $iter_type_member = no; then
264   LB_CHECK_COMPILE([if iov_iter has member iter_type],
265   iov_iter_has_iter_type_member, [
266         #include <linux/uio.h>
267   ],[
268         struct iov_iter iter = { .iter_type = ITER_KVEC };
269         (void)iter;
270   ],[
271         AC_DEFINE(HAVE_IOV_ITER_HAS_TYPE_MEMBER, 1,
272                 [if iov_iter has member iter_type])
273         iter_type_member=yes
274   ])
275 fi
276 EXTRA_KCFLAGS="$tmp_flags"
277 ]) # LIBCFS_IOV_ITER_HAS_TYPE
278
279 #
280 # LIBCFS_HAVE_NS_TO_TIMESPEC64
281 #
282 # Kernel version 3.16-rc3 commit a84d1169164b274f13b97a23ff235c000efe3b49
283 # introduced struct __kernel_old_timeval
284 #
285 AC_DEFUN([LIBCFS_HAVE_NS_TO_TIMESPEC64],[
286 LB_CHECK_COMPILE([does 'ns_to_timespec64()' exist],
287 kernel_old_timeval, [
288         #include <linux/time.h>
289 ],[
290         struct timespec64 kts;
291
292         kts = ns_to_timespec64(0);
293 ],[
294         AC_DEFINE(HAVE_NS_TO_TIMESPEC64, 1,
295                 [ns_to_timespec64() is available])
296 ])
297 ]) # LIBCFS_HAVE_NS_TO_TIMESPEC64
298
299 #
300 # LIBCFS_HAVE_GLOB
301 #
302 # Kernel version 3.16 commit b01250856b25f4417c51aa33afc451fbf7da1484
303 # added glob support to the Linux kernel
304 #
305 AC_DEFUN([LIBCFS_HAVE_GLOB],[
306 tmp_flags="$EXTRA_KCFLAGS"
307 EXTRA_KCFLAGS="-Werror"
308 LB_CHECK_COMPILE([does 'glob_match()' exist],
309 glob, [
310         #include <linux/glob.h>
311 ],[
312         return glob_match(NULL, NULL);
313 ],[
314         AC_DEFINE(HAVE_GLOB, 1,
315                 [glob_match() is available])
316 ])
317 EXTRA_KCFLAGS="$tmp_flags"
318 ]) # LIBCFS_HAVE_GLOB
319
320 #
321 # Kernel version 3.17 changed hlist_add_after to
322 # hlist_add_behind
323 #
324 AC_DEFUN([LIBCFS_HLIST_ADD_AFTER],[
325 LB_CHECK_COMPILE([does function 'hlist_add_after' exist],
326 hlist_add_after, [
327         #include <linux/list.h>
328 ],[
329         hlist_add_after(NULL, NULL);
330 ],[
331         AC_DEFINE(HAVE_HLIST_ADD_AFTER, 1,
332                 [hlist_add_after is available])
333 ])
334 ]) # LIBCFS_HLIST_ADD_AFTER
335
336 #
337 # Kernel version 3.17 introduced struct timespec64
338 #
339 AC_DEFUN([LIBCFS_TIMESPEC64],[
340 LB_CHECK_COMPILE([does 'struct timespec64' exist],
341 timespec64, [
342         #include <linux/time.h>
343 ],[
344         struct timespec64 ts;
345
346         ts.tv_sec = 0;
347         ts.tv_nsec = 0;
348 ],[
349         AC_DEFINE(HAVE_TIMESPEC64, 1,
350                 ['struct timespec64' is available])
351 ])
352 ]) # LIBCFS_TIMESPEC64
353
354 #
355 # Kernel version 3.17 introduced ktime_get_real_ts64
356 #
357 AC_DEFUN([LIBCFS_KTIME_GET_REAL_TS64],[
358 LB_CHECK_COMPILE([does function 'ktime_get_real_ts64' exist],
359 ktime_get_real_ts64, [
360         #include <linux/ktime.h>
361 ],[
362         struct timespec64 *ts = NULL;
363
364         ktime_get_real_ts64(ts);
365 ],[
366         AC_DEFINE(HAVE_KTIME_GET_REAL_TS64, 1,
367                 ['ktime_get_real_ts64' is available])
368 ])
369 ]) # LIBCFS_KTIME_GET_REAL_TS64
370
371 #
372 # Kernel version 3.17 introduced ktime_get_real_seconds
373 #
374 AC_DEFUN([LIBCFS_KTIME_GET_REAL_SECONDS],[
375 LB_CHECK_COMPILE([does function 'ktime_get_real_seconds' exist],
376 ktime_get_real_seconds, [
377         #include <linux/hrtimer.h>
378         #include <linux/ktime.h>
379 ],[
380         time64_t now;
381
382         now = ktime_get_real_seconds();
383 ],[
384         AC_DEFINE(HAVE_KTIME_GET_REAL_SECONDS, 1,
385                 ['ktime_get_real_seconds' is available])
386 ])
387 ]) # LIBCFS_KTIME_GET_REAL_SECONDS
388
389 #
390 # Kernel version 3.17 created ktime_get_ns wrapper
391 #
392 AC_DEFUN([LIBCFS_KTIME_GET_NS],[
393 LB_CHECK_COMPILE([does function 'ktime_get_ns' exist],
394 ktime_get_ns, [
395         #include <linux/hrtimer.h>
396         #include <linux/ktime.h>
397 ],[
398         u64 nanoseconds;
399
400         nanoseconds = ktime_get_ns();
401 ],[],[
402         AC_DEFINE(NEED_KTIME_GET_NS, 1,
403                 ['ktime_get_ns' is not available])
404 ])
405 ]) # LIBCFS_KTIME_GET_NS
406
407 #
408 # Kernel version 3.17 created ktime_get_real_ns wrapper
409 #
410 AC_DEFUN([LIBCFS_KTIME_GET_REAL_NS],[
411 LB_CHECK_COMPILE([does function 'ktime_get_real_ns' exist],
412 ktime_get_real_ns, [
413         #include <linux/hrtimer.h>
414         #include <linux/ktime.h>
415 ],[
416         u64 nanoseconds;
417
418         nanoseconds = ktime_get_real_ns();
419 ],[],[
420         AC_DEFINE(NEED_KTIME_GET_REAL_NS, 1,
421                 ['ktime_get_real_ns' is not available])
422 ])
423 ]) # LIBCFS_KTIME_GET_REAL_NS
424
425 #
426 # Kernel version 3.17 introduced ktime_to_timespec64
427 #
428 AC_DEFUN([LIBCFS_KTIME_TO_TIMESPEC64],[
429 LB_CHECK_COMPILE([does function 'ktime_to_timespec64' exist],
430 ktime_to_timespec64, [
431         #include <linux/hrtimer.h>
432         #include <linux/ktime.h>
433 ],[
434         ktime_t now = ktime_set(0, 0);
435         struct timespec64 ts;
436
437         ts = ktime_to_timespec64(now);
438 ],[
439         AC_DEFINE(HAVE_KTIME_TO_TIMESPEC64, 1,
440                 ['ktime_to_timespec64' is available])
441 ])
442 ]) # LIBCFS_KTIME_TO_TIMESPEC64
443
444 #
445 # Kernel version 3.17 introduced timespec64_sub
446 #
447 AC_DEFUN([LIBCFS_TIMESPEC64_SUB],[
448 LB_CHECK_COMPILE([does function 'timespec64_sub' exist],
449 timespec64_sub, [
450         #include <linux/time.h>
451 ],[
452         struct timespec64 later = { }, earlier = { }, diff;
453
454         diff = timespec64_sub(later, earlier);
455 ],[
456         AC_DEFINE(HAVE_TIMESPEC64_SUB, 1,
457                 ['timespec64_sub' is available])
458 ])
459 ]) # LIBCFS_TIMESPEC64_SUB
460
461 #
462 # Kernel version 3.17 introduced timespec64_to_ktime
463 #
464 AC_DEFUN([LIBCFS_TIMESPEC64_TO_KTIME],[
465 LB_CHECK_COMPILE([does function 'timespec64_to_ktime' exist],
466 timespec64_to_ktime, [
467         #include <linux/ktime.h>
468 ],[
469         struct timespec64 ts;
470         ktime_t now;
471
472         now = timespec64_to_ktime(ts);
473 ],[
474         AC_DEFINE(HAVE_TIMESPEC64_TO_KTIME, 1,
475                 ['timespec64_to_ktime' is available])
476 ])
477 ]) # LIBCFS_TIMESPEC64_TO_KTIME
478
479 #
480 # Kernel version 3.19 introduced ktime_get_seconds
481 #
482 AC_DEFUN([LIBCFS_KTIME_GET_SECONDS],[
483 LB_CHECK_COMPILE([does function 'ktime_get_seconds' exist],
484 ktime_get_seconds, [
485         #include <linux/ktime.h>
486 ],[
487         time64_t now;
488
489         now = ktime_get_seconds();
490 ],[
491         AC_DEFINE(HAVE_KTIME_GET_SECONDS, 1,
492                 ['ktime_get_seconds' is available])
493 ])
494 ]) # LIBCFS_KTIME_GET_SECONDS
495
496 #
497 # Kernel version 3.19 commit v3.18-rc2-26-g61ada528dea0
498 # introduce wait_woken()
499 #
500 AC_DEFUN([LIBCFS_WAIT_WOKEN],[
501 LB_CHECK_COMPILE([does function 'wait_woken' exist],
502 wait_woken, [
503         #include <linux/wait.h>
504 ],[
505         wait_woken(NULL, 0, 0);
506 ],[
507         AC_DEFINE(HAVE_WAIT_WOKEN, 1,
508                 ['wait_woken, is available'])
509 ])
510 ]) # LIBCFS_WAIT_WOKEN
511
512 #
513 # Kernel version 4.0 commit 41fbf3b39d5eca01527338b4d0ee15ee1ae1023c
514 # introduced the helper function ktime_ms_delta.
515 #
516 AC_DEFUN([LIBCFS_KTIME_MS_DELTA],[
517 LB_CHECK_COMPILE([does function 'ktime_ms_delta' exist],
518 ktime_ms_delta, [
519         #include <linux/ktime.h>
520 ],[
521         ktime_t start = ktime_set(0, 0);
522         ktime_t end = start;
523
524         ktime_ms_delta(start, end);
525 ],[
526         AC_DEFINE(HAVE_KTIME_MS_DELTA, 1,
527                 ['ktime_ms_delta' is available])
528 ])
529 ]) # LIBCFS_KTIME_MS_DELTA
530
531 #
532 # Kernel version 4.1 commit b51d23e4e9fea6f264d39535c2a62d1f51e7ccc3
533 # create per module locks which added kernel_param_[un]lock(). Older
534 # kernels you have to use __kernel_param_[un]lock(). In that case its
535 # a global lock for all modules but that is okay since its a rare event.
536 #
537 AC_DEFUN([LIBCFS_KERNEL_PARAM_LOCK],[
538 LB_CHECK_COMPILE([does function 'kernel_param_[un]lock' exist],
539 kernel_param_lock, [
540         #include <linux/moduleparam.h>
541 ],[
542         kernel_param_lock(NULL);
543         kernel_param_unlock(NULL);
544 ],[
545         AC_DEFINE(HAVE_KERNEL_PARAM_LOCK, 1,
546                 ['kernel_param_[un]lock' is available])
547 ])
548 ]) # LIBCFS_KERNEL_PARAM_LOCK
549
550 #
551 # Kernel version 4.2 changed topology_thread_cpumask
552 # to topology_sibling_cpumask
553 #
554 AC_DEFUN([LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK],[
555 LB_CHECK_COMPILE([does function 'topology_sibling_cpumask' exist],
556 topology_sibling_cpumask, [
557         #include <linux/topology.h>
558 ],[
559         const struct cpumask *mask;
560
561         mask = topology_sibling_cpumask(0);
562 ],[
563         AC_DEFINE(HAVE_TOPOLOGY_SIBLING_CPUMASK, 1,
564                 [topology_sibling_cpumask is available])
565 ])
566 ]) # LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK
567
568 #
569 # Kernel version 4.4 commit ef951599074ba4fad2d0efa0a977129b41e6d203
570 # introduced kstrtobool and kstrtobool_from_user.
571 #
572 AC_DEFUN([LIBCFS_KSTRTOBOOL_FROM_USER], [
573 LB_CHECK_COMPILE([if Linux kernel has 'kstrtobool_from_user'],
574 kstrtobool_from_user, [
575         #include <linux/kernel.h>
576 ],[
577         bool result;
578         return kstrtobool_from_user(NULL, 0, &result);
579 ],[
580         AC_DEFINE(HAVE_KSTRTOBOOL_FROM_USER, 1,
581                 [kernel has kstrtobool_from_user])
582 ])
583 ]) # LIBCFS_KSTRTOBOOL_FROM_USER
584
585 #
586 # LIBCFS_NETLINK_CALLBACK_START
587 #
588 # Kernel version 4.4-rc3 commit fc9e50f5a5a4e1fa9ba2756f745a13e693cf6a06
589 # added a start function callback for struct netlink_callback
590 #
591 AC_DEFUN([LIBCFS_NETLINK_CALLBACK_START], [
592 LB_CHECK_COMPILE([if struct genl_ops has start callback],
593 cb_start, [
594         #include <net/genetlink.h>
595 ],[
596         struct genl_ops ops;
597
598         ops.start = NULL;
599 ],[
600         AC_DEFINE(HAVE_NETLINK_CALLBACK_START, 1,
601                 [struct genl_ops has 'start' callback])
602 ])
603 ]) # LIBCFS_NETLINK_CALLBACK_START
604
605 #
606 # Kernel version 4.5-rc1 commit d12481bc58fba89427565f8592e88446ec084a24
607 # added crypto hash helpers
608 #
609 AC_DEFUN([LIBCFS_CRYPTO_HASH_HELPERS], [
610 LB_CHECK_COMPILE([does crypto hash helper functions exist],
611 crypto_hash_helpers, [
612         #include <crypto/hash.h>
613 ],[
614         crypto_ahash_alg_name(NULL);
615         crypto_ahash_driver_name(NULL);
616 ],[
617         AC_DEFINE(HAVE_CRYPTO_HASH_HELPERS, 1,
618                 [crypto hash helper functions are available])
619 ])
620 ]) # LIBCFS_CRYPTO_HASH_HELPERS
621
622 #
623 # Kernel version 4.5-rc1 commit 3502cad73c4bbf8f6365d539e814159275252c59
624 # introduced rhashtable_replace_fast
625 #
626 AC_DEFUN([LIBCFS_RHASHTABLE_REPLACE], [
627 LB_CHECK_COMPILE([if 'rhashtable_replace_fast' exists],
628 rhashtable_replace_fast, [
629         #include <linux/rhashtable.h>
630 ],[
631         const struct rhashtable_params params = { 0 };
632
633         rhashtable_replace_fast(NULL, NULL, NULL, params);
634 ],[
635         AC_DEFINE(HAVE_RHASHTABLE_REPLACE, 1,
636                 [rhashtable_replace_fast() is available])
637 ])
638 ]) # LIBCFS_RHASHTABLE_REPLACE
639
640 #
641 # Kernel version 4.5-rc3 commit 2fe829aca9d7bed5fd6b49c6a1452e5e486b6cc3dd
642 # made kset_find_obj() exportable to modules
643 #
644 AC_DEFUN([LIBCFS_EXPORT_KSET_FIND_OBJ], [
645 LB_CHECK_EXPORT([kset_find_obj], [lib/kobject.c],
646         [AC_DEFINE(HAVE_KSET_FIND_OBJ, 1,
647                 [kset_find_obj is exported by the kernel])])
648 ]) # LIBCFS_EXPORT_KSET_FIND_OBJ
649
650 #
651 # Kernel version 4.6+ commit ef703f49a6c5b909a85149bb6625c4ed0d697186
652 # fixed the brokenness of hash_64(). The fix removed GOLDEN_RATIO_PRIME_64
653 # since it was a poor prime value.
654 #
655 AC_DEFUN([LIBCFS_BROKEN_HASH_64], [
656 LB_CHECK_COMPILE([kernel has fixed hash_64()],
657 broken_hash_64, [
658         #include <linux/hash.h>
659 ],[
660         int tmp = GOLDEN_RATIO_PRIME_64;
661 ],[
662         AC_DEFINE(HAVE_BROKEN_HASH_64, 1, [kernel hash_64() is broken])
663 ])
664 ]) # LIBCFS_BROKEN_HASH_64
665
666 #
667 # LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
668 #
669 # linux 4.6 kernel changed stacktrace_ops address to return an int
670 #
671 AC_DEFUN([LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT], [
672 LB_CHECK_COMPILE([if 'struct stacktrace_ops' address function returns an int],
673 stacktrace_ops_address_return_int, [
674         #include <asm/stacktrace.h>
675 ],[
676         int rc;
677
678         rc = ((struct stacktrace_ops *)0)->address(NULL, 0, 0);
679 ],[
680         AC_DEFINE(STACKTRACE_OPS_ADDRESS_RETURN_INT, 1,
681                 ['struct stacktrace_ops' address function returns an int])
682 ])
683 ]) # LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
684
685 #
686 # Kernel version 4.6 removed both struct task_struct and struct mm_struct
687 # arguments to get_user_pages
688 #
689 AC_DEFUN([LIBCFS_GET_USER_PAGES_6ARG], [
690 LB_CHECK_COMPILE([if 'get_user_pages()' takes 6 arguments],
691 get_user_pages_6arg, [
692         #include <linux/mm.h>
693 ],[
694         int rc;
695
696         rc = get_user_pages(0, 0, 0, 0, NULL, NULL);
697 ],[
698         AC_DEFINE(HAVE_GET_USER_PAGES_6ARG, 1,
699                 [get_user_pages takes 6 arguments])
700 ])
701 ]) # LIBCFS_GET_USER_PAGES_6ARG
702
703 #
704 # LIBCFS_STRINGHASH
705 #
706 # 4.6 kernel created stringhash.h which moved stuff out of dcache.h
707 # commit f4bcbe792b8f434e32487cff9d9e30ab45a3ce02
708 #
709 AC_DEFUN([LIBCFS_STRINGHASH], [
710 LB_CHECK_LINUX_HEADER([linux/stringhash.h], [
711         AC_DEFINE(HAVE_STRINGHASH, 1,
712                 [stringhash.h is present])])
713 ]) # LIBCFS_STRINGHASH
714
715 #
716 # LIBCFS_RHASHTABLE_INSERT_FAST
717 #
718 # 4.7+ kernel commit 5ca8cc5bf11faed257c762018aea9106d529232f
719 # changed __rhashtable_insert_fast to support the new function
720 # rhashtable_lookup_get_insert_key().
721 #
722 AC_DEFUN([LIBCFS_RHASHTABLE_INSERT_FAST], [
723 tmp_flags="$EXTRA_KCFLAGS"
724 EXTRA_KCFLAGS="-Werror"
725 LB_CHECK_COMPILE([if internal '__rhashtable_insert_fast()' returns int],
726 rhashtable_insert_fast, [
727         #include <linux/rhashtable.h>
728 ],[
729         const struct rhashtable_params params = { 0 };
730         int rc;
731
732         rc = __rhashtable_insert_fast(NULL, NULL, NULL, params);
733 ],[
734         AC_DEFINE(HAVE_HASHTABLE_INSERT_FAST_RETURN_INT, 1,
735                   ['__rhashtable_insert_fast()' returns int])
736 ])
737 EXTRA_KCFLAGS="$tmp_flags"
738 ]) # LIBCFS_RHASHTABLE_INSERT_FAST
739
740 #
741 # Kernel version 4.7-rc1 commit 8f6fd83c6c5ec66a4a70c728535ddcdfef4f3697
742 # added 3rd arg to rhashtable_walk_init
743 #
744 AC_DEFUN([LIBCFS_RHASHTABLE_WALK_INIT_3ARG], [
745 LB_CHECK_COMPILE([if 'rhashtable_walk_init' has 3 args],
746 rhashtable_walk_init, [
747         #include <linux/gfp.h>
748         #include <linux/rhashtable.h>
749 ],[
750         rhashtable_walk_init(NULL, NULL, GFP_KERNEL);
751 ],[
752         AC_DEFINE(HAVE_3ARG_RHASHTABLE_WALK_INIT, 1,
753                 [rhashtable_walk_init() has 3 args])
754 ])
755 ]) # LIBCFS_RHASHTABLE_WALK_INIT_3ARG
756
757 #
758 # Kernel version 4.8-rc6 commit ca26893f05e86497a86732768ec53cd38c0819ca
759 # introduced rhashtable_lookup
760 #
761 AC_DEFUN([LIBCFS_RHASHTABLE_LOOKUP], [
762 LB_CHECK_COMPILE([if 'rhashtable_lookup' exist],
763 rhashtable_lookup, [
764         #include <linux/rhashtable.h>
765 ],[
766         const struct rhashtable_params params = { 0 };
767         void *ret;
768
769         ret = rhashtable_lookup(NULL, NULL, params);
770 ],[
771         AC_DEFINE(HAVE_RHASHTABLE_LOOKUP, 1,
772                 [rhashtable_lookup() is available])
773 ])
774 ]) # LIBCFS_RHASHTABLE_LOOKUP
775
776 #
777 # LIBCFS_RHLTABLE
778 # Kernel version 4.8-rc6 commit ca26893f05e86497a86732768ec53cd38c0819ca
779 # created the rhlist interface to allow inserting duplicate objects
780 # into the same table.
781 #
782 AC_DEFUN([LIBCFS_RHLTABLE], [
783 LB_CHECK_COMPILE([does 'struct rhltable' exist],
784 rhtable, [
785         #include <linux/rhashtable.h>
786 ],[
787         struct rhltable *hlt;
788
789         rhltable_destroy(hlt);
790 ],[
791         AC_DEFINE(HAVE_RHLTABLE, 1,
792                   [struct rhltable exist])
793 ])
794 ]) # LIBCFS_RHLTABLE
795
796 #
797 # LIBCFS_STACKTRACE_OPS
798 #
799 # Kernel version 4.8 commit c8fe4609827aedc9c4b45de80e7cdc8ccfa8541b
800 # removed both struct stacktrace_ops and dump_trace() function
801 #
802 AC_DEFUN([LIBCFS_STACKTRACE_OPS], [
803 LB_CHECK_COMPILE([if 'struct stacktrace_ops' exists],
804 stacktrace_ops, [
805         struct task_struct;
806         struct pt_regs;
807         #include <asm/stacktrace.h>
808 ],[
809         struct stacktrace_ops ops;
810         ops.stack = NULL;
811 ],[
812         AC_DEFINE(HAVE_STACKTRACE_OPS, 1,
813                 [struct stacktrace_ops exists])
814 ])
815 ]) # LIBCFS_STACKTRACE_OPS
816
817 #
818 # Kernel version 4.9-rc1 commit 246779dd090bd1b74d2652b3a6ca7759f593b27a
819 # introduced rhashtable_walk_enter
820 #
821 AC_DEFUN([LIBCFS_RHASHTABLE_WALK_ENTER], [
822 LB_CHECK_COMPILE([if 'rhashtable_walk_enter' exists],
823 rhashtable_walk_enter, [
824         #include <linux/rhashtable.h>
825 ],[
826         rhashtable_walk_enter(NULL, NULL);
827 ],[
828         AC_DEFINE(HAVE_RHASHTABLE_WALK_ENTER, 1,
829                 [rhashtable_walk_enter() is available])
830 ])
831 ]) # LIBCFS_RHASHTABLE_WALK_ENTER
832
833 #
834 # Kernel version 4.9 commit 768ae309a96103ed02eb1e111e838c87854d8b51
835 # mm: replace get_user_pages() write/force parameters with gup_flags
836 #
837 AC_DEFUN([LIBCFS_GET_USER_PAGES_GUP_FLAGS], [
838 LB_CHECK_COMPILE([if 'get_user_pages()' takes gup_flags in arguments],
839 get_user_pages_gup_flags, [
840         #include <linux/mm.h>
841 ],[
842         int rc;
843         rc = get_user_pages(0, 0, FOLL_WRITE, NULL, NULL);
844 ],[
845         AC_DEFINE(HAVE_GET_USER_PAGES_GUP_FLAGS, 1,
846                 [get_user_pages takes gup_flags in arguments])
847 ])
848 ]) # LIBCFS_GET_USER_PAGES_GUP_FLAGS
849
850 #
851 # Kernel version 4.10 commit 7b737965b33188bd3dbb44e938535c4006d97fbb
852 # libcfs: Convert to hotplug state machine
853 #
854 AC_DEFUN([LIBCFS_HOTPLUG_STATE_MACHINE], [
855 LB_CHECK_COMPILE([if libcfs supports CPU hotplug state machine],
856 cpu_hotplug_state_machine, [
857         #include <linux/cpuhotplug.h>
858 ],[
859         cpuhp_remove_state(CPUHP_LUSTRE_CFS_DEAD);
860 ],[
861         AC_DEFINE(HAVE_HOTPLUG_STATE_MACHINE, 1,
862                 [hotplug state machine is supported])
863 ])
864 ]) # LIBCFS_HOTPLUG_STATE_MACHINE
865
866 #
867 # Kernel version 4.10-rc3 commit f405df5de3170c00e5c54f8b7cf4766044a032ba
868 # introduced refcount_t which is atomic_t plus over flow guards.
869 #
870 AC_DEFUN([LIBCFS_REFCOUNT_T], [
871 tmp_flags="$EXTRA_KCFLAGS"
872 EXTRA_KCFLAGS="-Werror"
873 LB_CHECK_LINUX_HEADER([linux/refcount.h], [
874         AC_DEFINE(HAVE_REFCOUNT_T, 1,
875                 [refcount_t is supported])
876 ])
877 EXTRA_KCFLAGS="$tmp_flags"
878 ]) # LIBCFS_REFCOUNT_T
879
880 #
881 # Kernel version 4.12 commit 499118e966f1d2150bd66647c8932343c4e9a0b8
882 # introduce memalloc_noreclaim_{save,restore}
883 #
884 AC_DEFUN([LIBCFS_MEMALLOC_NORECLAIM], [
885 LB_CHECK_COMPILE([if memalloc_noreclaim_{save,restore} exist],
886 memalloc_noreclaim, [
887         #include <linux/sched/mm.h>
888 ],[
889         int flag = memalloc_noreclaim_save();
890         memalloc_noreclaim_restore(flag);
891 ],[
892         AC_DEFINE(HAVE_MEMALLOC_RECLAIM, 1,
893                 [memalloc_noreclaim_{save,restore}() is supported])
894 ])
895 ]) # LIBCFS_MEMALLOC_NORECLAIM
896
897 #
898 # LIBCFS_SCHED_HEADERS
899 #
900 # 4.11 has broken up sched.h into more headers.
901 #
902 AC_DEFUN([LIBCFS_SCHED_HEADERS], [
903 LB_CHECK_LINUX_HEADER([linux/sched/signal.h], [
904         AC_DEFINE(HAVE_SCHED_HEADERS, 1,
905                 [linux/sched header directory exist])])
906 ]) # LIBCFS_SCHED_HEADERS
907
908 #
909 # Kernel version 4.11-rc1 commit 2c935bc57221cc2edc787c72ea0e2d30cdcd3d5e
910 # introduce kref_read
911 #
912 AC_DEFUN([LIBCFS_KREF_READ], [
913 LB_CHECK_COMPILE([if 'kref_read' exists],
914 kref_read, [
915         #include <linux/kref.h>
916 ],[
917         kref_read(NULL);
918 ],[
919         AC_DEFINE(HAVE_KREF_READ, 1,
920                 [kref_read() is available])
921 ])
922 ]) # LIBCFS_KREF_READ
923
924 #
925 # Kernel version 4.11-rc1 commit da20420f83ea0fbcf3d03afda08d971ea1d8a356
926 # introduced rht_bucket_var
927 #
928 AC_DEFUN([LIBCFS_RHT_BUCKET_VAR], [
929 LB_CHECK_COMPILE([if 'rht_bucket_var' exists],
930 rht_bucket_var, [
931         #include <linux/rhashtable.h>
932 ],[
933
934         rht_bucket_var(NULL, 0);
935 ],[
936         AC_DEFINE(HAVE_RHT_BUCKET_VAR, 1,
937                 [rht_bucket_var() is available])
938 ])
939 ]) # LIBCFS_RHT_BUCKET_VAR
940
941 #
942 # Kernel version 4.11-rc5 commit fceb6435e85298f747fee938415057af837f5a8a
943 # began the enhanchement of Netlink with extended ACK struct for advanced
944 # error handling. By commit 7ab606d1609dd6dfeae9c8ad0a8a4e051d831e46 we
945 # had full support for this new feature.
946 #
947 AC_DEFUN([LIBCFS_NL_EXT_ACK], [
948 LB_CHECK_COMPILE([if Netlink supports netlink_ext_ack],
949 netlink_ext_ack, [
950         #include <net/genetlink.h>
951 ],[
952         struct genl_info info;
953
954         info.extack = NULL;
955 ],[
956         AC_DEFINE(HAVE_NL_PARSE_WITH_EXT_ACK, 1,
957                 [netlink_ext_ack is an argument to nla_parse type function])
958 ])
959 ]) # LIBCFS_NL_EXT_ACK
960
961 #
962 # Kernel version 4.11 commit f9fe1c12d126f9887441fa5bb165046f30ddd4b5
963 # introduced rhashtable_lookup_get_insert_fast
964 #
965 AC_DEFUN([LIBCFS_RHASHTABLE_LOOKUP_GET_INSERT_FAST], [
966 LB_CHECK_COMPILE([if 'rhashtable_lookup_get_insert_fast' exist],
967 rhashtable_lookup_get_insert_fast, [
968         #include <linux/rhashtable.h>
969 ],[
970         const struct rhashtable_params params = { 0 };
971         void *ret;
972
973         ret = rhashtable_lookup_get_insert_fast(NULL, NULL, params);
974 ],[
975         AC_DEFINE(HAVE_RHASHTABLE_LOOKUP_GET_INSERT_FAST, 1,
976                 [rhashtable_lookup_get_insert_fast() is available])
977 ])
978 ]) # LIBCFS_RHASHTABLE_LOOKUP_GET_INSERT_FAST
979
980 #
981 # Kernel version 4.12-rc2 8f553c498e1772cccb39a114da4a498d22992758
982 # provide proper CPU hotplug locking
983 #
984 AC_DEFUN([LIBCFS_CPUS_READ_LOCK], [
985 LB_CHECK_COMPILE([if 'cpus_read_[un]lock' exist],
986 cpu_read_lock, [
987         #include <linux/cpu.h>
988 ],[
989         cpus_read_lock();
990         cpus_read_unlock();
991 ],[
992         AC_DEFINE(HAVE_CPUS_READ_LOCK, 1, ['cpus_read_lock' exist])
993 ])
994 ]) # LIBCFS_CPUS_READ_LOCK
995
996 #
997 # Kernel version 4.12-rc3 f9727a17db9bab71ddae91f74f11a8a2f9a0ece6
998 # renamed uuid_be to uuid_t
999 #
1000 AC_DEFUN([LIBCFS_UUID_T], [
1001 LB_CHECK_COMPILE([if 'uuid_t' exist],
1002 uuid_t, [
1003         #include <linux/uuid.h>
1004 ],[
1005         uuid_t uuid;
1006
1007         memset(uuid.b, 0, 16);
1008 ],[
1009         AC_DEFINE(HAVE_UUID_T, 1, ['uuid_t' exist])
1010 ])
1011 ]) # LIBCFS_UUID_T
1012
1013 #
1014 # Kernel version 4.12-rc3 commit fd851a3cdc196bfc1d229b5f22369069af532bf8
1015 # introduce processor.h
1016 #
1017 AC_DEFUN([LIBCFS_HAVE_PROCESSOR_HEADER], [
1018 tmp_flags="$EXTRA_KCFLAGS"
1019 EXTRA_KCFLAGS="-Werror"
1020 LB_CHECK_LINUX_HEADER([linux/processor.h], [
1021         AC_DEFINE(HAVE_PROCESSOR_H, 1,
1022                 [processor.h is present])
1023 ])
1024 EXTRA_KCFLAGS="$tmp_flags"
1025 ]) # LIBCFS_HAVE_PROCESSOR_HEADER
1026
1027 #
1028 # Kernel verison 4.12-rc6 commit 5dd43ce2f69d42a71dcacdb13d17d8c0ac1fe8f7
1029 # created wait_bit.h
1030 #
1031 AC_DEFUN([LIBCFS_HAVE_WAIT_BIT_HEADER], [
1032 LB_CHECK_LINUX_HEADER([linux/wait_bit.h], [
1033         AC_DEFINE(HAVE_WAIT_BIT_HEADER_H, 1,
1034                 [wait_bit.h is present])])
1035 ]) # LIBCFS_HAVE_WAIT_BIT_HEADER
1036
1037 #
1038 # Kernel version 4.12-rc6 commmit 2055da97389a605c8a00d163d40903afbe413921
1039 # changed:
1040 #       struct wait_queue_head::task_list       => ::head
1041 #       struct wait_queue_entry::task_list      => ::entry
1042 #
1043 AC_DEFUN([LIBCFS_WAIT_QUEUE_TASK_LIST_RENAME], [
1044 LB_CHECK_COMPILE([if linux wait_queue_head list_head is named head],
1045 wait_queue_task_list, [
1046         #include <linux/wait.h>
1047 ],[
1048         wait_queue_head_t e;
1049
1050         INIT_LIST_HEAD(&e.head);
1051 ],[
1052         AC_DEFINE(HAVE_WAIT_QUEUE_ENTRY_LIST, 1,
1053                 [linux wait_queue_head_t list_head is name head])
1054 ])
1055 ]) # LIBCFS_WAIT_QUEUE_TASK_LIST_RENAME
1056
1057 #
1058 # LIBCFS_WAIT_BIT_QUEUE_ENTRY_EXISTS
1059 #
1060 # Kernel version v4.12-rc6-23-g76c85ddc4695
1061 # sched/wait: Standardize wait_bit_queue naming
1062 #
1063 # renamed struct wait_bit_queue  => wait_bit_queue_entry
1064 #
1065 AC_DEFUN([LIBCFS_WAIT_BIT_QUEUE_ENTRY_EXISTS], [
1066 LB_CHECK_COMPILE([if struct wait_bit_queue_entry exists],
1067 struct_wait_bit_queue_entry_exists, [
1068         #include <linux/wait.h>
1069         #if HAVE_WAIT_BIT_HEADER_H
1070                 #include <linux/wait_bit.h>
1071         #endif
1072 ],[
1073         struct wait_bit_queue_entry entry;
1074         memset(&entry, 0, sizeof(entry));
1075 ],[
1076         AC_DEFINE(HAVE_WAIT_BIT_QUEUE_ENTRY, 1,
1077                 [if struct wait_bit_queue_entry exists])
1078 ])
1079 ]) # LIBCFS_WAIT_BIT_QUEUE_ENTRY_EXISTS
1080
1081 #
1082 # LIBCFS_NLA_STRDUP
1083 #
1084 # Kernel version 4.13-rc1 commit 2cf0c8b3e6942ecafe6ebb1a6d0328a81641bf39
1085 # created nla_strdup(). This is needed since push strings can be
1086 # any size.
1087 #
1088 AC_DEFUN([LIBCFS_NLA_STRDUP], [
1089 LB_CHECK_COMPILE([if 'nla_strdup()' exists],
1090 nla_strdup, [
1091         #include <net/netlink.h>
1092 ],[
1093         char *tmp = nla_strdup(NULL, GFP_KERNEL);
1094 ],[
1095         AC_DEFINE(HAVE_NLA_STRDUP, 1,
1096                 ['nla_strdup' is available])
1097 ])
1098 ]) # LIBCFS_NLA_STRDUP
1099
1100 #
1101 # LIBCFS_WAIT_QUEUE_ENTRY
1102 #
1103 # Kernel version 4.13 ac6424b981bce1c4bc55675c6ce11bfe1bbfa64f
1104 # Rename wait_queue_t => wait_queue_entry_t
1105 #
1106 AC_DEFUN([LIBCFS_WAIT_QUEUE_ENTRY], [
1107 LB_CHECK_COMPILE([if 'wait_queue_entry_t' exists],
1108 wait_queue_entry, [
1109         #include <linux/wait.h>
1110 ],[
1111         wait_queue_entry_t e;
1112
1113         e.flags = 0;
1114 ],[
1115         AC_DEFINE(HAVE_WAIT_QUEUE_ENTRY, 1,
1116                 ['wait_queue_entry_t' is available])
1117 ])
1118 ]) # LIBCFS_WAIT_QUEUE_ENTRY
1119
1120 #
1121 # LIBCFS_NEW_KERNEL_WRITE
1122 #
1123 # Kernel version 4.14 e13ec939e96b13e664bb6cee361cc976a0ee621a
1124 # changed kernel_write prototype to make is plug compatible
1125 # with the unexported vfs_write()
1126 #
1127 AC_DEFUN([LIBCFS_NEW_KERNEL_WRITE], [
1128 tmp_flags="$EXTRA_KCFLAGS"
1129 EXTRA_KCFLAGS="-Werror"
1130 LB_CHECK_COMPILE([if 'kernel_write' matches other read/write helpers],
1131 kernel_write_match, [
1132         #include <linux/fs.h>
1133 ],[
1134         const void *buf = NULL;
1135         loff_t pos = 0;
1136         return kernel_write(NULL, buf, 0, &pos);
1137 ],[
1138         AC_DEFINE(HAVE_NEW_KERNEL_WRITE, 1,
1139                 ['kernel_write' aligns with read/write helpers])
1140 ])
1141 EXTRA_KCFLAGS="$tmp_flags"
1142 ]) # LIBCFS_NEW_KERNEL_WRITE
1143
1144 #
1145 # LIBCFS_MM_TOTALRAM_PAGES_FUNC
1146 #
1147 # kernel 5.0 commit ca79b0c211af63fa3276f0e3fd7dd9ada2439839
1148 # mm: convert totalram_pages and totalhigh_pages variables to atomic
1149 #
1150 AC_DEFUN([LIBCFS_MM_TOTALRAM_PAGES_FUNC], [
1151 tmp_flags="$EXTRA_KCFLAGS"
1152 EXTRA_KCFLAGS="-Werror"
1153 LB_CHECK_COMPILE([if totalram_pages is a function],
1154 totalram_pages, [
1155         #include <linux/mm.h>
1156 ],[
1157         totalram_pages_inc();
1158 ],[
1159         AC_DEFINE(HAVE_TOTALRAM_PAGES_AS_FUNC, 1,
1160                 [if totalram_pages is a function])
1161 ])
1162 EXTRA_KCFLAGS="$tmp_flags"
1163 ]) # LIBCFS_MM_TOTALRAM_PAGES_FUNC
1164
1165 #
1166 # LIBCFS_NEW_KERNEL_READ
1167 #
1168 # 4.14 commit bdd1d2d3d251c65b74ac4493e08db18971c09240 changed
1169 # the signature of kernel_read to match other read/write helpers
1170 # and place offset last.
1171 #
1172 AC_DEFUN([LIBCFS_NEW_KERNEL_READ], [
1173 tmp_flags="$EXTRA_KCFLAGS"
1174 EXTRA_KCFLAGS="-Werror"
1175 LB_CHECK_COMPILE([if 'kernel_read()' has loff_t *pos as last parameter],
1176 kernel_read, [
1177         #include <linux/fs.h>
1178         ],[
1179         loff_t pos = 0;
1180         kernel_read(NULL, NULL, 0, &pos);
1181 ],[
1182         AC_DEFINE(HAVE_KERNEL_READ_LAST_POSP, 1,
1183                 [kernel_read() signature ends with loff_t *pos])
1184 ])
1185 EXTRA_KCFLAGS="$tmp_flags"
1186 ]) # LIBCFS_NEW_KERNEL_READ
1187
1188 #
1189 # LIBCFS_DEFINE_TIMER
1190 #
1191 # Kernel version 4.14 commit 1d27e3e2252ba9d949ca82fbdb73cde102cb2067
1192 # remove expires and data arguments from DEFINE_TIMER. Also the callback
1193 # when from using unsigned long argument to using struct timer_list pointer.
1194 #
1195 AC_DEFUN([LIBCFS_DEFINE_TIMER], [
1196 LB_CHECK_COMPILE([if DEFINE_TIMER takes only 2 arguments],
1197 define_timer, [
1198         #include <linux/timer.h>
1199 ],[
1200         static DEFINE_TIMER(my_timer, NULL);
1201 ],[
1202         AC_DEFINE(HAVE_NEW_DEFINE_TIMER, 1,
1203                 [DEFINE_TIMER uses only 2 arguements])
1204 ])
1205 ]) # LIBCFS_DEFINE_TIMER
1206
1207 #
1208 # LIBCFS_EXPORT_SAVE_STACK_TRACE_TSK
1209 #
1210 # Kernel 2.6.27 commit 8594698ebddeef5443b7da8258ae33b3eaca61d5
1211 # exported save_stack_trace_tsk for x86.
1212 # Kernel 2.6.27 commit 01f4b8b8b8db09b88be7df7e51192e4e678b69d3
1213 # exported save_stack_trace_tsk for powerpc
1214 # Kernel 4.13 commit e27c7fa015d61c8be6a2c32b2144aad2ae6ec975
1215 # exported save_stack_trace_tsk for arm64
1216 # Kernel 4.14 commit 9a3dc3186fc3795e076a4122da9e0258651a9631
1217 # exported save_stack_trace_tsk for arm
1218 #
1219 AC_DEFUN([LIBCFS_EXPORT_SAVE_STACK_TRACE_TSK], [
1220 LB_CHECK_EXPORT([save_stack_trace_tsk], [arch/$SUBARCH/kernel/stacktrace.c],
1221         [AC_DEFINE(HAVE_SAVE_STACK_TRACE_TSK, 1,
1222                 [save_stack_trace_tsk is exported])])
1223 ]) # LIBCFS_EXPORT_SAVE_STACK_TRACE_TSK
1224
1225 #
1226 # LIBCFS_LOCKDEP_IS_HELD
1227 #
1228 # Kernel v4.15-rc8-106-g08f36ff64234
1229 # lockdep: Make lockdep checking constant
1230 #
1231 AC_DEFUN([LIBCFS_LOCKDEP_IS_HELD], [
1232 tmp_flags="$EXTRA_KCFLAGS"
1233 EXTRA_KCFLAGS="-Werror"
1234 LB_CHECK_COMPILE([if 'lockdep_is_held()' uses const argument],
1235 lockdep_is_held, [
1236         #include <linux/lockdep.h>
1237 ],[
1238 #ifdef CONFIG_LOCKDEP
1239         const struct spinlock *lock = NULL;
1240
1241         lockdep_is_held(lock);
1242 #endif
1243 ],[],[
1244         AC_DEFINE(NEED_LOCKDEP_IS_HELD_DISCARD_CONST, 1,
1245                 [lockdep_is_held() argument is const])
1246 ])
1247 EXTRA_KCFLAGS="$tmp_flags"
1248 ]) # LIBCFS_LOCKDEP_IS_HELD
1249
1250 #
1251 # LIBCFS_TIMER_SETUP
1252 #
1253 # Kernel version 4.15 commit e99e88a9d2b067465adaa9c111ada99a041bef9a
1254 # setup_timer() was replaced by timer_setup(), where the callback
1255 # argument is the structure already holding the struct timer_list.
1256 #
1257 AC_DEFUN([LIBCFS_TIMER_SETUP], [
1258 LB_CHECK_COMPILE([if setup_timer has been replaced with timer_setup],
1259 timer_setup, [
1260         #include <linux/timer.h>
1261 ],[
1262         timer_setup(NULL, NULL, 0);
1263 ],[
1264         AC_DEFINE(HAVE_TIMER_SETUP, 1,
1265                 [timer_setup has replaced setup_timer])
1266 ])
1267 ]) # LIBCFS_TIMER_SETUP
1268
1269 #
1270 # LIBCFS_WAIT_VAR_EVENT
1271 #
1272 # Kernel version 4.16-rc4 commit 6b2bb7265f0b62605e8caee3613449ed0db270b9
1273 # added wait_var_event()
1274 #
1275 AC_DEFUN([LIBCFS_WAIT_VAR_EVENT], [
1276 LB_CHECK_COMPILE([if 'wait_var_event' exist],
1277 wait_var_event, [
1278         #ifdef HAVE_WAIT_BIT_HEADER_H
1279         #include <linux/wait_bit.h>
1280         #endif
1281         #include <linux/wait.h>
1282 ],[
1283         wake_up_var(NULL);
1284 ],[
1285         AC_DEFINE(HAVE_WAIT_VAR_EVENT, 1,
1286                 ['wait_var_event' is available])
1287 ])
1288 ]) # LIBCFS_WAIT_VAR_EVENT
1289
1290 #
1291 # LIBCFS_BITMAP_ALLOC
1292 #
1293 # Kernel version 4.17 commit c42b65e363ce97a828f81b59033c3558f8fa7f70
1294 # added bitmap memory allocation handling.
1295 #
1296 AC_DEFUN([LIBCFS_BITMAP_ALLOC], [
1297 LB_CHECK_COMPILE([if Linux bitmap memory management exist],
1298 bitmap_alloc, [
1299         #include <linux/bitmap.h>
1300 ],[
1301         unsigned long *map = bitmap_alloc(1, GFP_KERNEL);
1302 ],[
1303         AC_DEFINE(HAVE_BITMAP_ALLOC, 1,
1304                 [Linux bitmap can be allocated])
1305 ])
1306 ]) # LIBCFS_BITMAP_ALLOC
1307
1308 #
1309 # LIBCFS_CLEAR_AND_WAKE_UP_BIT
1310 #
1311 # Kernel version 4.17-rc2 commit 8236b0ae31c837d2b3a2565c5f8d77f637e824cc
1312 # added clear_and_wake_up_bit()
1313 #
1314 AC_DEFUN([LIBCFS_CLEAR_AND_WAKE_UP_BIT], [
1315 LB_CHECK_COMPILE([if 'clear_and_wake_up_bit' exist],
1316 clear_and_wake_up_bit, [
1317         #ifdef HAVE_WAIT_BIT_HEADER_H
1318         #include <linux/wait_bit.h>
1319         #endif
1320         #include <linux/wait.h>
1321 ],[
1322         clear_and_wake_up_bit(0, NULL);
1323 ],[
1324         AC_DEFINE(HAVE_CLEAR_AND_WAKE_UP_BIT, 1,
1325                 ['clear_and_wake_up_bit' is available])
1326 ])
1327 ]) # LIBCFS_CLEAR_AND_WAKE_UP_BIT
1328
1329 #
1330 # LIBCFS_TCP_SOCK_SET_NODELAY
1331 #
1332 # kernel 4.18.0-293.el8
1333 # tcp_sock_set_nodelay() was added
1334 AC_DEFUN([LIBCFS_TCP_SOCK_SET_NODELAY], [
1335 tmp_flags="$EXTRA_KCFLAGS"
1336 EXTRA_KCFLAGS="-Werror"
1337 LB_CHECK_COMPILE([if 'tcp_sock_set_nodelay()' exists],
1338 tcp_sock_set_nodelay_exists, [
1339         #include <linux/tcp.h>
1340 ],[
1341         tcp_sock_set_nodelay(NULL);
1342 ],[
1343         AC_DEFINE(HAVE_TCP_SOCK_SET_NODELAY, 1,
1344                 ['tcp_sock_set_nodelay()' exists])
1345 ])
1346 EXTRA_KCFLAGS="$tmp_flags"
1347 ]) # LIBCFS_TCP_SOCK_SET_NODELAY
1348
1349 #
1350 # LIBCFS_TCP_SOCK_SET_KEEPIDLE
1351 #
1352 # kernel 4.18.0-293.el8
1353 # tcp_sock_set_keepidle() was added
1354 AC_DEFUN([LIBCFS_TCP_SOCK_SET_KEEPIDLE], [
1355 tmp_flags="$EXTRA_KCFLAGS"
1356 EXTRA_KCFLAGS="-Werror"
1357 LB_CHECK_COMPILE([if 'tcp_sock_set_keepidle()' exists],
1358 tcp_sock_set_keepidle_exists, [
1359         #include <linux/tcp.h>
1360 ],[
1361         tcp_sock_set_keepidle(NULL, 0);
1362 ],[
1363         AC_DEFINE(HAVE_TCP_SOCK_SET_KEEPIDLE, 1,
1364                 ['tcp_sock_set_keepidle()' exists])
1365 ])
1366 EXTRA_KCFLAGS="$tmp_flags"
1367 ]) # LIBCFS_TCP_SOCK_SET_KEEPIDLE
1368
1369 #
1370 # LIBCFS_TCP_SOCK_SET_QUICKACK
1371 # kernel v5.7-rc6-2504-gddd061b8daed
1372 #   tcp: add tcp_sock_set_quickack
1373 #
1374 AC_DEFUN([LIBCFS_TCP_SOCK_SET_QUICKACK], [
1375 tmp_flags="$EXTRA_KCFLAGS"
1376 EXTRA_KCFLAGS="-Werror"
1377 LB_CHECK_COMPILE([if 'tcp_sock_set_quickack()' exists],
1378 tcp_sock_set_quickack_exists, [
1379         #include <linux/tcp.h>
1380 ],[
1381         tcp_sock_set_quickack(NULL, 0);
1382 ],[
1383         AC_DEFINE(HAVE_TCP_SOCK_SET_QUICKACK, 1,
1384                 ['tcp_sock_set_quickack()' exists])
1385 ])
1386 EXTRA_KCFLAGS="$tmp_flags"
1387 ]) # LIBCFS_TCP_SOCK_SET_QUICKACK
1388
1389 #
1390 # LIBCFS_TCP_SOCK_SET_KEEPINTVL
1391 # v5.7-rc6-2508-gd41ecaac903c
1392 # tcp: add tcp_sock_set_keepintvl
1393 #
1394 AC_DEFUN([LIBCFS_TCP_SOCK_SET_KEEPINTVL], [
1395 tmp_flags="$EXTRA_KCFLAGS"
1396 EXTRA_KCFLAGS="-Werror"
1397 LB_CHECK_COMPILE([if 'tcp_sock_set_keepintvl()' exists],
1398 tcp_sock_set_keepintvl_exists, [
1399         #include <linux/tcp.h>
1400 ],[
1401         tcp_sock_set_keepintvl(NULL, 0);
1402 ],[
1403         AC_DEFINE(HAVE_TCP_SOCK_SET_KEEPINTVL, 1,
1404                 ['tcp_sock_set_keepintvl()' exists])
1405 ])
1406 EXTRA_KCFLAGS="$tmp_flags"
1407 ]) # LIBCFS_TCP_SOCK_SET_KEEPINTVL
1408
1409 #
1410 # LIBCFS_TCP_SOCK_SET_KEEPCNT
1411 # v5.7-rc6-2509-g480aeb9639d6
1412 # tcp: add tcp_sock_set_keepcnt
1413 #
1414 AC_DEFUN([LIBCFS_TCP_SOCK_SET_KEEPCNT], [
1415 tmp_flags="$EXTRA_KCFLAGS"
1416 EXTRA_KCFLAGS="-Werror"
1417 LB_CHECK_COMPILE([if 'tcp_sock_set_keepcnt()' exists],
1418 tcp_sock_set_keepcnt_exists, [
1419         #include <linux/tcp.h>
1420 ],[
1421         tcp_sock_set_keepcnt(NULL, 0);
1422 ],[
1423         AC_DEFINE(HAVE_TCP_SOCK_SET_KEEPCNT, 1,
1424                 ['tcp_sock_set_keepcnt()' exists])
1425 ])
1426 EXTRA_KCFLAGS="$tmp_flags"
1427 ]) # LIBCFS_TCP_SOCK_SET_KEEPCNT
1428
1429 #
1430 # LIBCFS_XARRAY_SUPPORT
1431 #
1432 # 4.19-rc5 kernel commit 3159f943aafdbacb2f94c38fdaadabf2bbde2a14
1433 # replaced the radix tree implementation with Xarrays. This change
1434 # introduced functionaly needed for general Xarray support
1435 #
1436 AC_DEFUN([LIBCFS_XARRAY_SUPPORT], [
1437 tmp_flags="$EXTRA_KCFLAGS"
1438 EXTRA_KCFLAGS="-Werror"
1439 LB_CHECK_COMPILE([if page cache uses Xarray],
1440 xarray_support, [
1441         #include <linux/xarray.h>
1442 ],[
1443         xa_is_value(NULL);
1444 ],[
1445         AC_DEFINE(HAVE_XARRAY_SUPPORT, 1,
1446                 [kernel Xarray implementation lacks 'xa_is_value'])
1447 ])
1448 EXTRA_KCFLAGS="$tmp_flags"
1449 ]) # LIBCFS_XARRAY_SUPPORT
1450
1451 #
1452 # Kernel version 4.19-rc6 commit 4a19edb60d0203cd5bf95a8b46ea8f63fd41194c
1453 # added extended ACK handling to Netlink dump handlers
1454 #
1455 AC_DEFUN([LIBCFS_NL_DUMP_EXT_ACK], [
1456 LB_CHECK_COMPILE([if Netlink dump handlers support ext_ack],
1457 netlink_dump_ext_ack, [
1458         #include <net/netlink.h>
1459 ],[
1460         struct netlink_callback *cb = NULL;
1461         cb->extack = NULL;
1462 ],[
1463         AC_DEFINE(HAVE_NL_DUMP_WITH_EXT_ACK, 1,
1464                 [netlink_ext_ack is handled for Netlink dump handlers])
1465 ])
1466 ]) # LIBCFS_NL_DUMP_EXT_ACK
1467
1468 #
1469 # LIBCFS_HAVE_IOV_ITER_TYPE
1470 #
1471 # kernel 4.20 commit 00e23707442a75b404392cef1405ab4fd498de6b
1472 # iov_iter: Use accessor functions to access an iterator's type and direction.
1473 #
1474 AC_DEFUN([LIBCFS_HAVE_IOV_ITER_TYPE], [
1475 tmp_flags="$EXTRA_KCFLAGS"
1476 EXTRA_KCFLAGS="-Werror"
1477 LB_CHECK_COMPILE([if iov_iter_type exists],
1478 macro_iov_iter_type_exists, [
1479         #include <linux/uio.h>
1480 ],[
1481         struct iov_iter iter = { };
1482         enum iter_type type = iov_iter_type(&iter);
1483         (void)type;
1484 ],[
1485         AC_DEFINE(HAVE_IOV_ITER_TYPE, 1,
1486                 [if iov_iter_type exists])
1487 ])
1488 EXTRA_KCFLAGS="$tmp_flags"
1489 ]) # LIBCFS_HAVE_IOV_ITER_TYPE
1490
1491 #
1492 # LIBCFS_GET_REQUEST_KEY_AUTH
1493 #
1494 # kernel 5.0 commit 822ad64d7e46a8e2c8b8a796738d7b657cbb146d
1495 # keys: Fix dependency loop between construction record and auth key
1496 #
1497 # Added <keys/request_key_auth-type.h> and get_request_key_auth()
1498 # which was propagated to stable
1499 #
1500 AC_DEFUN([LIBCFS_GET_REQUEST_KEY_AUTH], [
1501 tmp_flags="$EXTRA_KCFLAGS"
1502 EXTRA_KCFLAGS="-Werror"
1503 LB_CHECK_COMPILE([if get_request_key_auth() is available],
1504 get_request_key_auth_exported, [
1505         #include <linux/key.h>
1506         #include <linux/keyctl.h>
1507         #include <keys/request_key_auth-type.h>
1508 ],[
1509         struct key *ring;
1510         const struct key *key = NULL;
1511         struct request_key_auth *rka = get_request_key_auth(key);
1512
1513         ring = key_get(rka->dest_keyring);
1514 ],[
1515         AC_DEFINE(HAVE_GET_REQUEST_KEY_AUTH, 1,
1516                 [get_request_key_auth() is available])
1517 ])
1518 EXTRA_KCFLAGS="$tmp_flags"
1519 ]) # LIBCFS_GET_REQUEST_KEY_AUTH
1520
1521 #
1522 # LIBCFS_LOOKUP_USER_KEY
1523 #
1524 # kernel 5.3 commit 3cf5d076fb4d48979f382bc9452765bf8b79e740
1525 # signal: Remove task parameter from force_sig
1526 #
1527 AC_DEFUN([LIBCFS_LOOKUP_USER_KEY], [
1528 tmp_flags="$EXTRA_KCFLAGS"
1529 EXTRA_KCFLAGS="-Werror"
1530 LB_CHECK_COMPILE([if lookup_user_key() is available],
1531 lookup_user_key_exported, [
1532         #include <linux/key.h>
1533         #include <linux/keyctl.h>
1534 ],[
1535         lookup_user_key(KEY_SPEC_USER_KEYRING, 0, 0);
1536 ],[
1537         AC_DEFINE(HAVE_LOOKUP_USER_KEY, 1,
1538                 [lookup_user_key() is available])
1539 ])
1540 EXTRA_KCFLAGS="$tmp_flags"
1541 ]) # LIBCFS_LOOKUP_USER_KEY
1542
1543 #
1544 # LIBCFS_FORCE_SIG_WITH_TASK
1545 #
1546 # kernel 5.3 commit 3cf5d076fb4d48979f382bc9452765bf8b79e740
1547 # signal: Remove task parameter from force_sig
1548 #
1549 AC_DEFUN([LIBCFS_FORCE_SIG_WITH_TASK], [
1550 tmp_flags="$EXTRA_KCFLAGS"
1551 EXTRA_KCFLAGS="-Werror"
1552 LB_CHECK_COMPILE([if force_sig has task parameter],
1553 force_sig_with_task, [
1554         #include <linux/sched/signal.h>
1555 ],[
1556         force_sig(SIGINT, NULL);
1557 ],[
1558         AC_DEFINE(HAVE_FORCE_SIG_WITH_TASK, 1,
1559                 [force_sig() has task parameter])
1560 ])
1561 EXTRA_KCFLAGS="$tmp_flags"
1562 ]) # LIBCFS_FORCE_SIG_WITH_TASK
1563
1564 #
1565 # LIBCFS_CACHE_DETAIL_WRITERS
1566 #
1567 # kernel v5.3-rc2-1-g64a38e840ce5
1568 # SUNRPC: Track writers of the 'channel' file to improve cache_listeners_exist
1569 #
1570 AC_DEFUN([LIBCFS_CACHE_DETAIL_WRITERS], [
1571 tmp_flags="$EXTRA_KCFLAGS"
1572 EXTRA_KCFLAGS="-Werror"
1573 LB_CHECK_COMPILE([if struct cache_detail has writers],
1574 cache_detail_writers_atomic, [
1575         #include <linux/sunrpc/cache.h>
1576
1577         static struct cache_detail rsi_cache;
1578 ],[
1579         atomic_set(&rsi_cache.writers, 0);
1580 ],[
1581         AC_DEFINE(HAVE_CACHE_DETAIL_WRITERS, 1,
1582                 [struct cache_detail has writers])
1583 ])
1584 EXTRA_KCFLAGS="$tmp_flags"
1585 ]) # LIBCFS_CACHE_DETAIL_WRITERS
1586
1587 #
1588 # LIBCFS_GENL_DUMPIT_INFO
1589 #
1590 # kernel v5.4-rc1 commit bf813b0afeae2f012f0e527a526c1b78ca21ad82
1591 # expanded struct genl_dumpit_info to include struct genl_family.
1592 #
1593 AC_DEFUN([LIBCFS_GENL_DUMPIT_INFO], [
1594 tmp_flags="$EXTRA_KCFLAGS"
1595 EXTRA_KCFLAGS="-Werror"
1596 LB_CHECK_COMPILE([if struct genl_dumpit_info has family field],
1597 genl_dumpit_info, [
1598         #include <net/genetlink.h>
1599 ],[
1600         static struct genl_dumpit_info info;
1601
1602         info.family = NULL;
1603 ],[
1604         AC_DEFINE(HAVE_GENL_DUMPIT_INFO, 1,
1605                 [struct genl_dumpit_info has family field])
1606 ])
1607 EXTRA_KCFLAGS="$tmp_flags"
1608 ]) # LIBCFS_GENL_DUMPIT_INFO
1609
1610 #
1611 # LIBCFS_KALLSYMS_LOOKUP
1612 #
1613 # kernel v5.6-11591-g0bd476e6c671
1614 # kallsyms: unexport kallsyms_lookup_name() and kallsyms_on_each_symbol()
1615 AC_DEFUN([LIBCFS_KALLSYMS_LOOKUP], [
1616 LB_CHECK_EXPORT([kallsyms_lookup_name], [kernel/kallsyms.c],
1617         [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1618                 [kallsyms_lookup_name is exported by kernel])])
1619 ]) # LIBCFS_KALLSYMS_LOOKUP
1620
1621 #
1622 # v5.5-8862-gd56c0d45f0e2
1623 # proc: decouple proc from VFS with "struct proc_ops"
1624 #
1625 AC_DEFUN([LIBCFS_SRC_HAVE_PROC_OPS], [
1626         LB2_LINUX_TEST_SRC([proc_ops], [
1627                 #include <linux/proc_fs.h>
1628
1629                 static struct proc_ops *my_proc;
1630         ],[
1631                 my_proc->proc_lseek = NULL;
1632         ],[-Werror])
1633 ]) # LIBCFS_SRC_HAVE_PROC_OPS
1634 AC_DEFUN([LIBCFS_HAVE_PROC_OPS], [
1635         AC_MSG_CHECKING([if struct proc_ops exists])
1636         LB2_LINUX_TEST_RESULT([proc_ops], [
1637                 AC_DEFINE(HAVE_PROC_OPS, 1,
1638                         [struct proc_ops exists])
1639                 AC_MSG_RESULT(yes)
1640         ],[
1641                 AC_MSG_RESULT(no)
1642         ])
1643 ]) # LIBCFS_HAVE_PROC_OPS
1644
1645 #
1646 # LIBCFS_VMALLOC_2ARGS
1647 #
1648 # kernel v5.8-rc1~201^2~19
1649 # mm: remove the pgprot argument to __vmalloc
1650 AC_DEFUN([LIBCFS_VMALLOC_2ARGS], [
1651 LB_CHECK_COMPILE([if __vmalloc has 2 args],
1652 vmalloc_2args, [
1653         #include <linux/vmalloc.h>
1654 ],[
1655         __vmalloc(0, 0);
1656 ],[
1657         AC_DEFINE(HAVE_VMALLOC_2ARGS, 1,
1658                 [__vmalloc only takes 2 args.])
1659 ])
1660 ]) # LIBCFS_VMALLOC_2ARGS
1661
1662 #
1663 # LIBCFS_HAVE_NR_UNSTABLE_NFS
1664 #
1665 # kernel v5.8-rc1~201^2~75
1666 # mm/writeback: discard NR_UNSTABLE_NFS, use NR_WRITEBACK instead
1667 #
1668 AC_DEFUN([LIBCFS_HAVE_NR_UNSTABLE_NFS], [
1669 tmp_flags="$EXTRA_KCFLAGS"
1670 EXTRA_KCFLAGS="-Werror"
1671 LB_CHECK_COMPILE([if NR_UNSTABLE_NFS still in use],
1672 nr_unstable_nfs_exists, [
1673         #include <linux/mm.h>
1674
1675         int i;
1676 ],[
1677         i = NR_UNSTABLE_NFS;
1678 ],[
1679         AC_DEFINE(HAVE_NR_UNSTABLE_NFS, 1,
1680                 [NR_UNSTABLE_NFS is still in use.])
1681 ])
1682 EXTRA_KCFLAGS="$tmp_flags"
1683 ]) # LIBCFS_HAVE_NR_UNSTABLE_NFS
1684
1685 #
1686 # LIBCFS_HAVE_MMAP_LOCK
1687 #
1688 # kernel v5.8-rc1~83^2~24
1689 # mmap locking API: rename mmap_sem to mmap_lock
1690 #
1691 AC_DEFUN([LIBCFS_HAVE_MMAP_LOCK], [
1692 LB_CHECK_COMPILE([if mmap_lock API is available],
1693 mmap_write_lock, [
1694         #include <linux/mm.h>
1695 ],[
1696         mmap_write_lock(NULL);
1697 ],[
1698         AC_DEFINE(HAVE_MMAP_LOCK, 1,
1699                 [mmap_lock API is available.])
1700 ])
1701 ]) # LIBCFS_HAVE_MMAP_LOCK
1702
1703 #
1704 # LIBCFS_KERNEL_SETSOCKOPT
1705 #
1706 # kernel v5.8-rc1~165^2~59^2
1707 # net: remove kernel_setsockopt
1708 AC_DEFUN([LIBCFS_KERNEL_SETSOCKOPT], [
1709 tmp_flags="$EXTRA_KCFLAGS"
1710 EXTRA_KCFLAGS="-Werror"
1711 LB_CHECK_COMPILE([if kernel_setsockopt still in use],
1712 kernel_setsockopt_exists, [
1713         #include <linux/net.h>
1714 ],[
1715         kernel_setsockopt(NULL, 0, 0, NULL, 0);
1716 ],[
1717         AC_DEFINE(HAVE_KERNEL_SETSOCKOPT, 1,
1718                 [kernel_setsockopt still in use])
1719 ])
1720 EXTRA_KCFLAGS="$tmp_flags"
1721 ]) # LIBCFS_KERNEL_SETSOCKOPT
1722
1723 #
1724 # LIBCFS_SEC_RELEASE_SECCTX
1725 #
1726 # kernel linux-hwe-5.8 (5.8.0-22.23~20.04.1)
1727 # LSM: Use lsmcontext in security_release_secctx
1728 AC_DEFUN([LIBCFS_SEC_RELEASE_SECCTX], [
1729 LB_CHECK_COMPILE([if security_release_secctx has 1 arg],
1730 security_release_secctx_1arg, [
1731         #include <linux/security.h>
1732 ],[
1733         security_release_secctx(NULL);
1734 ],[
1735         AC_DEFINE(HAVE_SEC_RELEASE_SECCTX_1ARG, 1,
1736                 [security_release_secctx has 1 arg.])
1737 ])
1738 ]) # LIBCFS_SEC_RELEASE_SECCTX
1739
1740 #
1741 # LIBCFS_HAVE_KFREE_SENSITIVE
1742 #
1743 # kernel v5.10-rc1~3
1744 # mm: remove kzfree() compatibility definition
1745 #
1746 AC_DEFUN([LIBCFS_HAVE_KFREE_SENSITIVE], [
1747 LB_CHECK_COMPILE([if kfree_sensitive() is available],
1748 kfree_sensitive_exists, [
1749         #include <linux/slab.h>
1750
1751 ],[
1752         kfree_sensitive(NULL);
1753 ],[
1754         AC_DEFINE(HAVE_KFREE_SENSITIVE, 1,
1755                 [kfree_sensitive() is available.])
1756 ])
1757 EXTRA_KCFLAGS="$tmp_flags"
1758 ]) # LIBCFS_HAVE_KFREE_SENSITIVE
1759
1760 #
1761 # LIBCFS_HAVE_CRYPTO_SHA2_HEADER
1762 #
1763 # Kernel v5.10-rc1-114-ga24d22b225ce
1764 # crypto: sha - split sha.h into sha1.h and sha2.h
1765 #
1766 AC_DEFUN([LIBCFS_HAVE_CRYPTO_SHA2_HEADER], [
1767 LB_CHECK_LINUX_HEADER([crypto/sha2.h], [
1768         AC_DEFINE(HAVE_CRYPTO_SHA2_HEADER, 1,
1769                 [crypto/sha2.h is present])])
1770 ]) # LIBCFS_HAVE_CRYPTO_SHA2_HEADER
1771
1772 #
1773 # LIBCFS_HAVE_LIST_CMP_FUNC_T
1774 #
1775 # kernel 5.10.70 commit 4f0f586bf0c898233d8f316f471a21db2abd522d
1776 # treewide: Change list_sort to use const pointers
1777 AC_DEFUN([LIBCFS_HAVE_LIST_CMP_FUNC_T], [
1778 tmp_flags="$EXTRA_KCFLAGS"
1779 EXTRA_KCFLAGS="-Werror -Wno-unused-variable"
1780 LB_CHECK_COMPILE([if list_cmp_func_t type is defined],
1781 list_cmp_func_t, [
1782         #include <linux/list_sort.h>
1783 ],[
1784         list_cmp_func_t cmp;
1785 ],[
1786         AC_DEFINE(HAVE_LIST_CMP_FUNC_T, 1,
1787                 [list_cmp_func_t type is defined])
1788 ])
1789 EXTRA_KCFLAGS="$tmp_flags"
1790 ]) # LIBCFS_HAVE_LIST_CMP_FUNC_T
1791
1792 #
1793 # LIBCFS_NLA_STRLCPY
1794 #
1795 # Kernel version 5.10-rc3 commit 872f690341948b502c93318f806d821c56772c42
1796 # replaced nla_strlcpy() with nla_strscpy().
1797 #
1798 AC_DEFUN([LIBCFS_NLA_STRLCPY], [
1799 LB_CHECK_COMPILE([if 'nla_strlcpy()' still exists],
1800 nla_strlcpy, [
1801         #include <net/netlink.h>
1802 ],[
1803         if (nla_strlcpy(NULL, NULL, 0) == 0)
1804                 return -EINVAL;
1805 ],[
1806         AC_DEFINE(HAVE_NLA_STRLCPY, 1,
1807                 ['nla_strlcpy' is available])
1808 ])
1809 ]) # LIBCFS_NLA_STRLCPY
1810
1811 #
1812 # LIBCFS_HAVE_CIPHER_HEADER
1813 #
1814 # Kernel 5.12 commit 0eb76ba29d16df2951d37c54ca279c4e5630b071
1815 # crypto: remove cipher routines from public crypto API
1816 #
1817 AC_DEFUN([LIBCFS_HAVE_CIPHER_HEADER], [
1818 tmp_flags="$EXTRA_KCFLAGS"
1819 EXTRA_KCFLAGS="-Werror"
1820 LB_CHECK_LINUX_HEADER([crypto/internal/cipher.h], [
1821         AC_DEFINE(HAVE_CIPHER_H, 1,
1822                 [crypto/internal/cipher.h is present])
1823 ])
1824 EXTRA_KCFLAGS="$tmp_flags"
1825 ]) # LIBCFS_HAVE_CIPHER_HEADER
1826
1827 #
1828 # LIBCFS_HAVE_TASK_RUNNING
1829 #
1830 # Kernel 5.13-rc6 commit b03fbd4ff24c5f075e58eb19261d5f8b3e40d
1831 # introduced task_is_running() macro.
1832 #
1833 AC_DEFUN([LIBCFS_HAVE_TASK_IS_RUNNING], [
1834 tmp_flags="$EXTRA_KCFLAGS"
1835 EXTRA_KCFLAGS="-Werror"
1836 LB_CHECK_COMPILE([if task_is_running() is defined],
1837 task_is_running, [
1838         #include <linux/sched.h>
1839 ],[
1840         if (task_is_running(current))
1841                 schedule();
1842 ],[
1843         AC_DEFINE(HAVE_TASK_IS_RUNNING, 1,
1844                 [task_is_running() is defined])
1845 ])
1846 EXTRA_KCFLAGS="$tmp_flags"
1847 ]) # LIBCFS_HAVE_TASK_IS_RUNNING
1848
1849 #
1850 # LIBCFS_LINUX_STDARG_HEADER
1851 #
1852 # Kernel 5.14-rc5 commit c0891ac15f0428ffa81b2e818d416bdf3cb74ab6
1853 # isystem: ship and use stdarg.h
1854 #
1855 AC_DEFUN([LIBCFS_LINUX_STDARG_HEADER], [
1856 tmp_flags="$EXTRA_KCFLAGS"
1857 EXTRA_KCFLAGS="-Werror"
1858 LB_CHECK_LINUX_HEADER([linux/stdarg.h], [
1859         AC_DEFINE(HAVE_LINUX_STDARG_HEADER, 1, [linux/stdarg.h is present])
1860 ])
1861 EXTRA_KCFLAGS="$tmp_flags"
1862 ]) # LIBCFS_LINUX_STDARG_HEADER
1863
1864 #
1865 # LIBCFS_HAVE_PANIC_NOTIFIER_HEADER
1866 #
1867 # Kernel 5.14 commit f39650de687e35766572ac89dbcd16a5911e2f0a
1868 # kernel.h: split out panic and oops helpers
1869 #
1870 AC_DEFUN([LIBCFS_HAVE_PANIC_NOTIFIER_HEADER], [
1871 tmp_flags="$EXTRA_KCFLAGS"
1872 EXTRA_KCFLAGS="-Werror"
1873 LB_CHECK_LINUX_HEADER([linux/panic_notifier.h], [
1874         AC_DEFINE(HAVE_PANIC_NOTIFIER_H, 1,
1875                 [linux/panic_notifier.h is present])
1876 ])
1877 EXTRA_KCFLAGS="$tmp_flags"
1878 ]) # LIBCFS_HAVE_PANIC_NOTIFIER_HEADER
1879
1880 #
1881 # LIBCFS_PARAM_SET_UINT_MINMAX
1882 #
1883 # Kernel 5.15-rc1 commit 2a14c9ae15a38148484a128b84bff7e9ffd90d68
1884 # moved param_set_uint_minmax to common code
1885 #
1886 AC_DEFUN([LIBCFS_PARAM_SET_UINT_MINMAX],[
1887 LB_CHECK_COMPILE([does function 'param_set_uint_minmax' exist],
1888 param_set_uint_minmax, [
1889         #include <linux/moduleparam.h>
1890 ],[
1891         param_set_uint_minmax(NULL, NULL, 0, 0);
1892 ],[
1893         AC_DEFINE(HAVE_PARAM_SET_UINT_MINMAX, 1,
1894                 ['param_set_uint_minmax' is available])
1895 ])
1896 ]) # LIBCFS_PARAM_SET_UINT_MINMAX
1897
1898 AC_DEFUN([LIBCFS_PROG_LINUX_SRC], [
1899         # 5.6
1900         LIBCFS_SRC_HAVE_PROC_OPS
1901
1902         AC_MSG_CHECKING([for available kernel interfaces to libcfs])
1903         LB2_LINUX_TEST_COMPILE_ALL([libcfs])
1904         AC_MSG_RESULT([done])
1905 ])
1906 AC_DEFUN([LIBCFS_PROG_LINUX_RESULTS], [
1907         # 5.6
1908         LIBCFS_HAVE_PROC_OPS
1909 ])
1910
1911 #
1912 # LIBCFS_LINUX_BLK_INTEGRITY_HEADER
1913 #
1914 # Kernel 5.15-rc6 commit fe45e630a1035aea94c29016f2598bbde149bbe3
1915 # block: move integrity handling out of <linux/blkdev.h>
1916 #
1917 AC_DEFUN([LIBCFS_LINUX_BLK_INTEGRITY_HEADER], [
1918 tmp_flags="$EXTRA_KCFLAGS"
1919 EXTRA_KCFLAGS="-Werror"
1920 LB_CHECK_LINUX_HEADER([linux/blk-integrity.h], [
1921         AC_DEFINE(HAVE_LINUX_BLK_INTEGRITY_HEADER, 1,
1922                 [linux/blk-integrity.h is present])
1923 ])
1924 EXTRA_KCFLAGS="$tmp_flags"
1925 ]) # LIBCFS_LINUX_BLK_INTEGRITY_HEADER
1926
1927 #
1928 # LIBCFS_PROG_LINUX
1929 #
1930 # LibCFS linux kernel checks
1931 #
1932 AC_DEFUN([LIBCFS_PROG_LINUX], [
1933 AC_MSG_NOTICE([LibCFS kernel checks
1934 ==============================================================================])
1935 LIBCFS_CONFIG_PANIC_DUMPLOG
1936
1937 # 3.11
1938 LIBCFS_KTIME_GET_TS64
1939 # 3.12
1940 LIBCFS_PREPARE_TO_WAIT_EVENT
1941 LIBCFS_KERNEL_PARAM_OPS
1942 LIBCFS_KTIME_ADD
1943 LIBCFS_KTIME_AFTER
1944 LIBCFS_KTIME_BEFORE
1945 LIBCFS_KTIME_COMPARE
1946 LIBCFS_SHRINKER_COUNT
1947 # 3.13
1948 LIBCFS_MATCH_WILDCARD
1949 # 3.15
1950 LIBCFS_HAVE_MAPPING_AS_EXITING_FLAG
1951 LIBCFS_IOV_ITER_HAS_TYPE
1952 # 3.16
1953 LIBCFS_HAVE_GLOB
1954 LIBCFS_HAVE_NS_TO_TIMESPEC64
1955 # 3.17
1956 LIBCFS_HLIST_ADD_AFTER
1957 LIBCFS_TIMESPEC64
1958 LIBCFS_KTIME_GET_NS
1959 LIBCFS_KTIME_GET_REAL_TS64
1960 LIBCFS_KTIME_GET_REAL_SECONDS
1961 LIBCFS_KTIME_GET_REAL_NS
1962 LIBCFS_KTIME_TO_TIMESPEC64
1963 LIBCFS_TIMESPEC64_SUB
1964 LIBCFS_TIMESPEC64_TO_KTIME
1965 # 3.19
1966 LIBCFS_KTIME_GET_SECONDS
1967 LIBCFS_WAIT_WOKEN
1968 # 4.0
1969 LIBCFS_KTIME_MS_DELTA
1970 # 4.1
1971 LIBCFS_KERNEL_PARAM_LOCK
1972 # 4.2
1973 LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK
1974 # 4.4
1975 LIBCFS_KSTRTOBOOL_FROM_USER
1976 LIBCFS_NETLINK_CALLBACK_START
1977 # 4.5
1978 LIBCFS_CRYPTO_HASH_HELPERS
1979 LIBCFS_EXPORT_KSET_FIND_OBJ
1980 LIBCFS_RHASHTABLE_REPLACE
1981 # 4.6
1982 LIBCFS_BROKEN_HASH_64
1983 LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
1984 LIBCFS_GET_USER_PAGES_6ARG
1985 LIBCFS_STRINGHASH
1986 # 4.7
1987 LIBCFS_RHASHTABLE_INSERT_FAST
1988 LIBCFS_RHASHTABLE_WALK_INIT_3ARG
1989 # 4.8
1990 LIBCFS_RHASHTABLE_LOOKUP
1991 LIBCFS_RHLTABLE
1992 LIBCFS_STACKTRACE_OPS
1993 # 4.9
1994 LIBCFS_GET_USER_PAGES_GUP_FLAGS
1995 LIBCFS_RHASHTABLE_WALK_ENTER
1996 # 4.10
1997 LIBCFS_HOTPLUG_STATE_MACHINE
1998 LIBCFS_REFCOUNT_T
1999 # 4.11
2000 LIBCFS_RHASHTABLE_LOOKUP_GET_INSERT_FAST
2001 LIBCFS_SCHED_HEADERS
2002 LIBCFS_KREF_READ
2003 LIBCFS_RHT_BUCKET_VAR
2004 # 4.12
2005 LIBCFS_HAVE_PROCESSOR_HEADER
2006 LIBCFS_HAVE_WAIT_BIT_HEADER
2007 LIBCFS_MEMALLOC_NORECLAIM
2008 LIBCFS_NL_EXT_ACK
2009 LIBCFS_WAIT_QUEUE_TASK_LIST_RENAME
2010 LIBCFS_CPUS_READ_LOCK
2011 LIBCFS_UUID_T
2012 # 4.13
2013 LIBCFS_NLA_STRDUP
2014 LIBCFS_WAIT_QUEUE_ENTRY
2015 LIBCFS_WAIT_BIT_QUEUE_ENTRY_EXISTS
2016 # 4.14
2017 LIBCFS_DEFINE_TIMER
2018 LIBCFS_NEW_KERNEL_WRITE
2019 LIBCFS_NEW_KERNEL_READ
2020 LIBCFS_EXPORT_SAVE_STACK_TRACE_TSK
2021 # 4.15
2022 LIBCFS_LOCKDEP_IS_HELD
2023 LIBCFS_TIMER_SETUP
2024 # 4.16
2025 LIBCFS_WAIT_VAR_EVENT
2026 # 4.17
2027 LIBCFS_BITMAP_ALLOC
2028 LIBCFS_CLEAR_AND_WAKE_UP_BIT
2029 # 4.18
2030 LIBCFS_TCP_SOCK_SET_NODELAY
2031 LIBCFS_TCP_SOCK_SET_KEEPIDLE
2032 # 4.19
2033 LIBCFS_XARRAY_SUPPORT
2034 LIBCFS_NL_DUMP_EXT_ACK
2035 # 4.20
2036 LIBCFS_HAVE_IOV_ITER_TYPE
2037 # 5.0
2038 LIBCFS_MM_TOTALRAM_PAGES_FUNC
2039 LIBCFS_GET_REQUEST_KEY_AUTH
2040 # 5.3
2041 LIBCFS_LOOKUP_USER_KEY
2042 LIBCFS_FORCE_SIG_WITH_TASK
2043 LIBCFS_CACHE_DETAIL_WRITERS
2044 # 5.4
2045 LIBCFS_GENL_DUMPIT_INFO
2046 # 5.7
2047 LIBCFS_KALLSYMS_LOOKUP
2048 LIBCFS_TCP_SOCK_SET_QUICKACK
2049 LIBCFS_TCP_SOCK_SET_KEEPINTVL
2050 LIBCFS_TCP_SOCK_SET_KEEPCNT
2051 # 5.8
2052 LIBCFS_HAVE_MMAP_LOCK
2053 LIBCFS_KERNEL_SETSOCKOPT
2054 LIBCFS_VMALLOC_2ARGS
2055 LIBCFS_HAVE_NR_UNSTABLE_NFS
2056 LIBCFS_SEC_RELEASE_SECCTX
2057 # 5.10
2058 LIBCFS_HAVE_KFREE_SENSITIVE
2059 LIBCFS_HAVE_CRYPTO_SHA2_HEADER
2060 LIBCFS_HAVE_LIST_CMP_FUNC_T
2061 LIBCFS_NLA_STRLCPY
2062 # 5.12
2063 LIBCFS_HAVE_CIPHER_HEADER
2064 # 5.13
2065 LIBCFS_HAVE_TASK_IS_RUNNING
2066 # 5.14
2067 LIBCFS_LINUX_STDARG_HEADER
2068 LIBCFS_HAVE_PANIC_NOTIFIER_HEADER
2069 # 5.15
2070 LIBCFS_PARAM_SET_UINT_MINMAX
2071 LIBCFS_LINUX_BLK_INTEGRITY_HEADER
2072 ]) # LIBCFS_PROG_LINUX
2073
2074 #
2075 # LIBCFS_PATH_DEFAULTS
2076 #
2077 # default paths for installed files
2078 #
2079 AC_DEFUN([LIBCFS_PATH_DEFAULTS], [
2080 ]) # LIBCFS_PATH_DEFAULTS
2081
2082 #
2083 # LIBCFS_CONFIGURE
2084 #
2085 # other configure checks
2086 #
2087 AC_DEFUN([LIBCFS_CONFIGURE], [
2088 AC_MSG_NOTICE([LibCFS core checks
2089 ==============================================================================])
2090
2091 # libcfs/libcfs/util/nidstrings.c
2092 AC_CHECK_HEADERS([netdb.h asm/types.h endian.h])
2093 AC_CHECK_FUNCS([gethostbyname])
2094
2095 # --------  Check for required packages  --------------
2096
2097 AC_MSG_NOTICE([LibCFS required packages checks
2098 ==============================================================================])
2099
2100 AC_MSG_CHECKING([whether to enable readline support])
2101 AC_ARG_ENABLE(readline,
2102         AS_HELP_STRING([--disable-readline],
2103                 [disable readline support]),
2104         [], [enable_readline="yes"])
2105 AC_MSG_RESULT([$enable_readline])
2106
2107 LIBREADLINE=""
2108 AS_IF([test "x$enable_readline" = xyes], [
2109         AC_CHECK_LIB([readline], [readline], [
2110                 LIBREADLINE="-lreadline"
2111                 AC_DEFINE(HAVE_LIBREADLINE, 1,
2112                         [readline library is available])
2113         ])
2114 ])
2115 AC_SUBST(LIBREADLINE)
2116
2117 AC_MSG_CHECKING([whether to use libpthread for libcfs library])
2118 AC_ARG_ENABLE([libpthread],
2119         AS_HELP_STRING([--disable-libpthread],
2120                 [disable libpthread]),
2121         [], [enable_libpthread="yes"])
2122 AC_MSG_RESULT([$enable_libpthread])
2123
2124 PTHREAD_LIBS=""
2125 AS_IF([test "x$enable_libpthread" = xyes], [
2126         AC_CHECK_LIB([pthread], [pthread_create], [
2127                 PTHREAD_LIBS="-lpthread"
2128                 AC_DEFINE([HAVE_LIBPTHREAD], 1,
2129                         [use libpthread for libcfs library])
2130         ])
2131 ], [
2132         AC_MSG_WARN([Using libpthread for libcfs library is disabled explicitly])
2133 ])
2134 AC_SUBST(PTHREAD_LIBS)
2135 ]) # LIBCFS_CONFIGURE
2136
2137 #
2138 # LIBCFS_CONFIG_FILES
2139 #
2140 # files that should be generated with AC_OUTPUT
2141 #
2142 AC_DEFUN([LIBCFS_CONFIG_FILES], [
2143 AC_CONFIG_FILES([
2144 libcfs/Makefile
2145 libcfs/autoMakefile
2146 libcfs/autoconf/Makefile
2147 libcfs/include/Makefile
2148 libcfs/include/libcfs/Makefile
2149 libcfs/include/uapi/Makefile
2150 libcfs/include/libcfs/linux/Makefile
2151 libcfs/include/libcfs/util/Makefile
2152 libcfs/include/libcfs/crypto/Makefile
2153 libcfs/include/uapi/linux/Makefile
2154 libcfs/libcfs/Makefile
2155 libcfs/libcfs/autoMakefile
2156 libcfs/libcfs/linux/Makefile
2157 libcfs/libcfs/util/Makefile
2158 libcfs/libcfs/crypto/Makefile
2159 ])
2160 ]) # LIBCFS_CONFIG_FILES