mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-23 02:44:41 +03:00
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 <ryao@gentoo.org> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes zfsonlinux/zfs#1732 Closes zfsonlinux/zfs#1822 Closes #293 Closes #307
This commit is contained in:
committed by
Brian Behlendorf
parent
184c687387
commit
c3d9c0df3e
+86
-30
@@ -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"
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user