Whamcloud - gitweb
LU-4270 test: fix sanity test_209
[fs/lustre-release.git] / libcfs / libcfs / tracefile.c
index 29a65ef..e15ec68 100644 (file)
@@ -55,7 +55,7 @@ static struct tracefiled_ctl trace_tctl;
 struct mutex cfs_trace_thread_mutex;
 static int thread_running = 0;
 
-cfs_atomic_t cfs_tage_allocated = CFS_ATOMIC_INIT(0);
+atomic_t cfs_tage_allocated = ATOMIC_INIT(0);
 
 static void put_pages_on_tcd_daemon_list(struct page_collection *pc,
                                          struct cfs_trace_cpu_data *tcd);
@@ -91,7 +91,7 @@ static struct cfs_trace_page *cfs_tage_alloc(int gfp)
        }
 
        tage->page = page;
-       cfs_atomic_inc(&cfs_tage_allocated);
+       atomic_inc(&cfs_tage_allocated);
        return tage;
 }
 
@@ -102,7 +102,7 @@ static void cfs_tage_free(struct cfs_trace_page *tage)
 
        __free_page(tage->page);
        kfree(tage);
-       cfs_atomic_dec(&cfs_tage_allocated);
+       atomic_dec(&cfs_tage_allocated);
 }
 
 static void cfs_tage_to_tail(struct cfs_trace_page *tage,
@@ -201,7 +201,6 @@ static void cfs_tcd_shrink(struct cfs_trace_cpu_data *tcd)
                       pgcount + 1, tcd->tcd_cur_pages);
 
         CFS_INIT_LIST_HEAD(&pc.pc_pages);
-       spin_lock_init(&pc.pc_lock);
 
         cfs_list_for_each_entry_safe_typed(tage, tmp, &tcd->tcd_pages,
                                            struct cfs_trace_page, linkage) {
@@ -529,7 +528,6 @@ static void collect_pages_on_all_cpus(struct page_collection *pc)
        struct cfs_trace_cpu_data *tcd;
        int i, cpu;
 
-       spin_lock(&pc->pc_lock);
         cfs_for_each_possible_cpu(cpu) {
                 cfs_tcd_for_each_type_lock(tcd, i, cpu) {
                         cfs_list_splice_init(&tcd->tcd_pages, &pc->pc_pages);
@@ -541,7 +539,6 @@ static void collect_pages_on_all_cpus(struct page_collection *pc)
                         }
                 }
         }
-       spin_unlock(&pc->pc_lock);
 }
 
 static void collect_pages(struct page_collection *pc)
@@ -562,7 +559,6 @@ static void put_pages_back_on_all_cpus(struct page_collection *pc)
         struct cfs_trace_page *tmp;
         int i, cpu;
 
-       spin_lock(&pc->pc_lock);
         cfs_for_each_possible_cpu(cpu) {
                 cfs_tcd_for_each_type_lock(tcd, i, cpu) {
                         cur_head = tcd->tcd_pages.next;
@@ -582,7 +578,6 @@ static void put_pages_back_on_all_cpus(struct page_collection *pc)
                         }
                 }
         }
-       spin_unlock(&pc->pc_lock);
 }
 
 static void put_pages_back(struct page_collection *pc)
@@ -601,7 +596,6 @@ static void put_pages_on_tcd_daemon_list(struct page_collection *pc,
        struct cfs_trace_page *tage;
        struct cfs_trace_page *tmp;
 
-       spin_lock(&pc->pc_lock);
         cfs_list_for_each_entry_safe_typed(tage, tmp, &pc->pc_pages,
                                            struct cfs_trace_page, linkage) {
 
@@ -626,7 +620,6 @@ static void put_pages_on_tcd_daemon_list(struct page_collection *pc,
                         tcd->tcd_cur_daemon_pages--;
                 }
         }
-       spin_unlock(&pc->pc_lock);
 }
 
 static void put_pages_on_daemon_list(struct page_collection *pc)
@@ -646,8 +639,6 @@ void cfs_trace_debug_print(void)
        struct cfs_trace_page *tage;
        struct cfs_trace_page *tmp;
 
-       spin_lock_init(&pc.pc_lock);
-
         pc.pc_want_daemon_pages = 1;
         collect_pages(&pc);
         cfs_list_for_each_entry_safe_typed(tage, tmp, &pc.pc_pages,
@@ -701,7 +692,6 @@ int cfs_tracefile_dump_all_pages(char *filename)
                goto out;
        }
 
-       spin_lock_init(&pc.pc_lock);
         pc.pc_want_daemon_pages = 1;
         collect_pages(&pc);
         if (cfs_list_empty(&pc.pc_pages)) {
@@ -746,8 +736,6 @@ void cfs_trace_flush_pages(void)
        struct cfs_trace_page *tage;
        struct cfs_trace_page *tmp;
 
-       spin_lock_init(&pc.pc_lock);
-
         pc.pc_want_daemon_pages = 1;
         collect_pages(&pc);
         cfs_list_for_each_entry_safe_typed(tage, tmp, &pc.pc_pages,
@@ -993,7 +981,6 @@ static int tracefiled(void *arg)
        /* we're started late enough that we pick up init's fs context */
        /* this is so broken in uml?  what on earth is going on? */
 
-       spin_lock_init(&pc.pc_lock);
        complete(&tctl->tctl_start);
 
        while (1) {
@@ -1072,17 +1059,17 @@ static int tracefiled(void *arg)
                                       "%d\n", ++i, tage->cpu);
                        printk(KERN_ERR "There are %d pages unwritten\n",
                               i);
-                }
-                __LASSERT(cfs_list_empty(&pc.pc_pages));
+               }
+               __LASSERT(cfs_list_empty(&pc.pc_pages));
 end_loop:
-                if (cfs_atomic_read(&tctl->tctl_shutdown)) {
-                        if (last_loop == 0) {
-                                last_loop = 1;
-                                continue;
-                        } else {
-                                break;
-                        }
-                }
+               if (atomic_read(&tctl->tctl_shutdown)) {
+                       if (last_loop == 0) {
+                               last_loop = 1;
+                               continue;
+                       } else {
+                               break;
+                       }
+               }
                init_waitqueue_entry_current(&__wait);
                add_wait_queue(&tctl->tctl_waitq, &__wait);
                set_current_state(TASK_INTERRUPTIBLE);
@@ -1106,7 +1093,7 @@ int cfs_trace_start_thread(void)
        init_completion(&tctl->tctl_start);
        init_completion(&tctl->tctl_stop);
        init_waitqueue_head(&tctl->tctl_waitq);
-       cfs_atomic_set(&tctl->tctl_shutdown, 0);
+       atomic_set(&tctl->tctl_shutdown, 0);
 
        if (IS_ERR(kthread_run(tracefiled, tctl, "ktracefiled"))) {
                rc = -ECHILD;
@@ -1128,7 +1115,7 @@ void cfs_trace_stop_thread(void)
        if (thread_running) {
                printk(KERN_INFO
                       "Lustre: shutting down debug daemon thread...\n");
-               cfs_atomic_set(&tctl->tctl_shutdown, 1);
+               atomic_set(&tctl->tctl_shutdown, 1);
                wait_for_completion(&tctl->tctl_stop);
                thread_running = 0;
        }
@@ -1195,7 +1182,6 @@ static void cfs_trace_cleanup(void)
        struct page_collection pc;
 
        CFS_INIT_LIST_HEAD(&pc.pc_pages);
-       spin_lock_init(&pc.pc_lock);
 
        trace_cleanup_on_all_cpus();