Commit e77a0a5c authored by Andreas Gruenbacher's avatar Andreas Gruenbacher Committed by Philipp Reisner

drbd: Convert all constants in enum drbd_thread_state to upper case

Signed-off-by: default avatarPhilipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: default avatarLars Ellenberg <lars.ellenberg@linbit.com>
parent 8554df1c
...@@ -649,10 +649,10 @@ union p_polymorph { ...@@ -649,10 +649,10 @@ union p_polymorph {
/**********************************************************************/ /**********************************************************************/
enum drbd_thread_state { enum drbd_thread_state {
None, NONE,
Running, RUNNING,
Exiting, EXITING,
Restarting RESTARTING
}; };
struct drbd_thread { struct drbd_thread {
......
...@@ -1627,25 +1627,25 @@ static int drbd_thread_setup(void *arg) ...@@ -1627,25 +1627,25 @@ static int drbd_thread_setup(void *arg)
spin_lock_irqsave(&thi->t_lock, flags); spin_lock_irqsave(&thi->t_lock, flags);
/* if the receiver has been "Exiting", the last thing it did /* if the receiver has been "EXITING", the last thing it did
* was set the conn state to "StandAlone", * was set the conn state to "StandAlone",
* if now a re-connect request comes in, conn state goes C_UNCONNECTED, * if now a re-connect request comes in, conn state goes C_UNCONNECTED,
* and receiver thread will be "started". * and receiver thread will be "started".
* drbd_thread_start needs to set "Restarting" in that case. * drbd_thread_start needs to set "RESTARTING" in that case.
* t_state check and assignment needs to be within the same spinlock, * t_state check and assignment needs to be within the same spinlock,
* so either thread_start sees Exiting, and can remap to Restarting, * so either thread_start sees EXITING, and can remap to RESTARTING,
* or thread_start see None, and can proceed as normal. * or thread_start see NONE, and can proceed as normal.
*/ */
if (thi->t_state == Restarting) { if (thi->t_state == RESTARTING) {
dev_info(DEV, "Restarting %s\n", current->comm); dev_info(DEV, "Restarting %s\n", current->comm);
thi->t_state = Running; thi->t_state = RUNNING;
spin_unlock_irqrestore(&thi->t_lock, flags); spin_unlock_irqrestore(&thi->t_lock, flags);
goto restart; goto restart;
} }
thi->task = NULL; thi->task = NULL;
thi->t_state = None; thi->t_state = NONE;
smp_mb(); smp_mb();
complete(&thi->stop); complete(&thi->stop);
spin_unlock_irqrestore(&thi->t_lock, flags); spin_unlock_irqrestore(&thi->t_lock, flags);
...@@ -1662,7 +1662,7 @@ static void drbd_thread_init(struct drbd_conf *mdev, struct drbd_thread *thi, ...@@ -1662,7 +1662,7 @@ static void drbd_thread_init(struct drbd_conf *mdev, struct drbd_thread *thi,
{ {
spin_lock_init(&thi->t_lock); spin_lock_init(&thi->t_lock);
thi->task = NULL; thi->task = NULL;
thi->t_state = None; thi->t_state = NONE;
thi->function = func; thi->function = func;
thi->mdev = mdev; thi->mdev = mdev;
} }
...@@ -1683,7 +1683,7 @@ int drbd_thread_start(struct drbd_thread *thi) ...@@ -1683,7 +1683,7 @@ int drbd_thread_start(struct drbd_thread *thi)
spin_lock_irqsave(&thi->t_lock, flags); spin_lock_irqsave(&thi->t_lock, flags);
switch (thi->t_state) { switch (thi->t_state) {
case None: case NONE:
dev_info(DEV, "Starting %s thread (from %s [%d])\n", dev_info(DEV, "Starting %s thread (from %s [%d])\n",
me, current->comm, current->pid); me, current->comm, current->pid);
...@@ -1697,7 +1697,7 @@ int drbd_thread_start(struct drbd_thread *thi) ...@@ -1697,7 +1697,7 @@ int drbd_thread_start(struct drbd_thread *thi)
init_completion(&thi->stop); init_completion(&thi->stop);
D_ASSERT(thi->task == NULL); D_ASSERT(thi->task == NULL);
thi->reset_cpu_mask = 1; thi->reset_cpu_mask = 1;
thi->t_state = Running; thi->t_state = RUNNING;
spin_unlock_irqrestore(&thi->t_lock, flags); spin_unlock_irqrestore(&thi->t_lock, flags);
flush_signals(current); /* otherw. may get -ERESTARTNOINTR */ flush_signals(current); /* otherw. may get -ERESTARTNOINTR */
...@@ -1712,17 +1712,17 @@ int drbd_thread_start(struct drbd_thread *thi) ...@@ -1712,17 +1712,17 @@ int drbd_thread_start(struct drbd_thread *thi)
} }
spin_lock_irqsave(&thi->t_lock, flags); spin_lock_irqsave(&thi->t_lock, flags);
thi->task = nt; thi->task = nt;
thi->t_state = Running; thi->t_state = RUNNING;
spin_unlock_irqrestore(&thi->t_lock, flags); spin_unlock_irqrestore(&thi->t_lock, flags);
wake_up_process(nt); wake_up_process(nt);
break; break;
case Exiting: case EXITING:
thi->t_state = Restarting; thi->t_state = RESTARTING;
dev_info(DEV, "Restarting %s thread (from %s [%d])\n", dev_info(DEV, "Restarting %s thread (from %s [%d])\n",
me, current->comm, current->pid); me, current->comm, current->pid);
/* fall through */ /* fall through */
case Running: case RUNNING:
case Restarting: case RESTARTING:
default: default:
spin_unlock_irqrestore(&thi->t_lock, flags); spin_unlock_irqrestore(&thi->t_lock, flags);
break; break;
...@@ -1736,12 +1736,12 @@ void _drbd_thread_stop(struct drbd_thread *thi, int restart, int wait) ...@@ -1736,12 +1736,12 @@ void _drbd_thread_stop(struct drbd_thread *thi, int restart, int wait)
{ {
unsigned long flags; unsigned long flags;
enum drbd_thread_state ns = restart ? Restarting : Exiting; enum drbd_thread_state ns = restart ? RESTARTING : EXITING;
/* may be called from state engine, holding the req lock irqsave */ /* may be called from state engine, holding the req lock irqsave */
spin_lock_irqsave(&thi->t_lock, flags); spin_lock_irqsave(&thi->t_lock, flags);
if (thi->t_state == None) { if (thi->t_state == NONE) {
spin_unlock_irqrestore(&thi->t_lock, flags); spin_unlock_irqrestore(&thi->t_lock, flags);
if (restart) if (restart)
drbd_thread_start(thi); drbd_thread_start(thi);
...@@ -2504,7 +2504,7 @@ static int we_should_drop_the_connection(struct drbd_conf *mdev, struct socket * ...@@ -2504,7 +2504,7 @@ static int we_should_drop_the_connection(struct drbd_conf *mdev, struct socket *
drop_it = mdev->meta.socket == sock drop_it = mdev->meta.socket == sock
|| !mdev->asender.task || !mdev->asender.task
|| get_t_state(&mdev->asender) != Running || get_t_state(&mdev->asender) != RUNNING
|| mdev->state.conn < C_CONNECTED; || mdev->state.conn < C_CONNECTED;
if (drop_it) if (drop_it)
...@@ -3046,7 +3046,7 @@ void drbd_init_set_defaults(struct drbd_conf *mdev) ...@@ -3046,7 +3046,7 @@ void drbd_init_set_defaults(struct drbd_conf *mdev)
void drbd_mdev_cleanup(struct drbd_conf *mdev) void drbd_mdev_cleanup(struct drbd_conf *mdev)
{ {
int i; int i;
if (mdev->receiver.t_state != None) if (mdev->receiver.t_state != NONE)
dev_err(DEV, "ASSERT FAILED: receiver t_state == %d expected 0.\n", dev_err(DEV, "ASSERT FAILED: receiver t_state == %d expected 0.\n",
mdev->receiver.t_state); mdev->receiver.t_state);
......
...@@ -833,7 +833,7 @@ static int drbd_connect(struct drbd_conf *mdev) ...@@ -833,7 +833,7 @@ static int drbd_connect(struct drbd_conf *mdev)
if (signal_pending(current)) { if (signal_pending(current)) {
flush_signals(current); flush_signals(current);
smp_rmb(); smp_rmb();
if (get_t_state(&mdev->receiver) == Exiting) if (get_t_state(&mdev->receiver) == EXITING)
goto out_release_sockets; goto out_release_sockets;
} }
...@@ -3700,7 +3700,7 @@ static void drbdd(struct drbd_conf *mdev) ...@@ -3700,7 +3700,7 @@ static void drbdd(struct drbd_conf *mdev)
size_t shs; /* sub header size */ size_t shs; /* sub header size */
int rv; int rv;
while (get_t_state(&mdev->receiver) == Running) { while (get_t_state(&mdev->receiver) == RUNNING) {
drbd_thread_current_set_cpu(mdev); drbd_thread_current_set_cpu(mdev);
if (!drbd_recv_header(mdev, &cmd, &packet_size)) if (!drbd_recv_header(mdev, &cmd, &packet_size))
goto err_out; goto err_out;
...@@ -4490,7 +4490,7 @@ int drbd_asender(struct drbd_thread *thi) ...@@ -4490,7 +4490,7 @@ int drbd_asender(struct drbd_thread *thi)
current->policy = SCHED_RR; /* Make this a realtime task! */ current->policy = SCHED_RR; /* Make this a realtime task! */
current->rt_priority = 2; /* more important than all other tasks */ current->rt_priority = 2; /* more important than all other tasks */
while (get_t_state(thi) == Running) { while (get_t_state(thi) == RUNNING) {
drbd_thread_current_set_cpu(mdev); drbd_thread_current_set_cpu(mdev);
if (test_and_clear_bit(SEND_PING, &mdev->flags)) { if (test_and_clear_bit(SEND_PING, &mdev->flags)) {
ERR_IF(!drbd_send_ping(mdev)) goto reconnect; ERR_IF(!drbd_send_ping(mdev)) goto reconnect;
......
...@@ -1617,7 +1617,7 @@ int drbd_worker(struct drbd_thread *thi) ...@@ -1617,7 +1617,7 @@ int drbd_worker(struct drbd_thread *thi)
sprintf(current->comm, "drbd%d_worker", mdev_to_minor(mdev)); sprintf(current->comm, "drbd%d_worker", mdev_to_minor(mdev));
while (get_t_state(thi) == Running) { while (get_t_state(thi) == RUNNING) {
drbd_thread_current_set_cpu(mdev); drbd_thread_current_set_cpu(mdev);
if (down_trylock(&mdev->data.work.s)) { if (down_trylock(&mdev->data.work.s)) {
...@@ -1637,12 +1637,12 @@ int drbd_worker(struct drbd_thread *thi) ...@@ -1637,12 +1637,12 @@ int drbd_worker(struct drbd_thread *thi)
if (intr) { if (intr) {
D_ASSERT(intr == -EINTR); D_ASSERT(intr == -EINTR);
flush_signals(current); flush_signals(current);
ERR_IF (get_t_state(thi) == Running) ERR_IF (get_t_state(thi) == RUNNING)
continue; continue;
break; break;
} }
if (get_t_state(thi) != Running) if (get_t_state(thi) != RUNNING)
break; break;
/* With this break, we have done a down() but not consumed /* With this break, we have done a down() but not consumed
the entry from the list. The cleanup code takes care of the entry from the list. The cleanup code takes care of
...@@ -1704,7 +1704,7 @@ int drbd_worker(struct drbd_thread *thi) ...@@ -1704,7 +1704,7 @@ int drbd_worker(struct drbd_thread *thi)
D_ASSERT(mdev->state.disk == D_DISKLESS && mdev->state.conn == C_STANDALONE); D_ASSERT(mdev->state.disk == D_DISKLESS && mdev->state.conn == C_STANDALONE);
/* _drbd_set_state only uses stop_nowait. /* _drbd_set_state only uses stop_nowait.
* wait here for the Exiting receiver. */ * wait here for the EXITING receiver. */
drbd_thread_stop(&mdev->receiver); drbd_thread_stop(&mdev->receiver);
drbd_mdev_cleanup(mdev); drbd_mdev_cleanup(mdev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment