Commit 4308a0a3 authored by Philipp Reisner's avatar Philipp Reisner

drbd: Removed the os parameter form sanitize_state()

Signed-off-by: default avatarPhilipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: default avatarLars Ellenberg <lars.ellenberg@linbit.com>
parent fda74117
...@@ -48,8 +48,8 @@ static void after_conn_state_ch(struct drbd_tconn *tconn, union drbd_state os, ...@@ -48,8 +48,8 @@ static void after_conn_state_ch(struct drbd_tconn *tconn, union drbd_state os,
static enum drbd_state_rv is_valid_state(struct drbd_conf *, union drbd_state); static enum drbd_state_rv is_valid_state(struct drbd_conf *, union drbd_state);
static enum drbd_state_rv is_valid_soft_transition(union drbd_state, union drbd_state); static enum drbd_state_rv is_valid_soft_transition(union drbd_state, union drbd_state);
static enum drbd_state_rv is_valid_transition(union drbd_state os, union drbd_state ns); static enum drbd_state_rv is_valid_transition(union drbd_state os, union drbd_state ns);
static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state os, static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state ns,
union drbd_state ns, const char **warn_sync_abort); const char **warn_sync_abort);
/** /**
* cl_wide_st_chg() - true if the state change is a cluster wide one * cl_wide_st_chg() - true if the state change is a cluster wide one
...@@ -116,7 +116,7 @@ _req_st_cond(struct drbd_conf *mdev, union drbd_state mask, ...@@ -116,7 +116,7 @@ _req_st_cond(struct drbd_conf *mdev, union drbd_state mask,
spin_lock_irqsave(&mdev->tconn->req_lock, flags); spin_lock_irqsave(&mdev->tconn->req_lock, flags);
os = mdev->state; os = mdev->state;
ns.i = (os.i & ~mask.i) | val.i; ns.i = (os.i & ~mask.i) | val.i;
ns = sanitize_state(mdev, os, ns, NULL); ns = sanitize_state(mdev, ns, NULL);
rv = is_valid_transition(os, ns); rv = is_valid_transition(os, ns);
if (rv == SS_SUCCESS) if (rv == SS_SUCCESS)
rv = SS_UNKNOWN_ERROR; /* cont waiting, otherwise fail. */ rv = SS_UNKNOWN_ERROR; /* cont waiting, otherwise fail. */
...@@ -163,7 +163,7 @@ drbd_req_state(struct drbd_conf *mdev, union drbd_state mask, ...@@ -163,7 +163,7 @@ drbd_req_state(struct drbd_conf *mdev, union drbd_state mask,
spin_lock_irqsave(&mdev->tconn->req_lock, flags); spin_lock_irqsave(&mdev->tconn->req_lock, flags);
os = mdev->state; os = mdev->state;
ns.i = (os.i & ~mask.i) | val.i; ns.i = (os.i & ~mask.i) | val.i;
ns = sanitize_state(mdev, os, ns, NULL); ns = sanitize_state(mdev, ns, NULL);
rv = is_valid_transition(os, ns); rv = is_valid_transition(os, ns);
if (rv < SS_SUCCESS) if (rv < SS_SUCCESS)
goto abort; goto abort;
...@@ -436,6 +436,13 @@ is_valid_transition(union drbd_state os, union drbd_state ns) ...@@ -436,6 +436,13 @@ is_valid_transition(union drbd_state os, union drbd_state ns)
if (ns.disk == D_FAILED && os.disk == D_DISKLESS) if (ns.disk == D_FAILED && os.disk == D_DISKLESS)
rv = SS_IS_DISKLESS; rv = SS_IS_DISKLESS;
/* if we are only D_ATTACHING yet,
* we can (and should) go directly to D_DISKLESS. */
if (ns.disk == D_FAILED && os.disk == D_ATTACHING) {
printk("TODO: FIX ME\n");
rv = SS_IS_DISKLESS;
}
return rv; return rv;
} }
...@@ -449,8 +456,8 @@ is_valid_transition(union drbd_state os, union drbd_state ns) ...@@ -449,8 +456,8 @@ is_valid_transition(union drbd_state os, union drbd_state ns)
* When we loose connection, we have to set the state of the peers disk (pdsk) * When we loose connection, we have to set the state of the peers disk (pdsk)
* to D_UNKNOWN. This rule and many more along those lines are in this function. * to D_UNKNOWN. This rule and many more along those lines are in this function.
*/ */
static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state os, static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state ns,
union drbd_state ns, const char **warn_sync_abort) const char **warn_sync_abort)
{ {
enum drbd_fencing_p fp; enum drbd_fencing_p fp;
enum drbd_disk_state disk_min, disk_max, pdsk_min, pdsk_max; enum drbd_disk_state disk_min, disk_max, pdsk_min, pdsk_max;
...@@ -461,11 +468,6 @@ static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state ...@@ -461,11 +468,6 @@ static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state
put_ldev(mdev); put_ldev(mdev);
} }
/* if we are only D_ATTACHING yet,
* we can (and should) go directly to D_DISKLESS. */
if (ns.disk == D_FAILED && os.disk == D_ATTACHING)
ns.disk = D_DISKLESS;
/* Implications from connection to peer and peer_isp */ /* Implications from connection to peer and peer_isp */
if (ns.conn < C_CONNECTED) { if (ns.conn < C_CONNECTED) {
ns.peer_isp = 0; ns.peer_isp = 0;
...@@ -478,12 +480,12 @@ static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state ...@@ -478,12 +480,12 @@ static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state
if (ns.conn == C_STANDALONE && ns.disk == D_DISKLESS && ns.role == R_SECONDARY) if (ns.conn == C_STANDALONE && ns.disk == D_DISKLESS && ns.role == R_SECONDARY)
ns.aftr_isp = 0; ns.aftr_isp = 0;
/* An implication of the disk states onto the connection state */
/* Abort resync if a disk fails/detaches */ /* Abort resync if a disk fails/detaches */
if (os.conn > C_CONNECTED && ns.conn > C_CONNECTED && if (ns.conn > C_CONNECTED && (ns.disk <= D_FAILED || ns.pdsk <= D_FAILED)) {
(ns.disk <= D_FAILED || ns.pdsk <= D_FAILED)) {
if (warn_sync_abort) if (warn_sync_abort)
*warn_sync_abort = *warn_sync_abort =
os.conn == C_VERIFY_S || os.conn == C_VERIFY_T ? ns.conn == C_VERIFY_S || ns.conn == C_VERIFY_T ?
"Online-verify" : "Resync"; "Online-verify" : "Resync";
ns.conn = C_CONNECTED; ns.conn = C_CONNECTED;
} }
...@@ -591,13 +593,11 @@ static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state ...@@ -591,13 +593,11 @@ static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state
} }
if (fp == FP_STONITH && if (fp == FP_STONITH &&
(ns.role == R_PRIMARY && ns.conn < C_CONNECTED && ns.pdsk > D_OUTDATED) && (ns.role == R_PRIMARY && ns.conn < C_CONNECTED && ns.pdsk > D_OUTDATED))
!(os.role == R_PRIMARY && os.conn < C_CONNECTED && os.pdsk > D_OUTDATED))
ns.susp_fen = 1; /* Suspend IO while fence-peer handler runs (peer lost) */ ns.susp_fen = 1; /* Suspend IO while fence-peer handler runs (peer lost) */
if (mdev->sync_conf.on_no_data == OND_SUSPEND_IO && if (mdev->sync_conf.on_no_data == OND_SUSPEND_IO &&
(ns.role == R_PRIMARY && ns.disk < D_UP_TO_DATE && ns.pdsk < D_UP_TO_DATE) && (ns.role == R_PRIMARY && ns.disk < D_UP_TO_DATE && ns.pdsk < D_UP_TO_DATE))
!(os.role == R_PRIMARY && os.disk < D_UP_TO_DATE && os.pdsk < D_UP_TO_DATE))
ns.susp_nod = 1; /* Suspend IO while no data available (no accessible data available) */ ns.susp_nod = 1; /* Suspend IO while no data available (no accessible data available) */
if (ns.aftr_isp || ns.peer_isp || ns.user_isp) { if (ns.aftr_isp || ns.peer_isp || ns.user_isp) {
...@@ -668,8 +668,7 @@ __drbd_set_state(struct drbd_conf *mdev, union drbd_state ns, ...@@ -668,8 +668,7 @@ __drbd_set_state(struct drbd_conf *mdev, union drbd_state ns,
os = mdev->state; os = mdev->state;
ns = sanitize_state(mdev, os, ns, &warn_sync_abort); ns = sanitize_state(mdev, ns, &warn_sync_abort);
if (ns.i == os.i) if (ns.i == os.i)
return SS_NOTHING_TO_DO; return SS_NOTHING_TO_DO;
......
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