aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Reisner <philipp.reisner@linbit.com>2011-02-10 04:38:06 -0500
committerPhilipp Reisner <philipp.reisner@linbit.com>2011-09-28 04:33:20 -0400
commitfda74117dc7f07b844c398157f1ed398f3bc02da (patch)
tree147fea6421d778004d8d655e139d390e3d6f9136
parent3509502dc88ce8226b29bea5e25edf066eca9a8a (diff)
drbd: Extracted is_valid_conn_transition() out of is_valid_transition()
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com> Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
-rw-r--r--drivers/block/drbd/drbd_state.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/drivers/block/drbd/drbd_state.c b/drivers/block/drbd/drbd_state.c
index 3199bf92e46e..b381faade0a7 100644
--- a/drivers/block/drbd/drbd_state.c
+++ b/drivers/block/drbd/drbd_state.c
@@ -396,33 +396,42 @@ is_valid_soft_transition(union drbd_state os, union drbd_state ns)
396 return rv; 396 return rv;
397} 397}
398 398
399/**
400 * is_valid_transition() - Returns an SS_ error code if the state transition is not possible
401 * This limits hard state transitions. Hard state transitions are facts there are
402 * imposed on DRBD by the environment. E.g. disk broke or network broke down.
403 * But those hard state transitions are still not allowed to do everything.
404 * @ns: new state.
405 * @os: old state.
406 */
407static enum drbd_state_rv 399static enum drbd_state_rv
408is_valid_transition(union drbd_state os, union drbd_state ns) 400is_valid_conn_transition(enum drbd_conns oc, enum drbd_conns nc)
409{ 401{
410 enum drbd_state_rv rv = SS_SUCCESS; 402 enum drbd_state_rv rv = SS_SUCCESS;
411 403
412 /* Disallow Network errors to configure a device's network part */ 404 /* Disallow Network errors to configure a device's network part */
413 if ((ns.conn >= C_TIMEOUT && ns.conn <= C_TEAR_DOWN) && 405 if ((nc >= C_TIMEOUT && nc <= C_TEAR_DOWN) && oc <= C_DISCONNECTING)
414 os.conn <= C_DISCONNECTING)
415 rv = SS_NEED_CONNECTION; 406 rv = SS_NEED_CONNECTION;
416 407
417 /* After a network error only C_UNCONNECTED or C_DISCONNECTING may follow. */ 408 /* After a network error only C_UNCONNECTED or C_DISCONNECTING may follow. */
418 if (os.conn >= C_TIMEOUT && os.conn <= C_TEAR_DOWN && 409 if (oc >= C_TIMEOUT && oc <= C_TEAR_DOWN && nc != C_UNCONNECTED && nc != C_DISCONNECTING)
419 ns.conn != C_UNCONNECTED && ns.conn != C_DISCONNECTING)
420 rv = SS_IN_TRANSIENT_STATE; 410 rv = SS_IN_TRANSIENT_STATE;
421 411
422 /* After C_DISCONNECTING only C_STANDALONE may follow */ 412 /* After C_DISCONNECTING only C_STANDALONE may follow */
423 if (os.conn == C_DISCONNECTING && ns.conn != C_STANDALONE) 413 if (oc == C_DISCONNECTING && nc != C_STANDALONE)
424 rv = SS_IN_TRANSIENT_STATE; 414 rv = SS_IN_TRANSIENT_STATE;
425 415
416 return rv;
417}
418
419
420/**
421 * is_valid_transition() - Returns an SS_ error code if the state transition is not possible
422 * This limits hard state transitions. Hard state transitions are facts there are
423 * imposed on DRBD by the environment. E.g. disk broke or network broke down.
424 * But those hard state transitions are still not allowed to do everything.
425 * @ns: new state.
426 * @os: old state.
427 */
428static enum drbd_state_rv
429is_valid_transition(union drbd_state os, union drbd_state ns)
430{
431 enum drbd_state_rv rv;
432
433 rv = is_valid_conn_transition(os.conn, ns.conn);
434
426 /* we cannot fail (again) if we already detached */ 435 /* we cannot fail (again) if we already detached */
427 if (ns.disk == D_FAILED && os.disk == D_DISKLESS) 436 if (ns.disk == D_FAILED && os.disk == D_DISKLESS)
428 rv = SS_IS_DISKLESS; 437 rv = SS_IS_DISKLESS;