Whamcloud - gitweb
LU-1346 libcfs: tcpip/time/type related cleanup
[fs/lustre-release.git] / libcfs / libcfs / winnt / winnt-curproc.c
index 16b47b8..e59719e 100644 (file)
@@ -26,6 +26,8 @@
 /*
  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright (c) 2012, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -153,18 +155,12 @@ struct idr_context * cfs_win_task_slot_idp = NULL;
  *  task slot routiens
  */
 
-PTASK_SLOT
-alloc_task_slot()
+PTASK_SLOT alloc_task_slot()
 {
-    PTASK_SLOT task = NULL;
-
-    if (cfs_win_task_manger.slab) {
-        task = cfs_mem_cache_alloc(cfs_win_task_manger.slab, 0);
-    } else {
-        task = cfs_alloc(sizeof(TASK_SLOT), 0);
-    }
-
-    return task;
+       if (cfs_win_task_manger.slab)
+               return kmem_cache_alloc(cfs_win_task_manger.slab, 0);
+       else
+               return kmalloc(sizeof(TASK_SLOT), 0);
 }
 
 void
@@ -176,18 +172,15 @@ init_task_slot(PTASK_SLOT task)
     cfs_init_event(&task->Event, TRUE, FALSE);
 }
 
-void
-cleanup_task_slot(PTASK_SLOT task)
+void cleanup_task_slot(PTASK_SLOT task)
 {
-    if (task->task.pid) {
-        cfs_idr_remove(cfs_win_task_slot_idp, task->task.pid);
-    }
+       if (task->task.pid)
+               cfs_idr_remove(cfs_win_task_slot_idp, task->task.pid);
 
-    if (cfs_win_task_manger.slab) {
-        cfs_mem_cache_free(cfs_win_task_manger.slab, task);
-    } else {
-        cfs_free(task);
-    }
+       if (cfs_win_task_manger.slab)
+               kmem_cache_free(cfs_win_task_manger.slab, task);
+       else
+               kfree(task);
 }
 
 /*
@@ -204,7 +197,7 @@ task_manager_notify(
     PLIST_ENTRY ListEntry = NULL; 
     PTASK_SLOT  TaskSlot  = NULL;
 
-    cfs_spin_lock(&(cfs_win_task_manger.Lock));
+       spin_lock(&(cfs_win_task_manger.Lock));
 
     ListEntry = cfs_win_task_manger.TaskList.Flink;
     while (ListEntry != (&(cfs_win_task_manger.TaskList))) {
@@ -226,7 +219,7 @@ task_manager_notify(
         ListEntry = ListEntry->Flink;
     }
 
-    cfs_spin_unlock(&(cfs_win_task_manger.Lock));
+       spin_unlock(&(cfs_win_task_manger.Lock));
 }
 
 int
@@ -239,11 +232,11 @@ init_task_manager()
     cfs_win_task_manger.Magic = TASKMAN_MAGIC;
 
     /* initialize the spinlock protection */
-    cfs_spin_lock_init(&cfs_win_task_manger.Lock);
+       spin_lock_init(&cfs_win_task_manger.Lock);
 
-    /* create slab memory cache */
-    cfs_win_task_manger.slab = cfs_mem_cache_create(
-        "TSLT", sizeof(TASK_SLOT), 0, 0);
+       /* create slab memory cache */
+       cfs_win_task_manger.slab = kmem_cache_create("TSLT", sizeof(TASK_SLOT),
+                                                    0, 0, NULL);
 
     /* intialize the list header */
     InitializeListHead(&(cfs_win_task_manger.TaskList));
@@ -285,7 +278,7 @@ cleanup_task_manager()
     }
 
     /* cleanup all the taskslots attached to the list */
-    cfs_spin_lock(&(cfs_win_task_manger.Lock));
+       spin_lock(&(cfs_win_task_manger.Lock));
 
     while (!IsListEmpty(&(cfs_win_task_manger.TaskList))) {
 
@@ -296,11 +289,11 @@ cleanup_task_manager()
         cleanup_task_slot(TaskSlot);
     }
 
-    cfs_spin_unlock(&cfs_win_task_manger.Lock);
+       spin_unlock(&cfs_win_task_manger.Lock);
 
-    /* destroy the taskslot cache slab */
-    cfs_mem_cache_destroy(cfs_win_task_manger.slab);
-    memset(&cfs_win_task_manger, 0, sizeof(TASK_MAN));
+       /* destroy the taskslot cache slab */
+       kmem_cache_destroy(cfs_win_task_manger.slab);
+       memset(&cfs_win_task_manger, 0, sizeof(TASK_MAN));
 }
 
 
@@ -319,7 +312,7 @@ cfs_current()
     PLIST_ENTRY ListEntry = NULL; 
     PTASK_SLOT  TaskSlot  = NULL;
 
-    cfs_spin_lock(&(cfs_win_task_manger.Lock));
+       spin_lock(&(cfs_win_task_manger.Lock));
 
     ListEntry = cfs_win_task_manger.TaskList.Flink;
     while (ListEntry != (&(cfs_win_task_manger.TaskList))) {
@@ -415,7 +408,7 @@ cfs_current()
 
 errorout:
 
-    cfs_spin_unlock(&(cfs_win_task_manger.Lock));
+       spin_unlock(&(cfs_win_task_manger.Lock));
 
     if (!TaskSlot) {
         cfs_enter_debugger();