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)
{
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,
}
rv = _drbd_set_state(mdev, ns, CS_VERBOSE, NULL);
- ns = mdev->state;
spin_unlock_irq(&mdev->tconn->req_lock);
if (rv < SS_SUCCESS)
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,
}
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;
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) {
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;
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)
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) {
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);
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)
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)
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);
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 {
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);
}
write_lock_irq(&global_state_lock);
- ns = mdev->state;
+ ns = drbd_read_state(mdev);
ns.aftr_isp = !_drbd_may_sync_now(mdev);
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;