Lines Matching full:connection

162  * @connection:	DRBD connection.
168 * termination of the connection.
170 void tl_release(struct drbd_connection *connection, unsigned int barrier_nr, in tl_release() argument
178 spin_lock_irq(&connection->resource->req_lock); in tl_release()
182 list_for_each_entry(r, &connection->transfer_log, tl_requests) { in tl_release()
207 drbd_err(connection, "BAD! BarrierAck #%u received, but no epoch in tl!?\n", in tl_release()
212 drbd_err(connection, "BAD! BarrierAck #%u received, expected #%u!\n", in tl_release()
218 drbd_err(connection, "BAD! BarrierAck #%u received with n_writes=%u, expected n_writes=%u!\n", in tl_release()
227 list_for_each_entry(req, &connection->transfer_log, tl_requests) in tl_release()
232 req = list_prepare_entry(tmp, &connection->transfer_log, tl_requests); in tl_release()
233 list_for_each_entry_safe_from(req, r, &connection->transfer_log, tl_requests) { in tl_release()
238 spin_unlock_irq(&connection->resource->req_lock); in tl_release()
243 spin_unlock_irq(&connection->resource->req_lock); in tl_release()
244 conn_request_state(connection, NS(conn, C_PROTOCOL_ERROR), CS_HARD); in tl_release()
250 * @connection: DRBD connection to operate on.
257 void _tl_restart(struct drbd_connection *connection, enum drbd_req_event what) in _tl_restart() argument
261 list_for_each_entry_safe(req, r, &connection->transfer_log, tl_requests) in _tl_restart()
265 void tl_restart(struct drbd_connection *connection, enum drbd_req_event what) in tl_restart() argument
267 spin_lock_irq(&connection->resource->req_lock); in tl_restart()
268 _tl_restart(connection, what); in tl_restart()
269 spin_unlock_irq(&connection->resource->req_lock); in tl_restart()
274 * @connection: DRBD connection.
276 * This is called after the connection to the peer was lost. The storage covered
280 void tl_clear(struct drbd_connection *connection) in tl_clear() argument
282 tl_restart(connection, CONNECTION_LOST_WHILE_PENDING); in tl_clear()
291 struct drbd_connection *connection = first_peer_device(device)->connection; in tl_abort_disk_io() local
294 spin_lock_irq(&connection->resource->req_lock); in tl_abort_disk_io()
295 list_for_each_entry_safe(req, r, &connection->transfer_log, tl_requests) { in tl_abort_disk_io()
302 spin_unlock_irq(&connection->resource->req_lock); in tl_abort_disk_io()
350 if (thi->connection) in drbd_thread_setup()
351 kref_put(&thi->connection->kref, drbd_destroy_connection); in drbd_thread_setup()
365 thi->connection = NULL; in drbd_thread_init()
392 if (thi->connection) in drbd_thread_start()
393 kref_get(&thi->connection->kref); in drbd_thread_start()
407 if (thi->connection) in drbd_thread_start()
408 kref_put(&thi->connection->kref, drbd_destroy_connection); in drbd_thread_start()
470 int conn_lowest_minor(struct drbd_connection *connection) in conn_lowest_minor() argument
476 peer_device = idr_get_next(&connection->peer_devices, &vnr); in conn_lowest_minor()
550 unsigned int drbd_header_size(struct drbd_connection *connection) in drbd_header_size() argument
552 if (connection->agreed_pro_version >= 100) { in drbd_header_size()
590 static unsigned int prepare_header(struct drbd_connection *connection, int vnr, in prepare_header() argument
593 if (connection->agreed_pro_version >= 100) in prepare_header()
595 else if (connection->agreed_pro_version >= 95 && in prepare_header()
602 static void *__conn_prepare_command(struct drbd_connection *connection, in __conn_prepare_command() argument
607 return sock->sbuf + drbd_header_size(connection); in __conn_prepare_command()
610 void *conn_prepare_command(struct drbd_connection *connection, struct drbd_socket *sock) in conn_prepare_command() argument
615 p = __conn_prepare_command(connection, sock); in conn_prepare_command()
624 return conn_prepare_command(peer_device->connection, sock); in drbd_prepare_command()
627 static int __send_command(struct drbd_connection *connection, int vnr, in __send_command() argument
644 header_size += prepare_header(connection, vnr, sock->sbuf, cmd, in __send_command()
646 err = drbd_send_all(connection, sock->socket, sock->sbuf, header_size, in __send_command()
649 err = drbd_send_all(connection, sock->socket, data, size, 0); in __send_command()
658 static int __conn_send_command(struct drbd_connection *connection, struct drbd_socket *sock, in __conn_send_command() argument
662 return __send_command(connection, 0, sock, cmd, header_size, data, size); in __conn_send_command()
665 int conn_send_command(struct drbd_connection *connection, struct drbd_socket *sock, in conn_send_command() argument
671 err = __conn_send_command(connection, sock, cmd, header_size, data, size); in conn_send_command()
682 err = __send_command(peer_device->connection, peer_device->device->vnr, in drbd_send_command()
688 int drbd_send_ping(struct drbd_connection *connection) in drbd_send_ping() argument
692 sock = &connection->meta; in drbd_send_ping()
693 if (!conn_prepare_command(connection, sock)) in drbd_send_ping()
695 return conn_send_command(connection, sock, P_PING, 0, NULL, 0); in drbd_send_ping()
698 int drbd_send_ping_ack(struct drbd_connection *connection) in drbd_send_ping_ack() argument
702 sock = &connection->meta; in drbd_send_ping_ack()
703 if (!conn_prepare_command(connection, sock)) in drbd_send_ping_ack()
705 return conn_send_command(connection, sock, P_PING_ACK, 0, NULL, 0); in drbd_send_ping_ack()
713 const int apv = peer_device->connection->agreed_pro_version; in drbd_send_sync_param()
718 sock = &peer_device->connection->data; in drbd_send_sync_param()
724 nc = rcu_dereference(peer_device->connection->net_conf); in drbd_send_sync_param()
763 int __drbd_send_protocol(struct drbd_connection *connection, enum drbd_packet cmd) in __drbd_send_protocol() argument
770 sock = &connection->data; in __drbd_send_protocol()
771 p = __conn_prepare_command(connection, sock); in __drbd_send_protocol()
776 nc = rcu_dereference(connection->net_conf); in __drbd_send_protocol()
778 if (nc->tentative && connection->agreed_pro_version < 92) { in __drbd_send_protocol()
780 drbd_err(connection, "--dry-run is not supported by peer"); in __drbd_send_protocol()
785 if (connection->agreed_pro_version >= 87) in __drbd_send_protocol()
800 if (connection->agreed_pro_version >= 87) in __drbd_send_protocol()
804 return __conn_send_command(connection, sock, cmd, size, NULL, 0); in __drbd_send_protocol()
807 int drbd_send_protocol(struct drbd_connection *connection) in drbd_send_protocol() argument
811 mutex_lock(&connection->data.mutex); in drbd_send_protocol()
812 err = __drbd_send_protocol(connection, P_PROTOCOL); in drbd_send_protocol()
813 mutex_unlock(&connection->data.mutex); in drbd_send_protocol()
828 sock = &peer_device->connection->data; in _drbd_send_uuids()
842 uuid_flags |= rcu_dereference(peer_device->connection->net_conf)->discard_my_data ? 1 : 0; in _drbd_send_uuids()
898 sock = &peer_device->connection->data; in drbd_gen_and_send_sync_uuid()
916 sock = &peer_device->connection->data; in drbd_send_sizes()
922 if (peer_device->connection->agreed_features & DRBD_FF_WSAME) in drbd_send_sizes()
965 if (peer_device->connection->agreed_pro_version <= 94) in drbd_send_sizes()
967 else if (peer_device->connection->agreed_pro_version < 100) in drbd_send_sizes()
992 sock = &peer_device->connection->data; in drbd_send_current_state()
1015 sock = &peer_device->connection->data; in drbd_send_state()
1028 sock = &peer_device->connection->data; in drbd_send_state_req()
1037 int conn_send_state_req(struct drbd_connection *connection, union drbd_state mask, union drbd_state… in conn_send_state_req() argument
1043 cmd = connection->agreed_pro_version < 100 ? P_STATE_CHG_REQ : P_CONN_ST_CHG_REQ; in conn_send_state_req()
1044 sock = &connection->data; in conn_send_state_req()
1045 p = conn_prepare_command(connection, sock); in conn_send_state_req()
1050 return conn_send_command(connection, sock, cmd, sizeof(*p), NULL, 0); in conn_send_state_req()
1058 sock = &peer_device->connection->meta; in drbd_send_sr_reply()
1066 void conn_send_sr_reply(struct drbd_connection *connection, enum drbd_state_rv retcode) in conn_send_sr_reply() argument
1070 …enum drbd_packet cmd = connection->agreed_pro_version < 100 ? P_STATE_CHG_REPLY : P_CONN_ST_CHG_RE… in conn_send_sr_reply()
1072 sock = &connection->meta; in conn_send_sr_reply()
1073 p = conn_prepare_command(connection, sock); in conn_send_sr_reply()
1076 conn_send_command(connection, sock, cmd, sizeof(*p), NULL, 0); in conn_send_sr_reply()
1112 use_rle = rcu_dereference(first_peer_device(device)->connection->net_conf)->use_rle; in fill_bitmap_rle_bits()
1114 if (!use_rle || first_peer_device(device)->connection->agreed_pro_version < 90) in fill_bitmap_rle_bits()
1203 struct drbd_socket *sock = &first_peer_device(device)->connection->data; in send_bitmap_rle_or_plain()
1204 unsigned int header_size = drbd_header_size(first_peer_device(device)->connection); in send_bitmap_rle_or_plain()
1215 err = __send_command(first_peer_device(device)->connection, device->vnr, sock, in send_bitmap_rle_or_plain()
1236 …err = __send_command(first_peer_device(device)->connection, device->vnr, sock, P_BITMAP, len, NULL… in send_bitmap_rle_or_plain()
1296 struct drbd_socket *sock = &first_peer_device(device)->connection->data; in drbd_send_bitmap()
1306 void drbd_send_b_ack(struct drbd_connection *connection, u32 barrier_nr, u32 set_size) in drbd_send_b_ack() argument
1311 if (connection->cstate < C_WF_REPORT_PARAMS) in drbd_send_b_ack()
1314 sock = &connection->meta; in drbd_send_b_ack()
1315 p = conn_prepare_command(connection, sock); in drbd_send_b_ack()
1320 conn_send_command(connection, sock, P_BARRIER_ACK, sizeof(*p), NULL, 0); in drbd_send_b_ack()
1340 sock = &peer_device->connection->meta; in _drbd_send_ack()
1357 if (peer_device->connection->peer_integrity_tfm) in drbd_send_ack_dp()
1358 data_size -= crypto_shash_digestsize(peer_device->connection->peer_integrity_tfm); in drbd_send_ack_dp()
1401 sock = &peer_device->connection->data; in drbd_send_rs_deallocated()
1417 sock = &peer_device->connection->data; in drbd_send_drequest()
1435 sock = &peer_device->connection->data; in drbd_send_drequest_csum()
1450 sock = &peer_device->connection->data; in drbd_send_ov_request()
1462 * true if we think connection is dead
1464 static int we_should_drop_the_connection(struct drbd_connection *connection, struct socket *sock) in we_should_drop_the_connection() argument
1469 drop_it = connection->meta.socket == sock in we_should_drop_the_connection()
1470 || !connection->ack_receiver.task in we_should_drop_the_connection()
1471 || get_t_state(&connection->ack_receiver) != RUNNING in we_should_drop_the_connection()
1472 || connection->cstate < C_WF_REPORT_PARAMS; in we_should_drop_the_connection()
1477 drop_it = !--connection->ko_count; in we_should_drop_the_connection()
1479 drbd_err(connection, "[%s/%d] sock_sendmsg time expired, ko = %u\n", in we_should_drop_the_connection()
1480 current->comm, current->pid, connection->ko_count); in we_should_drop_the_connection()
1481 request_ping(connection); in we_should_drop_the_connection()
1487 static void drbd_update_congested(struct drbd_connection *connection) in drbd_update_congested() argument
1489 struct sock *sk = connection->data.socket->sk; in drbd_update_congested()
1491 set_bit(NET_CONGESTED, &connection->flags); in drbd_update_congested()
1522 socket = peer_device->connection->data.socket; in _drbd_no_send_page()
1524 err = drbd_send_all(peer_device->connection, socket, addr, size, msg_flags); in _drbd_no_send_page()
1534 struct socket *socket = peer_device->connection->data.socket; in _drbd_send_page()
1548 drbd_update_congested(peer_device->connection); in _drbd_send_page()
1555 if (we_should_drop_the_connection(peer_device->connection, socket)) in _drbd_send_page()
1568 clear_bit(NET_CONGESTED, &peer_device->connection->flags); in _drbd_send_page()
1634 static u32 bio_flags_to_wire(struct drbd_connection *connection, in bio_flags_to_wire() argument
1637 if (connection->agreed_pro_version >= 95) in bio_flags_to_wire()
1643 ((connection->agreed_features & DRBD_FF_WZEROES) ? in bio_flags_to_wire()
1664 sock = &peer_device->connection->data; in drbd_send_dblock()
1666 digest_size = peer_device->connection->integrity_tfm ? in drbd_send_dblock()
1667 crypto_shash_digestsize(peer_device->connection->integrity_tfm) : 0; in drbd_send_dblock()
1674 dp_flags = bio_flags_to_wire(peer_device->connection, req->master_bio); in drbd_send_dblock()
1678 if (peer_device->connection->agreed_pro_version >= 100) { in drbd_send_dblock()
1693 err = __send_command(peer_device->connection, device->vnr, sock, cmd, sizeof(*t), NULL, 0); in drbd_send_dblock()
1701 drbd_csum_bio(peer_device->connection->integrity_tfm, req->master_bio, digest_out); in drbd_send_dblock()
1702 err = __send_command(peer_device->connection, device->vnr, sock, P_DATA, in drbd_send_dblock()
1726 drbd_csum_bio(peer_device->connection->integrity_tfm, req->master_bio, digest); in drbd_send_dblock()
1755 sock = &peer_device->connection->data; in drbd_send_block()
1758 digest_size = peer_device->connection->integrity_tfm ? in drbd_send_block()
1759 crypto_shash_digestsize(peer_device->connection->integrity_tfm) : 0; in drbd_send_block()
1768 drbd_csum_ee(peer_device->connection->integrity_tfm, peer_req, p + 1); in drbd_send_block()
1769 …err = __send_command(peer_device->connection, device->vnr, sock, cmd, sizeof(*p) + digest_size, NU… in drbd_send_block()
1782 sock = &peer_device->connection->data; in drbd_send_out_of_sync()
1807 int drbd_send(struct drbd_connection *connection, struct socket *sock, in drbd_send() argument
1821 if (sock == connection->data.socket) { in drbd_send()
1823 connection->ko_count = rcu_dereference(connection->net_conf)->ko_count; in drbd_send()
1825 drbd_update_congested(connection); in drbd_send()
1830 if (we_should_drop_the_connection(connection, sock)) in drbd_send()
1844 if (sock == connection->data.socket) in drbd_send()
1845 clear_bit(NET_CONGESTED, &connection->flags); in drbd_send()
1849 drbd_err(connection, "%s_sendmsg returned %d\n", in drbd_send()
1850 sock == connection->meta.socket ? "msock" : "sock", in drbd_send()
1852 conn_request_state(connection, NS(conn, C_BROKEN_PIPE), CS_HARD); in drbd_send()
1854 conn_request_state(connection, NS(conn, C_TIMEOUT), CS_HARD); in drbd_send()
1865 int drbd_send_all(struct drbd_connection *connection, struct socket *sock, void *buffer, in drbd_send_all() argument
1870 err = drbd_send(connection, sock, buffer, size, msg_flags); in drbd_send_all()
1919 &first_peer_device(device)->connection->sender_work, in drbd_queue_unplug()
2010 if (first_peer_device(device)->connection->receiver.t_state != NONE) in drbd_device_cleanup()
2012 first_peer_device(device)->connection->receiver.t_state); in drbd_device_cleanup()
2030 D_ASSERT(device, first_peer_device(device)->connection->net_conf == NULL); in drbd_device_cleanup()
2050 D_ASSERT(device, list_empty(&first_peer_device(device)->connection->sender_work.q)); in drbd_device_cleanup()
2213 /* not for_each_connection(connection, resource): in drbd_destroy_device()
2217 kref_put(&peer_device->connection->kref, drbd_destroy_connection); in drbd_destroy_device()
2318 struct drbd_connection *connection, *tmp; in drbd_free_resource() local
2320 for_each_connection_safe(connection, tmp, resource) { in drbd_free_resource()
2321 list_del(&connection->connections); in drbd_free_resource()
2322 drbd_debugfs_connection_cleanup(connection); in drbd_free_resource()
2323 kref_put(&connection->kref, drbd_destroy_connection); in drbd_free_resource()
2425 struct drbd_connection *connection; in conn_get_by_addrs() local
2429 for_each_connection_rcu(connection, resource) { in conn_get_by_addrs()
2430 if (connection->my_addr_len == my_addr_len && in conn_get_by_addrs()
2431 connection->peer_addr_len == peer_addr_len && in conn_get_by_addrs()
2432 !memcmp(&connection->my_addr, my_addr, my_addr_len) && in conn_get_by_addrs()
2433 !memcmp(&connection->peer_addr, peer_addr, peer_addr_len)) { in conn_get_by_addrs()
2434 kref_get(&connection->kref); in conn_get_by_addrs()
2439 connection = NULL; in conn_get_by_addrs()
2442 return connection; in conn_get_by_addrs()
2462 void conn_free_crypto(struct drbd_connection *connection) in conn_free_crypto() argument
2464 drbd_free_sock(connection); in conn_free_crypto()
2466 crypto_free_shash(connection->csums_tfm); in conn_free_crypto()
2467 crypto_free_shash(connection->verify_tfm); in conn_free_crypto()
2468 crypto_free_shash(connection->cram_hmac_tfm); in conn_free_crypto()
2469 crypto_free_shash(connection->integrity_tfm); in conn_free_crypto()
2470 crypto_free_shash(connection->peer_integrity_tfm); in conn_free_crypto()
2471 kfree(connection->int_dig_in); in conn_free_crypto()
2472 kfree(connection->int_dig_vv); in conn_free_crypto()
2474 connection->csums_tfm = NULL; in conn_free_crypto()
2475 connection->verify_tfm = NULL; in conn_free_crypto()
2476 connection->cram_hmac_tfm = NULL; in conn_free_crypto()
2477 connection->integrity_tfm = NULL; in conn_free_crypto()
2478 connection->peer_integrity_tfm = NULL; in conn_free_crypto()
2479 connection->int_dig_in = NULL; in conn_free_crypto()
2480 connection->int_dig_vv = NULL; in conn_free_crypto()
2485 struct drbd_connection *connection; in set_resource_options() local
2521 for_each_connection_rcu(connection, resource) { in set_resource_options()
2522 connection->receiver.reset_cpu_mask = 1; in set_resource_options()
2523 connection->ack_receiver.reset_cpu_mask = 1; in set_resource_options()
2524 connection->worker.reset_cpu_mask = 1; in set_resource_options()
2570 struct drbd_connection *connection; in conn_create() local
2572 connection = kzalloc(sizeof(struct drbd_connection), GFP_KERNEL); in conn_create()
2573 if (!connection) in conn_create()
2576 if (drbd_alloc_socket(&connection->data)) in conn_create()
2578 if (drbd_alloc_socket(&connection->meta)) in conn_create()
2581 connection->current_epoch = kzalloc(sizeof(struct drbd_epoch), GFP_KERNEL); in conn_create()
2582 if (!connection->current_epoch) in conn_create()
2585 INIT_LIST_HEAD(&connection->transfer_log); in conn_create()
2587 INIT_LIST_HEAD(&connection->current_epoch->list); in conn_create()
2588 connection->epochs = 1; in conn_create()
2589 spin_lock_init(&connection->epoch_lock); in conn_create()
2591 connection->send.seen_any_write_yet = false; in conn_create()
2592 connection->send.current_epoch_nr = 0; in conn_create()
2593 connection->send.current_epoch_writes = 0; in conn_create()
2599 connection->cstate = C_STANDALONE; in conn_create()
2600 mutex_init(&connection->cstate_mutex); in conn_create()
2601 init_waitqueue_head(&connection->ping_wait); in conn_create()
2602 idr_init(&connection->peer_devices); in conn_create()
2604 drbd_init_workqueue(&connection->sender_work); in conn_create()
2605 mutex_init(&connection->data.mutex); in conn_create()
2606 mutex_init(&connection->meta.mutex); in conn_create()
2608 drbd_thread_init(resource, &connection->receiver, drbd_receiver, "receiver"); in conn_create()
2609 connection->receiver.connection = connection; in conn_create()
2610 drbd_thread_init(resource, &connection->worker, drbd_worker, "worker"); in conn_create()
2611 connection->worker.connection = connection; in conn_create()
2612 drbd_thread_init(resource, &connection->ack_receiver, drbd_ack_receiver, "ack_recv"); in conn_create()
2613 connection->ack_receiver.connection = connection; in conn_create()
2615 kref_init(&connection->kref); in conn_create()
2617 connection->resource = resource; in conn_create()
2623 list_add_tail_rcu(&connection->connections, &resource->connections); in conn_create()
2624 drbd_debugfs_connection_add(connection); in conn_create()
2625 return connection; in conn_create()
2631 kfree(connection->current_epoch); in conn_create()
2632 drbd_free_socket(&connection->meta); in conn_create()
2633 drbd_free_socket(&connection->data); in conn_create()
2634 kfree(connection); in conn_create()
2640 struct drbd_connection *connection = container_of(kref, struct drbd_connection, kref); in drbd_destroy_connection() local
2641 struct drbd_resource *resource = connection->resource; in drbd_destroy_connection()
2643 if (atomic_read(&connection->current_epoch->epoch_size) != 0) in drbd_destroy_connection()
2644 drbd_err(connection, "epoch_size:%d\n", atomic_read(&connection->current_epoch->epoch_size)); in drbd_destroy_connection()
2645 kfree(connection->current_epoch); in drbd_destroy_connection()
2647 idr_destroy(&connection->peer_devices); in drbd_destroy_connection()
2649 drbd_free_socket(&connection->meta); in drbd_destroy_connection()
2650 drbd_free_socket(&connection->data); in drbd_destroy_connection()
2651 kfree(connection->int_dig_in); in drbd_destroy_connection()
2652 kfree(connection->int_dig_vv); in drbd_destroy_connection()
2653 memset(connection, 0xfc, sizeof(*connection)); in drbd_destroy_connection()
2654 kfree(connection); in drbd_destroy_connection()
2675 struct drbd_connection *connection, *n; in drbd_create_device() local
2750 for_each_connection(connection, resource) { in drbd_create_device()
2754 peer_device->connection = connection; in drbd_create_device()
2760 id = idr_alloc(&connection->peer_devices, peer_device, vnr, vnr + 1, GFP_KERNEL); in drbd_create_device()
2766 kref_get(&connection->kref); in drbd_create_device()
2779 /* inherit the connection state */ in drbd_create_device()
2792 for_each_connection_safe(connection, n, resource) { in drbd_create_device()
2793 peer_device = idr_remove(&connection->peer_devices, vnr); in drbd_create_device()
2795 kref_put(&connection->kref, drbd_destroy_connection); in drbd_create_device()
2820 struct drbd_connection *connection; in drbd_delete_device() local
2827 for_each_connection(connection, resource) { in drbd_delete_device()
2828 idr_remove(&connection->peer_devices, device->vnr); in drbd_delete_device()
2930 void drbd_free_sock(struct drbd_connection *connection) in drbd_free_sock() argument
2932 if (connection->data.socket) in drbd_free_sock()
2933 drbd_free_one_sock(&connection->data); in drbd_free_sock()
2934 if (connection->meta.socket) in drbd_free_sock()
2935 drbd_free_one_sock(&connection->meta); in drbd_free_sock()
2940 void conn_md_sync(struct drbd_connection *connection) in conn_md_sync() argument
2946 idr_for_each_entry(&connection->peer_devices, peer_device, vnr) { in conn_md_sync()
3494 D_ASSERT(device, current == first_peer_device(device)->connection->worker.task); in drbd_queue_bitmap_io()
3514 drbd_queue_work(&first_peer_device(device)->connection->sender_work, in drbd_queue_bitmap_io()
3537 D_ASSERT(device, current != first_peer_device(device)->connection->worker.task); in drbd_bitmap_io()
3665 nc = rcu_dereference(first_peer_device(device)->connection->net_conf); in drbd_wait_misc()