Lines Matching defs:connection
216 nla_len(adm_ctx->my_addr) > sizeof(adm_ctx->connection->my_addr)) ||
218 nla_len(adm_ctx->peer_addr) > sizeof(adm_ctx->connection->peer_addr))) {
258 adm_ctx->connection = conn_get_by_addrs(nla_data(adm_ctx->my_addr),
262 if (!adm_ctx->connection) {
263 drbd_msg_put_info(adm_ctx->reply_skb, "unknown connection");
290 : adm_ctx->connection ? adm_ctx->connection->resource : NULL;
310 if (adm_ctx->connection) {
311 kref_put(&adm_ctx->connection->kref, &drbd_destroy_connection);
312 adm_ctx->connection = NULL;
327 static void setup_khelper_env(struct drbd_connection *connection, char **envp)
332 if (connection->my_addr_len == 0 || connection->peer_addr_len == 0)
335 switch (((struct sockaddr *)&connection->peer_addr)->sa_family) {
339 &((struct sockaddr_in6 *)&connection->peer_addr)->sin6_addr);
344 &((struct sockaddr_in *)&connection->peer_addr)->sin_addr);
349 &((struct sockaddr_in *)&connection->peer_addr)->sin_addr);
364 struct drbd_connection *connection = first_peer_device(device)->connection;
368 if (current == connection->worker.task)
369 set_bit(CALLBACK_PENDING, &connection->flags);
372 setup_khelper_env(connection, envp);
382 notify_helper(NOTIFY_CALL, device, connection, cmd, 0);
395 notify_helper(NOTIFY_RESPONSE, device, connection, cmd, ret);
397 if (current == connection->worker.task)
398 clear_bit(CALLBACK_PENDING, &connection->flags);
406 enum drbd_peer_state conn_khelper(struct drbd_connection *connection, char *cmd)
414 char *resource_name = connection->resource->name;
418 setup_khelper_env(connection, envp);
419 conn_md_sync(connection);
421 drbd_info(connection, "helper command: %s %s %s\n", drbd_usermode_helper, cmd, resource_name);
423 notify_helper(NOTIFY_CALL, NULL, connection, cmd, 0);
427 drbd_warn(connection, "helper command: %s %s %s exit code %u (0x%x)\n",
431 drbd_info(connection, "helper command: %s %s %s exit code %u (0x%x)\n",
435 notify_helper(NOTIFY_RESPONSE, NULL, connection, cmd, ret);
443 static enum drbd_fencing_p highest_fencing_policy(struct drbd_connection *connection)
450 idr_for_each_entry(&connection->peer_devices, peer_device, vnr) {
469 bool conn_try_outdate_peer(struct drbd_connection *connection)
471 struct drbd_resource * const resource = connection->resource;
480 if (connection->cstate >= C_WF_REPORT_PARAMS) {
481 drbd_err(connection, "Expected cstate < C_WF_REPORT_PARAMS\n");
486 connect_cnt = connection->connect_cnt;
489 fp = highest_fencing_policy(connection);
492 drbd_warn(connection, "Not fencing peer, I'm not even Consistent myself.\n");
494 if (connection->cstate < C_WF_REPORT_PARAMS) {
495 _conn_request_state(connection,
503 _tl_restart(connection, CONNECTION_LOST_WHILE_PENDING);
505 /* Else: in case we raced with a connection handshake,
519 r = conn_khelper(connection, "fence-peer");
533 if (conn_highest_disk(connection) == D_UP_TO_DATE) {
546 drbd_warn(connection, "Peer is primary, outdating myself.\n");
554 drbd_err(connection, "fence-peer() = 7 && fencing != Stonith !!!\n");
561 drbd_err(connection, "fence-peer helper broken, returned %d\n", (r>>8)&0xff);
565 drbd_info(connection, "fence-peer helper returned %d (%s)\n",
569 conn_request_state(connection, mask, val, CS_VERBOSE);
570 here, because we might were able to re-establish the connection in the
573 if (connection->cstate < C_WF_REPORT_PARAMS && !test_bit(STATE_SENT, &connection->flags)) {
574 if (connection->connect_cnt != connect_cnt)
575 /* In case the connection was established and droped
577 drbd_info(connection, "Ignoring fence-peer exit code\n");
579 _conn_request_state(connection, mask, val, CS_VERBOSE);
583 return conn_highest_pdsk(connection) <= D_OUTDATED;
588 struct drbd_connection *connection = (struct drbd_connection *)data;
590 conn_try_outdate_peer(connection);
592 kref_put(&connection->kref, drbd_destroy_connection);
596 void conn_try_outdate_peer_async(struct drbd_connection *connection)
600 kref_get(&connection->kref);
607 opa = kthread_run(_try_outdate_peer_async, connection, "drbd_async_h");
609 drbd_err(connection, "out of mem, failed to invoke fence-peer helper\n");
610 kref_put(&connection->kref, drbd_destroy_connection);
618 struct drbd_connection *const connection = peer_device ? peer_device->connection : NULL;
627 struct drbd_connection *connection;
632 for_each_connection(connection, device->resource)
633 request_ping(connection);
646 * but now suddenly could establish a connection */
666 if (conn_try_outdate_peer(connection)) {
676 if (!conn_try_outdate_peer(connection) && force) {
691 nc = rcu_dereference(connection->net_conf);
725 nc = connection->net_conf;
1197 static unsigned int drbd_max_discard_sectors(struct drbd_connection *connection)
1201 if (connection->agreed_features & DRBD_FF_WSAME)
1210 struct drbd_connection *connection =
1211 first_peer_device(device)->connection;
1218 if (connection->cstate >= C_CONNECTED &&
1219 !(connection->agreed_features & DRBD_FF_TRIM)) {
1220 drbd_info(connection,
1234 max_discard_sectors = drbd_max_discard_sectors(connection);
1250 struct drbd_connection *connection = first_peer_device(device)->connection;
1253 if (connection->agreed_features & DRBD_FF_WZEROES)
1324 if (first_peer_device(device)->connection->agreed_pro_version < 94)
1327 else if (first_peer_device(device)->connection->agreed_pro_version == 94)
1329 else if (first_peer_device(device)->connection->agreed_pro_version < 100)
1353 static void conn_reconfig_start(struct drbd_connection *connection)
1355 drbd_thread_start(&connection->worker);
1356 drbd_flush_workqueue(&connection->sender_work);
1360 static void conn_reconfig_done(struct drbd_connection *connection)
1363 spin_lock_irq(&connection->resource->req_lock);
1364 stop_threads = conn_all_vols_unconf(connection) &&
1365 connection->cstate == C_STANDALONE;
1366 spin_unlock_irq(&connection->resource->req_lock);
1370 drbd_thread_stop(&connection->receiver);
1371 drbd_thread_stop(&connection->worker);
1728 struct drbd_connection *connection;
1751 connection = peer_device->connection;
1752 conn_reconfig_start(connection);
1813 nc = rcu_dereference(connection->net_conf);
1903 drbd_flush_workqueue(&connection->sender_work);
2006 * Now, if I had no connection before that crash
2120 conn_reconfig_done(connection);
2131 conn_reconfig_done(connection);
2195 static bool conn_resync_running(struct drbd_connection *connection)
2202 idr_for_each_entry(&connection->peer_devices, peer_device, vnr) {
2217 static bool conn_ov_running(struct drbd_connection *connection)
2224 idr_for_each_entry(&connection->peer_devices, peer_device, vnr) {
2238 _check_net_options(struct drbd_connection *connection, struct net_conf *old_net_conf, struct net_conf *new_net_conf)
2243 if (old_net_conf && connection->cstate == C_WF_REPORT_PARAMS && connection->agreed_pro_version < 100) {
2255 conn_highest_role(connection) == R_PRIMARY &&
2256 conn_highest_peer(connection) == R_PRIMARY)
2263 idr_for_each_entry(&connection->peer_devices, peer_device, i) {
2282 check_net_options(struct drbd_connection *connection, struct net_conf *new_net_conf)
2289 rv = _check_net_options(connection, rcu_dereference(connection->net_conf), new_net_conf);
2292 /* connection->peer_devices protected by genl_lock() here */
2293 idr_for_each_entry(&connection->peer_devices, peer_device, i) {
2367 struct drbd_connection *connection;
2380 connection = adm_ctx.connection;
2389 conn_reconfig_start(connection);
2391 mutex_lock(&connection->data.mutex);
2392 mutex_lock(&connection->resource->conf_update);
2393 old_net_conf = connection->net_conf;
2412 retcode = check_net_options(connection, new_net_conf);
2417 rsr = conn_resync_running(connection);
2424 ovr = conn_ov_running(connection);
2434 rcu_assign_pointer(connection->net_conf, new_net_conf);
2437 crypto_free_shash(connection->csums_tfm);
2438 connection->csums_tfm = crypto.csums_tfm;
2442 crypto_free_shash(connection->verify_tfm);
2443 connection->verify_tfm = crypto.verify_tfm;
2447 crypto_free_shash(connection->integrity_tfm);
2448 connection->integrity_tfm = crypto.integrity_tfm;
2449 if (connection->cstate >= C_WF_REPORT_PARAMS && connection->agreed_pro_version >= 100)
2450 /* Do this without trying to take connection->data.mutex again. */
2451 __drbd_send_protocol(connection, P_PROTOCOL_UPDATE);
2453 crypto_free_shash(connection->cram_hmac_tfm);
2454 connection->cram_hmac_tfm = crypto.cram_hmac_tfm;
2456 mutex_unlock(&connection->resource->conf_update);
2457 mutex_unlock(&connection->data.mutex);
2460 if (connection->cstate >= C_WF_REPORT_PARAMS) {
2464 idr_for_each_entry(&connection->peer_devices, peer_device, vnr)
2471 mutex_unlock(&connection->resource->conf_update);
2472 mutex_unlock(&connection->data.mutex);
2476 conn_reconfig_done(connection);
2485 struct drbd_connection *connection)
2487 info->conn_connection_state = connection->cstate;
2488 info->conn_role = conn_highest_peer(connection);
2514 struct drbd_connection *connection;
2527 drbd_msg_put_info(adm_ctx.reply_skb, "connection endpoint(s) missing");
2536 for_each_connection(connection, resource) {
2537 if (nla_len(adm_ctx.my_addr) == connection->my_addr_len &&
2538 !memcmp(nla_data(adm_ctx.my_addr), &connection->my_addr,
2539 connection->my_addr_len)) {
2544 if (nla_len(adm_ctx.peer_addr) == connection->peer_addr_len &&
2545 !memcmp(nla_data(adm_ctx.peer_addr), &connection->peer_addr,
2546 connection->peer_addr_len)) {
2554 connection = first_connection(adm_ctx.resource);
2555 conn_reconfig_start(connection);
2557 if (connection->cstate > C_STANDALONE) {
2578 retcode = check_net_options(connection, new_net_conf);
2588 drbd_flush_workqueue(&connection->sender_work);
2591 old_net_conf = connection->net_conf;
2597 rcu_assign_pointer(connection->net_conf, new_net_conf);
2599 conn_free_crypto(connection);
2600 connection->cram_hmac_tfm = crypto.cram_hmac_tfm;
2601 connection->integrity_tfm = crypto.integrity_tfm;
2602 connection->csums_tfm = crypto.csums_tfm;
2603 connection->verify_tfm = crypto.verify_tfm;
2605 connection->my_addr_len = nla_len(adm_ctx.my_addr);
2606 memcpy(&connection->my_addr, nla_data(adm_ctx.my_addr), connection->my_addr_len);
2607 connection->peer_addr_len = nla_len(adm_ctx.peer_addr);
2608 memcpy(&connection->peer_addr, nla_data(adm_ctx.peer_addr), connection->peer_addr_len);
2610 idr_for_each_entry(&connection->peer_devices, peer_device, i) {
2614 connection_to_info(&connection_info, connection);
2617 notify_connection_state(NULL, 0, connection, &connection_info, NOTIFY_CREATE | flags);
2618 idr_for_each_entry(&connection->peer_devices, peer_device, i) {
2629 idr_for_each_entry(&connection->peer_devices, peer_device, i) {
2636 rv = conn_request_state(connection, NS(conn, C_UNCONNECTED), CS_VERBOSE);
2638 conn_reconfig_done(connection);
2647 conn_reconfig_done(connection);
2654 static enum drbd_state_rv conn_try_disconnect(struct drbd_connection *connection, bool force)
2660 rv = conn_request_state(connection, NS(conn, C_DISCONNECTING),
2670 rv = conn_request_state(connection, NS2(conn, C_DISCONNECTING, pdsk, D_OUTDATED), 0);
2672 if (rv == SS_OUTDATE_WO_CONN) /* lost connection before graceful disconnect succeeded */
2673 rv = conn_request_state(connection, NS(conn, C_DISCONNECTING), CS_VERBOSE);
2677 spin_lock_irq(&connection->resource->req_lock);
2678 cstate = connection->cstate;
2679 spin_unlock_irq(&connection->resource->req_lock);
2683 rv = conn_request_state(connection, NS2(conn, C_DISCONNECTING,
2686 rv = conn_request_state(connection, NS(conn, C_DISCONNECTING),
2700 drbd_thread_stop(&connection->receiver);
2708 rv2 = conn_request_state(connection, NS(conn, C_STANDALONE),
2711 drbd_err(connection,
2715 * NOTIFY_DESTROY events before clearing connection->net_conf. */
2724 struct drbd_connection *connection;
2735 connection = adm_ctx.connection;
2747 rv = conn_try_disconnect(connection, parms.force_disconnect);
2767 iass = test_bit(RESOLVE_CONFLICTS, &first_peer_device(device)->connection->flags);
2824 if (rs.no_resync && first_peer_device(device)->connection->agreed_pro_version < 93) {
2974 drbd_flush_workqueue(&first_peer_device(device)->connection->sender_work);
3052 drbd_flush_workqueue(&first_peer_device(device)->connection->sender_work);
3152 * lost the replication connection, and are configured
3154 * So we still don't have a replication connection.
3176 tl_clear(first_peer_device(device)->connection);
3178 tl_restart(first_peer_device(device)->connection, FAIL_FROZEN_DISK_IO);
3194 struct drbd_connection *connection,
3206 if (connection) {
3207 if (connection->my_addr_len &&
3208 nla_put(skb, T_ctx_my_addr, connection->my_addr_len, &connection->my_addr))
3210 if (connection->peer_addr_len &&
3211 nla_put(skb, T_ctx_peer_addr, connection->peer_addr_len, &connection->peer_addr))
3447 struct drbd_connection *connection;
3480 for_each_connection_rcu(connection, resource)
3481 if (connection == (struct drbd_connection *)cb->args[2])
3483 /* connection was probably deleted */
3486 connection = list_entry(&resource->connections, struct drbd_connection, connections);
3489 list_for_each_entry_continue_rcu(connection, &resource->connections, connections) {
3490 if (!has_net_conf(connection))
3530 err = nla_put_drbd_cfg_context(skb, resource, connection, NULL);
3533 net_conf = rcu_dereference(connection->net_conf);
3539 connection_to_info(&connection_info, connection);
3543 connection_statistics.conn_congested = test_bit(NET_CONGESTED, &connection->flags);
3547 cb->args[2] = (long)connection;
3653 if (!has_net_conf(peer_device->connection))
3674 err = nla_put_drbd_cfg_context(skb, device->resource, peer_device->connection, device);
3698 * Return the connection of @resource if @resource has exactly one connection.
3734 /* We need to add connection name and volume number information still.
3752 nc = rcu_dereference(first_peer_device(device)->connection->net_conf);
3867 * connection = "first connection of resource or undefined";
3929 /* This is a connection without a single volume.
3932 struct drbd_connection *connection;
3936 connection = the_only_connection(resource);
3937 if (nla_put_drbd_cfg_context(skb, resource, connection, NULL))
3939 if (connection) {
3942 nc = rcu_dereference(connection->net_conf);
4028 * only dump this connection. */
4147 first_peer_device(device)->connection->agreed_pro_version >= 90 &&
4216 struct drbd_connection *connection;
4251 connection = conn_create(adm_ctx.resource_name, &res_opts);
4254 if (connection) {
4258 resource_to_info(&resource_info, connection->resource);
4259 notify_resource_state(NULL, 0, connection->resource,
4301 * that first_peer_device(device)->connection and device->vnr match the request. */
4320 if (!has_net_conf(peer_device->connection))
4332 if (!has_net_conf(peer_device->connection))
4356 struct drbd_connection *connection =
4365 if (get_t_state(&connection->worker) == RUNNING)
4366 drbd_flush_workqueue(&connection->sender_work);
4370 if (!has_net_conf(peer_device->connection))
4405 struct drbd_connection *connection;
4407 for_each_connection(connection, resource) {
4408 if (connection->cstate > C_STANDALONE)
4426 list_for_each_entry(connection, &resource->connections, connections)
4427 drbd_thread_stop(&connection->worker);
4437 struct drbd_connection *connection;
4451 for_each_connection(connection, resource) {
4454 idr_for_each_entry(&connection->peer_devices, peer_device, i) {
4462 retcode = conn_try_disconnect(connection, 0);
4668 struct drbd_connection *connection,
4692 if (nla_put_drbd_cfg_context(skb, connection->resource, connection, NULL) ||
4697 connection_statistics.conn_congested = test_bit(NET_CONGESTED, &connection->flags);
4711 drbd_err(connection, "Error %d while broadcasting event. Event seq:%u\n",
4743 if (nla_put_drbd_cfg_context(skb, resource, peer_device->connection, peer_device->device) ||
4768 struct drbd_device *device, struct drbd_connection *connection,
4771 struct drbd_resource *resource = device ? device->resource : connection->resource;
4794 if (nla_put_drbd_cfg_context(skb, resource, connection, device) ||