From 3301b4b58d992a30581d2e95815913d8290f440e Mon Sep 17 00:00:00 2001
From: shadow <shadow>
Date: Thu, 21 Jun 2007 05:41:47 +0000
Subject: [PATCH] 2.6.22 has only one visble change for patchless cleint,
 SLAB_CTOR_* constants is removed. In this case we need drop using os depended
 interface to kmem_cache and use cfs_mem_cache API.

b=12764
i=green
i=wangdi
---
 lnet/autoconf/lustre-lnet.m4          | 28 +++++++++++++++++++++++++--
 lnet/include/libcfs/linux/linux-mem.h |  6 +++++-
 2 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/lnet/autoconf/lustre-lnet.m4 b/lnet/autoconf/lustre-lnet.m4
index bec57e5fba..3ed69b48f3 100644
--- a/lnet/autoconf/lustre-lnet.m4
+++ b/lnet/autoconf/lustre-lnet.m4
@@ -1120,7 +1120,7 @@ LB_LINUX_TRY_COMPILE([
 
 # 2.6.21 api change. 'register_sysctl_table' use only one argument,
 # instead of more old which need two.
-AC_DEFUN([LL_2ARGS_REGISTER_SYSCTL],
+AC_DEFUN([LN_2ARGS_REGISTER_SYSCTL],
 [AC_MSG_CHECKING([check register_sysctl_table want 2 args])
 LB_LINUX_TRY_COMPILE([
         #include <linux/sysctl.h>
@@ -1135,6 +1135,29 @@ LB_LINUX_TRY_COMPILE([
 ])
 ])
 
+# 2.6.21 uses struct kmem_cache instead of kmem_cache_s for
+# kmem_cache_t
+AC_DEFUN([LN_KMEM_CACHE_S],
+[AC_MSG_CHECKING([check kernel has struct kmem_cache_s])
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_LINUX_TRY_COMPILE([
+        #include <linux/slab.h>
+],[
+	struct kmem_cache_s *cachep = NULL;
+	
+	kmem_cache_free(cachep, NULL);
+
+],[
+        AC_MSG_RESULT(yes)
+        AC_DEFINE(HAVE_KMEM_CACHE_n, 1,
+                  [kernel has struct kmem_cache_s])
+],[
+        AC_MSG_RESULT(NO)
+])
+EXTRA_KCFLAGS="$tmp_flags"
+])
+
 #
 # LN_PROG_LINUX
 #
@@ -1170,7 +1193,8 @@ LN_ATOMIC_PANIC_NOTIFIER
 # 2.6.20
 LN_3ARGS_INIT_WORK
 # 2.6.21
-LL_2ARGS_REGISTER_SYSCTL
+LN_2ARGS_REGISTER_SYSCTL
+LN_KMEM_CACHE_S
 ])
 
 #
diff --git a/lnet/include/libcfs/linux/linux-mem.h b/lnet/include/libcfs/linux/linux-mem.h
index 7591213ffb..9a49dda332 100644
--- a/lnet/include/libcfs/linux/linux-mem.h
+++ b/lnet/include/libcfs/linux/linux-mem.h
@@ -97,7 +97,11 @@ extern void  cfs_free_large(void *addr);
  * SLAB allocator
  * XXX Liang: move these declare to public file
  */
-typedef kmem_cache_t    cfs_mem_cache_t;
+#ifdef HAVE_KMEM_CACHE_S
+typedef struct kmem_cache_s cfs_mem_cache_t;
+#else
+typedef struct kmem_cache cfs_mem_cache_t;
+#endif
 extern cfs_mem_cache_t * cfs_mem_cache_create (const char *, size_t, size_t, unsigned long);
 extern int cfs_mem_cache_destroy ( cfs_mem_cache_t * );
 extern void *cfs_mem_cache_alloc ( cfs_mem_cache_t *, int);
-- 
GitLab