diff options
author | Richard Yao <[email protected]> | 2013-11-05 11:35:54 -0500 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2013-11-06 13:23:40 -0800 |
commit | c3d9c0df3ee8d43db22815ebbfbe8b803fa46e46 (patch) | |
tree | a5287be334d3eb702cfee2177791e69aa79a90fa /config/spl-build.m4 | |
parent | 184c6873874c350bfb0b74f9e08ec8d89750d603 (diff) |
Linux 3.12 compat: New shrinker API
torvalds/linux@24f7c6 introduced a new shrinker API while
torvalds/linux@a0b021 dropped support for the old shrinker API.
This patch adds support for the new shrinker API by wrapping
the old one with the new one.
This change also reorganizes the autotools checks on the shrinker
API such that the configure script will fail early if an unknown
API is encountered in the future.
Support for the set_shrinker() API which was used by Linux 2.6.22
and older has been dropped. As a general rule compatibility is
only maintained back to Linux 2.6.26.
Signed-off-by: Richard Yao <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Closes zfsonlinux/zfs#1732
Closes zfsonlinux/zfs#1822
Closes #293
Closes #307
Diffstat (limited to 'config/spl-build.m4')
-rw-r--r-- | config/spl-build.m4 | 116 |
1 files changed, 86 insertions, 30 deletions
diff --git a/config/spl-build.m4 b/config/spl-build.m4 index b0e334815..7d744db13 100644 --- a/config/spl-build.m4 +++ b/config/spl-build.m4 @@ -27,8 +27,7 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [ SPL_AC_TYPE_ATOMIC64_XCHG SPL_AC_TYPE_UINTPTR_T SPL_AC_2ARGS_REGISTER_SYSCTL - SPL_AC_SET_SHRINKER - SPL_AC_3ARGS_SHRINKER_CALLBACK + SPL_AC_SHRINKER_CALLBACK SPL_AC_PATH_IN_NAMEIDATA SPL_AC_TASK_CURR SPL_AC_CTL_UNNUMBERED @@ -885,37 +884,18 @@ AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL], ]) ]) -dnl # -dnl # 2.6.23 API change -dnl # Old set_shrinker API replaced with register_shrinker -dnl # -AC_DEFUN([SPL_AC_SET_SHRINKER], [ - AC_MSG_CHECKING([whether set_shrinker() available]) - SPL_LINUX_TRY_COMPILE([ - #include <linux/mm.h> - ],[ - return set_shrinker(DEFAULT_SEEKS, NULL); - ],[ - AC_MSG_RESULT([yes]) - AC_DEFINE(HAVE_SET_SHRINKER, 1, - [set_shrinker() available]) - ],[ - AC_MSG_RESULT([no]) - ]) -]) - -dnl # -dnl # 2.6.35 API change, -dnl # Add context to shrinker callback -dnl # -AC_DEFUN([SPL_AC_3ARGS_SHRINKER_CALLBACK], - [AC_MSG_CHECKING([whether shrinker callback wants 3 args]) +AC_DEFUN([SPL_AC_SHRINKER_CALLBACK],[ tmp_flags="$EXTRA_KCFLAGS" EXTRA_KCFLAGS="-Werror" + dnl # + dnl # 2.6.23 to 2.6.34 API change + dnl # ->shrink(int nr_to_scan, gfp_t gfp_mask) + dnl # + AC_MSG_CHECKING([whether old 2-argument shrinker exists]) SPL_LINUX_TRY_COMPILE([ #include <linux/mm.h> - int shrinker_cb(struct shrinker *, int, unsigned int); + int shrinker_cb(int nr_to_scan, gfp_t gfp_mask); ],[ struct shrinker cache_shrinker = { .shrink = shrinker_cb, @@ -924,10 +904,86 @@ AC_DEFUN([SPL_AC_3ARGS_SHRINKER_CALLBACK], register_shrinker(&cache_shrinker); ],[ AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1, - [shrinker callback wants 3 args]) + AC_DEFINE(HAVE_2ARGS_OLD_SHRINKER_CALLBACK, 1, + [old shrinker callback wants 2 args]) ],[ AC_MSG_RESULT(no) + dnl # + dnl # 2.6.35 - 2.6.39 API change + dnl # ->shrink(struct shrinker *, + dnl # int nr_to_scan, gfp_t gfp_mask) + dnl # + AC_MSG_CHECKING([whether old 3-argument shrinker exists]) + SPL_LINUX_TRY_COMPILE([ + #include <linux/mm.h> + + int shrinker_cb(struct shrinker *, int nr_to_scan, + gfp_t gfp_mask); + ],[ + struct shrinker cache_shrinker = { + .shrink = shrinker_cb, + .seeks = DEFAULT_SEEKS, + }; + register_shrinker(&cache_shrinker); + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1, + [old shrinker callback wants 3 args]) + ],[ + AC_MSG_RESULT(no) + dnl # + dnl # 3.0 - 3.11 API change + dnl # ->shrink(struct shrinker *, + dnl # struct shrink_control *sc) + dnl # + AC_MSG_CHECKING( + [whether new 2-argument shrinker exists]) + SPL_LINUX_TRY_COMPILE([ + #include <linux/mm.h> + + int shrinker_cb(struct shrinker *, + struct shrink_control *sc); + ],[ + struct shrinker cache_shrinker = { + .shrink = shrinker_cb, + .seeks = DEFAULT_SEEKS, + }; + register_shrinker(&cache_shrinker); + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_2ARGS_NEW_SHRINKER_CALLBACK, 1, + [new shrinker callback wants 2 args]) + ],[ + AC_MSG_RESULT(no) + dnl # + dnl # 3.12 API change, + dnl # ->shrink() is logically split in to + dnl # ->count_objects() and ->scan_objects() + dnl # + AC_MSG_CHECKING( + [whether ->count_objects callback exists]) + SPL_LINUX_TRY_COMPILE([ + #include <linux/mm.h> + + unsigned long shrinker_cb( + struct shrinker *, + struct shrink_control *sc); + ],[ + struct shrinker cache_shrinker = { + .count_objects = shrinker_cb, + .scan_objects = shrinker_cb, + .seeks = DEFAULT_SEEKS, + }; + register_shrinker(&cache_shrinker); + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK, + 1, [->count_objects exists]) + ],[ + AC_MSG_ERROR(error) + ]) + ]) + ]) ]) EXTRA_KCFLAGS="$tmp_flags" ]) |