Whamcloud - gitweb
LU-1346 libcfs: replace cfs_ memory wrappers
[fs/lustre-release.git] / libcfs / libcfs / winnt / winnt-prim.c
index 1d04567..6bedace 100644 (file)
@@ -59,9 +59,7 @@
  */
 
 void
-cfs_thread_proc(
-    void * context
-    )
+cfs_thread_proc(void *context)
 {
     cfs_thread_context_t * thread_context =
         (cfs_thread_context_t *) context;
@@ -74,7 +72,7 @@ cfs_thread_proc(
 
     /* Free the context memory */
 
-    cfs_free(context);
+    kfree(context);
 
     /* Terminate this system thread */
 
@@ -101,11 +99,11 @@ cfs_task_t kthread_run(int (*func)(void *), void *arg, char *name)
 {
     cfs_handle_t  thread = NULL;
     NTSTATUS      status;
-    cfs_thread_context_t * context = NULL;
+    cfs_thread_context_t *context = NULL;
 
     /* Allocate the context to be transferred to system thread */
 
-    context = cfs_alloc(sizeof(cfs_thread_context_t), CFS_ALLOC_ZERO);
+    context = kmalloc(sizeof(cfs_thread_context_t), __GFP_ZERO);
 
     if (!context) {
        return ERR_PTR(-ENOMEM);
@@ -126,7 +124,7 @@ cfs_task_t kthread_run(int (*func)(void *), void *arg, char *name)
     if (!NT_SUCCESS(status)) {
 
 
-        cfs_free(context);
+       kfree(context);
 
         /* We need translate the nt status to linux error code */
 
@@ -248,10 +246,10 @@ cfs_symbol_register(const char *name, const void *value)
     struct cfs_symbol       *sym = NULL;
     struct cfs_symbol       *new = NULL;
 
-    new = cfs_alloc(sizeof(struct cfs_symbol), CFS_ALLOC_ZERO);
-    if (!new) {
-        return (-ENOMEM);
-    }
+       new = kmalloc(sizeof(struct cfs_symbol), __GFP_ZERO);
+       if (!new)
+               return -ENOMEM;
+
     strncpy(new->name, name, CFS_SYMBOL_LEN);
     new->value = (void *)value;
     new->ref = 0;
@@ -262,7 +260,7 @@ cfs_symbol_register(const char *name, const void *value)
                sym = cfs_list_entry (walker, struct cfs_symbol, sym_list);
                if (!strcmp(sym->name, name)) {
                        up_write(&cfs_symbol_lock);
-                       cfs_free(new);
+                       kfree(new);
                        return 0; /* alreay registerred */
                }
        }
@@ -299,7 +297,7 @@ cfs_symbol_unregister(const char *name)
         if (!strcmp(sym->name, name)) {
             LASSERT(sym->ref == 0);
             cfs_list_del (&sym->sym_list);
-            cfs_free(sym);
+           kfree(sym);
             break;
         }
     }
@@ -331,7 +329,7 @@ cfs_symbol_clean()
                sym = cfs_list_entry (walker, struct cfs_symbol, sym_list);
                LASSERT(sym->ref == 0);
                cfs_list_del (&sym->sym_list);
-               cfs_free(sym);
+               kfree(sym);
        }
        up_write(&cfs_symbol_lock);
        return;
@@ -767,12 +765,12 @@ libcfs_arch_init(void)
        and kernel ntoskrnl.lib) */
     cfs_libc_init();
 
-    /* create slab memory caches for page alloctors */
-    cfs_page_t_slab = cfs_mem_cache_create(
-        "CPGT", sizeof(cfs_page_t), 0, 0 );
+       /* create slab memory caches for page alloctors */
+       cfs_page_t_slab = kmem_cache_create("CPGT", sizeof(struct page),
+                                           0, 0, NULL);
 
-    cfs_page_p_slab = cfs_mem_cache_create(
-        "CPGP", CFS_PAGE_SIZE, 0, 0 );
+       cfs_page_p_slab = kmem_cache_create("CPGP", PAGE_CACHE_SIZE,
+                                           0, 0, NULL);
 
     if ( cfs_page_t_slab == NULL ||
          cfs_page_p_slab == NULL ){
@@ -810,15 +808,13 @@ libcfs_arch_init(void)
 
 errorout:
 
-    if (rc != 0) {
-        /* destroy the taskslot cache slab */
-        if (cfs_page_t_slab) {
-            cfs_mem_cache_destroy(cfs_page_t_slab);
-        }
-        if (cfs_page_p_slab) {
-            cfs_mem_cache_destroy(cfs_page_p_slab);
-        }
-    }
+       if (rc != 0) {
+               /* destroy the taskslot cache slab */
+               if (cfs_page_t_slab)
+                       kmem_cache_destroy(cfs_page_t_slab);
+               if (cfs_page_p_slab)
+                       kmem_cache_destroy(cfs_page_p_slab);
+       }
 
     return rc;
 }
@@ -840,11 +836,11 @@ libcfs_arch_cleanup(void)
 
     /* destroy the taskslot cache slab */
     if (cfs_page_t_slab) {
-        cfs_mem_cache_destroy(cfs_page_t_slab);
+kmem_cache_destroy(cfs_page_t_slab);
     }
 
     if (cfs_page_p_slab) {
-        cfs_mem_cache_destroy(cfs_page_p_slab);
+kmem_cache_destroy(cfs_page_p_slab);
     }
 
     return;