void
cfs_wi_sched_destroy(struct cfs_wi_sched *sched)
{
- int i;
-
LASSERT(cfs_wi_data.wi_init);
LASSERT(!cfs_wi_data.wi_stopping);
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);
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);
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);
}
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);