Lines Matching refs:thi

307 	struct drbd_thread *thi = (struct drbd_thread *) arg;  in drbd_thread_setup()  local
308 struct drbd_resource *resource = thi->resource; in drbd_thread_setup()
313 thi->name[0], in drbd_thread_setup()
319 retval = thi->function(thi); in drbd_thread_setup()
321 spin_lock_irqsave(&thi->t_lock, flags); in drbd_thread_setup()
333 if (thi->t_state == RESTARTING) { in drbd_thread_setup()
334 drbd_info(resource, "Restarting %s thread\n", thi->name); in drbd_thread_setup()
335 thi->t_state = RUNNING; in drbd_thread_setup()
336 spin_unlock_irqrestore(&thi->t_lock, flags); in drbd_thread_setup()
340 thi->task = NULL; in drbd_thread_setup()
341 thi->t_state = NONE; in drbd_thread_setup()
343 complete_all(&thi->stop); in drbd_thread_setup()
344 spin_unlock_irqrestore(&thi->t_lock, flags); in drbd_thread_setup()
350 if (thi->connection) in drbd_thread_setup()
351 kref_put(&thi->connection->kref, drbd_destroy_connection); in drbd_thread_setup()
357 static void drbd_thread_init(struct drbd_resource *resource, struct drbd_thread *thi, in drbd_thread_init() argument
360 spin_lock_init(&thi->t_lock); in drbd_thread_init()
361 thi->task = NULL; in drbd_thread_init()
362 thi->t_state = NONE; in drbd_thread_init()
363 thi->function = func; in drbd_thread_init()
364 thi->resource = resource; in drbd_thread_init()
365 thi->connection = NULL; in drbd_thread_init()
366 thi->name = name; in drbd_thread_init()
369 int drbd_thread_start(struct drbd_thread *thi) in drbd_thread_start() argument
371 struct drbd_resource *resource = thi->resource; in drbd_thread_start()
377 spin_lock_irqsave(&thi->t_lock, flags); in drbd_thread_start()
379 switch (thi->t_state) { in drbd_thread_start()
382 thi->name, current->comm, current->pid); in drbd_thread_start()
387 spin_unlock_irqrestore(&thi->t_lock, flags); in drbd_thread_start()
392 if (thi->connection) in drbd_thread_start()
393 kref_get(&thi->connection->kref); in drbd_thread_start()
395 init_completion(&thi->stop); in drbd_thread_start()
396 thi->reset_cpu_mask = 1; in drbd_thread_start()
397 thi->t_state = RUNNING; in drbd_thread_start()
398 spin_unlock_irqrestore(&thi->t_lock, flags); in drbd_thread_start()
401 nt = kthread_create(drbd_thread_setup, (void *) thi, in drbd_thread_start()
402 "drbd_%c_%s", thi->name[0], thi->resource->name); in drbd_thread_start()
407 if (thi->connection) in drbd_thread_start()
408 kref_put(&thi->connection->kref, drbd_destroy_connection); in drbd_thread_start()
413 spin_lock_irqsave(&thi->t_lock, flags); in drbd_thread_start()
414 thi->task = nt; in drbd_thread_start()
415 thi->t_state = RUNNING; in drbd_thread_start()
416 spin_unlock_irqrestore(&thi->t_lock, flags); in drbd_thread_start()
420 thi->t_state = RESTARTING; in drbd_thread_start()
422 thi->name, current->comm, current->pid); in drbd_thread_start()
427 spin_unlock_irqrestore(&thi->t_lock, flags); in drbd_thread_start()
435 void _drbd_thread_stop(struct drbd_thread *thi, int restart, int wait) in _drbd_thread_stop() argument
442 spin_lock_irqsave(&thi->t_lock, flags); in _drbd_thread_stop()
444 if (thi->t_state == NONE) { in _drbd_thread_stop()
445 spin_unlock_irqrestore(&thi->t_lock, flags); in _drbd_thread_stop()
447 drbd_thread_start(thi); in _drbd_thread_stop()
451 if (thi->t_state != ns) { in _drbd_thread_stop()
452 if (thi->task == NULL) { in _drbd_thread_stop()
453 spin_unlock_irqrestore(&thi->t_lock, flags); in _drbd_thread_stop()
457 thi->t_state = ns; in _drbd_thread_stop()
459 init_completion(&thi->stop); in _drbd_thread_stop()
460 if (thi->task != current) in _drbd_thread_stop()
461 send_sig(DRBD_SIGKILL, thi->task, 1); in _drbd_thread_stop()
464 spin_unlock_irqrestore(&thi->t_lock, flags); in _drbd_thread_stop()
467 wait_for_completion(&thi->stop); in _drbd_thread_stop()
529 void drbd_thread_current_set_cpu(struct drbd_thread *thi) in drbd_thread_current_set_cpu() argument
531 struct drbd_resource *resource = thi->resource; in drbd_thread_current_set_cpu()
534 if (!thi->reset_cpu_mask) in drbd_thread_current_set_cpu()
536 thi->reset_cpu_mask = 0; in drbd_thread_current_set_cpu()