Due to some long overdue memory management cleanup in the ZoL kmem
implementation the definition of KM_SLEEP has changed. This change
was expected to be transparent to consumers but it causes issues
for Lustre because it explicitly redefines KM_SLEEP. This was
originally done to avoid overriding the Linux slab interfaces.
This change implements a more portable fix. Instead of preventing
the inclusion of the kmem.h header by setting the guard. The
kmem_cache_* preprocessor macros are explictly undefined to make
the Linux interface available.
The related ZoL pull requests are as follows:
https://github.com/zfsonlinux/spl/pull/414
https://github.com/zfsonlinux/zfs/pull/2918
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Change-Id: Id1d19d7b4c440808b8b3fd042f687b10c1b869f3
Reviewed-on: http://review.whamcloud.com/13096
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Reviewed-by: Isaac Huang <he.huang@intel.com>
Reviewed-by: Nathaniel Clark <nathaniel.l.clark@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
#include <dt_object.h>
#include <md_object.h>
#include <lustre_quota.h>
#include <dt_object.h>
#include <md_object.h>
#include <lustre_quota.h>
-
-#define _SPL_KMEM_H
-/* SPL redefines this but to the same value: ~0UL vs -1, but GCC complains.
- * fixed in SPL master 52479ecf58fa89190e384edcf838fecccc786af5 */
-#include <sys/kstat.h>
-#define kmem_zalloc(a, b) kzalloc(a, b)
-#define kmem_free(ptr, sz) ((void)(sz), kfree(ptr))
-#ifndef KM_SLEEP
-#define KM_SLEEP GFP_KERNEL
#include <sys/arc.h>
#include <sys/nvpair.h>
#include <sys/zfs_znode.h>
#include <sys/zap.h>
#include <sys/arc.h>
#include <sys/nvpair.h>
#include <sys/zfs_znode.h>
#include <sys/zap.h>
+/**
+ * By design including kmem.h overrides the Linux slab interfaces to provide
+ * the Illumos kmem cache interfaces. To override this and gain access to
+ * the Linux interfaces these preprocessor macros must be undefined.
+ */
+#ifdef kmem_cache_destroy
+#undef kmem_cache_destroy
+#endif
+
+#ifdef kmem_cache_create
+#undef kmem_cache_create
+#endif
+
+#ifdef kmem_cache_alloc
+#undef kmem_cache_alloc
+#endif
+
+#ifdef kmem_cache_free
+#undef kmem_cache_free
+#endif
+
#define LUSTRE_ROOT_FID_SEQ 0
#define DMU_OSD_SVNAME "svname"
#define DMU_OSD_OI_NAME_BASE "oi"
#define LUSTRE_ROOT_FID_SEQ 0
#define DMU_OSD_SVNAME "svname"
#define DMU_OSD_OI_NAME_BASE "oi"