aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorLars Ellenberg <lars.ellenberg@linbit.com>2010-07-22 11:39:26 -0400
committerPhilipp Reisner <philipp.reisner@linbit.com>2010-10-14 12:38:46 -0400
commit4ac4aadacb5badc45679cd94cd362132daafe8c4 (patch)
tree3577305d13bd60a536cb8ed156d639e707bdeca4 /drivers/block
parent2b2bf2148fd46874ee72a877c951e5c6675d1caa (diff)
drbd: preparation commit, using full state in receive_state()
no functional change, just using full state instead of just the .conn part of it for comparisons. Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com> Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/drbd/drbd_receiver.c39
1 files changed, 18 insertions, 21 deletions
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
index 45a2d610ca1..585049dfb71 100644
--- a/drivers/block/drbd/drbd_receiver.c
+++ b/drivers/block/drbd/drbd_receiver.c
@@ -3242,8 +3242,7 @@ static int receive_req_state(struct drbd_conf *mdev, enum drbd_packets cmd, unsi
3242static int receive_state(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned int data_size) 3242static int receive_state(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned int data_size)
3243{ 3243{
3244 struct p_state *p = &mdev->data.rbuf.state; 3244 struct p_state *p = &mdev->data.rbuf.state;
3245 enum drbd_conns nconn, oconn; 3245 union drbd_state os, ns, peer_state;
3246 union drbd_state ns, peer_state;
3247 enum drbd_disk_state real_peer_disk; 3246 enum drbd_disk_state real_peer_disk;
3248 enum chg_state_flags cs_flags; 3247 enum chg_state_flags cs_flags;
3249 int rv; 3248 int rv;
@@ -3258,38 +3257,38 @@ static int receive_state(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned
3258 3257
3259 spin_lock_irq(&mdev->req_lock); 3258 spin_lock_irq(&mdev->req_lock);
3260 retry: 3259 retry:
3261 oconn = nconn = mdev->state.conn; 3260 os = ns = mdev->state;
3262 spin_unlock_irq(&mdev->req_lock); 3261 spin_unlock_irq(&mdev->req_lock);
3263 3262
3264 if (nconn == C_WF_REPORT_PARAMS) 3263 if (ns.conn == C_WF_REPORT_PARAMS)
3265 nconn = C_CONNECTED; 3264 ns.conn = C_CONNECTED;
3266 3265
3267 if (mdev->p_uuid && peer_state.disk >= D_NEGOTIATING && 3266 if (mdev->p_uuid && peer_state.disk >= D_NEGOTIATING &&
3268 get_ldev_if_state(mdev, D_NEGOTIATING)) { 3267 get_ldev_if_state(mdev, D_NEGOTIATING)) {
3269 int cr; /* consider resync */ 3268 int cr; /* consider resync */
3270 3269
3271 /* if we established a new connection */ 3270 /* if we established a new connection */
3272 cr = (oconn < C_CONNECTED); 3271 cr = (os.conn < C_CONNECTED);
3273 /* if we had an established connection 3272 /* if we had an established connection
3274 * and one of the nodes newly attaches a disk */ 3273 * and one of the nodes newly attaches a disk */
3275 cr |= (oconn == C_CONNECTED && 3274 cr |= (os.conn == C_CONNECTED &&
3276 (peer_state.disk == D_NEGOTIATING || 3275 (peer_state.disk == D_NEGOTIATING ||
3277 mdev->state.disk == D_NEGOTIATING)); 3276 os.disk == D_NEGOTIATING));
3278 /* if we have both been inconsistent, and the peer has been 3277 /* if we have both been inconsistent, and the peer has been
3279 * forced to be UpToDate with --overwrite-data */ 3278 * forced to be UpToDate with --overwrite-data */
3280 cr |= test_bit(CONSIDER_RESYNC, &mdev->flags); 3279 cr |= test_bit(CONSIDER_RESYNC, &mdev->flags);
3281 /* if we had been plain connected, and the admin requested to 3280 /* if we had been plain connected, and the admin requested to
3282 * start a sync by "invalidate" or "invalidate-remote" */ 3281 * start a sync by "invalidate" or "invalidate-remote" */
3283 cr |= (oconn == C_CONNECTED && 3282 cr |= (os.conn == C_CONNECTED &&
3284 (peer_state.conn >= C_STARTING_SYNC_S && 3283 (peer_state.conn >= C_STARTING_SYNC_S &&
3285 peer_state.conn <= C_WF_BITMAP_T)); 3284 peer_state.conn <= C_WF_BITMAP_T));
3286 3285
3287 if (cr) 3286 if (cr)
3288 nconn = drbd_sync_handshake(mdev, peer_state.role, real_peer_disk); 3287 ns.conn = drbd_sync_handshake(mdev, peer_state.role, real_peer_disk);
3289 3288
3290 put_ldev(mdev); 3289 put_ldev(mdev);
3291 if (nconn == C_MASK) { 3290 if (ns.conn == C_MASK) {
3292 nconn = C_CONNECTED; 3291 ns.conn = C_CONNECTED;
3293 if (mdev->state.disk == D_NEGOTIATING) { 3292 if (mdev->state.disk == D_NEGOTIATING) {
3294 drbd_force_state(mdev, NS(disk, D_DISKLESS)); 3293 drbd_force_state(mdev, NS(disk, D_DISKLESS));
3295 } else if (peer_state.disk == D_NEGOTIATING) { 3294 } else if (peer_state.disk == D_NEGOTIATING) {
@@ -3299,7 +3298,7 @@ static int receive_state(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned
3299 } else { 3298 } else {
3300 if (test_and_clear_bit(CONN_DRY_RUN, &mdev->flags)) 3299 if (test_and_clear_bit(CONN_DRY_RUN, &mdev->flags))
3301 return FALSE; 3300 return FALSE;
3302 D_ASSERT(oconn == C_WF_REPORT_PARAMS); 3301 D_ASSERT(os.conn == C_WF_REPORT_PARAMS);
3303 drbd_force_state(mdev, NS(conn, C_DISCONNECTING)); 3302 drbd_force_state(mdev, NS(conn, C_DISCONNECTING));
3304 return FALSE; 3303 return FALSE;
3305 } 3304 }
@@ -3307,18 +3306,16 @@ static int receive_state(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned
3307 } 3306 }
3308 3307
3309 spin_lock_irq(&mdev->req_lock); 3308 spin_lock_irq(&mdev->req_lock);
3310 if (mdev->state.conn != oconn) 3309 if (mdev->state.i != os.i)
3311 goto retry; 3310 goto retry;
3312 clear_bit(CONSIDER_RESYNC, &mdev->flags); 3311 clear_bit(CONSIDER_RESYNC, &mdev->flags);
3313 ns.i = mdev->state.i;
3314 ns.conn = nconn;
3315 ns.peer = peer_state.role; 3312 ns.peer = peer_state.role;
3316 ns.pdsk = real_peer_disk; 3313 ns.pdsk = real_peer_disk;
3317 ns.peer_isp = (peer_state.aftr_isp | peer_state.user_isp); 3314 ns.peer_isp = (peer_state.aftr_isp | peer_state.user_isp);
3318 if ((nconn == C_CONNECTED || nconn == C_WF_BITMAP_S) && ns.disk == D_NEGOTIATING) 3315 if ((ns.conn == C_CONNECTED || ns.conn == C_WF_BITMAP_S) && ns.disk == D_NEGOTIATING)
3319 ns.disk = mdev->new_state_tmp.disk; 3316 ns.disk = mdev->new_state_tmp.disk;
3320 cs_flags = CS_VERBOSE + (oconn < C_CONNECTED && nconn >= C_CONNECTED ? 0 : CS_HARD); 3317 cs_flags = CS_VERBOSE + (os.conn < C_CONNECTED && ns.conn >= C_CONNECTED ? 0 : CS_HARD);
3321 if (ns.pdsk == D_CONSISTENT && is_susp(ns) && nconn == C_CONNECTED && oconn < C_CONNECTED && 3318 if (ns.pdsk == D_CONSISTENT && is_susp(ns) && ns.conn == C_CONNECTED && os.conn < C_CONNECTED &&
3322 test_bit(NEW_CUR_UUID, &mdev->flags)) { 3319 test_bit(NEW_CUR_UUID, &mdev->flags)) {
3323 /* Do not allow tl_restart(resend) for a rebooted peer. We can only allow this 3320 /* Do not allow tl_restart(resend) for a rebooted peer. We can only allow this
3324 for temporal network outages! */ 3321 for temporal network outages! */
@@ -3339,8 +3336,8 @@ static int receive_state(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned
3339 return FALSE; 3336 return FALSE;
3340 } 3337 }
3341 3338
3342 if (oconn > C_WF_REPORT_PARAMS) { 3339 if (os.conn > C_WF_REPORT_PARAMS) {
3343 if (nconn > C_CONNECTED && peer_state.conn <= C_CONNECTED && 3340 if (ns.conn > C_CONNECTED && peer_state.conn <= C_CONNECTED &&
3344 peer_state.disk != D_NEGOTIATING ) { 3341 peer_state.disk != D_NEGOTIATING ) {
3345 /* we want resync, peer has not yet decided to sync... */ 3342 /* we want resync, peer has not yet decided to sync... */
3346 /* Nowadays only used when forcing a node into primary role and 3343 /* Nowadays only used when forcing a node into primary role and