2011-12-23 00:20:43 +04:00
|
|
|
dnl #
|
|
|
|
dnl # 3.1 API change
|
|
|
|
dnl # The super_block structure now stores a per-filesystem shrinker.
|
|
|
|
dnl # This interface is preferable because it can be used to specifically
|
|
|
|
dnl # target only the zfs filesystem for pruning.
|
|
|
|
dnl #
|
2019-10-01 22:50:34 +03:00
|
|
|
AC_DEFUN([ZFS_AC_KERNEL_SRC_SUPER_BLOCK_S_SHRINK], [
|
|
|
|
ZFS_LINUX_TEST_SRC([super_block_s_shrink], [
|
2011-12-23 00:20:43 +04:00
|
|
|
#include <linux/fs.h>
|
2013-02-15 03:54:04 +04:00
|
|
|
|
|
|
|
static const struct super_block
|
|
|
|
sb __attribute__ ((unused)) = {
|
2011-12-23 00:20:43 +04:00
|
|
|
.s_shrink.seeks = DEFAULT_SEEKS,
|
|
|
|
.s_shrink.batch = 0,
|
|
|
|
};
|
2019-10-01 22:50:34 +03:00
|
|
|
],[])
|
|
|
|
])
|
|
|
|
|
2023-12-16 09:39:07 +03:00
|
|
|
dnl #
|
|
|
|
dnl # 6.7 API change
|
|
|
|
dnl # s_shrink is now a pointer.
|
|
|
|
dnl #
|
|
|
|
AC_DEFUN([ZFS_AC_KERNEL_SRC_SUPER_BLOCK_S_SHRINK_PTR], [
|
|
|
|
ZFS_LINUX_TEST_SRC([super_block_s_shrink_ptr], [
|
|
|
|
#include <linux/fs.h>
|
2024-01-23 02:50:53 +03:00
|
|
|
static unsigned long shrinker_cb(struct shrinker *shrink,
|
2023-12-16 09:39:07 +03:00
|
|
|
struct shrink_control *sc) { return 0; }
|
|
|
|
static struct shrinker shrinker = {
|
|
|
|
.count_objects = shrinker_cb,
|
|
|
|
.scan_objects = shrinker_cb,
|
|
|
|
.seeks = DEFAULT_SEEKS,
|
|
|
|
};
|
|
|
|
static const struct super_block
|
|
|
|
sb __attribute__ ((unused)) = {
|
|
|
|
.s_shrink = &shrinker,
|
|
|
|
};
|
|
|
|
],[])
|
|
|
|
])
|
|
|
|
|
2019-10-01 22:50:34 +03:00
|
|
|
AC_DEFUN([ZFS_AC_KERNEL_SUPER_BLOCK_S_SHRINK], [
|
|
|
|
AC_MSG_CHECKING([whether super_block has s_shrink])
|
|
|
|
ZFS_LINUX_TEST_RESULT([super_block_s_shrink], [
|
2011-12-23 00:20:43 +04:00
|
|
|
AC_MSG_RESULT(yes)
|
2023-12-16 09:39:07 +03:00
|
|
|
AC_DEFINE(HAVE_SUPER_BLOCK_S_SHRINK, 1,
|
|
|
|
[have super_block s_shrink])
|
2011-12-23 00:20:43 +04:00
|
|
|
],[
|
2023-12-16 09:39:07 +03:00
|
|
|
AC_MSG_RESULT(no)
|
|
|
|
AC_MSG_CHECKING([whether super_block has s_shrink pointer])
|
|
|
|
ZFS_LINUX_TEST_RESULT([super_block_s_shrink_ptr], [
|
|
|
|
AC_MSG_RESULT(yes)
|
|
|
|
AC_DEFINE(HAVE_SUPER_BLOCK_S_SHRINK_PTR, 1,
|
|
|
|
[have super_block s_shrink pointer])
|
|
|
|
],[
|
|
|
|
AC_MSG_RESULT(no)
|
|
|
|
ZFS_LINUX_TEST_ERROR([sb->s_shrink()])
|
|
|
|
])
|
2011-12-23 00:20:43 +04:00
|
|
|
])
|
|
|
|
])
|
2015-06-14 19:19:40 +03:00
|
|
|
|
|
|
|
dnl #
|
|
|
|
dnl # 3.12 API change
|
|
|
|
dnl # The nid member was added to struct shrink_control to support
|
|
|
|
dnl # NUMA-aware shrinkers.
|
|
|
|
dnl #
|
2019-10-01 22:50:34 +03:00
|
|
|
AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_HAS_NID], [
|
|
|
|
ZFS_LINUX_TEST_SRC([shrink_control_nid], [
|
2015-06-14 19:19:40 +03:00
|
|
|
#include <linux/fs.h>
|
|
|
|
],[
|
|
|
|
struct shrink_control sc __attribute__ ((unused));
|
|
|
|
unsigned long scnidsize __attribute__ ((unused)) =
|
|
|
|
sizeof(sc.nid);
|
2019-10-01 22:50:34 +03:00
|
|
|
])
|
|
|
|
])
|
|
|
|
|
|
|
|
AC_DEFUN([ZFS_AC_KERNEL_SHRINK_CONTROL_HAS_NID], [
|
|
|
|
AC_MSG_CHECKING([whether shrink_control has nid])
|
|
|
|
ZFS_LINUX_TEST_RESULT([shrink_control_nid], [
|
2015-06-14 19:19:40 +03:00
|
|
|
AC_MSG_RESULT(yes)
|
|
|
|
AC_DEFINE(SHRINK_CONTROL_HAS_NID, 1,
|
|
|
|
[struct shrink_control has nid])
|
|
|
|
],[
|
|
|
|
AC_MSG_RESULT(no)
|
|
|
|
])
|
|
|
|
])
|
2018-02-16 04:53:18 +03:00
|
|
|
|
2022-08-09 02:18:30 +03:00
|
|
|
AC_DEFUN([ZFS_AC_KERNEL_SRC_REGISTER_SHRINKER_VARARG], [
|
|
|
|
ZFS_LINUX_TEST_SRC([register_shrinker_vararg], [
|
|
|
|
#include <linux/mm.h>
|
2024-01-23 02:50:53 +03:00
|
|
|
static unsigned long shrinker_cb(struct shrinker *shrink,
|
2022-08-09 02:18:30 +03:00
|
|
|
struct shrink_control *sc) { return 0; }
|
|
|
|
],[
|
|
|
|
struct shrinker cache_shrinker = {
|
|
|
|
.count_objects = shrinker_cb,
|
|
|
|
.scan_objects = shrinker_cb,
|
|
|
|
.seeks = DEFAULT_SEEKS,
|
|
|
|
};
|
|
|
|
register_shrinker(&cache_shrinker, "vararg-reg-shrink-test");
|
|
|
|
])
|
|
|
|
])
|
|
|
|
|
2019-10-01 22:50:34 +03:00
|
|
|
AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINKER_CALLBACK], [
|
|
|
|
ZFS_LINUX_TEST_SRC([shrinker_cb_shrink_control], [
|
|
|
|
#include <linux/mm.h>
|
2024-01-23 02:50:53 +03:00
|
|
|
static int shrinker_cb(struct shrinker *shrink,
|
2019-10-01 22:50:34 +03:00
|
|
|
struct shrink_control *sc) { return 0; }
|
2018-02-16 04:53:18 +03:00
|
|
|
],[
|
|
|
|
struct shrinker cache_shrinker = {
|
|
|
|
.shrink = shrinker_cb,
|
|
|
|
.seeks = DEFAULT_SEEKS,
|
|
|
|
};
|
|
|
|
register_shrinker(&cache_shrinker);
|
2019-10-01 22:50:34 +03:00
|
|
|
])
|
|
|
|
|
|
|
|
ZFS_LINUX_TEST_SRC([shrinker_cb_shrink_control_split], [
|
|
|
|
#include <linux/mm.h>
|
2024-01-23 02:50:53 +03:00
|
|
|
static unsigned long shrinker_cb(struct shrinker *shrink,
|
2019-10-01 22:50:34 +03:00
|
|
|
struct shrink_control *sc) { return 0; }
|
2018-02-16 04:53:18 +03:00
|
|
|
],[
|
2019-10-01 22:50:34 +03:00
|
|
|
struct shrinker cache_shrinker = {
|
|
|
|
.count_objects = shrinker_cb,
|
|
|
|
.scan_objects = shrinker_cb,
|
|
|
|
.seeks = DEFAULT_SEEKS,
|
|
|
|
};
|
|
|
|
register_shrinker(&cache_shrinker);
|
|
|
|
])
|
|
|
|
])
|
|
|
|
|
2023-12-16 16:36:21 +03:00
|
|
|
dnl #
|
|
|
|
dnl # 6.7 API change
|
|
|
|
dnl # register_shrinker has been replaced by shrinker_register.
|
|
|
|
dnl #
|
|
|
|
AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINKER_REGISTER], [
|
|
|
|
ZFS_LINUX_TEST_SRC([shrinker_register], [
|
|
|
|
#include <linux/shrinker.h>
|
2024-01-23 02:50:53 +03:00
|
|
|
static unsigned long shrinker_cb(struct shrinker *shrink,
|
2023-12-16 16:36:21 +03:00
|
|
|
struct shrink_control *sc) { return 0; }
|
|
|
|
],[
|
|
|
|
struct shrinker cache_shrinker = {
|
|
|
|
.count_objects = shrinker_cb,
|
|
|
|
.scan_objects = shrinker_cb,
|
|
|
|
.seeks = DEFAULT_SEEKS,
|
|
|
|
};
|
|
|
|
shrinker_register(&cache_shrinker);
|
|
|
|
])
|
|
|
|
])
|
|
|
|
|
2019-10-01 22:50:34 +03:00
|
|
|
AC_DEFUN([ZFS_AC_KERNEL_SHRINKER_CALLBACK],[
|
|
|
|
dnl #
|
2022-08-09 02:18:30 +03:00
|
|
|
dnl # 6.0 API change
|
|
|
|
dnl # register_shrinker() becomes a var-arg function that takes
|
|
|
|
dnl # a printf-style format string as args > 0
|
2019-10-01 22:50:34 +03:00
|
|
|
dnl #
|
2022-08-09 02:18:30 +03:00
|
|
|
AC_MSG_CHECKING([whether new var-arg register_shrinker() exists])
|
|
|
|
ZFS_LINUX_TEST_RESULT([register_shrinker_vararg], [
|
2018-02-16 04:53:18 +03:00
|
|
|
AC_MSG_RESULT(yes)
|
2022-08-09 02:18:30 +03:00
|
|
|
AC_DEFINE(HAVE_REGISTER_SHRINKER_VARARG, 1,
|
|
|
|
[register_shrinker is vararg])
|
|
|
|
|
|
|
|
dnl # We assume that the split shrinker callback exists if the
|
|
|
|
dnl # vararg register_shrinker() exists, because the latter is
|
|
|
|
dnl # a much more recent addition, and the macro test for the
|
|
|
|
dnl # var-arg version only works if the callback is split
|
|
|
|
AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK, 1,
|
|
|
|
[cs->count_objects exists])
|
2018-02-16 04:53:18 +03:00
|
|
|
],[
|
|
|
|
AC_MSG_RESULT(no)
|
|
|
|
dnl #
|
2022-08-09 02:18:30 +03:00
|
|
|
dnl # 3.0 - 3.11 API change
|
|
|
|
dnl # cs->shrink(struct shrinker *, struct shrink_control *sc)
|
2018-02-16 04:53:18 +03:00
|
|
|
dnl #
|
2022-08-09 02:18:30 +03:00
|
|
|
AC_MSG_CHECKING([whether new 2-argument shrinker exists])
|
|
|
|
ZFS_LINUX_TEST_RESULT([shrinker_cb_shrink_control], [
|
2018-02-16 04:53:18 +03:00
|
|
|
AC_MSG_RESULT(yes)
|
2022-08-09 02:18:30 +03:00
|
|
|
AC_DEFINE(HAVE_SINGLE_SHRINKER_CALLBACK, 1,
|
|
|
|
[new shrinker callback wants 2 args])
|
2018-02-16 04:53:18 +03:00
|
|
|
],[
|
2022-08-09 02:18:30 +03:00
|
|
|
AC_MSG_RESULT(no)
|
|
|
|
|
|
|
|
dnl #
|
|
|
|
dnl # 3.12 API change,
|
|
|
|
dnl # cs->shrink() is logically split in to
|
|
|
|
dnl # cs->count_objects() and cs->scan_objects()
|
|
|
|
dnl #
|
2023-12-16 16:36:21 +03:00
|
|
|
AC_MSG_CHECKING(
|
|
|
|
[whether cs->count_objects callback exists])
|
2022-08-09 02:18:30 +03:00
|
|
|
ZFS_LINUX_TEST_RESULT(
|
2023-12-16 16:36:21 +03:00
|
|
|
[shrinker_cb_shrink_control_split],[
|
|
|
|
AC_MSG_RESULT(yes)
|
|
|
|
AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK, 1,
|
|
|
|
[cs->count_objects exists])
|
2022-08-09 02:18:30 +03:00
|
|
|
],[
|
2023-12-16 16:36:21 +03:00
|
|
|
AC_MSG_RESULT(no)
|
|
|
|
|
|
|
|
AC_MSG_CHECKING(
|
|
|
|
[whether shrinker_register exists])
|
|
|
|
ZFS_LINUX_TEST_RESULT([shrinker_register], [
|
|
|
|
AC_MSG_RESULT(yes)
|
|
|
|
AC_DEFINE(HAVE_SHRINKER_REGISTER, 1,
|
|
|
|
[shrinker_register exists])
|
|
|
|
|
|
|
|
dnl # We assume that the split shrinker
|
|
|
|
dnl # callback exists if
|
|
|
|
dnl # shrinker_register() exists,
|
|
|
|
dnl # because the latter is a much more
|
|
|
|
dnl # recent addition, and the macro
|
|
|
|
dnl # test for shrinker_register() only
|
|
|
|
dnl # works if the callback is split
|
|
|
|
AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK,
|
|
|
|
1, [cs->count_objects exists])
|
|
|
|
],[
|
|
|
|
AC_MSG_RESULT(no)
|
2022-08-09 02:18:30 +03:00
|
|
|
ZFS_LINUX_TEST_ERROR([shrinker])
|
2023-12-16 16:36:21 +03:00
|
|
|
])
|
2022-08-09 02:18:30 +03:00
|
|
|
])
|
2018-02-16 04:53:18 +03:00
|
|
|
])
|
|
|
|
])
|
|
|
|
])
|
|
|
|
|
|
|
|
dnl #
|
|
|
|
dnl # 2.6.39 API change,
|
|
|
|
dnl # Shrinker adjust to use common shrink_control structure.
|
|
|
|
dnl #
|
2019-10-01 22:50:34 +03:00
|
|
|
AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_STRUCT], [
|
|
|
|
ZFS_LINUX_TEST_SRC([shrink_control_struct], [
|
2018-02-16 04:53:18 +03:00
|
|
|
#include <linux/mm.h>
|
|
|
|
],[
|
|
|
|
struct shrink_control sc __attribute__ ((unused));
|
|
|
|
|
|
|
|
sc.nr_to_scan = 0;
|
|
|
|
sc.gfp_mask = GFP_KERNEL;
|
2019-10-01 22:50:34 +03:00
|
|
|
])
|
|
|
|
])
|
|
|
|
|
|
|
|
AC_DEFUN([ZFS_AC_KERNEL_SHRINK_CONTROL_STRUCT], [
|
|
|
|
AC_MSG_CHECKING([whether struct shrink_control exists])
|
|
|
|
ZFS_LINUX_TEST_RESULT([shrink_control_struct], [
|
2018-02-16 04:53:18 +03:00
|
|
|
AC_MSG_RESULT(yes)
|
|
|
|
AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
|
2019-10-01 22:50:34 +03:00
|
|
|
[struct shrink_control exists])
|
2018-02-16 04:53:18 +03:00
|
|
|
],[
|
2019-11-12 19:59:06 +03:00
|
|
|
ZFS_LINUX_TEST_ERROR([shrink_control])
|
2018-02-16 04:53:18 +03:00
|
|
|
])
|
|
|
|
])
|
2019-10-01 22:50:34 +03:00
|
|
|
|
|
|
|
AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINKER], [
|
|
|
|
ZFS_AC_KERNEL_SRC_SUPER_BLOCK_S_SHRINK
|
2023-12-16 09:39:07 +03:00
|
|
|
ZFS_AC_KERNEL_SRC_SUPER_BLOCK_S_SHRINK_PTR
|
2019-10-01 22:50:34 +03:00
|
|
|
ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_HAS_NID
|
|
|
|
ZFS_AC_KERNEL_SRC_SHRINKER_CALLBACK
|
|
|
|
ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_STRUCT
|
2022-08-09 02:18:30 +03:00
|
|
|
ZFS_AC_KERNEL_SRC_REGISTER_SHRINKER_VARARG
|
2023-12-16 16:36:21 +03:00
|
|
|
ZFS_AC_KERNEL_SRC_SHRINKER_REGISTER
|
2019-10-01 22:50:34 +03:00
|
|
|
])
|
|
|
|
|
|
|
|
AC_DEFUN([ZFS_AC_KERNEL_SHRINKER], [
|
|
|
|
ZFS_AC_KERNEL_SUPER_BLOCK_S_SHRINK
|
|
|
|
ZFS_AC_KERNEL_SHRINK_CONTROL_HAS_NID
|
|
|
|
ZFS_AC_KERNEL_SHRINKER_CALLBACK
|
|
|
|
ZFS_AC_KERNEL_SHRINK_CONTROL_STRUCT
|
|
|
|
])
|