* in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see [sun.com URL with a
- * copy of GPLv2].
+ * version 2 along with this program; If not, see
+ * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* GPL HEADER END
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*/
/*
#error Do not #include this file directly. #include <libcfs/libcfs.h> instead
#endif
-#ifdef __KERNEL__
-# include <linux/mm.h>
-# include <linux/vmalloc.h>
-# include <linux/pagemap.h>
-# include <linux/slab.h>
-# ifdef HAVE_MM_INLINE
-# include <linux/mm_inline.h>
-# endif
+#ifndef __KERNEL__
+#error This include is only for kernel use.
+#endif
+
+#include <linux/mm.h>
+#include <linux/vmalloc.h>
+#include <linux/pagemap.h>
+#include <linux/slab.h>
+#ifdef HAVE_MM_INLINE
+# include <linux/mm_inline.h>
+#endif
typedef struct page cfs_page_t;
#define CFS_PAGE_SIZE PAGE_CACHE_SIZE
#define CFS_PAGE_SHIFT PAGE_CACHE_SHIFT
#define CFS_PAGE_MASK (~((__u64)CFS_PAGE_SIZE-1))
+#define cfs_num_physpages num_physpages
+
+#define cfs_copy_from_user(to, from, n) copy_from_user(to, from, n)
+#define cfs_copy_to_user(to, from, n) copy_to_user(to, from, n)
+
static inline void *cfs_page_address(cfs_page_t *page)
{
/*
#define __cfs_free_page(page) __cfs_free_pages(page, 0)
#define cfs_free_page(p) __free_pages(p, 0)
+#define libcfs_memory_pressure_get() (current->flags & PF_MEMALLOC)
+#define libcfs_memory_pressure_set() do { current->flags |= PF_MEMALLOC; } while (0)
+#define libcfs_memory_pressure_clr() do { current->flags &= ~PF_MEMALLOC; } while (0)
+
+#if BITS_PER_LONG == 32
+/* limit to lowmem on 32-bit systems */
+#define CFS_NUM_CACHEPAGES \
+ min(cfs_num_physpages, 1UL << (30 - CFS_PAGE_SHIFT) * 3 / 4)
+#else
+#define CFS_NUM_CACHEPAGES cfs_num_physpages
+#endif
+
/*
* In Linux there is no way to determine whether current execution context is
* blockable.
extern int cfs_mem_cache_destroy ( cfs_mem_cache_t * );
extern void *cfs_mem_cache_alloc ( cfs_mem_cache_t *, int);
extern void cfs_mem_cache_free ( cfs_mem_cache_t *, void *);
+extern int cfs_mem_is_in_cache(const void *addr, const cfs_mem_cache_t *kmem);
-/*
- */
#define CFS_DECL_MMSPACE mm_segment_t __oldfs
-#define CFS_MMSPACE_OPEN do { __oldfs = get_fs(); set_fs(get_ds());} while(0)
+#define CFS_MMSPACE_OPEN \
+ do { __oldfs = get_fs(); set_fs(get_ds());} while(0)
#define CFS_MMSPACE_CLOSE set_fs(__oldfs)
-#else /* !__KERNEL__ */
-#ifdef HAVE_ASM_PAGE_H
-#include <asm/page.h> /* needed for PAGE_SIZE - rread */
-#endif
+#define CFS_SLAB_HWCACHE_ALIGN SLAB_HWCACHE_ALIGN
+#define CFS_SLAB_KERNEL SLAB_KERNEL
+#define CFS_SLAB_NOFS SLAB_NOFS
-#include <libcfs/user-prim.h>
-/* __KERNEL__ */
-#endif
+/*
+ * Shrinker
+ */
+
+#ifndef HAVE_REGISTER_SHRINKER
+/* Shrinker callback */
+typedef shrinker_t cfs_shrinker_t;
+#define cfs_set_shrinker(seeks, shrinker) set_shrinker(seeks, shrinker)
+#define cfs_remove_shrinker(shrinker) remove_shrinker(shrinker)
+#endif /* !HAVE_REGISTER_SHRINKER */
+
+/* struct shrinker */
+#define cfs_shrinker shrinker
+#define CFS_DEFAULT_SEEKS DEFAULT_SEEKS
#endif /* __LINUX_CFS_MEM_H__ */