/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
* vim:expandtab:shiftwidth=8:tabstop=8:
*
- * Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
+ * GPL HEADER START
*
- * This file is part of Lustre, http://www.lustre.org.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
- * Lustre is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
*
- * Lustre is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
*
- * You should have received a copy of the GNU General Public License
- * along with Lustre; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see
+ * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
*
- * Basic library routines.
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved
+ * Use is subject to license terms.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
*
+ * libcfs/include/libcfs/linux/linux-mem.h
+ *
+ * Basic library routines.
*/
#ifndef __LIBCFS_LINUX_CFS_MEM_H__
#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_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)
+
/*
* 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_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
-
-#include <libcfs/user-prim.h>
-/* __KERNEL__ */
-#endif
-
#endif /* __LINUX_CFS_MEM_H__ */