Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 345806
b: refs/heads/master
c: 56707f9
h: refs/heads/master
v: v3
  • Loading branch information
Philipp Reisner committed Sep 28, 2011
1 parent 60c2635 commit 5843e49
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 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: 4308a0a390deee88b6de6dbf8b05bcf0f506bbcf
refs/heads/master: 56707f9e873108c0173b4edf20ea452e1d2a89d2
22 changes: 13 additions & 9 deletions trunk/drivers/block/drbd/drbd_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,24 @@ static int cl_wide_st_chg(struct drbd_conf *mdev,
(os.conn == C_CONNECTED && ns.conn == C_VERIFY_S);
}

static union drbd_state
apply_mask_val(union drbd_state os, union drbd_state mask, union drbd_state val)
{
union drbd_state ns;
ns.i = (os.i & ~mask.i) | val.i;
return ns;
}

enum drbd_state_rv
drbd_change_state(struct drbd_conf *mdev, enum chg_state_flags f,
union drbd_state mask, union drbd_state val)
{
unsigned long flags;
union drbd_state os, ns;
union drbd_state ns;
enum drbd_state_rv rv;

spin_lock_irqsave(&mdev->tconn->req_lock, flags);
os = mdev->state;
ns.i = (os.i & ~mask.i) | val.i;
ns = apply_mask_val(mdev->state, mask, val);
rv = _drbd_set_state(mdev, ns, f, NULL);
ns = mdev->state;
spin_unlock_irqrestore(&mdev->tconn->req_lock, flags);
Expand Down Expand Up @@ -115,8 +122,7 @@ _req_st_cond(struct drbd_conf *mdev, union drbd_state mask,

spin_lock_irqsave(&mdev->tconn->req_lock, flags);
os = mdev->state;
ns.i = (os.i & ~mask.i) | val.i;
ns = sanitize_state(mdev, ns, NULL);
ns = sanitize_state(mdev, apply_mask_val(os, mask, val), NULL);
rv = is_valid_transition(os, ns);
if (rv == SS_SUCCESS)
rv = SS_UNKNOWN_ERROR; /* cont waiting, otherwise fail. */
Expand Down Expand Up @@ -162,8 +168,7 @@ drbd_req_state(struct drbd_conf *mdev, union drbd_state mask,

spin_lock_irqsave(&mdev->tconn->req_lock, flags);
os = mdev->state;
ns.i = (os.i & ~mask.i) | val.i;
ns = sanitize_state(mdev, ns, NULL);
ns = sanitize_state(mdev, apply_mask_val(os, mask, val), NULL);
rv = is_valid_transition(os, ns);
if (rv < SS_SUCCESS)
goto abort;
Expand Down Expand Up @@ -199,8 +204,7 @@ drbd_req_state(struct drbd_conf *mdev, union drbd_state mask,
goto abort;
}
spin_lock_irqsave(&mdev->tconn->req_lock, flags);
os = mdev->state;
ns.i = (os.i & ~mask.i) | val.i;
ns = apply_mask_val(mdev->state, mask, val);
rv = _drbd_set_state(mdev, ns, f, &done);
drbd_state_unlock(mdev);
} else {
Expand Down

0 comments on commit 5843e49

Please sign in to comment.