diff options
author | Andreas Gruenbacher <agruen@linbit.com> | 2011-08-08 21:54:55 -0400 |
---|---|---|
committer | Philipp Reisner <philipp.reisner@linbit.com> | 2014-02-17 10:49:37 -0500 |
commit | 9f4fe9ad206028fb77fe8d1b485f81d186df1645 (patch) | |
tree | fd8e66f729ba3a2127a4ddba0d776717f540c14c | |
parent | 79a3c8d38cabd1a900340852e527b0a4ce8a459d (diff) |
drbd: Replace vnr_to_mdev() with conn_peer_device()
The new function returns a peer device, which allows us to eliminate a few
instances of first_peer_device().
Signed-off-by: Andreas Gruenbacher <agruen@linbit.com>
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
-rw-r--r-- | drivers/block/drbd/drbd_int.h | 8 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_receiver.c | 174 |
2 files changed, 109 insertions, 73 deletions
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h index 4f4d2dbe1bb9..26211513d6de 100644 --- a/drivers/block/drbd/drbd_int.h +++ b/drivers/block/drbd/drbd_int.h | |||
@@ -856,14 +856,6 @@ static inline unsigned int device_to_minor(struct drbd_device *device) | |||
856 | return device->minor; | 856 | return device->minor; |
857 | } | 857 | } |
858 | 858 | ||
859 | static inline struct drbd_device *vnr_to_device(struct drbd_connection *connection, int vnr) | ||
860 | { | ||
861 | struct drbd_peer_device *peer_device; | ||
862 | |||
863 | peer_device = idr_find(&connection->peer_devices, vnr); | ||
864 | return peer_device ? peer_device->device : NULL; | ||
865 | } | ||
866 | |||
867 | /* | 859 | /* |
868 | * function declarations | 860 | * function declarations |
869 | *************************/ | 861 | *************************/ |
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c index a4655e579ed6..701c3293b09b 100644 --- a/drivers/block/drbd/drbd_receiver.c +++ b/drivers/block/drbd/drbd_receiver.c | |||
@@ -1422,6 +1422,12 @@ static void conn_wait_active_ee_empty(struct drbd_connection *connection) | |||
1422 | rcu_read_unlock(); | 1422 | rcu_read_unlock(); |
1423 | } | 1423 | } |
1424 | 1424 | ||
1425 | static struct drbd_peer_device * | ||
1426 | conn_peer_device(struct drbd_connection *connection, int volume_number) | ||
1427 | { | ||
1428 | return idr_find(&connection->peer_devices, volume_number); | ||
1429 | } | ||
1430 | |||
1425 | static int receive_Barrier(struct drbd_connection *connection, struct packet_info *pi) | 1431 | static int receive_Barrier(struct drbd_connection *connection, struct packet_info *pi) |
1426 | { | 1432 | { |
1427 | int rv; | 1433 | int rv; |
@@ -1731,15 +1737,17 @@ find_request(struct drbd_device *device, struct rb_root *root, u64 id, | |||
1731 | 1737 | ||
1732 | static int receive_DataReply(struct drbd_connection *connection, struct packet_info *pi) | 1738 | static int receive_DataReply(struct drbd_connection *connection, struct packet_info *pi) |
1733 | { | 1739 | { |
1740 | struct drbd_peer_device *peer_device; | ||
1734 | struct drbd_device *device; | 1741 | struct drbd_device *device; |
1735 | struct drbd_request *req; | 1742 | struct drbd_request *req; |
1736 | sector_t sector; | 1743 | sector_t sector; |
1737 | int err; | 1744 | int err; |
1738 | struct p_data *p = pi->data; | 1745 | struct p_data *p = pi->data; |
1739 | 1746 | ||
1740 | device = vnr_to_device(connection, pi->vnr); | 1747 | peer_device = conn_peer_device(connection, pi->vnr); |
1741 | if (!device) | 1748 | if (!peer_device) |
1742 | return -EIO; | 1749 | return -EIO; |
1750 | device = peer_device->device; | ||
1743 | 1751 | ||
1744 | sector = be64_to_cpu(p->sector); | 1752 | sector = be64_to_cpu(p->sector); |
1745 | 1753 | ||
@@ -1764,14 +1772,16 @@ static int receive_DataReply(struct drbd_connection *connection, struct packet_i | |||
1764 | 1772 | ||
1765 | static int receive_RSDataReply(struct drbd_connection *connection, struct packet_info *pi) | 1773 | static int receive_RSDataReply(struct drbd_connection *connection, struct packet_info *pi) |
1766 | { | 1774 | { |
1775 | struct drbd_peer_device *peer_device; | ||
1767 | struct drbd_device *device; | 1776 | struct drbd_device *device; |
1768 | sector_t sector; | 1777 | sector_t sector; |
1769 | int err; | 1778 | int err; |
1770 | struct p_data *p = pi->data; | 1779 | struct p_data *p = pi->data; |
1771 | 1780 | ||
1772 | device = vnr_to_device(connection, pi->vnr); | 1781 | peer_device = conn_peer_device(connection, pi->vnr); |
1773 | if (!device) | 1782 | if (!peer_device) |
1774 | return -EIO; | 1783 | return -EIO; |
1784 | device = peer_device->device; | ||
1775 | 1785 | ||
1776 | sector = be64_to_cpu(p->sector); | 1786 | sector = be64_to_cpu(p->sector); |
1777 | D_ASSERT(device, p->block_id == ID_SYNCER); | 1787 | D_ASSERT(device, p->block_id == ID_SYNCER); |
@@ -2154,6 +2164,7 @@ static int handle_write_conflicts(struct drbd_device *device, | |||
2154 | /* mirrored write */ | 2164 | /* mirrored write */ |
2155 | static int receive_Data(struct drbd_connection *connection, struct packet_info *pi) | 2165 | static int receive_Data(struct drbd_connection *connection, struct packet_info *pi) |
2156 | { | 2166 | { |
2167 | struct drbd_peer_device *peer_device; | ||
2157 | struct drbd_device *device; | 2168 | struct drbd_device *device; |
2158 | sector_t sector; | 2169 | sector_t sector; |
2159 | struct drbd_peer_request *peer_req; | 2170 | struct drbd_peer_request *peer_req; |
@@ -2163,9 +2174,10 @@ static int receive_Data(struct drbd_connection *connection, struct packet_info * | |||
2163 | u32 dp_flags; | 2174 | u32 dp_flags; |
2164 | int err, tp; | 2175 | int err, tp; |
2165 | 2176 | ||
2166 | device = vnr_to_device(connection, pi->vnr); | 2177 | peer_device = conn_peer_device(connection, pi->vnr); |
2167 | if (!device) | 2178 | if (!peer_device) |
2168 | return -EIO; | 2179 | return -EIO; |
2180 | device = peer_device->device; | ||
2169 | 2181 | ||
2170 | if (!get_ldev(device)) { | 2182 | if (!get_ldev(device)) { |
2171 | int err2; | 2183 | int err2; |
@@ -2211,7 +2223,7 @@ static int receive_Data(struct drbd_connection *connection, struct packet_info * | |||
2211 | spin_unlock(&connection->epoch_lock); | 2223 | spin_unlock(&connection->epoch_lock); |
2212 | 2224 | ||
2213 | rcu_read_lock(); | 2225 | rcu_read_lock(); |
2214 | tp = rcu_dereference(first_peer_device(device)->connection->net_conf)->two_primaries; | 2226 | tp = rcu_dereference(peer_device->connection->net_conf)->two_primaries; |
2215 | rcu_read_unlock(); | 2227 | rcu_read_unlock(); |
2216 | if (tp) { | 2228 | if (tp) { |
2217 | peer_req->flags |= EE_IN_INTERVAL_TREE; | 2229 | peer_req->flags |= EE_IN_INTERVAL_TREE; |
@@ -2238,9 +2250,9 @@ static int receive_Data(struct drbd_connection *connection, struct packet_info * | |||
2238 | if (device->state.conn == C_SYNC_TARGET) | 2250 | if (device->state.conn == C_SYNC_TARGET) |
2239 | wait_event(device->ee_wait, !overlapping_resync_write(device, peer_req)); | 2251 | wait_event(device->ee_wait, !overlapping_resync_write(device, peer_req)); |
2240 | 2252 | ||
2241 | if (first_peer_device(device)->connection->agreed_pro_version < 100) { | 2253 | if (peer_device->connection->agreed_pro_version < 100) { |
2242 | rcu_read_lock(); | 2254 | rcu_read_lock(); |
2243 | switch (rcu_dereference(first_peer_device(device)->connection->net_conf)->wire_protocol) { | 2255 | switch (rcu_dereference(peer_device->connection->net_conf)->wire_protocol) { |
2244 | case DRBD_PROT_C: | 2256 | case DRBD_PROT_C: |
2245 | dp_flags |= DP_SEND_WRITE_ACK; | 2257 | dp_flags |= DP_SEND_WRITE_ACK; |
2246 | break; | 2258 | break; |
@@ -2366,6 +2378,7 @@ int drbd_rs_should_slow_down(struct drbd_device *device, sector_t sector) | |||
2366 | 2378 | ||
2367 | static int receive_DataRequest(struct drbd_connection *connection, struct packet_info *pi) | 2379 | static int receive_DataRequest(struct drbd_connection *connection, struct packet_info *pi) |
2368 | { | 2380 | { |
2381 | struct drbd_peer_device *peer_device; | ||
2369 | struct drbd_device *device; | 2382 | struct drbd_device *device; |
2370 | sector_t sector; | 2383 | sector_t sector; |
2371 | sector_t capacity; | 2384 | sector_t capacity; |
@@ -2375,9 +2388,10 @@ static int receive_DataRequest(struct drbd_connection *connection, struct packet | |||
2375 | unsigned int fault_type; | 2388 | unsigned int fault_type; |
2376 | struct p_block_req *p = pi->data; | 2389 | struct p_block_req *p = pi->data; |
2377 | 2390 | ||
2378 | device = vnr_to_device(connection, pi->vnr); | 2391 | peer_device = conn_peer_device(connection, pi->vnr); |
2379 | if (!device) | 2392 | if (!peer_device) |
2380 | return -EIO; | 2393 | return -EIO; |
2394 | device = peer_device->device; | ||
2381 | capacity = drbd_get_capacity(device->this_bdev); | 2395 | capacity = drbd_get_capacity(device->this_bdev); |
2382 | 2396 | ||
2383 | sector = be64_to_cpu(p->sector); | 2397 | sector = be64_to_cpu(p->sector); |
@@ -2457,11 +2471,11 @@ static int receive_DataRequest(struct drbd_connection *connection, struct packet | |||
2457 | peer_req->digest = di; | 2471 | peer_req->digest = di; |
2458 | peer_req->flags |= EE_HAS_DIGEST; | 2472 | peer_req->flags |= EE_HAS_DIGEST; |
2459 | 2473 | ||
2460 | if (drbd_recv_all(first_peer_device(device)->connection, di->digest, pi->size)) | 2474 | if (drbd_recv_all(peer_device->connection, di->digest, pi->size)) |
2461 | goto out_free_e; | 2475 | goto out_free_e; |
2462 | 2476 | ||
2463 | if (pi->cmd == P_CSUM_RS_REQUEST) { | 2477 | if (pi->cmd == P_CSUM_RS_REQUEST) { |
2464 | D_ASSERT(device, first_peer_device(device)->connection->agreed_pro_version >= 89); | 2478 | D_ASSERT(device, peer_device->connection->agreed_pro_version >= 89); |
2465 | peer_req->w.cb = w_e_end_csum_rs_req; | 2479 | peer_req->w.cb = w_e_end_csum_rs_req; |
2466 | /* used in the sector offset progress display */ | 2480 | /* used in the sector offset progress display */ |
2467 | device->bm_resync_fo = BM_SECT_TO_BIT(sector); | 2481 | device->bm_resync_fo = BM_SECT_TO_BIT(sector); |
@@ -2478,7 +2492,7 @@ static int receive_DataRequest(struct drbd_connection *connection, struct packet | |||
2478 | 2492 | ||
2479 | case P_OV_REQUEST: | 2493 | case P_OV_REQUEST: |
2480 | if (device->ov_start_sector == ~(sector_t)0 && | 2494 | if (device->ov_start_sector == ~(sector_t)0 && |
2481 | first_peer_device(device)->connection->agreed_pro_version >= 90) { | 2495 | peer_device->connection->agreed_pro_version >= 90) { |
2482 | unsigned long now = jiffies; | 2496 | unsigned long now = jiffies; |
2483 | int i; | 2497 | int i; |
2484 | device->ov_start_sector = sector; | 2498 | device->ov_start_sector = sector; |
@@ -3323,6 +3337,7 @@ static int config_unknown_volume(struct drbd_connection *connection, struct pack | |||
3323 | 3337 | ||
3324 | static int receive_SyncParam(struct drbd_connection *connection, struct packet_info *pi) | 3338 | static int receive_SyncParam(struct drbd_connection *connection, struct packet_info *pi) |
3325 | { | 3339 | { |
3340 | struct drbd_peer_device *peer_device; | ||
3326 | struct drbd_device *device; | 3341 | struct drbd_device *device; |
3327 | struct p_rs_param_95 *p; | 3342 | struct p_rs_param_95 *p; |
3328 | unsigned int header_size, data_size, exp_max_sz; | 3343 | unsigned int header_size, data_size, exp_max_sz; |
@@ -3335,9 +3350,10 @@ static int receive_SyncParam(struct drbd_connection *connection, struct packet_i | |||
3335 | int fifo_size = 0; | 3350 | int fifo_size = 0; |
3336 | int err; | 3351 | int err; |
3337 | 3352 | ||
3338 | device = vnr_to_device(connection, pi->vnr); | 3353 | peer_device = conn_peer_device(connection, pi->vnr); |
3339 | if (!device) | 3354 | if (!peer_device) |
3340 | return config_unknown_volume(connection, pi); | 3355 | return config_unknown_volume(connection, pi); |
3356 | device = peer_device->device; | ||
3341 | 3357 | ||
3342 | exp_max_sz = apv <= 87 ? sizeof(struct p_rs_param) | 3358 | exp_max_sz = apv <= 87 ? sizeof(struct p_rs_param) |
3343 | : apv == 88 ? sizeof(struct p_rs_param) | 3359 | : apv == 88 ? sizeof(struct p_rs_param) |
@@ -3368,12 +3384,12 @@ static int receive_SyncParam(struct drbd_connection *connection, struct packet_i | |||
3368 | p = pi->data; | 3384 | p = pi->data; |
3369 | memset(p->verify_alg, 0, 2 * SHARED_SECRET_MAX); | 3385 | memset(p->verify_alg, 0, 2 * SHARED_SECRET_MAX); |
3370 | 3386 | ||
3371 | err = drbd_recv_all(first_peer_device(device)->connection, p, header_size); | 3387 | err = drbd_recv_all(peer_device->connection, p, header_size); |
3372 | if (err) | 3388 | if (err) |
3373 | return err; | 3389 | return err; |
3374 | 3390 | ||
3375 | mutex_lock(&connection->resource->conf_update); | 3391 | mutex_lock(&connection->resource->conf_update); |
3376 | old_net_conf = first_peer_device(device)->connection->net_conf; | 3392 | old_net_conf = peer_device->connection->net_conf; |
3377 | if (get_ldev(device)) { | 3393 | if (get_ldev(device)) { |
3378 | new_disk_conf = kzalloc(sizeof(struct disk_conf), GFP_KERNEL); | 3394 | new_disk_conf = kzalloc(sizeof(struct disk_conf), GFP_KERNEL); |
3379 | if (!new_disk_conf) { | 3395 | if (!new_disk_conf) { |
@@ -3399,7 +3415,7 @@ static int receive_SyncParam(struct drbd_connection *connection, struct packet_i | |||
3399 | goto reconnect; | 3415 | goto reconnect; |
3400 | } | 3416 | } |
3401 | 3417 | ||
3402 | err = drbd_recv_all(first_peer_device(device)->connection, p->verify_alg, data_size); | 3418 | err = drbd_recv_all(peer_device->connection, p->verify_alg, data_size); |
3403 | if (err) | 3419 | if (err) |
3404 | goto reconnect; | 3420 | goto reconnect; |
3405 | /* we expect NUL terminated string */ | 3421 | /* we expect NUL terminated string */ |
@@ -3473,15 +3489,15 @@ static int receive_SyncParam(struct drbd_connection *connection, struct packet_i | |||
3473 | if (verify_tfm) { | 3489 | if (verify_tfm) { |
3474 | strcpy(new_net_conf->verify_alg, p->verify_alg); | 3490 | strcpy(new_net_conf->verify_alg, p->verify_alg); |
3475 | new_net_conf->verify_alg_len = strlen(p->verify_alg) + 1; | 3491 | new_net_conf->verify_alg_len = strlen(p->verify_alg) + 1; |
3476 | crypto_free_hash(first_peer_device(device)->connection->verify_tfm); | 3492 | crypto_free_hash(peer_device->connection->verify_tfm); |
3477 | first_peer_device(device)->connection->verify_tfm = verify_tfm; | 3493 | peer_device->connection->verify_tfm = verify_tfm; |
3478 | drbd_info(device, "using verify-alg: \"%s\"\n", p->verify_alg); | 3494 | drbd_info(device, "using verify-alg: \"%s\"\n", p->verify_alg); |
3479 | } | 3495 | } |
3480 | if (csums_tfm) { | 3496 | if (csums_tfm) { |
3481 | strcpy(new_net_conf->csums_alg, p->csums_alg); | 3497 | strcpy(new_net_conf->csums_alg, p->csums_alg); |
3482 | new_net_conf->csums_alg_len = strlen(p->csums_alg) + 1; | 3498 | new_net_conf->csums_alg_len = strlen(p->csums_alg) + 1; |
3483 | crypto_free_hash(first_peer_device(device)->connection->csums_tfm); | 3499 | crypto_free_hash(peer_device->connection->csums_tfm); |
3484 | first_peer_device(device)->connection->csums_tfm = csums_tfm; | 3500 | peer_device->connection->csums_tfm = csums_tfm; |
3485 | drbd_info(device, "using csums-alg: \"%s\"\n", p->csums_alg); | 3501 | drbd_info(device, "using csums-alg: \"%s\"\n", p->csums_alg); |
3486 | } | 3502 | } |
3487 | rcu_assign_pointer(connection->net_conf, new_net_conf); | 3503 | rcu_assign_pointer(connection->net_conf, new_net_conf); |
@@ -3527,7 +3543,7 @@ disconnect: | |||
3527 | crypto_free_hash(csums_tfm); | 3543 | crypto_free_hash(csums_tfm); |
3528 | /* but free the verify_tfm again, if csums_tfm did not work out */ | 3544 | /* but free the verify_tfm again, if csums_tfm did not work out */ |
3529 | crypto_free_hash(verify_tfm); | 3545 | crypto_free_hash(verify_tfm); |
3530 | conn_request_state(first_peer_device(device)->connection, NS(conn, C_DISCONNECTING), CS_HARD); | 3546 | conn_request_state(peer_device->connection, NS(conn, C_DISCONNECTING), CS_HARD); |
3531 | return -EIO; | 3547 | return -EIO; |
3532 | } | 3548 | } |
3533 | 3549 | ||
@@ -3546,6 +3562,7 @@ static void warn_if_differ_considerably(struct drbd_device *device, | |||
3546 | 3562 | ||
3547 | static int receive_sizes(struct drbd_connection *connection, struct packet_info *pi) | 3563 | static int receive_sizes(struct drbd_connection *connection, struct packet_info *pi) |
3548 | { | 3564 | { |
3565 | struct drbd_peer_device *peer_device; | ||
3549 | struct drbd_device *device; | 3566 | struct drbd_device *device; |
3550 | struct p_sizes *p = pi->data; | 3567 | struct p_sizes *p = pi->data; |
3551 | enum determine_dev_size dd = DS_UNCHANGED; | 3568 | enum determine_dev_size dd = DS_UNCHANGED; |
@@ -3553,9 +3570,10 @@ static int receive_sizes(struct drbd_connection *connection, struct packet_info | |||
3553 | int ldsc = 0; /* local disk size changed */ | 3570 | int ldsc = 0; /* local disk size changed */ |
3554 | enum dds_flags ddsf; | 3571 | enum dds_flags ddsf; |
3555 | 3572 | ||
3556 | device = vnr_to_device(connection, pi->vnr); | 3573 | peer_device = conn_peer_device(connection, pi->vnr); |
3557 | if (!device) | 3574 | if (!peer_device) |
3558 | return config_unknown_volume(connection, pi); | 3575 | return config_unknown_volume(connection, pi); |
3576 | device = peer_device->device; | ||
3559 | 3577 | ||
3560 | p_size = be64_to_cpu(p->d_size); | 3578 | p_size = be64_to_cpu(p->d_size); |
3561 | p_usize = be64_to_cpu(p->u_size); | 3579 | p_usize = be64_to_cpu(p->u_size); |
@@ -3586,7 +3604,7 @@ static int receive_sizes(struct drbd_connection *connection, struct packet_info | |||
3586 | device->state.disk >= D_OUTDATED && | 3604 | device->state.disk >= D_OUTDATED && |
3587 | device->state.conn < C_CONNECTED) { | 3605 | device->state.conn < C_CONNECTED) { |
3588 | drbd_err(device, "The peer's disk size is too small!\n"); | 3606 | drbd_err(device, "The peer's disk size is too small!\n"); |
3589 | conn_request_state(first_peer_device(device)->connection, NS(conn, C_DISCONNECTING), CS_HARD); | 3607 | conn_request_state(peer_device->connection, NS(conn, C_DISCONNECTING), CS_HARD); |
3590 | put_ldev(device); | 3608 | put_ldev(device); |
3591 | return -EIO; | 3609 | return -EIO; |
3592 | } | 3610 | } |
@@ -3667,14 +3685,16 @@ static int receive_sizes(struct drbd_connection *connection, struct packet_info | |||
3667 | 3685 | ||
3668 | static int receive_uuids(struct drbd_connection *connection, struct packet_info *pi) | 3686 | static int receive_uuids(struct drbd_connection *connection, struct packet_info *pi) |
3669 | { | 3687 | { |
3688 | struct drbd_peer_device *peer_device; | ||
3670 | struct drbd_device *device; | 3689 | struct drbd_device *device; |
3671 | struct p_uuids *p = pi->data; | 3690 | struct p_uuids *p = pi->data; |
3672 | u64 *p_uuid; | 3691 | u64 *p_uuid; |
3673 | int i, updated_uuids = 0; | 3692 | int i, updated_uuids = 0; |
3674 | 3693 | ||
3675 | device = vnr_to_device(connection, pi->vnr); | 3694 | peer_device = conn_peer_device(connection, pi->vnr); |
3676 | if (!device) | 3695 | if (!peer_device) |
3677 | return config_unknown_volume(connection, pi); | 3696 | return config_unknown_volume(connection, pi); |
3697 | device = peer_device->device; | ||
3678 | 3698 | ||
3679 | p_uuid = kmalloc(sizeof(u64)*UI_EXTENDED_SIZE, GFP_NOIO); | 3699 | p_uuid = kmalloc(sizeof(u64)*UI_EXTENDED_SIZE, GFP_NOIO); |
3680 | if (!p_uuid) { | 3700 | if (!p_uuid) { |
@@ -3694,14 +3714,14 @@ static int receive_uuids(struct drbd_connection *connection, struct packet_info | |||
3694 | (device->ed_uuid & ~((u64)1)) != (p_uuid[UI_CURRENT] & ~((u64)1))) { | 3714 | (device->ed_uuid & ~((u64)1)) != (p_uuid[UI_CURRENT] & ~((u64)1))) { |
3695 | drbd_err(device, "Can only connect to data with current UUID=%016llX\n", | 3715 | drbd_err(device, "Can only connect to data with current UUID=%016llX\n", |
3696 | (unsigned long long)device->ed_uuid); | 3716 | (unsigned long long)device->ed_uuid); |
3697 | conn_request_state(first_peer_device(device)->connection, NS(conn, C_DISCONNECTING), CS_HARD); | 3717 | conn_request_state(peer_device->connection, NS(conn, C_DISCONNECTING), CS_HARD); |
3698 | return -EIO; | 3718 | return -EIO; |
3699 | } | 3719 | } |
3700 | 3720 | ||
3701 | if (get_ldev(device)) { | 3721 | if (get_ldev(device)) { |
3702 | int skip_initial_sync = | 3722 | int skip_initial_sync = |
3703 | device->state.conn == C_CONNECTED && | 3723 | device->state.conn == C_CONNECTED && |
3704 | first_peer_device(device)->connection->agreed_pro_version >= 90 && | 3724 | peer_device->connection->agreed_pro_version >= 90 && |
3705 | device->ldev->md.uuid[UI_CURRENT] == UUID_JUST_CREATED && | 3725 | device->ldev->md.uuid[UI_CURRENT] == UUID_JUST_CREATED && |
3706 | (p_uuid[UI_FLAGS] & 8); | 3726 | (p_uuid[UI_FLAGS] & 8); |
3707 | if (skip_initial_sync) { | 3727 | if (skip_initial_sync) { |
@@ -3772,19 +3792,21 @@ static union drbd_state convert_state(union drbd_state ps) | |||
3772 | 3792 | ||
3773 | static int receive_req_state(struct drbd_connection *connection, struct packet_info *pi) | 3793 | static int receive_req_state(struct drbd_connection *connection, struct packet_info *pi) |
3774 | { | 3794 | { |
3795 | struct drbd_peer_device *peer_device; | ||
3775 | struct drbd_device *device; | 3796 | struct drbd_device *device; |
3776 | struct p_req_state *p = pi->data; | 3797 | struct p_req_state *p = pi->data; |
3777 | union drbd_state mask, val; | 3798 | union drbd_state mask, val; |
3778 | enum drbd_state_rv rv; | 3799 | enum drbd_state_rv rv; |
3779 | 3800 | ||
3780 | device = vnr_to_device(connection, pi->vnr); | 3801 | peer_device = conn_peer_device(connection, pi->vnr); |
3781 | if (!device) | 3802 | if (!peer_device) |
3782 | return -EIO; | 3803 | return -EIO; |
3804 | device = peer_device->device; | ||
3783 | 3805 | ||
3784 | mask.i = be32_to_cpu(p->mask); | 3806 | mask.i = be32_to_cpu(p->mask); |
3785 | val.i = be32_to_cpu(p->val); | 3807 | val.i = be32_to_cpu(p->val); |
3786 | 3808 | ||
3787 | if (test_bit(RESOLVE_CONFLICTS, &first_peer_device(device)->connection->flags) && | 3809 | if (test_bit(RESOLVE_CONFLICTS, &peer_device->connection->flags) && |
3788 | mutex_is_locked(device->state_mutex)) { | 3810 | mutex_is_locked(device->state_mutex)) { |
3789 | drbd_send_sr_reply(device, SS_CONCURRENT_ST_CHG); | 3811 | drbd_send_sr_reply(device, SS_CONCURRENT_ST_CHG); |
3790 | return 0; | 3812 | return 0; |
@@ -3827,6 +3849,7 @@ static int receive_req_conn_state(struct drbd_connection *connection, struct pac | |||
3827 | 3849 | ||
3828 | static int receive_state(struct drbd_connection *connection, struct packet_info *pi) | 3850 | static int receive_state(struct drbd_connection *connection, struct packet_info *pi) |
3829 | { | 3851 | { |
3852 | struct drbd_peer_device *peer_device; | ||
3830 | struct drbd_device *device; | 3853 | struct drbd_device *device; |
3831 | struct p_state *p = pi->data; | 3854 | struct p_state *p = pi->data; |
3832 | union drbd_state os, ns, peer_state; | 3855 | union drbd_state os, ns, peer_state; |
@@ -3834,9 +3857,10 @@ static int receive_state(struct drbd_connection *connection, struct packet_info | |||
3834 | enum chg_state_flags cs_flags; | 3857 | enum chg_state_flags cs_flags; |
3835 | int rv; | 3858 | int rv; |
3836 | 3859 | ||
3837 | device = vnr_to_device(connection, pi->vnr); | 3860 | peer_device = conn_peer_device(connection, pi->vnr); |
3838 | if (!device) | 3861 | if (!peer_device) |
3839 | return config_unknown_volume(connection, pi); | 3862 | return config_unknown_volume(connection, pi); |
3863 | device = peer_device->device; | ||
3840 | 3864 | ||
3841 | peer_state.i = be32_to_cpu(p->state); | 3865 | peer_state.i = be32_to_cpu(p->state); |
3842 | 3866 | ||
@@ -3943,10 +3967,10 @@ static int receive_state(struct drbd_connection *connection, struct packet_info | |||
3943 | peer_state.disk = D_DISKLESS; | 3967 | peer_state.disk = D_DISKLESS; |
3944 | real_peer_disk = D_DISKLESS; | 3968 | real_peer_disk = D_DISKLESS; |
3945 | } else { | 3969 | } else { |
3946 | if (test_and_clear_bit(CONN_DRY_RUN, &first_peer_device(device)->connection->flags)) | 3970 | if (test_and_clear_bit(CONN_DRY_RUN, &peer_device->connection->flags)) |
3947 | return -EIO; | 3971 | return -EIO; |
3948 | D_ASSERT(device, os.conn == C_WF_REPORT_PARAMS); | 3972 | D_ASSERT(device, os.conn == C_WF_REPORT_PARAMS); |
3949 | conn_request_state(first_peer_device(device)->connection, NS(conn, C_DISCONNECTING), CS_HARD); | 3973 | conn_request_state(peer_device->connection, NS(conn, C_DISCONNECTING), CS_HARD); |
3950 | return -EIO; | 3974 | return -EIO; |
3951 | } | 3975 | } |
3952 | } | 3976 | } |
@@ -3968,10 +3992,10 @@ static int receive_state(struct drbd_connection *connection, struct packet_info | |||
3968 | for temporal network outages! */ | 3992 | for temporal network outages! */ |
3969 | spin_unlock_irq(&device->resource->req_lock); | 3993 | spin_unlock_irq(&device->resource->req_lock); |
3970 | drbd_err(device, "Aborting Connect, can not thaw IO with an only Consistent peer\n"); | 3994 | drbd_err(device, "Aborting Connect, can not thaw IO with an only Consistent peer\n"); |
3971 | tl_clear(first_peer_device(device)->connection); | 3995 | tl_clear(peer_device->connection); |
3972 | drbd_uuid_new_current(device); | 3996 | drbd_uuid_new_current(device); |
3973 | clear_bit(NEW_CUR_UUID, &device->flags); | 3997 | clear_bit(NEW_CUR_UUID, &device->flags); |
3974 | conn_request_state(first_peer_device(device)->connection, NS2(conn, C_PROTOCOL_ERROR, susp, 0), CS_HARD); | 3998 | conn_request_state(peer_device->connection, NS2(conn, C_PROTOCOL_ERROR, susp, 0), CS_HARD); |
3975 | return -EIO; | 3999 | return -EIO; |
3976 | } | 4000 | } |
3977 | rv = _drbd_set_state(device, ns, cs_flags, NULL); | 4001 | rv = _drbd_set_state(device, ns, cs_flags, NULL); |
@@ -3979,7 +4003,7 @@ static int receive_state(struct drbd_connection *connection, struct packet_info | |||
3979 | spin_unlock_irq(&device->resource->req_lock); | 4003 | spin_unlock_irq(&device->resource->req_lock); |
3980 | 4004 | ||
3981 | if (rv < SS_SUCCESS) { | 4005 | if (rv < SS_SUCCESS) { |
3982 | conn_request_state(first_peer_device(device)->connection, NS(conn, C_DISCONNECTING), CS_HARD); | 4006 | conn_request_state(peer_device->connection, NS(conn, C_DISCONNECTING), CS_HARD); |
3983 | return -EIO; | 4007 | return -EIO; |
3984 | } | 4008 | } |
3985 | 4009 | ||
@@ -4003,12 +4027,14 @@ static int receive_state(struct drbd_connection *connection, struct packet_info | |||
4003 | 4027 | ||
4004 | static int receive_sync_uuid(struct drbd_connection *connection, struct packet_info *pi) | 4028 | static int receive_sync_uuid(struct drbd_connection *connection, struct packet_info *pi) |
4005 | { | 4029 | { |
4030 | struct drbd_peer_device *peer_device; | ||
4006 | struct drbd_device *device; | 4031 | struct drbd_device *device; |
4007 | struct p_rs_uuid *p = pi->data; | 4032 | struct p_rs_uuid *p = pi->data; |
4008 | 4033 | ||
4009 | device = vnr_to_device(connection, pi->vnr); | 4034 | peer_device = conn_peer_device(connection, pi->vnr); |
4010 | if (!device) | 4035 | if (!peer_device) |
4011 | return -EIO; | 4036 | return -EIO; |
4037 | device = peer_device->device; | ||
4012 | 4038 | ||
4013 | wait_event(device->misc_wait, | 4039 | wait_event(device->misc_wait, |
4014 | device->state.conn == C_WF_SYNC_UUID || | 4040 | device->state.conn == C_WF_SYNC_UUID || |
@@ -4225,13 +4251,15 @@ void INFO_bm_xfer_stats(struct drbd_device *device, | |||
4225 | returns 0 on failure, 1 if we successfully received it. */ | 4251 | returns 0 on failure, 1 if we successfully received it. */ |
4226 | static int receive_bitmap(struct drbd_connection *connection, struct packet_info *pi) | 4252 | static int receive_bitmap(struct drbd_connection *connection, struct packet_info *pi) |
4227 | { | 4253 | { |
4254 | struct drbd_peer_device *peer_device; | ||
4228 | struct drbd_device *device; | 4255 | struct drbd_device *device; |
4229 | struct bm_xfer_ctx c; | 4256 | struct bm_xfer_ctx c; |
4230 | int err; | 4257 | int err; |
4231 | 4258 | ||
4232 | device = vnr_to_device(connection, pi->vnr); | 4259 | peer_device = conn_peer_device(connection, pi->vnr); |
4233 | if (!device) | 4260 | if (!peer_device) |
4234 | return -EIO; | 4261 | return -EIO; |
4262 | device = peer_device->device; | ||
4235 | 4263 | ||
4236 | drbd_bm_lock(device, "receive bitmap", BM_LOCKED_SET_ALLOWED); | 4264 | drbd_bm_lock(device, "receive bitmap", BM_LOCKED_SET_ALLOWED); |
4237 | /* you are supposed to send additional out-of-sync information | 4265 | /* you are supposed to send additional out-of-sync information |
@@ -4260,7 +4288,7 @@ static int receive_bitmap(struct drbd_connection *connection, struct packet_info | |||
4260 | err = -EIO; | 4288 | err = -EIO; |
4261 | goto out; | 4289 | goto out; |
4262 | } | 4290 | } |
4263 | err = drbd_recv_all(first_peer_device(device)->connection, p, pi->size); | 4291 | err = drbd_recv_all(peer_device->connection, p, pi->size); |
4264 | if (err) | 4292 | if (err) |
4265 | goto out; | 4293 | goto out; |
4266 | err = decode_bitmap_c(device, p, &c, pi->size); | 4294 | err = decode_bitmap_c(device, p, &c, pi->size); |
@@ -4278,7 +4306,7 @@ static int receive_bitmap(struct drbd_connection *connection, struct packet_info | |||
4278 | goto out; | 4306 | goto out; |
4279 | break; | 4307 | break; |
4280 | } | 4308 | } |
4281 | err = drbd_recv_header(first_peer_device(device)->connection, pi); | 4309 | err = drbd_recv_header(peer_device->connection, pi); |
4282 | if (err) | 4310 | if (err) |
4283 | goto out; | 4311 | goto out; |
4284 | } | 4312 | } |
@@ -4328,12 +4356,14 @@ static int receive_UnplugRemote(struct drbd_connection *connection, struct packe | |||
4328 | 4356 | ||
4329 | static int receive_out_of_sync(struct drbd_connection *connection, struct packet_info *pi) | 4357 | static int receive_out_of_sync(struct drbd_connection *connection, struct packet_info *pi) |
4330 | { | 4358 | { |
4359 | struct drbd_peer_device *peer_device; | ||
4331 | struct drbd_device *device; | 4360 | struct drbd_device *device; |
4332 | struct p_block_desc *p = pi->data; | 4361 | struct p_block_desc *p = pi->data; |
4333 | 4362 | ||
4334 | device = vnr_to_device(connection, pi->vnr); | 4363 | peer_device = conn_peer_device(connection, pi->vnr); |
4335 | if (!device) | 4364 | if (!peer_device) |
4336 | return -EIO; | 4365 | return -EIO; |
4366 | device = peer_device->device; | ||
4337 | 4367 | ||
4338 | switch (device->state.conn) { | 4368 | switch (device->state.conn) { |
4339 | case C_WF_SYNC_UUID: | 4369 | case C_WF_SYNC_UUID: |
@@ -4893,13 +4923,15 @@ static int got_conn_RqSReply(struct drbd_connection *connection, struct packet_i | |||
4893 | 4923 | ||
4894 | static int got_RqSReply(struct drbd_connection *connection, struct packet_info *pi) | 4924 | static int got_RqSReply(struct drbd_connection *connection, struct packet_info *pi) |
4895 | { | 4925 | { |
4926 | struct drbd_peer_device *peer_device; | ||
4896 | struct drbd_device *device; | 4927 | struct drbd_device *device; |
4897 | struct p_req_state_reply *p = pi->data; | 4928 | struct p_req_state_reply *p = pi->data; |
4898 | int retcode = be32_to_cpu(p->retcode); | 4929 | int retcode = be32_to_cpu(p->retcode); |
4899 | 4930 | ||
4900 | device = vnr_to_device(connection, pi->vnr); | 4931 | peer_device = conn_peer_device(connection, pi->vnr); |
4901 | if (!device) | 4932 | if (!peer_device) |
4902 | return -EIO; | 4933 | return -EIO; |
4934 | device = peer_device->device; | ||
4903 | 4935 | ||
4904 | if (test_bit(CONN_WD_ST_CHG_REQ, &connection->flags)) { | 4936 | if (test_bit(CONN_WD_ST_CHG_REQ, &connection->flags)) { |
4905 | D_ASSERT(device, connection->agreed_pro_version < 100); | 4937 | D_ASSERT(device, connection->agreed_pro_version < 100); |
@@ -4936,16 +4968,18 @@ static int got_PingAck(struct drbd_connection *connection, struct packet_info *p | |||
4936 | 4968 | ||
4937 | static int got_IsInSync(struct drbd_connection *connection, struct packet_info *pi) | 4969 | static int got_IsInSync(struct drbd_connection *connection, struct packet_info *pi) |
4938 | { | 4970 | { |
4971 | struct drbd_peer_device *peer_device; | ||
4939 | struct drbd_device *device; | 4972 | struct drbd_device *device; |
4940 | struct p_block_ack *p = pi->data; | 4973 | struct p_block_ack *p = pi->data; |
4941 | sector_t sector = be64_to_cpu(p->sector); | 4974 | sector_t sector = be64_to_cpu(p->sector); |
4942 | int blksize = be32_to_cpu(p->blksize); | 4975 | int blksize = be32_to_cpu(p->blksize); |
4943 | 4976 | ||
4944 | device = vnr_to_device(connection, pi->vnr); | 4977 | peer_device = conn_peer_device(connection, pi->vnr); |
4945 | if (!device) | 4978 | if (!peer_device) |
4946 | return -EIO; | 4979 | return -EIO; |
4980 | device = peer_device->device; | ||
4947 | 4981 | ||
4948 | D_ASSERT(device, first_peer_device(device)->connection->agreed_pro_version >= 89); | 4982 | D_ASSERT(device, peer_device->connection->agreed_pro_version >= 89); |
4949 | 4983 | ||
4950 | update_peer_seq(device, be32_to_cpu(p->seq_num)); | 4984 | update_peer_seq(device, be32_to_cpu(p->seq_num)); |
4951 | 4985 | ||
@@ -4986,15 +5020,17 @@ validate_req_change_req_state(struct drbd_device *device, u64 id, sector_t secto | |||
4986 | 5020 | ||
4987 | static int got_BlockAck(struct drbd_connection *connection, struct packet_info *pi) | 5021 | static int got_BlockAck(struct drbd_connection *connection, struct packet_info *pi) |
4988 | { | 5022 | { |
5023 | struct drbd_peer_device *peer_device; | ||
4989 | struct drbd_device *device; | 5024 | struct drbd_device *device; |
4990 | struct p_block_ack *p = pi->data; | 5025 | struct p_block_ack *p = pi->data; |
4991 | sector_t sector = be64_to_cpu(p->sector); | 5026 | sector_t sector = be64_to_cpu(p->sector); |
4992 | int blksize = be32_to_cpu(p->blksize); | 5027 | int blksize = be32_to_cpu(p->blksize); |
4993 | enum drbd_req_event what; | 5028 | enum drbd_req_event what; |
4994 | 5029 | ||
4995 | device = vnr_to_device(connection, pi->vnr); | 5030 | peer_device = conn_peer_device(connection, pi->vnr); |
4996 | if (!device) | 5031 | if (!peer_device) |
4997 | return -EIO; | 5032 | return -EIO; |
5033 | device = peer_device->device; | ||
4998 | 5034 | ||
4999 | update_peer_seq(device, be32_to_cpu(p->seq_num)); | 5035 | update_peer_seq(device, be32_to_cpu(p->seq_num)); |
5000 | 5036 | ||
@@ -5030,15 +5066,17 @@ static int got_BlockAck(struct drbd_connection *connection, struct packet_info * | |||
5030 | 5066 | ||
5031 | static int got_NegAck(struct drbd_connection *connection, struct packet_info *pi) | 5067 | static int got_NegAck(struct drbd_connection *connection, struct packet_info *pi) |
5032 | { | 5068 | { |
5069 | struct drbd_peer_device *peer_device; | ||
5033 | struct drbd_device *device; | 5070 | struct drbd_device *device; |
5034 | struct p_block_ack *p = pi->data; | 5071 | struct p_block_ack *p = pi->data; |
5035 | sector_t sector = be64_to_cpu(p->sector); | 5072 | sector_t sector = be64_to_cpu(p->sector); |
5036 | int size = be32_to_cpu(p->blksize); | 5073 | int size = be32_to_cpu(p->blksize); |
5037 | int err; | 5074 | int err; |
5038 | 5075 | ||
5039 | device = vnr_to_device(connection, pi->vnr); | 5076 | peer_device = conn_peer_device(connection, pi->vnr); |
5040 | if (!device) | 5077 | if (!peer_device) |
5041 | return -EIO; | 5078 | return -EIO; |
5079 | device = peer_device->device; | ||
5042 | 5080 | ||
5043 | update_peer_seq(device, be32_to_cpu(p->seq_num)); | 5081 | update_peer_seq(device, be32_to_cpu(p->seq_num)); |
5044 | 5082 | ||
@@ -5064,13 +5102,15 @@ static int got_NegAck(struct drbd_connection *connection, struct packet_info *pi | |||
5064 | 5102 | ||
5065 | static int got_NegDReply(struct drbd_connection *connection, struct packet_info *pi) | 5103 | static int got_NegDReply(struct drbd_connection *connection, struct packet_info *pi) |
5066 | { | 5104 | { |
5105 | struct drbd_peer_device *peer_device; | ||
5067 | struct drbd_device *device; | 5106 | struct drbd_device *device; |
5068 | struct p_block_ack *p = pi->data; | 5107 | struct p_block_ack *p = pi->data; |
5069 | sector_t sector = be64_to_cpu(p->sector); | 5108 | sector_t sector = be64_to_cpu(p->sector); |
5070 | 5109 | ||
5071 | device = vnr_to_device(connection, pi->vnr); | 5110 | peer_device = conn_peer_device(connection, pi->vnr); |
5072 | if (!device) | 5111 | if (!peer_device) |
5073 | return -EIO; | 5112 | return -EIO; |
5113 | device = peer_device->device; | ||
5074 | 5114 | ||
5075 | update_peer_seq(device, be32_to_cpu(p->seq_num)); | 5115 | update_peer_seq(device, be32_to_cpu(p->seq_num)); |
5076 | 5116 | ||
@@ -5084,14 +5124,16 @@ static int got_NegDReply(struct drbd_connection *connection, struct packet_info | |||
5084 | 5124 | ||
5085 | static int got_NegRSDReply(struct drbd_connection *connection, struct packet_info *pi) | 5125 | static int got_NegRSDReply(struct drbd_connection *connection, struct packet_info *pi) |
5086 | { | 5126 | { |
5127 | struct drbd_peer_device *peer_device; | ||
5087 | struct drbd_device *device; | 5128 | struct drbd_device *device; |
5088 | sector_t sector; | 5129 | sector_t sector; |
5089 | int size; | 5130 | int size; |
5090 | struct p_block_ack *p = pi->data; | 5131 | struct p_block_ack *p = pi->data; |
5091 | 5132 | ||
5092 | device = vnr_to_device(connection, pi->vnr); | 5133 | peer_device = conn_peer_device(connection, pi->vnr); |
5093 | if (!device) | 5134 | if (!peer_device) |
5094 | return -EIO; | 5135 | return -EIO; |
5136 | device = peer_device->device; | ||
5095 | 5137 | ||
5096 | sector = be64_to_cpu(p->sector); | 5138 | sector = be64_to_cpu(p->sector); |
5097 | size = be32_to_cpu(p->blksize); | 5139 | size = be32_to_cpu(p->blksize); |
@@ -5142,15 +5184,17 @@ static int got_BarrierAck(struct drbd_connection *connection, struct packet_info | |||
5142 | 5184 | ||
5143 | static int got_OVResult(struct drbd_connection *connection, struct packet_info *pi) | 5185 | static int got_OVResult(struct drbd_connection *connection, struct packet_info *pi) |
5144 | { | 5186 | { |
5187 | struct drbd_peer_device *peer_device; | ||
5145 | struct drbd_device *device; | 5188 | struct drbd_device *device; |
5146 | struct p_block_ack *p = pi->data; | 5189 | struct p_block_ack *p = pi->data; |
5147 | struct drbd_work *w; | 5190 | struct drbd_work *w; |
5148 | sector_t sector; | 5191 | sector_t sector; |
5149 | int size; | 5192 | int size; |
5150 | 5193 | ||
5151 | device = vnr_to_device(connection, pi->vnr); | 5194 | peer_device = conn_peer_device(connection, pi->vnr); |
5152 | if (!device) | 5195 | if (!peer_device) |
5153 | return -EIO; | 5196 | return -EIO; |
5197 | device = peer_device->device; | ||
5154 | 5198 | ||
5155 | sector = be64_to_cpu(p->sector); | 5199 | sector = be64_to_cpu(p->sector); |
5156 | size = be32_to_cpu(p->blksize); | 5200 | size = be32_to_cpu(p->blksize); |
@@ -5179,7 +5223,7 @@ static int got_OVResult(struct drbd_connection *connection, struct packet_info * | |||
5179 | if (w) { | 5223 | if (w) { |
5180 | w->cb = w_ov_finished; | 5224 | w->cb = w_ov_finished; |
5181 | w->device = device; | 5225 | w->device = device; |
5182 | drbd_queue_work(&first_peer_device(device)->connection->sender_work, w); | 5226 | drbd_queue_work(&peer_device->connection->sender_work, w); |
5183 | } else { | 5227 | } else { |
5184 | drbd_err(device, "kmalloc(w) failed."); | 5228 | drbd_err(device, "kmalloc(w) failed."); |
5185 | ov_out_of_sync_print(device); | 5229 | ov_out_of_sync_print(device); |