Lines Matching defs:thi

325 	struct drbd_thread *thi = (struct drbd_thread *) arg;
326 struct drbd_resource *resource = thi->resource;
331 thi->name[0],
335 retval = thi->function(thi);
337 spin_lock_irqsave(&thi->t_lock, flags);
349 if (thi->t_state == RESTARTING) {
350 drbd_info(resource, "Restarting %s thread\n", thi->name);
351 thi->t_state = RUNNING;
352 spin_unlock_irqrestore(&thi->t_lock, flags);
356 thi->task = NULL;
357 thi->t_state = NONE;
359 complete_all(&thi->stop);
360 spin_unlock_irqrestore(&thi->t_lock, flags);
366 if (thi->connection)
367 kref_put(&thi->connection->kref, drbd_destroy_connection);
373 static void drbd_thread_init(struct drbd_resource *resource, struct drbd_thread *thi,
376 spin_lock_init(&thi->t_lock);
377 thi->task = NULL;
378 thi->t_state = NONE;
379 thi->function = func;
380 thi->resource = resource;
381 thi->connection = NULL;
382 thi->name = name;
385 int drbd_thread_start(struct drbd_thread *thi)
387 struct drbd_resource *resource = thi->resource;
393 spin_lock_irqsave(&thi->t_lock, flags);
395 switch (thi->t_state) {
398 thi->name, current->comm, current->pid);
403 spin_unlock_irqrestore(&thi->t_lock, flags);
408 if (thi->connection)
409 kref_get(&thi->connection->kref);
411 init_completion(&thi->stop);
412 thi->reset_cpu_mask = 1;
413 thi->t_state = RUNNING;
414 spin_unlock_irqrestore(&thi->t_lock, flags);
417 nt = kthread_create(drbd_thread_setup, (void *) thi,
418 "drbd_%c_%s", thi->name[0], thi->resource->name);
423 if (thi->connection)
424 kref_put(&thi->connection->kref, drbd_destroy_connection);
429 spin_lock_irqsave(&thi->t_lock, flags);
430 thi->task = nt;
431 thi->t_state = RUNNING;
432 spin_unlock_irqrestore(&thi->t_lock, flags);
436 thi->t_state = RESTARTING;
438 thi->name, current->comm, current->pid);
443 spin_unlock_irqrestore(&thi->t_lock, flags);
451 void _drbd_thread_stop(struct drbd_thread *thi, int restart, int wait)
458 spin_lock_irqsave(&thi->t_lock, flags);
460 if (thi->t_state == NONE) {
461 spin_unlock_irqrestore(&thi->t_lock, flags);
463 drbd_thread_start(thi);
467 if (thi->t_state != ns) {
468 if (thi->task == NULL) {
469 spin_unlock_irqrestore(&thi->t_lock, flags);
473 thi->t_state = ns;
475 init_completion(&thi->stop);
476 if (thi->task != current)
477 force_sig(DRBD_SIGKILL, thi->task);
480 spin_unlock_irqrestore(&thi->t_lock, flags);
483 wait_for_completion(&thi->stop);
540 * @thi: drbd_thread object
545 void drbd_thread_current_set_cpu(struct drbd_thread *thi)
547 struct drbd_resource *resource = thi->resource;
550 if (!thi->reset_cpu_mask)
552 thi->reset_cpu_mask = 0;