Lines Matching defs:thi

320 	struct drbd_thread *thi = (struct drbd_thread *) arg;
321 struct drbd_resource *resource = thi->resource;
326 thi->name[0],
332 retval = thi->function(thi);
334 spin_lock_irqsave(&thi->t_lock, flags);
346 if (thi->t_state == RESTARTING) {
347 drbd_info(resource, "Restarting %s thread\n", thi->name);
348 thi->t_state = RUNNING;
349 spin_unlock_irqrestore(&thi->t_lock, flags);
353 thi->task = NULL;
354 thi->t_state = NONE;
356 complete_all(&thi->stop);
357 spin_unlock_irqrestore(&thi->t_lock, flags);
363 if (thi->connection)
364 kref_put(&thi->connection->kref, drbd_destroy_connection);
370 static void drbd_thread_init(struct drbd_resource *resource, struct drbd_thread *thi,
373 spin_lock_init(&thi->t_lock);
374 thi->task = NULL;
375 thi->t_state = NONE;
376 thi->function = func;
377 thi->resource = resource;
378 thi->connection = NULL;
379 thi->name = name;
382 int drbd_thread_start(struct drbd_thread *thi)
384 struct drbd_resource *resource = thi->resource;
390 spin_lock_irqsave(&thi->t_lock, flags);
392 switch (thi->t_state) {
395 thi->name, current->comm, current->pid);
400 spin_unlock_irqrestore(&thi->t_lock, flags);
405 if (thi->connection)
406 kref_get(&thi->connection->kref);
408 init_completion(&thi->stop);
409 thi->reset_cpu_mask = 1;
410 thi->t_state = RUNNING;
411 spin_unlock_irqrestore(&thi->t_lock, flags);
414 nt = kthread_create(drbd_thread_setup, (void *) thi,
415 "drbd_%c_%s", thi->name[0], thi->resource->name);
420 if (thi->connection)
421 kref_put(&thi->connection->kref, drbd_destroy_connection);
426 spin_lock_irqsave(&thi->t_lock, flags);
427 thi->task = nt;
428 thi->t_state = RUNNING;
429 spin_unlock_irqrestore(&thi->t_lock, flags);
433 thi->t_state = RESTARTING;
435 thi->name, current->comm, current->pid);
440 spin_unlock_irqrestore(&thi->t_lock, flags);
448 void _drbd_thread_stop(struct drbd_thread *thi, int restart, int wait)
455 spin_lock_irqsave(&thi->t_lock, flags);
457 if (thi->t_state == NONE) {
458 spin_unlock_irqrestore(&thi->t_lock, flags);
460 drbd_thread_start(thi);
464 if (thi->t_state != ns) {
465 if (thi->task == NULL) {
466 spin_unlock_irqrestore(&thi->t_lock, flags);
470 thi->t_state = ns;
472 init_completion(&thi->stop);
473 if (thi->task != current)
474 send_sig(DRBD_SIGKILL, thi->task, 1);
477 spin_unlock_irqrestore(&thi->t_lock, flags);
480 wait_for_completion(&thi->stop);
538 * @thi: drbd_thread object
543 void drbd_thread_current_set_cpu(struct drbd_thread *thi)
545 struct drbd_resource *resource = thi->resource;
548 if (!thi->reset_cpu_mask)
550 thi->reset_cpu_mask = 0;