diff options
author | Philipp Reisner <philipp.reisner@linbit.com> | 2011-03-28 09:40:12 -0400 |
---|---|---|
committer | Philipp Reisner <philipp.reisner@linbit.com> | 2012-11-08 10:45:03 -0500 |
commit | 78bae59b1b7bc06c84e292e9ecf42c013723e057 (patch) | |
tree | 1deebbe72eab1b40c6b61f41c369c38e29fa816f /drivers/block/drbd/drbd_state.c | |
parent | e15766e9c94f7fa3396eff4ffbbf30dea8c0e22a (diff) |
drbd: Introduced drbd_read_state()
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Diffstat (limited to 'drivers/block/drbd/drbd_state.c')
-rw-r--r-- | drivers/block/drbd/drbd_state.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/drivers/block/drbd/drbd_state.c b/drivers/block/drbd/drbd_state.c index ca77da38a0dc..411d05f885e1 100644 --- a/drivers/block/drbd/drbd_state.c +++ b/drivers/block/drbd/drbd_state.c | |||
@@ -163,9 +163,8 @@ drbd_change_state(struct drbd_conf *mdev, enum chg_state_flags f, | |||
163 | enum drbd_state_rv rv; | 163 | enum drbd_state_rv rv; |
164 | 164 | ||
165 | spin_lock_irqsave(&mdev->tconn->req_lock, flags); | 165 | spin_lock_irqsave(&mdev->tconn->req_lock, flags); |
166 | ns = apply_mask_val(mdev->state, mask, val); | 166 | ns = apply_mask_val(drbd_read_state(mdev), mask, val); |
167 | rv = _drbd_set_state(mdev, ns, f, NULL); | 167 | rv = _drbd_set_state(mdev, ns, f, NULL); |
168 | ns = mdev->state; | ||
169 | spin_unlock_irqrestore(&mdev->tconn->req_lock, flags); | 168 | spin_unlock_irqrestore(&mdev->tconn->req_lock, flags); |
170 | 169 | ||
171 | return rv; | 170 | return rv; |
@@ -198,7 +197,7 @@ _req_st_cond(struct drbd_conf *mdev, union drbd_state mask, | |||
198 | return SS_CW_FAILED_BY_PEER; | 197 | return SS_CW_FAILED_BY_PEER; |
199 | 198 | ||
200 | spin_lock_irqsave(&mdev->tconn->req_lock, flags); | 199 | spin_lock_irqsave(&mdev->tconn->req_lock, flags); |
201 | os = mdev->state; | 200 | os = drbd_read_state(mdev); |
202 | ns = sanitize_state(mdev, apply_mask_val(os, mask, val), NULL); | 201 | ns = sanitize_state(mdev, apply_mask_val(os, mask, val), NULL); |
203 | rv = is_valid_transition(os, ns); | 202 | rv = is_valid_transition(os, ns); |
204 | if (rv == SS_SUCCESS) | 203 | if (rv == SS_SUCCESS) |
@@ -244,7 +243,7 @@ drbd_req_state(struct drbd_conf *mdev, union drbd_state mask, | |||
244 | mutex_lock(mdev->state_mutex); | 243 | mutex_lock(mdev->state_mutex); |
245 | 244 | ||
246 | spin_lock_irqsave(&mdev->tconn->req_lock, flags); | 245 | spin_lock_irqsave(&mdev->tconn->req_lock, flags); |
247 | os = mdev->state; | 246 | os = drbd_read_state(mdev); |
248 | ns = sanitize_state(mdev, apply_mask_val(os, mask, val), NULL); | 247 | ns = sanitize_state(mdev, apply_mask_val(os, mask, val), NULL); |
249 | rv = is_valid_transition(os, ns); | 248 | rv = is_valid_transition(os, ns); |
250 | if (rv < SS_SUCCESS) { | 249 | if (rv < SS_SUCCESS) { |
@@ -280,7 +279,7 @@ drbd_req_state(struct drbd_conf *mdev, union drbd_state mask, | |||
280 | goto abort; | 279 | goto abort; |
281 | } | 280 | } |
282 | spin_lock_irqsave(&mdev->tconn->req_lock, flags); | 281 | spin_lock_irqsave(&mdev->tconn->req_lock, flags); |
283 | ns = apply_mask_val(mdev->state, mask, val); | 282 | ns = apply_mask_val(drbd_read_state(mdev), mask, val); |
284 | rv = _drbd_set_state(mdev, ns, f, &done); | 283 | rv = _drbd_set_state(mdev, ns, f, &done); |
285 | } else { | 284 | } else { |
286 | rv = _drbd_set_state(mdev, ns, f, &done); | 285 | rv = _drbd_set_state(mdev, ns, f, &done); |
@@ -812,7 +811,7 @@ __drbd_set_state(struct drbd_conf *mdev, union drbd_state ns, | |||
812 | const char *warn_sync_abort = NULL; | 811 | const char *warn_sync_abort = NULL; |
813 | struct after_state_chg_work *ascw; | 812 | struct after_state_chg_work *ascw; |
814 | 813 | ||
815 | os = mdev->state; | 814 | os = drbd_read_state(mdev); |
816 | 815 | ||
817 | ns = sanitize_state(mdev, ns, &warn_sync_abort); | 816 | ns = sanitize_state(mdev, ns, &warn_sync_abort); |
818 | if (ns.i == os.i) | 817 | if (ns.i == os.i) |
@@ -1430,7 +1429,7 @@ conn_is_valid_transition(struct drbd_tconn *tconn, union drbd_state mask, union | |||
1430 | int vnr; | 1429 | int vnr; |
1431 | 1430 | ||
1432 | idr_for_each_entry(&tconn->volumes, mdev, vnr) { | 1431 | idr_for_each_entry(&tconn->volumes, mdev, vnr) { |
1433 | os = mdev->state; | 1432 | os = drbd_read_state(mdev); |
1434 | ns = sanitize_state(mdev, apply_mask_val(os, mask, val), NULL); | 1433 | ns = sanitize_state(mdev, apply_mask_val(os, mask, val), NULL); |
1435 | 1434 | ||
1436 | if (flags & CS_IGN_OUTD_FAIL && ns.disk == D_OUTDATED && os.disk < D_OUTDATED) | 1435 | if (flags & CS_IGN_OUTD_FAIL && ns.disk == D_OUTDATED && os.disk < D_OUTDATED) |
@@ -1474,7 +1473,7 @@ conn_set_state(struct drbd_tconn *tconn, union drbd_state mask, union drbd_state | |||
1474 | tconn->cstate = val.conn; | 1473 | tconn->cstate = val.conn; |
1475 | 1474 | ||
1476 | idr_for_each_entry(&tconn->volumes, mdev, vnr) { | 1475 | idr_for_each_entry(&tconn->volumes, mdev, vnr) { |
1477 | os = mdev->state; | 1476 | os = drbd_read_state(mdev); |
1478 | ns = apply_mask_val(os, mask, val); | 1477 | ns = apply_mask_val(os, mask, val); |
1479 | ns = sanitize_state(mdev, ns, NULL); | 1478 | ns = sanitize_state(mdev, ns, NULL); |
1480 | 1479 | ||