aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Reisner <philipp.reisner@linbit.com>2011-02-11 13:43:55 -0500
committerPhilipp Reisner <philipp.reisner@linbit.com>2011-10-14 10:45:01 -0400
commitdad20554812e73a2bfbe45d1b161d5d3c249e597 (patch)
treecd2e1d689a8366f0f460c63f6c37fc4797ab1820
parentbbeb641c3e4982d6bba21188545a7fd44ab0a715 (diff)
drbd: Removed drbd_state_lock() and drbd_state_unlock()
The lock they constructed is only taken when the state_mutex was already taken. It is superficial. Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com> Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
-rw-r--r--drivers/block/drbd/drbd_int.h18
-rw-r--r--drivers/block/drbd/drbd_receiver.c5
-rw-r--r--drivers/block/drbd/drbd_state.c4
-rw-r--r--drivers/block/drbd/drbd_worker.c10
4 files changed, 8 insertions, 29 deletions
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
index f718124c5c82..2dbcd13ba2af 100644
--- a/drivers/block/drbd/drbd_int.h
+++ b/drivers/block/drbd/drbd_int.h
@@ -764,7 +764,6 @@ enum {
764 UNPLUG_REMOTE, /* sending a "UnplugRemote" could help */ 764 UNPLUG_REMOTE, /* sending a "UnplugRemote" could help */
765 MD_DIRTY, /* current uuids and flags not yet on disk */ 765 MD_DIRTY, /* current uuids and flags not yet on disk */
766 USE_DEGR_WFC_T, /* degr-wfc-timeout instead of wfc-timeout. */ 766 USE_DEGR_WFC_T, /* degr-wfc-timeout instead of wfc-timeout. */
767 CLUSTER_ST_CHANGE, /* Cluster wide state change going on... */
768 CL_ST_CHG_SUCCESS, 767 CL_ST_CHG_SUCCESS,
769 CL_ST_CHG_FAIL, 768 CL_ST_CHG_FAIL,
770 CRASHED_PRIMARY, /* This node was a crashed primary. 769 CRASHED_PRIMARY, /* This node was a crashed primary.
@@ -1664,23 +1663,6 @@ static inline int drbd_ee_has_active_page(struct drbd_peer_request *peer_req)
1664 return 0; 1663 return 0;
1665} 1664}
1666 1665
1667
1668
1669
1670
1671
1672static inline void drbd_state_lock(struct drbd_conf *mdev)
1673{
1674 wait_event(mdev->misc_wait,
1675 !test_and_set_bit(CLUSTER_ST_CHANGE, &mdev->flags));
1676}
1677
1678static inline void drbd_state_unlock(struct drbd_conf *mdev)
1679{
1680 clear_bit(CLUSTER_ST_CHANGE, &mdev->flags);
1681 wake_up(&mdev->misc_wait);
1682}
1683
1684static inline enum drbd_state_rv 1666static inline enum drbd_state_rv
1685_drbd_set_state(struct drbd_conf *mdev, union drbd_state ns, 1667_drbd_set_state(struct drbd_conf *mdev, union drbd_state ns,
1686 enum chg_state_flags flags, struct completion *done) 1668 enum chg_state_flags flags, struct completion *done)
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
index 27e1eb7ce540..423e4dd2d53e 100644
--- a/drivers/block/drbd/drbd_receiver.c
+++ b/drivers/block/drbd/drbd_receiver.c
@@ -3167,7 +3167,8 @@ static int receive_uuids(struct drbd_conf *mdev, enum drbd_packet cmd,
3167 ongoing cluster wide state change is finished. That is important if 3167 ongoing cluster wide state change is finished. That is important if
3168 we are primary and are detaching from our disk. We need to see the 3168 we are primary and are detaching from our disk. We need to see the
3169 new disk state... */ 3169 new disk state... */
3170 wait_event(mdev->misc_wait, !test_bit(CLUSTER_ST_CHANGE, &mdev->flags)); 3170 mutex_lock(&mdev->state_mutex);
3171 mutex_unlock(&mdev->state_mutex);
3171 if (mdev->state.conn >= C_CONNECTED && mdev->state.disk < D_INCONSISTENT) 3172 if (mdev->state.conn >= C_CONNECTED && mdev->state.disk < D_INCONSISTENT)
3172 updated_uuids |= drbd_set_ed_uuid(mdev, p_uuid[UI_CURRENT]); 3173 updated_uuids |= drbd_set_ed_uuid(mdev, p_uuid[UI_CURRENT]);
3173 3174
@@ -3218,7 +3219,7 @@ static int receive_req_state(struct drbd_conf *mdev, enum drbd_packet cmd,
3218 val.i = be32_to_cpu(p->val); 3219 val.i = be32_to_cpu(p->val);
3219 3220
3220 if (test_bit(DISCARD_CONCURRENT, &mdev->tconn->flags) && 3221 if (test_bit(DISCARD_CONCURRENT, &mdev->tconn->flags) &&
3221 test_bit(CLUSTER_ST_CHANGE, &mdev->flags)) { 3222 mutex_is_locked(&mdev->state_mutex)) {
3222 drbd_send_sr_reply(mdev, SS_CONCURRENT_ST_CHG); 3223 drbd_send_sr_reply(mdev, SS_CONCURRENT_ST_CHG);
3223 return true; 3224 return true;
3224 } 3225 }
diff --git a/drivers/block/drbd/drbd_state.c b/drivers/block/drbd/drbd_state.c
index 7376d9dc0bc7..91433168e1d4 100644
--- a/drivers/block/drbd/drbd_state.c
+++ b/drivers/block/drbd/drbd_state.c
@@ -184,9 +184,7 @@ drbd_req_state(struct drbd_conf *mdev, union drbd_state mask,
184 goto abort; 184 goto abort;
185 } 185 }
186 186
187 drbd_state_lock(mdev);
188 if (!drbd_send_state_req(mdev, mask, val)) { 187 if (!drbd_send_state_req(mdev, mask, val)) {
189 drbd_state_unlock(mdev);
190 rv = SS_CW_FAILED_BY_PEER; 188 rv = SS_CW_FAILED_BY_PEER;
191 if (f & CS_VERBOSE) 189 if (f & CS_VERBOSE)
192 print_st_err(mdev, os, ns, rv); 190 print_st_err(mdev, os, ns, rv);
@@ -197,7 +195,6 @@ drbd_req_state(struct drbd_conf *mdev, union drbd_state mask,
197 (rv = _req_st_cond(mdev, mask, val))); 195 (rv = _req_st_cond(mdev, mask, val)));
198 196
199 if (rv < SS_SUCCESS) { 197 if (rv < SS_SUCCESS) {
200 drbd_state_unlock(mdev);
201 if (f & CS_VERBOSE) 198 if (f & CS_VERBOSE)
202 print_st_err(mdev, os, ns, rv); 199 print_st_err(mdev, os, ns, rv);
203 goto abort; 200 goto abort;
@@ -205,7 +202,6 @@ drbd_req_state(struct drbd_conf *mdev, union drbd_state mask,
205 spin_lock_irqsave(&mdev->tconn->req_lock, flags); 202 spin_lock_irqsave(&mdev->tconn->req_lock, flags);
206 ns = apply_mask_val(mdev->state, mask, val); 203 ns = apply_mask_val(mdev->state, mask, val);
207 rv = _drbd_set_state(mdev, ns, f, &done); 204 rv = _drbd_set_state(mdev, ns, f, &done);
208 drbd_state_unlock(mdev);
209 } else { 205 } else {
210 rv = _drbd_set_state(mdev, ns, f, &done); 206 rv = _drbd_set_state(mdev, ns, f, &done);
211 } 207 }
diff --git a/drivers/block/drbd/drbd_worker.c b/drivers/block/drbd/drbd_worker.c
index eee017dd6d7d..e8448712b958 100644
--- a/drivers/block/drbd/drbd_worker.c
+++ b/drivers/block/drbd/drbd_worker.c
@@ -1536,21 +1536,21 @@ void drbd_start_resync(struct drbd_conf *mdev, enum drbd_conns side)
1536 } 1536 }
1537 1537
1538 if (current == mdev->tconn->worker.task) { 1538 if (current == mdev->tconn->worker.task) {
1539 /* The worker should not sleep waiting for drbd_state_lock(), 1539 /* The worker should not sleep waiting for state_mutex,
1540 that can take long */ 1540 that can take long */
1541 if (test_and_set_bit(CLUSTER_ST_CHANGE, &mdev->flags)) { 1541 if (!mutex_trylock(&mdev->state_mutex)) {
1542 set_bit(B_RS_H_DONE, &mdev->flags); 1542 set_bit(B_RS_H_DONE, &mdev->flags);
1543 mdev->start_resync_timer.expires = jiffies + HZ/5; 1543 mdev->start_resync_timer.expires = jiffies + HZ/5;
1544 add_timer(&mdev->start_resync_timer); 1544 add_timer(&mdev->start_resync_timer);
1545 return; 1545 return;
1546 } 1546 }
1547 } else { 1547 } else {
1548 drbd_state_lock(mdev); 1548 mutex_lock(&mdev->state_mutex);
1549 } 1549 }
1550 clear_bit(B_RS_H_DONE, &mdev->flags); 1550 clear_bit(B_RS_H_DONE, &mdev->flags);
1551 1551
1552 if (!get_ldev_if_state(mdev, D_NEGOTIATING)) { 1552 if (!get_ldev_if_state(mdev, D_NEGOTIATING)) {
1553 drbd_state_unlock(mdev); 1553 mutex_unlock(&mdev->state_mutex);
1554 return; 1554 return;
1555 } 1555 }
1556 1556
@@ -1639,7 +1639,7 @@ void drbd_start_resync(struct drbd_conf *mdev, enum drbd_conns side)
1639 drbd_md_sync(mdev); 1639 drbd_md_sync(mdev);
1640 } 1640 }
1641 put_ldev(mdev); 1641 put_ldev(mdev);
1642 drbd_state_unlock(mdev); 1642 mutex_unlock(&mdev->state_mutex);
1643} 1643}
1644 1644
1645static int _worker_dying(int vnr, void *p, void *data) 1645static int _worker_dying(int vnr, void *p, void *data)