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()
1197 static unsigned int drbd_max_discard_sectors(struct drbd_connection *connection) in drbd_max_discard_sectors() argument
1201 if (connection->agreed_features & DRBD_FF_WSAME) in drbd_max_discard_sectors()
1210 struct drbd_connection *connection = in decide_on_discard_support() local
1211 first_peer_device(device)->connection; in decide_on_discard_support()
1218 if (connection->cstate >= C_CONNECTED && in decide_on_discard_support()
1219 !(connection->agreed_features & DRBD_FF_TRIM)) { in decide_on_discard_support()
1220 drbd_info(connection, in decide_on_discard_support()
1234 max_discard_sectors = drbd_max_discard_sectors(connection); in decide_on_discard_support()
1250 struct drbd_connection *connection = first_peer_device(device)->connection; in fixup_write_zeroes() local
1253 if (connection->agreed_features & DRBD_FF_WZEROES) in fixup_write_zeroes()
1324 if (first_peer_device(device)->connection->agreed_pro_version < 94) in drbd_reconsider_queue_parameters()
1327 else if (first_peer_device(device)->connection->agreed_pro_version == 94) in drbd_reconsider_queue_parameters()
1329 else if (first_peer_device(device)->connection->agreed_pro_version < 100) in drbd_reconsider_queue_parameters()
1353 static void conn_reconfig_start(struct drbd_connection *connection) in conn_reconfig_start() argument
1355 drbd_thread_start(&connection->worker); in conn_reconfig_start()
1356 drbd_flush_workqueue(&connection->sender_work); in conn_reconfig_start()
1360 static void conn_reconfig_done(struct drbd_connection *connection) in conn_reconfig_done() argument
1363 spin_lock_irq(&connection->resource->req_lock); in conn_reconfig_done()
1364 stop_threads = conn_all_vols_unconf(connection) && in conn_reconfig_done()
1365 connection->cstate == C_STANDALONE; in conn_reconfig_done()
1366 spin_unlock_irq(&connection->resource->req_lock); in conn_reconfig_done()
1370 drbd_thread_stop(&connection->receiver); in conn_reconfig_done()
1371 drbd_thread_stop(&connection->worker); in conn_reconfig_done()
1728 struct drbd_connection *connection; in drbd_adm_attach() local
1751 connection = peer_device->connection; in drbd_adm_attach()
1752 conn_reconfig_start(connection); in drbd_adm_attach()
1813 nc = rcu_dereference(connection->net_conf); in drbd_adm_attach()
1903 drbd_flush_workqueue(&connection->sender_work); in drbd_adm_attach()
2120 conn_reconfig_done(connection); in drbd_adm_attach()
2131 conn_reconfig_done(connection); in drbd_adm_attach()
2195 static bool conn_resync_running(struct drbd_connection *connection) in conn_resync_running() argument
2202 idr_for_each_entry(&connection->peer_devices, peer_device, vnr) { in conn_resync_running()
2217 static bool conn_ov_running(struct drbd_connection *connection) in conn_ov_running() argument
2224 idr_for_each_entry(&connection->peer_devices, peer_device, vnr) { in conn_ov_running()
2238 _check_net_options(struct drbd_connection *connection, struct net_conf *old_net_conf, struct net_co… in _check_net_options() argument
2243 …if (old_net_conf && connection->cstate == C_WF_REPORT_PARAMS && connection->agreed_pro_version < 1… in _check_net_options()
2255 conn_highest_role(connection) == R_PRIMARY && in _check_net_options()
2256 conn_highest_peer(connection) == R_PRIMARY) in _check_net_options()
2263 idr_for_each_entry(&connection->peer_devices, peer_device, i) { in _check_net_options()
2282 check_net_options(struct drbd_connection *connection, struct net_conf *new_net_conf) in check_net_options() argument
2289 rv = _check_net_options(connection, rcu_dereference(connection->net_conf), new_net_conf); in check_net_options()
2293 idr_for_each_entry(&connection->peer_devices, peer_device, i) { in check_net_options()
2367 struct drbd_connection *connection; in drbd_adm_net_opts() local
2380 connection = adm_ctx.connection; in drbd_adm_net_opts()
2389 conn_reconfig_start(connection); in drbd_adm_net_opts()
2391 mutex_lock(&connection->data.mutex); in drbd_adm_net_opts()
2392 mutex_lock(&connection->resource->conf_update); in drbd_adm_net_opts()
2393 old_net_conf = connection->net_conf; in drbd_adm_net_opts()
2412 retcode = check_net_options(connection, new_net_conf); in drbd_adm_net_opts()
2417 rsr = conn_resync_running(connection); in drbd_adm_net_opts()
2424 ovr = conn_ov_running(connection); in drbd_adm_net_opts()
2434 rcu_assign_pointer(connection->net_conf, new_net_conf); in drbd_adm_net_opts()
2437 crypto_free_shash(connection->csums_tfm); in drbd_adm_net_opts()
2438 connection->csums_tfm = crypto.csums_tfm; in drbd_adm_net_opts()
2442 crypto_free_shash(connection->verify_tfm); in drbd_adm_net_opts()
2443 connection->verify_tfm = crypto.verify_tfm; in drbd_adm_net_opts()
2447 crypto_free_shash(connection->integrity_tfm); in drbd_adm_net_opts()
2448 connection->integrity_tfm = crypto.integrity_tfm; in drbd_adm_net_opts()
2449 if (connection->cstate >= C_WF_REPORT_PARAMS && connection->agreed_pro_version >= 100) in drbd_adm_net_opts()
2451 __drbd_send_protocol(connection, P_PROTOCOL_UPDATE); in drbd_adm_net_opts()
2453 crypto_free_shash(connection->cram_hmac_tfm); in drbd_adm_net_opts()
2454 connection->cram_hmac_tfm = crypto.cram_hmac_tfm; in drbd_adm_net_opts()
2456 mutex_unlock(&connection->resource->conf_update); in drbd_adm_net_opts()
2457 mutex_unlock(&connection->data.mutex); in drbd_adm_net_opts()
2460 if (connection->cstate >= C_WF_REPORT_PARAMS) { in drbd_adm_net_opts()
2464 idr_for_each_entry(&connection->peer_devices, peer_device, vnr) in drbd_adm_net_opts()
2471 mutex_unlock(&connection->resource->conf_update); in drbd_adm_net_opts()
2472 mutex_unlock(&connection->data.mutex); in drbd_adm_net_opts()
2476 conn_reconfig_done(connection); in drbd_adm_net_opts()
2485 struct drbd_connection *connection) in connection_to_info() argument
2487 info->conn_connection_state = connection->cstate; in connection_to_info()
2488 info->conn_role = conn_highest_peer(connection); in connection_to_info()
2514 struct drbd_connection *connection; in drbd_adm_connect() local
2536 for_each_connection(connection, resource) { in drbd_adm_connect()
2537 if (nla_len(adm_ctx.my_addr) == connection->my_addr_len && in drbd_adm_connect()
2538 !memcmp(nla_data(adm_ctx.my_addr), &connection->my_addr, in drbd_adm_connect()
2539 connection->my_addr_len)) { in drbd_adm_connect()
2544 if (nla_len(adm_ctx.peer_addr) == connection->peer_addr_len && in drbd_adm_connect()
2545 !memcmp(nla_data(adm_ctx.peer_addr), &connection->peer_addr, in drbd_adm_connect()
2546 connection->peer_addr_len)) { in drbd_adm_connect()
2554 connection = first_connection(adm_ctx.resource); in drbd_adm_connect()
2555 conn_reconfig_start(connection); in drbd_adm_connect()
2557 if (connection->cstate > C_STANDALONE) { in drbd_adm_connect()
2578 retcode = check_net_options(connection, new_net_conf); in drbd_adm_connect()
2588 drbd_flush_workqueue(&connection->sender_work); in drbd_adm_connect()
2591 old_net_conf = connection->net_conf; in drbd_adm_connect()
2597 rcu_assign_pointer(connection->net_conf, new_net_conf); in drbd_adm_connect()
2599 conn_free_crypto(connection); in drbd_adm_connect()
2600 connection->cram_hmac_tfm = crypto.cram_hmac_tfm; in drbd_adm_connect()
2601 connection->integrity_tfm = crypto.integrity_tfm; in drbd_adm_connect()
2602 connection->csums_tfm = crypto.csums_tfm; in drbd_adm_connect()
2603 connection->verify_tfm = crypto.verify_tfm; in drbd_adm_connect()
2605 connection->my_addr_len = nla_len(adm_ctx.my_addr); in drbd_adm_connect()
2606 memcpy(&connection->my_addr, nla_data(adm_ctx.my_addr), connection->my_addr_len); in drbd_adm_connect()
2607 connection->peer_addr_len = nla_len(adm_ctx.peer_addr); in drbd_adm_connect()
2608 memcpy(&connection->peer_addr, nla_data(adm_ctx.peer_addr), connection->peer_addr_len); in drbd_adm_connect()
2610 idr_for_each_entry(&connection->peer_devices, peer_device, i) { in drbd_adm_connect()
2614 connection_to_info(&connection_info, connection); in drbd_adm_connect()
2617 notify_connection_state(NULL, 0, connection, &connection_info, NOTIFY_CREATE | flags); in drbd_adm_connect()
2618 idr_for_each_entry(&connection->peer_devices, peer_device, i) { in drbd_adm_connect()
2629 idr_for_each_entry(&connection->peer_devices, peer_device, i) { in drbd_adm_connect()
2636 rv = conn_request_state(connection, NS(conn, C_UNCONNECTED), CS_VERBOSE); in drbd_adm_connect()
2638 conn_reconfig_done(connection); in drbd_adm_connect()
2647 conn_reconfig_done(connection); in drbd_adm_connect()
2654 static enum drbd_state_rv conn_try_disconnect(struct drbd_connection *connection, bool force) in conn_try_disconnect() argument
2660 rv = conn_request_state(connection, NS(conn, C_DISCONNECTING), in conn_try_disconnect()
2670 rv = conn_request_state(connection, NS2(conn, C_DISCONNECTING, pdsk, D_OUTDATED), 0); in conn_try_disconnect()
2673 rv = conn_request_state(connection, NS(conn, C_DISCONNECTING), CS_VERBOSE); in conn_try_disconnect()
2677 spin_lock_irq(&connection->resource->req_lock); in conn_try_disconnect()
2678 cstate = connection->cstate; in conn_try_disconnect()
2679 spin_unlock_irq(&connection->resource->req_lock); in conn_try_disconnect()
2683 rv = conn_request_state(connection, NS2(conn, C_DISCONNECTING, in conn_try_disconnect()
2686 rv = conn_request_state(connection, NS(conn, C_DISCONNECTING), in conn_try_disconnect()
2700 drbd_thread_stop(&connection->receiver); in conn_try_disconnect()
2708 rv2 = conn_request_state(connection, NS(conn, C_STANDALONE), in conn_try_disconnect()
2711 drbd_err(connection, in conn_try_disconnect()
2724 struct drbd_connection *connection; in drbd_adm_disconnect() local
2735 connection = adm_ctx.connection; in drbd_adm_disconnect()
2747 rv = conn_try_disconnect(connection, parms.force_disconnect); in drbd_adm_disconnect()
2767 iass = test_bit(RESOLVE_CONFLICTS, &first_peer_device(device)->connection->flags); in resync_after_online_grow()
2824 if (rs.no_resync && first_peer_device(device)->connection->agreed_pro_version < 93) { in drbd_adm_resize()
2974 drbd_flush_workqueue(&first_peer_device(device)->connection->sender_work); in drbd_adm_invalidate()
3052 drbd_flush_workqueue(&first_peer_device(device)->connection->sender_work); in drbd_adm_invalidate_peer()
3176 tl_clear(first_peer_device(device)->connection); in drbd_adm_resume_io()
3178 tl_restart(first_peer_device(device)->connection, FAIL_FROZEN_DISK_IO); in drbd_adm_resume_io()
3194 struct drbd_connection *connection, in nla_put_drbd_cfg_context() argument
3206 if (connection) { in nla_put_drbd_cfg_context()
3207 if (connection->my_addr_len && in nla_put_drbd_cfg_context()
3208 nla_put(skb, T_ctx_my_addr, connection->my_addr_len, &connection->my_addr)) in nla_put_drbd_cfg_context()
3210 if (connection->peer_addr_len && in nla_put_drbd_cfg_context()
3211 nla_put(skb, T_ctx_peer_addr, connection->peer_addr_len, &connection->peer_addr)) in nla_put_drbd_cfg_context()
3447 struct drbd_connection *connection; in drbd_adm_dump_connections() local
3480 for_each_connection_rcu(connection, resource) in drbd_adm_dump_connections()
3481 if (connection == (struct drbd_connection *)cb->args[2]) in drbd_adm_dump_connections()
3486 connection = list_entry(&resource->connections, struct drbd_connection, connections); in drbd_adm_dump_connections()
3489 list_for_each_entry_continue_rcu(connection, &resource->connections, connections) { in drbd_adm_dump_connections()
3490 if (!has_net_conf(connection)) in drbd_adm_dump_connections()
3530 err = nla_put_drbd_cfg_context(skb, resource, connection, NULL); in drbd_adm_dump_connections()
3533 net_conf = rcu_dereference(connection->net_conf); in drbd_adm_dump_connections()
3539 connection_to_info(&connection_info, connection); in drbd_adm_dump_connections()
3543 connection_statistics.conn_congested = test_bit(NET_CONGESTED, &connection->flags); in drbd_adm_dump_connections()
3547 cb->args[2] = (long)connection; in drbd_adm_dump_connections()
3653 if (!has_net_conf(peer_device->connection)) in drbd_adm_dump_peer_devices()
3674 err = nla_put_drbd_cfg_context(skb, device->resource, peer_device->connection, device); in drbd_adm_dump_peer_devices()
3752 nc = rcu_dereference(first_peer_device(device)->connection->net_conf); in nla_put_status_info()
3932 struct drbd_connection *connection; in get_one_status() local
3936 connection = the_only_connection(resource); in get_one_status()
3937 if (nla_put_drbd_cfg_context(skb, resource, connection, NULL)) in get_one_status()
3939 if (connection) { in get_one_status()
3942 nc = rcu_dereference(connection->net_conf); in get_one_status()
4147 first_peer_device(device)->connection->agreed_pro_version >= 90 && in drbd_adm_new_c_uuid()
4216 struct drbd_connection *connection; in drbd_adm_new_resource() local
4251 connection = conn_create(adm_ctx.resource_name, &res_opts); in drbd_adm_new_resource()
4254 if (connection) { in drbd_adm_new_resource()
4258 resource_to_info(&resource_info, connection->resource); in drbd_adm_new_resource()
4259 notify_resource_state(NULL, 0, connection->resource, in drbd_adm_new_resource()
4320 if (!has_net_conf(peer_device->connection)) in drbd_adm_new_minor()
4332 if (!has_net_conf(peer_device->connection)) in drbd_adm_new_minor()
4356 struct drbd_connection *connection = in adm_del_minor() local
4365 if (get_t_state(&connection->worker) == RUNNING) in adm_del_minor()
4366 drbd_flush_workqueue(&connection->sender_work); in adm_del_minor()
4370 if (!has_net_conf(peer_device->connection)) in adm_del_minor()
4405 struct drbd_connection *connection; in adm_del_resource() local
4407 for_each_connection(connection, resource) { in adm_del_resource()
4408 if (connection->cstate > C_STANDALONE) in adm_del_resource()
4426 list_for_each_entry(connection, &resource->connections, connections) in adm_del_resource()
4427 drbd_thread_stop(&connection->worker); in adm_del_resource()
4437 struct drbd_connection *connection; in drbd_adm_down() local
4451 for_each_connection(connection, resource) { in drbd_adm_down()
4454 idr_for_each_entry(&connection->peer_devices, peer_device, i) { in drbd_adm_down()
4462 retcode = conn_try_disconnect(connection, 0); in drbd_adm_down()
4668 struct drbd_connection *connection, in notify_connection_state() argument
4692 if (nla_put_drbd_cfg_context(skb, connection->resource, connection, NULL) || in notify_connection_state()
4697 connection_statistics.conn_congested = test_bit(NET_CONGESTED, &connection->flags); in notify_connection_state()
4711 drbd_err(connection, "Error %d while broadcasting event. Event seq:%u\n", in notify_connection_state()
4743 if (nla_put_drbd_cfg_context(skb, resource, peer_device->connection, peer_device->device) || in notify_peer_device_state()
4768 struct drbd_device *device, struct drbd_connection *connection, in notify_helper() argument
4771 struct drbd_resource *resource = device ? device->resource : connection->resource; in notify_helper()
4794 if (nla_put_drbd_cfg_context(skb, resource, connection, device) || in notify_helper()