* osi_alloc.c - Linux memory allocation routines.
*
*/
+#include <afsconfig.h>
#include "../afs/param.h"
+
+RCSID("$Header$");
+
#include "../afs/sysincludes.h"
#include "../afs/afsincludes.h"
#include "../h/mm.h"
+#include "../h/slab.h"
#include "../afs/afs_atomlist.h"
#include "../afs/afs_lhash.h"
};
/* These assume 32-bit pointers */
-#define MEMTYPE(A) (((unsigned int)A) & 0x3)
-#define MEMADDR(A) (void *)((unsigned int)(A) & (~0x3))
+#define MEMTYPE(A) (((unsigned long)A) & 0x3)
+#define MEMADDR(A) (void *)((unsigned long)(A) & (~0x3))
/* globals */
afs_atomlist *al_mem_pool; /* pool of osi_linux_mem structures */
/* if we can use kmalloc use it to allocate the required memory. */
if (asize < MAX_KMALLOC_SIZE) {
- new = (void *)kmalloc(asize, GFP_KERNEL);
+ new = (void *)(unsigned long)kmalloc(asize,
+#ifdef GFP_NOFS
+ GFP_NOFS
+#else
+ GFP_KERNEL
+#endif
+ );
if (new) /* piggy back alloc type */
- (unsigned int)new |= KM_TYPE;
+ (unsigned long)new |= KM_TYPE;
}
if (!new) { /* otherwise use vmalloc */
int max_wait = 10;
if (--max_wait <=0) {
break;
}
- schedule();
+#ifdef set_current_state
+ set_current_state(TASK_INTERRUPTIBLE);
+#else
+ current->state = TASK_INTERRUPTIBLE;
+#endif
+ schedule_timeout(HZ);
}
if (new) /* piggy back alloc type */
- (unsigned int)new |= VM_TYPE;
+ (unsigned long)new |= VM_TYPE;
}
if (new)
memset(MEMADDR(new), 0, asize);
{
unsigned int key;
- key = (unsigned int)p >> 2;
+ key = (unsigned int)(long)p >> 2;
key = (key * HASH_CONST)%HASH_PRIME;
return key;
allocator_init = 1; /* initialization complete */
}
+ up(&afs_linux_alloc_sem);
new = linux_alloc(asize); /* get a chunk of memory of size asize */
+ down(&afs_linux_alloc_sem);
if (!new) {
printf("afs_osi_Alloc: Can't vmalloc %d bytes.\n", asize);
goto error;
return MEMADDR(new);
free_error:
- if (new)
- linux_free(new);
+ if (new) {
+ up(&afs_linux_alloc_sem);
+ linux_free(new);
+ down(&afs_linux_alloc_sem);
+ }
new = NULL;
goto error;