LINUX/: ifdef for GFP_NOFS conditionals
[openafs.git] / src / afs / LINUX / osi_alloc.c
index 24dd1f7..b586d7b 100644 (file)
 #include <afsconfig.h>
 #include "afs/param.h"
 
-RCSID
-    ("$Header$");
 
 #include "afs/sysincludes.h"
 #include "afsincludes.h"
-#include "h/mm.h"
-#include "h/slab.h"
+#include <linux/mm.h>
+#include <linux/slab.h>
 
 #include "afs_atomlist.h"
 #include "afs_lhash.h"
@@ -51,14 +49,7 @@ unsigned int afs_linux_hash_verify_count = 0;        /* used by hash_verify */
 struct afs_lhash_stat afs_linux_lsb;   /* hash table statistics */
 unsigned int afs_linux_hash_bucket_dist[MAX_BUCKET_LEN];       /* bucket population distribution in our hash table */
 
-#if defined(AFS_LINUX24_ENV)
-#include "h/vmalloc.h"
-#else
-/* externs : can we do this in a better way. Including vmalloc.h causes other
- * problems.*/
-extern void vfree(void *addr);
-extern void *vmalloc(unsigned long size);
-#endif
+#include <linux/vmalloc.h>
 
 /* Allocator support functions (static) */
 
@@ -88,17 +79,16 @@ linux_alloc(unsigned int asize, int drop_glock)
     /*  if we can use kmalloc use it to allocate the required memory. */
     while (!new && max_retry) {
        if (asize <= MAX_KMALLOC_SIZE) {
-           new = (void *)(unsigned long)kmalloc(asize,
-#ifdef GFP_NOFS
-                                                GFP_NOFS
-#else
-                                                GFP_KERNEL
-#endif
-               );
+           new = (void *)(unsigned long)kmalloc(asize, GFP_NOFS);
            if (new)            /* piggy back alloc type */
                new = (void *)(KM_TYPE | (unsigned long)new);
        } else {
+           osi_Assert(drop_glock || !haveGlock);
+           if (drop_glock && haveGlock)
+               AFS_GUNLOCK();
            new = (void *)vmalloc(asize);
+           if (drop_glock && haveGlock)
+               AFS_GLOCK();
            if (new)            /* piggy back alloc type */
                new = (void *)(VM_TYPE | (unsigned long)new);
        }
@@ -218,7 +208,7 @@ local_free(void *p, size_t n)
  *    1 - success
  */
 static int
-linux_alloc_init()
+linux_alloc_init(void)
 {
     /* initiate our pool of osi_linux_mem structs */
     al_mem_pool =
@@ -265,7 +255,7 @@ hash_bucket_stat(size_t index, unsigned key, void *data)
 
 /* get_hash_stats() : get hash table statistics */
 static void
-get_hash_stats()
+get_hash_stats(void)
 {
     int i;
 
@@ -281,15 +271,7 @@ get_hash_stats()
 
 /************** Linux memory allocator interface functions **********/
 
-#if defined(AFS_LINUX24_ENV)
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
-DEFINE_MUTEX(afs_linux_alloc_sem);
-#else
 DECLARE_MUTEX(afs_linux_alloc_sem);
-#endif
-#else
-struct semaphore afs_linux_alloc_sem = MUTEX;
-#endif
 
 void *
 osi_linux_alloc(unsigned int asize, int drop_glock)
@@ -365,6 +347,7 @@ osi_linux_free(void *addr)
        afs_atomlist_put(al_mem_pool, lmp);     /* return osi_linux_mem struct to pool */
        afs_linux_cur_allocs--;
     } else {
+       BUG();
        printf("osi_linux_free: failed to remove chunk from hashtable\n");
     }