Whamcloud - gitweb
LU-56 libcfs: implementation of cpu partition
[fs/lustre-release.git] / libcfs / libcfs / linux / linux-mem.c
index 20f3667..8ae2063 100644 (file)
@@ -1,6 +1,4 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
  * GPL HEADER START
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -26,7 +24,7 @@
  * 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.
  */
 /*
@@ -45,16 +43,6 @@ static unsigned int cfs_alloc_flags_to_gfp(u_int32_t flags)
 {
        unsigned int mflags = 0;
 
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
-        if (flags & CFS_ALLOC_ATOMIC)
-                mflags |= __GFP_HIGH;
-        else if (flags & CFS_ALLOC_WAIT)
-                mflags |= __GFP_WAIT;
-        else
-                mflags |= (__GFP_HIGH | __GFP_WAIT);
-        if (flags & CFS_ALLOC_IO)
-                mflags |= __GFP_IO | __GFP_HIGHIO;
-#else
         if (flags & CFS_ALLOC_ATOMIC)
                 mflags |= __GFP_HIGH;
         else
@@ -63,7 +51,6 @@ static unsigned int cfs_alloc_flags_to_gfp(u_int32_t flags)
                 mflags |= __GFP_NOWARN;
         if (flags & CFS_ALLOC_IO)
                 mflags |= __GFP_IO;
-#endif
         if (flags & CFS_ALLOC_FS)
                 mflags |= __GFP_FS;
         if (flags & CFS_ALLOC_HIGH)
@@ -100,18 +87,18 @@ cfs_free_large(void *addr)
        vfree(addr);
 }
 
-cfs_page_t *cfs_alloc_pages(unsigned int flags, unsigned int order)
+cfs_page_t *cfs_alloc_page(unsigned int flags)
 {
         /*
          * XXX nikita: do NOT call portals_debug_msg() (CDEBUG/ENTRY/EXIT)
          * from here: this will lead to infinite recursion.
          */
-        return alloc_pages(cfs_alloc_flags_to_gfp(flags), order);
+        return alloc_page(cfs_alloc_flags_to_gfp(flags));
 }
 
-void __cfs_free_pages(cfs_page_t *page, unsigned int order)
+void cfs_free_page(cfs_page_t *page)
 {
-        __free_pages(page, order);
+        __free_page(page);
 }
 
 cfs_mem_cache_t *
@@ -156,6 +143,7 @@ cfs_mem_cache_free(cfs_mem_cache_t *cachep, void *objp)
  */
 int cfs_mem_is_in_cache(const void *addr, const cfs_mem_cache_t *kmem)
 {
+#ifdef CONFIG_SLAB
         struct page *page;
 
         /*
@@ -164,8 +152,11 @@ int cfs_mem_is_in_cache(const void *addr, const cfs_mem_cache_t *kmem)
          */
         page = virt_to_page(addr);
         if (unlikely(PageCompound(page)))
-                page = (struct page *)page_private(page);
+                page = (struct page *)page->private;
         return PageSlab(page) && ((void *)page->lru.next) == kmem;
+#else
+        return 1;
+#endif
 }
 EXPORT_SYMBOL(cfs_mem_is_in_cache);
 
@@ -174,8 +165,8 @@ EXPORT_SYMBOL(cfs_alloc);
 EXPORT_SYMBOL(cfs_free);
 EXPORT_SYMBOL(cfs_alloc_large);
 EXPORT_SYMBOL(cfs_free_large);
-EXPORT_SYMBOL(cfs_alloc_pages);
-EXPORT_SYMBOL(__cfs_free_pages);
+EXPORT_SYMBOL(cfs_alloc_page);
+EXPORT_SYMBOL(cfs_free_page);
 EXPORT_SYMBOL(cfs_mem_cache_create);
 EXPORT_SYMBOL(cfs_mem_cache_destroy);
 EXPORT_SYMBOL(cfs_mem_cache_alloc);