#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"
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) */
/* 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 */
- (unsigned long)new |= KM_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 */
- (unsigned long)new |= VM_TYPE;
+ new = (void *)(VM_TYPE | (unsigned long)new);
}
if (!new) {
vfree(MEMADDR(p));
break;
default:
- printf("afs_osi_Free: Asked to free unknown type %d at 0x%x\n",
- MEMTYPE(p), MEMADDR(p));
+ printf("afs_osi_Free: Asked to free unknown type %d at 0x%lx\n",
+ (int)MEMTYPE(p), (unsigned long)MEMADDR(p));
break;
}
int memtype;
memtype = MEMTYPE(lmp->chunk);
-#if defined(AFS_SPARC64_LINUX24_ENV) || defined(AFS_I386_UMLINUX20_ENV)
- if ((memtype == KM_TYPE) && (!VALID_PAGE(virt_to_page(lmp->chunk)))) {
- printf
- ("osi_linux_verify_alloced_memory: address 0x%x outside range, index=%d, key=%d\n",
- lmp->chunk, index, key);
- }
-#else
- if ((memtype == KM_TYPE) && (AFS_LINUX_MAP_NR(lmp->chunk) > max_mapnr)) {
- printf
- ("osi_linux_verify_alloced_memory: address 0x%x outside range, index=%d, key=%d\n",
- lmp->chunk, index, key);
- }
-#endif
-
if (memtype != KM_TYPE && memtype != VM_TYPE) {
printf
- ("osi_linux_verify_alloced_memory: unknown type %d at 0x%x, index=%d\n",
- memtype, lmp->chunk, index);
+ ("osi_linux_verify_alloced_memory: unknown type %d at 0x%lx, index=%lu\n",
+ (int)memtype, (unsigned long)lmp->chunk, (unsigned long)index);
}
afs_linux_hash_verify_count++;
}
* 1 - success
*/
static int
-linux_alloc_init()
+linux_alloc_init(void)
{
/* initiate our pool of osi_linux_mem structs */
al_mem_pool =
/* get_hash_stats() : get hash table statistics */
static void
-get_hash_stats()
+get_hash_stats(void)
{
int i;
/************** Linux memory allocator interface functions **********/
-#if defined(AFS_LINUX24_ENV)
DECLARE_MUTEX(afs_linux_alloc_sem);
-#else
-struct semaphore afs_linux_alloc_sem = MUTEX;
-#endif
void *
osi_linux_alloc(unsigned int asize, int drop_glock)
free_error:
if (new) {
- up(&afs_linux_alloc_sem);
linux_free(new);
- down(&afs_linux_alloc_sem);
}
new = NULL;
goto error;
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");
}