diff options
author | Philipp Reisner <philipp.reisner@linbit.com> | 2011-03-28 15:40:12 +0200 |
---|---|---|
committer | Philipp Reisner <philipp.reisner@linbit.com> | 2012-11-08 16:45:03 +0100 |
commit | 78bae59b1b7bc06c84e292e9ecf42c013723e057 (patch) | |
tree | 1deebbe72eab1b40c6b61f41c369c38e29fa816f /drivers/block/drbd | |
parent | e15766e9c94f7fa3396eff4ffbbf30dea8c0e22a (diff) | |
download | linux-78bae59b1b7bc06c84e292e9ecf42c013723e057.tar.bz2 |
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')
-rw-r--r-- | drivers/block/drbd/drbd_int.h | 9 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_nl.c | 5 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_receiver.c | 6 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_state.c | 15 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_state.h | 6 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_worker.c | 6 |
6 files changed, 27 insertions, 20 deletions
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h index 2dbffb3b5485..24aed86e7364 100644 --- a/drivers/block/drbd/drbd_int.h +++ b/drivers/block/drbd/drbd_int.h @@ -1682,6 +1682,15 @@ _drbd_set_state(struct drbd_conf *mdev, union drbd_state ns, return rv; } +static inline union drbd_state drbd_read_state(struct drbd_conf *mdev) +{ + union drbd_state rv; + + rv = mdev->state; + + return rv; +} + #define __drbd_chk_io_error(m,f) __drbd_chk_io_error_(m,f, __func__) static inline void __drbd_chk_io_error_(struct drbd_conf *mdev, int forcedetach, const char *where) { diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c index 85290a9beb6d..75caac70aaae 100644 --- a/drivers/block/drbd/drbd_nl.c +++ b/drivers/block/drbd/drbd_nl.c @@ -1503,8 +1503,8 @@ int drbd_adm_attach(struct sk_buff *skb, struct genl_info *info) drbd_suspend_al(mdev); /* IO is still suspended here... */ spin_lock_irq(&mdev->tconn->req_lock); - os = mdev->state; - ns.i = os.i; + os = drbd_read_state(mdev); + ns = os; /* If MDF_CONSISTENT is not set go into inconsistent state, otherwise investigate MDF_WasUpToDate... If MDF_WAS_UP_TO_DATE is not set go into D_OUTDATED disk state, @@ -1546,7 +1546,6 @@ int drbd_adm_attach(struct sk_buff *skb, struct genl_info *info) } rv = _drbd_set_state(mdev, ns, CS_VERBOSE, NULL); - ns = mdev->state; spin_unlock_irq(&mdev->tconn->req_lock); if (rv < SS_SUCCESS) diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c index c456a141eeec..28cb19c8e264 100644 --- a/drivers/block/drbd/drbd_receiver.c +++ b/drivers/block/drbd/drbd_receiver.c @@ -3473,7 +3473,7 @@ static int receive_state(struct drbd_tconn *tconn, struct packet_info *pi) spin_lock_irq(&mdev->tconn->req_lock); retry: - os = ns = mdev->state; + os = ns = drbd_read_state(mdev); spin_unlock_irq(&mdev->tconn->req_lock); /* peer says his disk is uptodate, while we think it is inconsistent, @@ -3559,7 +3559,7 @@ static int receive_state(struct drbd_tconn *tconn, struct packet_info *pi) } spin_lock_irq(&mdev->tconn->req_lock); - if (mdev->state.i != os.i) + if (os.i != drbd_read_state(mdev).i) goto retry; clear_bit(CONSIDER_RESYNC, &mdev->flags); ns.peer = peer_state.role; @@ -3581,7 +3581,7 @@ static int receive_state(struct drbd_tconn *tconn, struct packet_info *pi) return -EIO; } rv = _drbd_set_state(mdev, ns, cs_flags, NULL); - ns = mdev->state; + ns = drbd_read_state(mdev); spin_unlock_irq(&mdev->tconn->req_lock); if (rv < SS_SUCCESS) { 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, enum drbd_state_rv rv; spin_lock_irqsave(&mdev->tconn->req_lock, flags); - ns = apply_mask_val(mdev->state, mask, val); + ns = apply_mask_val(drbd_read_state(mdev), mask, val); rv = _drbd_set_state(mdev, ns, f, NULL); - ns = mdev->state; spin_unlock_irqrestore(&mdev->tconn->req_lock, flags); return rv; @@ -198,7 +197,7 @@ _req_st_cond(struct drbd_conf *mdev, union drbd_state mask, return SS_CW_FAILED_BY_PEER; spin_lock_irqsave(&mdev->tconn->req_lock, flags); - os = mdev->state; + os = drbd_read_state(mdev); ns = sanitize_state(mdev, apply_mask_val(os, mask, val), NULL); rv = is_valid_transition(os, ns); if (rv == SS_SUCCESS) @@ -244,7 +243,7 @@ drbd_req_state(struct drbd_conf *mdev, union drbd_state mask, mutex_lock(mdev->state_mutex); spin_lock_irqsave(&mdev->tconn->req_lock, flags); - os = mdev->state; + os = drbd_read_state(mdev); ns = sanitize_state(mdev, apply_mask_val(os, mask, val), NULL); rv = is_valid_transition(os, ns); if (rv < SS_SUCCESS) { @@ -280,7 +279,7 @@ drbd_req_state(struct drbd_conf *mdev, union drbd_state mask, goto abort; } spin_lock_irqsave(&mdev->tconn->req_lock, flags); - ns = apply_mask_val(mdev->state, mask, val); + ns = apply_mask_val(drbd_read_state(mdev), mask, val); rv = _drbd_set_state(mdev, ns, f, &done); } else { rv = _drbd_set_state(mdev, ns, f, &done); @@ -812,7 +811,7 @@ __drbd_set_state(struct drbd_conf *mdev, union drbd_state ns, const char *warn_sync_abort = NULL; struct after_state_chg_work *ascw; - os = mdev->state; + os = drbd_read_state(mdev); ns = sanitize_state(mdev, ns, &warn_sync_abort); if (ns.i == os.i) @@ -1430,7 +1429,7 @@ conn_is_valid_transition(struct drbd_tconn *tconn, union drbd_state mask, union int vnr; idr_for_each_entry(&tconn->volumes, mdev, vnr) { - os = mdev->state; + os = drbd_read_state(mdev); ns = sanitize_state(mdev, apply_mask_val(os, mask, val), NULL); 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 tconn->cstate = val.conn; idr_for_each_entry(&tconn->volumes, mdev, vnr) { - os = mdev->state; + os = drbd_read_state(mdev); ns = apply_mask_val(os, mask, val); ns = sanitize_state(mdev, ns, NULL); diff --git a/drivers/block/drbd/drbd_state.h b/drivers/block/drbd/drbd_state.h index c0331f18371a..fdcfab9c1d84 100644 --- a/drivers/block/drbd/drbd_state.h +++ b/drivers/block/drbd/drbd_state.h @@ -48,12 +48,12 @@ struct drbd_tconn; val.T2 = (S2); val.T3 = (S3); val; }) #define _NS(D, T, S) \ - D, ({ union drbd_state __ns; __ns.i = D->state.i; __ns.T = (S); __ns; }) + D, ({ union drbd_state __ns; __ns = drbd_read_state(D); __ns.T = (S); __ns; }) #define _NS2(D, T1, S1, T2, S2) \ - D, ({ union drbd_state __ns; __ns.i = D->state.i; __ns.T1 = (S1); \ + D, ({ union drbd_state __ns; __ns = drbd_read_state(D); __ns.T1 = (S1); \ __ns.T2 = (S2); __ns; }) #define _NS3(D, T1, S1, T2, S2, T3, S3) \ - D, ({ union drbd_state __ns; __ns.i = D->state.i; __ns.T1 = (S1); \ + D, ({ union drbd_state __ns; __ns = drbd_read_state(D); __ns.T1 = (S1); \ __ns.T2 = (S2); __ns.T3 = (S3); __ns; }) enum chg_state_flags { diff --git a/drivers/block/drbd/drbd_worker.c b/drivers/block/drbd/drbd_worker.c index ab73aa2fb4ee..7350466ff30c 100644 --- a/drivers/block/drbd/drbd_worker.c +++ b/drivers/block/drbd/drbd_worker.c @@ -781,7 +781,7 @@ int drbd_resync_finished(struct drbd_conf *mdev) ping_peer(mdev); spin_lock_irq(&mdev->tconn->req_lock); - os = mdev->state; + os = drbd_read_state(mdev); verify_done = (os.conn == C_VERIFY_S || os.conn == C_VERIFY_T); @@ -1546,7 +1546,7 @@ void drbd_start_resync(struct drbd_conf *mdev, enum drbd_conns side) } write_lock_irq(&global_state_lock); - ns = mdev->state; + ns = drbd_read_state(mdev); ns.aftr_isp = !_drbd_may_sync_now(mdev); @@ -1558,7 +1558,7 @@ void drbd_start_resync(struct drbd_conf *mdev, enum drbd_conns side) ns.pdsk = D_INCONSISTENT; r = __drbd_set_state(mdev, ns, CS_VERBOSE, NULL); - ns = mdev->state; + ns = drbd_read_state(mdev); if (ns.conn < C_CONNECTED) r = SS_UNKNOWN_ERROR; |