Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 345804
b: refs/heads/master
c: fda7411
h: refs/heads/master
v: v3
  • Loading branch information
Philipp Reisner committed Sep 28, 2011
1 parent 2ef6193 commit bf75ee0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3509502dc88ce8226b29bea5e25edf066eca9a8a
refs/heads/master: fda74117dc7f07b844c398157f1ed398f3bc02da
37 changes: 23 additions & 14 deletions trunk/drivers/block/drbd/drbd_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,33 +396,42 @@ is_valid_soft_transition(union drbd_state os, union drbd_state ns)
return rv;
}

/**
* is_valid_transition() - Returns an SS_ error code if the state transition is not possible
* This limits hard state transitions. Hard state transitions are facts there are
* imposed on DRBD by the environment. E.g. disk broke or network broke down.
* But those hard state transitions are still not allowed to do everything.
* @ns: new state.
* @os: old state.
*/
static enum drbd_state_rv
is_valid_transition(union drbd_state os, union drbd_state ns)
is_valid_conn_transition(enum drbd_conns oc, enum drbd_conns nc)
{
enum drbd_state_rv rv = SS_SUCCESS;

/* Disallow Network errors to configure a device's network part */
if ((ns.conn >= C_TIMEOUT && ns.conn <= C_TEAR_DOWN) &&
os.conn <= C_DISCONNECTING)
if ((nc >= C_TIMEOUT && nc <= C_TEAR_DOWN) && oc <= C_DISCONNECTING)
rv = SS_NEED_CONNECTION;

/* After a network error only C_UNCONNECTED or C_DISCONNECTING may follow. */
if (os.conn >= C_TIMEOUT && os.conn <= C_TEAR_DOWN &&
ns.conn != C_UNCONNECTED && ns.conn != C_DISCONNECTING)
if (oc >= C_TIMEOUT && oc <= C_TEAR_DOWN && nc != C_UNCONNECTED && nc != C_DISCONNECTING)
rv = SS_IN_TRANSIENT_STATE;

/* After C_DISCONNECTING only C_STANDALONE may follow */
if (os.conn == C_DISCONNECTING && ns.conn != C_STANDALONE)
if (oc == C_DISCONNECTING && nc != C_STANDALONE)
rv = SS_IN_TRANSIENT_STATE;

return rv;
}


/**
* is_valid_transition() - Returns an SS_ error code if the state transition is not possible
* This limits hard state transitions. Hard state transitions are facts there are
* imposed on DRBD by the environment. E.g. disk broke or network broke down.
* But those hard state transitions are still not allowed to do everything.
* @ns: new state.
* @os: old state.
*/
static enum drbd_state_rv
is_valid_transition(union drbd_state os, union drbd_state ns)
{
enum drbd_state_rv rv;

rv = is_valid_conn_transition(os.conn, ns.conn);

/* we cannot fail (again) if we already detached */
if (ns.disk == D_FAILED && os.disk == D_DISKLESS)
rv = SS_IS_DISKLESS;
Expand Down

0 comments on commit bf75ee0

Please sign in to comment.