Lines Matching refs:connection
216 nla_len(adm_ctx->my_addr) > sizeof(adm_ctx->connection->my_addr)) || in drbd_adm_prepare()
218 nla_len(adm_ctx->peer_addr) > sizeof(adm_ctx->connection->peer_addr))) { in drbd_adm_prepare()
258 adm_ctx->connection = conn_get_by_addrs(nla_data(adm_ctx->my_addr), in drbd_adm_prepare()
262 if (!adm_ctx->connection) { in drbd_adm_prepare()
290 : adm_ctx->connection ? adm_ctx->connection->resource : NULL; in drbd_adm_prepare()
310 if (adm_ctx->connection) { in drbd_adm_finish()
311 kref_put(&adm_ctx->connection->kref, &drbd_destroy_connection); in drbd_adm_finish()
312 adm_ctx->connection = NULL; in drbd_adm_finish()
327 static void setup_khelper_env(struct drbd_connection *connection, char **envp) in setup_khelper_env() argument
332 if (connection->my_addr_len == 0 || connection->peer_addr_len == 0) in setup_khelper_env()
335 switch (((struct sockaddr *)&connection->peer_addr)->sa_family) { in setup_khelper_env()
339 &((struct sockaddr_in6 *)&connection->peer_addr)->sin6_addr); in setup_khelper_env()
344 &((struct sockaddr_in *)&connection->peer_addr)->sin_addr); in setup_khelper_env()
349 &((struct sockaddr_in *)&connection->peer_addr)->sin_addr); in setup_khelper_env()
364 struct drbd_connection *connection = first_peer_device(device)->connection; in drbd_khelper() local
368 if (current == connection->worker.task) in drbd_khelper()
369 set_bit(CALLBACK_PENDING, &connection->flags); in drbd_khelper()
372 setup_khelper_env(connection, envp); in drbd_khelper()
382 notify_helper(NOTIFY_CALL, device, connection, cmd, 0); in drbd_khelper()
395 notify_helper(NOTIFY_RESPONSE, device, connection, cmd, ret); in drbd_khelper()
397 if (current == connection->worker.task) in drbd_khelper()
398 clear_bit(CALLBACK_PENDING, &connection->flags); in drbd_khelper()
406 enum drbd_peer_state conn_khelper(struct drbd_connection *connection, char *cmd) in conn_khelper() argument
414 char *resource_name = connection->resource->name; in conn_khelper()
418 setup_khelper_env(connection, envp); in conn_khelper()
419 conn_md_sync(connection); in conn_khelper()
421 drbd_info(connection, "helper command: %s %s %s\n", drbd_usermode_helper, cmd, resource_name); in conn_khelper()
423 notify_helper(NOTIFY_CALL, NULL, connection, cmd, 0); in conn_khelper()
427 drbd_warn(connection, "helper command: %s %s %s exit code %u (0x%x)\n", in conn_khelper()
431 drbd_info(connection, "helper command: %s %s %s exit code %u (0x%x)\n", in conn_khelper()
435 notify_helper(NOTIFY_RESPONSE, NULL, connection, cmd, ret); in conn_khelper()
443 static enum drbd_fencing_p highest_fencing_policy(struct drbd_connection *connection) in highest_fencing_policy() argument
450 idr_for_each_entry(&connection->peer_devices, peer_device, vnr) { in highest_fencing_policy()
469 bool conn_try_outdate_peer(struct drbd_connection *connection) in conn_try_outdate_peer() argument
471 struct drbd_resource * const resource = connection->resource; in conn_try_outdate_peer()
480 if (connection->cstate >= C_WF_REPORT_PARAMS) { in conn_try_outdate_peer()
481 drbd_err(connection, "Expected cstate < C_WF_REPORT_PARAMS\n"); in conn_try_outdate_peer()
486 connect_cnt = connection->connect_cnt; in conn_try_outdate_peer()
489 fp = highest_fencing_policy(connection); in conn_try_outdate_peer()
492 drbd_warn(connection, "Not fencing peer, I'm not even Consistent myself.\n"); in conn_try_outdate_peer()
494 if (connection->cstate < C_WF_REPORT_PARAMS) { in conn_try_outdate_peer()
495 _conn_request_state(connection, in conn_try_outdate_peer()
503 _tl_restart(connection, CONNECTION_LOST_WHILE_PENDING); in conn_try_outdate_peer()
519 r = conn_khelper(connection, "fence-peer"); in conn_try_outdate_peer()
533 if (conn_highest_disk(connection) == D_UP_TO_DATE) { in conn_try_outdate_peer()
546 drbd_warn(connection, "Peer is primary, outdating myself.\n"); in conn_try_outdate_peer()
554 drbd_err(connection, "fence-peer() = 7 && fencing != Stonith !!!\n"); in conn_try_outdate_peer()
561 drbd_err(connection, "fence-peer helper broken, returned %d\n", (r>>8)&0xff); in conn_try_outdate_peer()
565 drbd_info(connection, "fence-peer helper returned %d (%s)\n", in conn_try_outdate_peer()
573 if (connection->cstate < C_WF_REPORT_PARAMS && !test_bit(STATE_SENT, &connection->flags)) { in conn_try_outdate_peer()
574 if (connection->connect_cnt != connect_cnt) in conn_try_outdate_peer()
577 drbd_info(connection, "Ignoring fence-peer exit code\n"); in conn_try_outdate_peer()
579 _conn_request_state(connection, mask, val, CS_VERBOSE); in conn_try_outdate_peer()
583 return conn_highest_pdsk(connection) <= D_OUTDATED; in conn_try_outdate_peer()
588 struct drbd_connection *connection = (struct drbd_connection *)data; in _try_outdate_peer_async() local
590 conn_try_outdate_peer(connection); in _try_outdate_peer_async()
592 kref_put(&connection->kref, drbd_destroy_connection); in _try_outdate_peer_async()
596 void conn_try_outdate_peer_async(struct drbd_connection *connection) in conn_try_outdate_peer_async() argument
600 kref_get(&connection->kref); in conn_try_outdate_peer_async()
607 opa = kthread_run(_try_outdate_peer_async, connection, "drbd_async_h"); in conn_try_outdate_peer_async()
609 drbd_err(connection, "out of mem, failed to invoke fence-peer helper\n"); in conn_try_outdate_peer_async()
610 kref_put(&connection->kref, drbd_destroy_connection); in conn_try_outdate_peer_async()
618 struct drbd_connection *const connection = peer_device ? peer_device->connection : NULL; in drbd_set_role() local
627 struct drbd_connection *connection; in drbd_set_role() local
632 for_each_connection(connection, device->resource) in drbd_set_role()
633 request_ping(connection); in drbd_set_role()
666 if (conn_try_outdate_peer(connection)) { in drbd_set_role()
676 if (!conn_try_outdate_peer(connection) && force) { in drbd_set_role()
691 nc = rcu_dereference(connection->net_conf); in drbd_set_role()
725 nc = connection->net_conf; in drbd_set_role()
1194 static unsigned int drbd_max_discard_sectors(struct drbd_connection *connection) in drbd_max_discard_sectors() argument
1198 if (connection->agreed_features & DRBD_FF_WSAME) in drbd_max_discard_sectors()
1213 struct drbd_connection *connection = first_peer_device(device)->connection; in decide_on_discard_support() local
1216 if (can_do && connection->cstate >= C_CONNECTED && !(connection->agreed_features & DRBD_FF_TRIM)) { in decide_on_discard_support()
1218 drbd_info(connection, "peer DRBD too old, does not support TRIM: disabling discards\n"); in decide_on_discard_support()
1228 q->limits.max_discard_sectors = drbd_max_discard_sectors(connection); in decide_on_discard_support()
1230 q->limits.max_write_zeroes_sectors = drbd_max_discard_sectors(connection); in decide_on_discard_support()
1257 struct drbd_connection *connection = first_peer_device(device)->connection; in fixup_write_zeroes() local
1260 if (connection->agreed_features & DRBD_FF_WZEROES) in fixup_write_zeroes()
1272 struct drbd_connection *connection = peer_device->connection; in decide_on_write_same_support() local
1280 …if (can_do && connection->cstate >= C_CONNECTED && !(connection->agreed_features & DRBD_FF_WSAME))… in decide_on_write_same_support()
1389 if (first_peer_device(device)->connection->agreed_pro_version < 94) in drbd_reconsider_queue_parameters()
1392 else if (first_peer_device(device)->connection->agreed_pro_version == 94) in drbd_reconsider_queue_parameters()
1394 else if (first_peer_device(device)->connection->agreed_pro_version < 100) in drbd_reconsider_queue_parameters()
1418 static void conn_reconfig_start(struct drbd_connection *connection) in conn_reconfig_start() argument
1420 drbd_thread_start(&connection->worker); in conn_reconfig_start()
1421 drbd_flush_workqueue(&connection->sender_work); in conn_reconfig_start()
1425 static void conn_reconfig_done(struct drbd_connection *connection) in conn_reconfig_done() argument
1428 spin_lock_irq(&connection->resource->req_lock); in conn_reconfig_done()
1429 stop_threads = conn_all_vols_unconf(connection) && in conn_reconfig_done()
1430 connection->cstate == C_STANDALONE; in conn_reconfig_done()
1431 spin_unlock_irq(&connection->resource->req_lock); in conn_reconfig_done()
1435 drbd_thread_stop(&connection->receiver); in conn_reconfig_done()
1436 drbd_thread_stop(&connection->worker); in conn_reconfig_done()
1787 struct drbd_connection *connection; in drbd_adm_attach() local
1810 connection = peer_device->connection; in drbd_adm_attach()
1811 conn_reconfig_start(connection); in drbd_adm_attach()
1872 nc = rcu_dereference(connection->net_conf); in drbd_adm_attach()
1962 drbd_flush_workqueue(&connection->sender_work); in drbd_adm_attach()
2177 conn_reconfig_done(connection); in drbd_adm_attach()
2188 conn_reconfig_done(connection); in drbd_adm_attach()
2249 static bool conn_resync_running(struct drbd_connection *connection) in conn_resync_running() argument
2256 idr_for_each_entry(&connection->peer_devices, peer_device, vnr) { in conn_resync_running()
2271 static bool conn_ov_running(struct drbd_connection *connection) in conn_ov_running() argument
2278 idr_for_each_entry(&connection->peer_devices, peer_device, vnr) { in conn_ov_running()
2292 _check_net_options(struct drbd_connection *connection, struct net_conf *old_net_conf, struct net_co… in _check_net_options() argument
2297 …if (old_net_conf && connection->cstate == C_WF_REPORT_PARAMS && connection->agreed_pro_version < 1… in _check_net_options()
2309 conn_highest_role(connection) == R_PRIMARY && in _check_net_options()
2310 conn_highest_peer(connection) == R_PRIMARY) in _check_net_options()
2317 idr_for_each_entry(&connection->peer_devices, peer_device, i) { in _check_net_options()
2336 check_net_options(struct drbd_connection *connection, struct net_conf *new_net_conf) in check_net_options() argument
2343 rv = _check_net_options(connection, rcu_dereference(connection->net_conf), new_net_conf); in check_net_options()
2347 idr_for_each_entry(&connection->peer_devices, peer_device, i) { in check_net_options()
2421 struct drbd_connection *connection; in drbd_adm_net_opts() local
2434 connection = adm_ctx.connection; in drbd_adm_net_opts()
2443 conn_reconfig_start(connection); in drbd_adm_net_opts()
2445 mutex_lock(&connection->data.mutex); in drbd_adm_net_opts()
2446 mutex_lock(&connection->resource->conf_update); in drbd_adm_net_opts()
2447 old_net_conf = connection->net_conf; in drbd_adm_net_opts()
2466 retcode = check_net_options(connection, new_net_conf); in drbd_adm_net_opts()
2471 rsr = conn_resync_running(connection); in drbd_adm_net_opts()
2478 ovr = conn_ov_running(connection); in drbd_adm_net_opts()
2488 rcu_assign_pointer(connection->net_conf, new_net_conf); in drbd_adm_net_opts()
2491 crypto_free_shash(connection->csums_tfm); in drbd_adm_net_opts()
2492 connection->csums_tfm = crypto.csums_tfm; in drbd_adm_net_opts()
2496 crypto_free_shash(connection->verify_tfm); in drbd_adm_net_opts()
2497 connection->verify_tfm = crypto.verify_tfm; in drbd_adm_net_opts()
2501 crypto_free_shash(connection->integrity_tfm); in drbd_adm_net_opts()
2502 connection->integrity_tfm = crypto.integrity_tfm; in drbd_adm_net_opts()
2503 if (connection->cstate >= C_WF_REPORT_PARAMS && connection->agreed_pro_version >= 100) in drbd_adm_net_opts()
2505 __drbd_send_protocol(connection, P_PROTOCOL_UPDATE); in drbd_adm_net_opts()
2507 crypto_free_shash(connection->cram_hmac_tfm); in drbd_adm_net_opts()
2508 connection->cram_hmac_tfm = crypto.cram_hmac_tfm; in drbd_adm_net_opts()
2510 mutex_unlock(&connection->resource->conf_update); in drbd_adm_net_opts()
2511 mutex_unlock(&connection->data.mutex); in drbd_adm_net_opts()
2515 if (connection->cstate >= C_WF_REPORT_PARAMS) { in drbd_adm_net_opts()
2519 idr_for_each_entry(&connection->peer_devices, peer_device, vnr) in drbd_adm_net_opts()
2526 mutex_unlock(&connection->resource->conf_update); in drbd_adm_net_opts()
2527 mutex_unlock(&connection->data.mutex); in drbd_adm_net_opts()
2531 conn_reconfig_done(connection); in drbd_adm_net_opts()
2540 struct drbd_connection *connection) in connection_to_info() argument
2542 info->conn_connection_state = connection->cstate; in connection_to_info()
2543 info->conn_role = conn_highest_peer(connection); in connection_to_info()
2569 struct drbd_connection *connection; in drbd_adm_connect() local
2590 for_each_connection(connection, resource) { in drbd_adm_connect()
2591 if (nla_len(adm_ctx.my_addr) == connection->my_addr_len && in drbd_adm_connect()
2592 !memcmp(nla_data(adm_ctx.my_addr), &connection->my_addr, in drbd_adm_connect()
2593 connection->my_addr_len)) { in drbd_adm_connect()
2598 if (nla_len(adm_ctx.peer_addr) == connection->peer_addr_len && in drbd_adm_connect()
2599 !memcmp(nla_data(adm_ctx.peer_addr), &connection->peer_addr, in drbd_adm_connect()
2600 connection->peer_addr_len)) { in drbd_adm_connect()
2608 connection = first_connection(adm_ctx.resource); in drbd_adm_connect()
2609 conn_reconfig_start(connection); in drbd_adm_connect()
2611 if (connection->cstate > C_STANDALONE) { in drbd_adm_connect()
2632 retcode = check_net_options(connection, new_net_conf); in drbd_adm_connect()
2642 drbd_flush_workqueue(&connection->sender_work); in drbd_adm_connect()
2645 old_net_conf = connection->net_conf; in drbd_adm_connect()
2651 rcu_assign_pointer(connection->net_conf, new_net_conf); in drbd_adm_connect()
2653 conn_free_crypto(connection); in drbd_adm_connect()
2654 connection->cram_hmac_tfm = crypto.cram_hmac_tfm; in drbd_adm_connect()
2655 connection->integrity_tfm = crypto.integrity_tfm; in drbd_adm_connect()
2656 connection->csums_tfm = crypto.csums_tfm; in drbd_adm_connect()
2657 connection->verify_tfm = crypto.verify_tfm; in drbd_adm_connect()
2659 connection->my_addr_len = nla_len(adm_ctx.my_addr); in drbd_adm_connect()
2660 memcpy(&connection->my_addr, nla_data(adm_ctx.my_addr), connection->my_addr_len); in drbd_adm_connect()
2661 connection->peer_addr_len = nla_len(adm_ctx.peer_addr); in drbd_adm_connect()
2662 memcpy(&connection->peer_addr, nla_data(adm_ctx.peer_addr), connection->peer_addr_len); in drbd_adm_connect()
2664 idr_for_each_entry(&connection->peer_devices, peer_device, i) { in drbd_adm_connect()
2668 connection_to_info(&connection_info, connection); in drbd_adm_connect()
2671 notify_connection_state(NULL, 0, connection, &connection_info, NOTIFY_CREATE | flags); in drbd_adm_connect()
2672 idr_for_each_entry(&connection->peer_devices, peer_device, i) { in drbd_adm_connect()
2683 idr_for_each_entry(&connection->peer_devices, peer_device, i) { in drbd_adm_connect()
2690 retcode = conn_request_state(connection, NS(conn, C_UNCONNECTED), CS_VERBOSE); in drbd_adm_connect()
2692 conn_reconfig_done(connection); in drbd_adm_connect()
2701 conn_reconfig_done(connection); in drbd_adm_connect()
2708 static enum drbd_state_rv conn_try_disconnect(struct drbd_connection *connection, bool force) in conn_try_disconnect() argument
2714 rv = conn_request_state(connection, NS(conn, C_DISCONNECTING), in conn_try_disconnect()
2724 rv = conn_request_state(connection, NS2(conn, C_DISCONNECTING, pdsk, D_OUTDATED), 0); in conn_try_disconnect()
2727 rv = conn_request_state(connection, NS(conn, C_DISCONNECTING), CS_VERBOSE); in conn_try_disconnect()
2731 spin_lock_irq(&connection->resource->req_lock); in conn_try_disconnect()
2732 cstate = connection->cstate; in conn_try_disconnect()
2733 spin_unlock_irq(&connection->resource->req_lock); in conn_try_disconnect()
2737 rv = conn_request_state(connection, NS2(conn, C_DISCONNECTING, in conn_try_disconnect()
2740 rv = conn_request_state(connection, NS(conn, C_DISCONNECTING), in conn_try_disconnect()
2754 drbd_thread_stop(&connection->receiver); in conn_try_disconnect()
2762 rv2 = conn_request_state(connection, NS(conn, C_STANDALONE), in conn_try_disconnect()
2765 drbd_err(connection, in conn_try_disconnect()
2778 struct drbd_connection *connection; in drbd_adm_disconnect() local
2789 connection = adm_ctx.connection; in drbd_adm_disconnect()
2801 rv = conn_try_disconnect(connection, parms.force_disconnect); in drbd_adm_disconnect()
2820 iass = test_bit(RESOLVE_CONFLICTS, &first_peer_device(device)->connection->flags); in resync_after_online_grow()
2877 if (rs.no_resync && first_peer_device(device)->connection->agreed_pro_version < 93) { in drbd_adm_resize()
3028 drbd_flush_workqueue(&first_peer_device(device)->connection->sender_work); in drbd_adm_invalidate()
3105 drbd_flush_workqueue(&first_peer_device(device)->connection->sender_work); in drbd_adm_invalidate_peer()
3229 tl_clear(first_peer_device(device)->connection); in drbd_adm_resume_io()
3231 tl_restart(first_peer_device(device)->connection, FAIL_FROZEN_DISK_IO); in drbd_adm_resume_io()
3247 struct drbd_connection *connection, in nla_put_drbd_cfg_context() argument
3259 if (connection) { in nla_put_drbd_cfg_context()
3260 if (connection->my_addr_len && in nla_put_drbd_cfg_context()
3261 nla_put(skb, T_ctx_my_addr, connection->my_addr_len, &connection->my_addr)) in nla_put_drbd_cfg_context()
3263 if (connection->peer_addr_len && in nla_put_drbd_cfg_context()
3264 nla_put(skb, T_ctx_peer_addr, connection->peer_addr_len, &connection->peer_addr)) in nla_put_drbd_cfg_context()
3500 struct drbd_connection *connection; in drbd_adm_dump_connections() local
3533 for_each_connection_rcu(connection, resource) in drbd_adm_dump_connections()
3534 if (connection == (struct drbd_connection *)cb->args[2]) in drbd_adm_dump_connections()
3539 connection = list_entry(&resource->connections, struct drbd_connection, connections); in drbd_adm_dump_connections()
3542 list_for_each_entry_continue_rcu(connection, &resource->connections, connections) { in drbd_adm_dump_connections()
3543 if (!has_net_conf(connection)) in drbd_adm_dump_connections()
3583 err = nla_put_drbd_cfg_context(skb, resource, connection, NULL); in drbd_adm_dump_connections()
3586 net_conf = rcu_dereference(connection->net_conf); in drbd_adm_dump_connections()
3592 connection_to_info(&connection_info, connection); in drbd_adm_dump_connections()
3596 connection_statistics.conn_congested = test_bit(NET_CONGESTED, &connection->flags); in drbd_adm_dump_connections()
3600 cb->args[2] = (long)connection; in drbd_adm_dump_connections()
3706 if (!has_net_conf(peer_device->connection)) in drbd_adm_dump_peer_devices()
3727 err = nla_put_drbd_cfg_context(skb, device->resource, peer_device->connection, device); in drbd_adm_dump_peer_devices()
3805 nc = rcu_dereference(first_peer_device(device)->connection->net_conf); in nla_put_status_info()
3985 struct drbd_connection *connection; in get_one_status() local
3989 connection = the_only_connection(resource); in get_one_status()
3990 if (nla_put_drbd_cfg_context(skb, resource, connection, NULL)) in get_one_status()
3992 if (connection) { in get_one_status()
3995 nc = rcu_dereference(connection->net_conf); in get_one_status()
4200 first_peer_device(device)->connection->agreed_pro_version >= 90 && in drbd_adm_new_c_uuid()
4269 struct drbd_connection *connection; in drbd_adm_new_resource() local
4304 connection = conn_create(adm_ctx.resource_name, &res_opts); in drbd_adm_new_resource()
4307 if (connection) { in drbd_adm_new_resource()
4311 resource_to_info(&resource_info, connection->resource); in drbd_adm_new_resource()
4312 notify_resource_state(NULL, 0, connection->resource, in drbd_adm_new_resource()
4373 if (!has_net_conf(peer_device->connection)) in drbd_adm_new_minor()
4385 if (!has_net_conf(peer_device->connection)) in drbd_adm_new_minor()
4409 struct drbd_connection *connection = in adm_del_minor() local
4418 if (get_t_state(&connection->worker) == RUNNING) in adm_del_minor()
4419 drbd_flush_workqueue(&connection->sender_work); in adm_del_minor()
4423 if (!has_net_conf(peer_device->connection)) in adm_del_minor()
4458 struct drbd_connection *connection; in adm_del_resource() local
4460 for_each_connection(connection, resource) { in adm_del_resource()
4461 if (connection->cstate > C_STANDALONE) in adm_del_resource()
4479 list_for_each_entry(connection, &resource->connections, connections) in adm_del_resource()
4480 drbd_thread_stop(&connection->worker); in adm_del_resource()
4490 struct drbd_connection *connection; in drbd_adm_down() local
4504 for_each_connection(connection, resource) { in drbd_adm_down()
4507 idr_for_each_entry(&connection->peer_devices, peer_device, i) { in drbd_adm_down()
4515 retcode = conn_try_disconnect(connection, 0); in drbd_adm_down()
4719 struct drbd_connection *connection, in notify_connection_state() argument
4743 if (nla_put_drbd_cfg_context(skb, connection->resource, connection, NULL) || in notify_connection_state()
4748 connection_statistics.conn_congested = test_bit(NET_CONGESTED, &connection->flags); in notify_connection_state()
4762 drbd_err(connection, "Error %d while broadcasting event. Event seq:%u\n", in notify_connection_state()
4793 if (nla_put_drbd_cfg_context(skb, resource, peer_device->connection, peer_device->device) || in notify_peer_device_state()
4817 struct drbd_device *device, struct drbd_connection *connection, in notify_helper() argument
4820 struct drbd_resource *resource = device ? device->resource : connection->resource; in notify_helper()
4843 if (nla_put_drbd_cfg_context(skb, resource, connection, device) || in notify_helper()