Lines Matching defs:thi
311 struct drbd_thread *thi = (struct drbd_thread *) arg;
312 struct drbd_resource *resource = thi->resource;
317 thi->name[0],
323 retval = thi->function(thi);
325 spin_lock_irqsave(&thi->t_lock, flags);
337 if (thi->t_state == RESTARTING) {
338 drbd_info(resource, "Restarting %s thread\n", thi->name);
339 thi->t_state = RUNNING;
340 spin_unlock_irqrestore(&thi->t_lock, flags);
344 thi->task = NULL;
345 thi->t_state = NONE;
347 complete_all(&thi->stop);
348 spin_unlock_irqrestore(&thi->t_lock, flags);
354 if (thi->connection)
355 kref_put(&thi->connection->kref, drbd_destroy_connection);
361 static void drbd_thread_init(struct drbd_resource *resource, struct drbd_thread *thi,
364 spin_lock_init(&thi->t_lock);
365 thi->task = NULL;
366 thi->t_state = NONE;
367 thi->function = func;
368 thi->resource = resource;
369 thi->connection = NULL;
370 thi->name = name;
373 int drbd_thread_start(struct drbd_thread *thi)
375 struct drbd_resource *resource = thi->resource;
381 spin_lock_irqsave(&thi->t_lock, flags);
383 switch (thi->t_state) {
386 thi->name, current->comm, current->pid);
391 spin_unlock_irqrestore(&thi->t_lock, flags);
396 if (thi->connection)
397 kref_get(&thi->connection->kref);
399 init_completion(&thi->stop);
400 thi->reset_cpu_mask = 1;
401 thi->t_state = RUNNING;
402 spin_unlock_irqrestore(&thi->t_lock, flags);
405 nt = kthread_create(drbd_thread_setup, (void *) thi,
406 "drbd_%c_%s", thi->name[0], thi->resource->name);
411 if (thi->connection)
412 kref_put(&thi->connection->kref, drbd_destroy_connection);
417 spin_lock_irqsave(&thi->t_lock, flags);
418 thi->task = nt;
419 thi->t_state = RUNNING;
420 spin_unlock_irqrestore(&thi->t_lock, flags);
424 thi->t_state = RESTARTING;
426 thi->name, current->comm, current->pid);
431 spin_unlock_irqrestore(&thi->t_lock, flags);
439 void _drbd_thread_stop(struct drbd_thread *thi, int restart, int wait)
446 spin_lock_irqsave(&thi->t_lock, flags);
448 if (thi->t_state == NONE) {
449 spin_unlock_irqrestore(&thi->t_lock, flags);
451 drbd_thread_start(thi);
455 if (thi->t_state != ns) {
456 if (thi->task == NULL) {
457 spin_unlock_irqrestore(&thi->t_lock, flags);
461 thi->t_state = ns;
463 init_completion(&thi->stop);
464 if (thi->task != current)
465 send_sig(DRBD_SIGKILL, thi->task, 1);
468 spin_unlock_irqrestore(&thi->t_lock, flags);
471 wait_for_completion(&thi->stop);
528 * @thi: drbd_thread object
533 void drbd_thread_current_set_cpu(struct drbd_thread *thi)
535 struct drbd_resource *resource = thi->resource;
538 if (!thi->reset_cpu_mask)
540 thi->reset_cpu_mask = 0;