Whamcloud - gitweb
LU-3204 build: clean up unused variables and dead code
[fs/lustre-release.git] / libcfs / libcfs / workitem.c
index 309cfec..5b66e60 100644 (file)
@@ -377,8 +377,6 @@ cfs_wi_check_events (void)
 void
 cfs_wi_sched_destroy(struct cfs_wi_sched *sched)
 {
-       int     i;
-
        LASSERT(cfs_wi_data.wi_init);
        LASSERT(!cfs_wi_data.wi_stopping);
 
@@ -395,26 +393,28 @@ cfs_wi_sched_destroy(struct cfs_wi_sched *sched)
 
        spin_unlock(&cfs_wi_data.wi_glock);
 
-       i = 2;
 #ifdef __KERNEL__
        cfs_waitq_broadcast(&sched->ws_waitq);
 
        spin_lock(&cfs_wi_data.wi_glock);
-       while (sched->ws_nthreads > 0) {
-               CDEBUG(IS_PO2(++i) ? D_WARNING : D_NET,
-                      "waiting for %d threads of WI sched[%s] to terminate\n",
-                      sched->ws_nthreads, sched->ws_name);
+       {
+               int i = 2;
 
-               spin_unlock(&cfs_wi_data.wi_glock);
-               cfs_pause(cfs_time_seconds(1) / 20);
-               spin_lock(&cfs_wi_data.wi_glock);
+               while (sched->ws_nthreads > 0) {
+                       CDEBUG(IS_PO2(++i) ? D_WARNING : D_NET,
+                              "waiting for %d threads of WI sched[%s] to "
+                              "terminate\n", sched->ws_nthreads,
+                              sched->ws_name);
+
+                       spin_unlock(&cfs_wi_data.wi_glock);
+                       cfs_pause(cfs_time_seconds(1) / 20);
+                       spin_lock(&cfs_wi_data.wi_glock);
+               }
        }
 
        cfs_list_del(&sched->ws_list);
 
        spin_unlock(&cfs_wi_data.wi_glock);
-#else
-       SET_BUT_UNUSED(i);
 #endif
        LASSERT(sched->ws_nscheduled == 0);
 
@@ -427,7 +427,6 @@ cfs_wi_sched_create(char *name, struct cfs_cpt_table *cptab,
                    int cpt, int nthrs, struct cfs_wi_sched **sched_pp)
 {
        struct cfs_wi_sched     *sched;
-       int                     rc;
 
        LASSERT(cfs_wi_data.wi_init);
        LASSERT(!cfs_wi_data.wi_stopping);
@@ -450,11 +449,11 @@ cfs_wi_sched_create(char *name, struct cfs_cpt_table *cptab,
        CFS_INIT_LIST_HEAD(&sched->ws_rerunq);
        CFS_INIT_LIST_HEAD(&sched->ws_list);
 
-       rc = 0;
 #ifdef __KERNEL__
-       while (nthrs > 0)  {
-               char    name[16];
+       for (; nthrs > 0; nthrs--)  {
+               char            name[16];
                cfs_task_t      *task;
+
                spin_lock(&cfs_wi_data.wi_glock);
                while (sched->ws_starting > 0) {
                        spin_unlock(&cfs_wi_data.wi_glock);
@@ -475,28 +474,24 @@ cfs_wi_sched_create(char *name, struct cfs_cpt_table *cptab,
                }
 
                task = kthread_run(cfs_wi_scheduler, sched, name);
-               if (!IS_ERR(task)) {
-                       nthrs--;
-                       continue;
-               }
-               rc = PTR_ERR(task);
+               if (IS_ERR(task)) {
+                       int rc = PTR_ERR(task);
 
-               CERROR("Failed to create thread for WI scheduler %s: %d\n",
-                      name, rc);
+                       CERROR("Failed to create thread for "
+                               "WI scheduler %s: %d\n", name, rc);
 
-               spin_lock(&cfs_wi_data.wi_glock);
+                       spin_lock(&cfs_wi_data.wi_glock);
 
-               /* make up for cfs_wi_sched_destroy */
-               cfs_list_add(&sched->ws_list, &cfs_wi_data.wi_scheds);
-               sched->ws_starting--;
+                       /* make up for cfs_wi_sched_destroy */
+                       cfs_list_add(&sched->ws_list, &cfs_wi_data.wi_scheds);
+                       sched->ws_starting--;
 
-               spin_unlock(&cfs_wi_data.wi_glock);
+                       spin_unlock(&cfs_wi_data.wi_glock);
 
-               cfs_wi_sched_destroy(sched);
-               return rc;
+                       cfs_wi_sched_destroy(sched);
+                       return rc;
+               }
        }
-#else
-       SET_BUT_UNUSED(rc);
 #endif
        spin_lock(&cfs_wi_data.wi_glock);
        cfs_list_add(&sched->ws_list, &cfs_wi_data.wi_scheds);