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;
1196 static unsigned int drbd_max_discard_sectors(struct drbd_connection *connection)
1200 if (connection->agreed_features & DRBD_FF_WSAME)
1215 struct drbd_connection *connection = first_peer_device(device)->connection;
1218 if (can_do && connection->cstate >= C_CONNECTED && !(connection->agreed_features & DRBD_FF_TRIM)) {
1220 drbd_info(connection, "peer DRBD too old, does not support TRIM: disabling discards\n");
1230 q->limits.max_discard_sectors = drbd_max_discard_sectors(connection);
1232 q->limits.max_write_zeroes_sectors = drbd_max_discard_sectors(connection);
1259 struct drbd_connection *connection = first_peer_device(device)->connection;
1262 if (connection->agreed_features & DRBD_FF_WZEROES)
1274 struct drbd_connection *connection = peer_device->connection;
1282 if (can_do && connection->cstate >= C_CONNECTED && !(connection->agreed_features & DRBD_FF_WSAME)) {
1391 if (first_peer_device(device)->connection->agreed_pro_version < 94)
1394 else if (first_peer_device(device)->connection->agreed_pro_version == 94)
1396 else if (first_peer_device(device)->connection->agreed_pro_version < 100)
1420 static void conn_reconfig_start(struct drbd_connection *connection)
1422 drbd_thread_start(&connection->worker);
1423 drbd_flush_workqueue(&connection->sender_work);
1427 static void conn_reconfig_done(struct drbd_connection *connection)
1430 spin_lock_irq(&connection->resource->req_lock);
1431 stop_threads = conn_all_vols_unconf(connection) &&
1432 connection->cstate == C_STANDALONE;
1433 spin_unlock_irq(&connection->resource->req_lock);
1437 drbd_thread_stop(&connection->receiver);
1438 drbd_thread_stop(&connection->worker);
1789 struct drbd_connection *connection;
1812 connection = peer_device->connection;
1813 conn_reconfig_start(connection);
1874 nc = rcu_dereference(connection->net_conf);
1964 drbd_flush_workqueue(&connection->sender_work);
2067 * Now, if I had no connection before that crash
2179 conn_reconfig_done(connection);
2190 conn_reconfig_done(connection);
2251 static bool conn_resync_running(struct drbd_connection *connection)
2258 idr_for_each_entry(&connection->peer_devices, peer_device, vnr) {
2273 static bool conn_ov_running(struct drbd_connection *connection)
2280 idr_for_each_entry(&connection->peer_devices, peer_device, vnr) {
2294 _check_net_options(struct drbd_connection *connection, struct net_conf *old_net_conf, struct net_conf *new_net_conf)
2299 if (old_net_conf && connection->cstate == C_WF_REPORT_PARAMS && connection->agreed_pro_version < 100) {
2311 conn_highest_role(connection) == R_PRIMARY &&
2312 conn_highest_peer(connection) == R_PRIMARY)
2319 idr_for_each_entry(&connection->peer_devices, peer_device, i) {
2338 check_net_options(struct drbd_connection *connection, struct net_conf *new_net_conf)
2345 rv = _check_net_options(connection, rcu_dereference(connection->net_conf), new_net_conf);
2348 /* connection->peer_devices protected by genl_lock() here */
2349 idr_for_each_entry(&connection->peer_devices, peer_device, i) {
2423 struct drbd_connection *connection;
2436 connection = adm_ctx.connection;
2445 conn_reconfig_start(connection);
2447 mutex_lock(&connection->data.mutex);
2448 mutex_lock(&connection->resource->conf_update);
2449 old_net_conf = connection->net_conf;
2468 retcode = check_net_options(connection, new_net_conf);
2473 rsr = conn_resync_running(connection);
2480 ovr = conn_ov_running(connection);
2490 rcu_assign_pointer(connection->net_conf, new_net_conf);
2493 crypto_free_shash(connection->csums_tfm);
2494 connection->csums_tfm = crypto.csums_tfm;
2498 crypto_free_shash(connection->verify_tfm);
2499 connection->verify_tfm = crypto.verify_tfm;
2503 crypto_free_shash(connection->integrity_tfm);
2504 connection->integrity_tfm = crypto.integrity_tfm;
2505 if (connection->cstate >= C_WF_REPORT_PARAMS && connection->agreed_pro_version >= 100)
2506 /* Do this without trying to take connection->data.mutex again. */
2507 __drbd_send_protocol(connection, P_PROTOCOL_UPDATE);
2509 crypto_free_shash(connection->cram_hmac_tfm);
2510 connection->cram_hmac_tfm = crypto.cram_hmac_tfm;
2512 mutex_unlock(&connection->resource->conf_update);
2513 mutex_unlock(&connection->data.mutex);
2517 if (connection->cstate >= C_WF_REPORT_PARAMS) {
2521 idr_for_each_entry(&connection->peer_devices, peer_device, vnr)
2528 mutex_unlock(&connection->resource->conf_update);
2529 mutex_unlock(&connection->data.mutex);
2533 conn_reconfig_done(connection);
2542 struct drbd_connection *connection)
2544 info->conn_connection_state = connection->cstate;
2545 info->conn_role = conn_highest_peer(connection);
2571 struct drbd_connection *connection;
2583 drbd_msg_put_info(adm_ctx.reply_skb, "connection endpoint(s) missing");
2592 for_each_connection(connection, resource) {
2593 if (nla_len(adm_ctx.my_addr) == connection->my_addr_len &&
2594 !memcmp(nla_data(adm_ctx.my_addr), &connection->my_addr,
2595 connection->my_addr_len)) {
2600 if (nla_len(adm_ctx.peer_addr) == connection->peer_addr_len &&
2601 !memcmp(nla_data(adm_ctx.peer_addr), &connection->peer_addr,
2602 connection->peer_addr_len)) {
2610 connection = first_connection(adm_ctx.resource);
2611 conn_reconfig_start(connection);
2613 if (connection->cstate > C_STANDALONE) {
2634 retcode = check_net_options(connection, new_net_conf);
2644 drbd_flush_workqueue(&connection->sender_work);
2647 old_net_conf = connection->net_conf;
2653 rcu_assign_pointer(connection->net_conf, new_net_conf);
2655 conn_free_crypto(connection);
2656 connection->cram_hmac_tfm = crypto.cram_hmac_tfm;
2657 connection->integrity_tfm = crypto.integrity_tfm;
2658 connection->csums_tfm = crypto.csums_tfm;
2659 connection->verify_tfm = crypto.verify_tfm;
2661 connection->my_addr_len = nla_len(adm_ctx.my_addr);
2662 memcpy(&connection->my_addr, nla_data(adm_ctx.my_addr), connection->my_addr_len);
2663 connection->peer_addr_len = nla_len(adm_ctx.peer_addr);
2664 memcpy(&connection->peer_addr, nla_data(adm_ctx.peer_addr), connection->peer_addr_len);
2666 idr_for_each_entry(&connection->peer_devices, peer_device, i) {
2670 connection_to_info(&connection_info, connection);
2673 notify_connection_state(NULL, 0, connection, &connection_info, NOTIFY_CREATE | flags);
2674 idr_for_each_entry(&connection->peer_devices, peer_device, i) {
2685 idr_for_each_entry(&connection->peer_devices, peer_device, i) {
2692 retcode = (enum drbd_ret_code)conn_request_state(connection,
2695 conn_reconfig_done(connection);
2704 conn_reconfig_done(connection);
2711 static enum drbd_state_rv conn_try_disconnect(struct drbd_connection *connection, bool force)
2717 rv = conn_request_state(connection, NS(conn, C_DISCONNECTING),
2727 rv = conn_request_state(connection, NS2(conn, C_DISCONNECTING, pdsk, D_OUTDATED), 0);
2729 if (rv == SS_OUTDATE_WO_CONN) /* lost connection before graceful disconnect succeeded */
2730 rv = conn_request_state(connection, NS(conn, C_DISCONNECTING), CS_VERBOSE);
2734 spin_lock_irq(&connection->resource->req_lock);
2735 cstate = connection->cstate;
2736 spin_unlock_irq(&connection->resource->req_lock);
2740 rv = conn_request_state(connection, NS2(conn, C_DISCONNECTING,
2743 rv = conn_request_state(connection, NS(conn, C_DISCONNECTING),
2757 drbd_thread_stop(&connection->receiver);
2765 rv2 = conn_request_state(connection, NS(conn, C_STANDALONE),
2768 drbd_err(connection,
2772 * NOTIFY_DESTROY events before clearing connection->net_conf. */
2781 struct drbd_connection *connection;
2792 connection = adm_ctx.connection;
2804 rv = conn_try_disconnect(connection, parms.force_disconnect);
2823 iass = test_bit(RESOLVE_CONFLICTS, &first_peer_device(device)->connection->flags);
2880 if (rs.no_resync && first_peer_device(device)->connection->agreed_pro_version < 93) {
3031 drbd_flush_workqueue(&first_peer_device(device)->connection->sender_work);
3108 drbd_flush_workqueue(&first_peer_device(device)->connection->sender_work);
3208 * lost the replication connection, and are configured
3210 * So we still don't have a replication connection.
3232 tl_clear(first_peer_device(device)->connection);
3234 tl_restart(first_peer_device(device)->connection, FAIL_FROZEN_DISK_IO);
3250 struct drbd_connection *connection,
3262 if (connection) {
3263 if (connection->my_addr_len &&
3264 nla_put(skb, T_ctx_my_addr, connection->my_addr_len, &connection->my_addr))
3266 if (connection->peer_addr_len &&
3267 nla_put(skb, T_ctx_peer_addr, connection->peer_addr_len, &connection->peer_addr))
3503 struct drbd_connection *connection;
3536 for_each_connection_rcu(connection, resource)
3537 if (connection == (struct drbd_connection *)cb->args[2])
3539 /* connection was probably deleted */
3542 connection = list_entry(&resource->connections, struct drbd_connection, connections);
3545 list_for_each_entry_continue_rcu(connection, &resource->connections, connections) {
3546 if (!has_net_conf(connection))
3586 err = nla_put_drbd_cfg_context(skb, resource, connection, NULL);
3589 net_conf = rcu_dereference(connection->net_conf);
3595 connection_to_info(&connection_info, connection);
3599 connection_statistics.conn_congested = test_bit(NET_CONGESTED, &connection->flags);
3603 cb->args[2] = (long)connection;
3709 if (!has_net_conf(peer_device->connection))
3730 err = nla_put_drbd_cfg_context(skb, device->resource, peer_device->connection, device);
3754 * Return the connection of @resource if @resource has exactly one connection.
3790 /* We need to add connection name and volume number information still.
3808 nc = rcu_dereference(first_peer_device(device)->connection->net_conf);
3923 * connection = "first connection of resource or undefined";
3985 /* This is a connection without a single volume.
3988 struct drbd_connection *connection;
3992 connection = the_only_connection(resource);
3993 if (nla_put_drbd_cfg_context(skb, resource, connection, NULL))
3995 if (connection) {
3998 nc = rcu_dereference(connection->net_conf);
4084 * only dump this connection. */
4203 first_peer_device(device)->connection->agreed_pro_version >= 90 &&
4272 struct drbd_connection *connection;
4307 connection = conn_create(adm_ctx.resource_name, &res_opts);
4310 if (connection) {
4314 resource_to_info(&resource_info, connection->resource);
4315 notify_resource_state(NULL, 0, connection->resource,
4357 * that first_peer_device(device)->connection and device->vnr match the request. */
4376 if (!has_net_conf(peer_device->connection))
4388 if (!has_net_conf(peer_device->connection))
4412 struct drbd_connection *connection =
4421 if (get_t_state(&connection->worker) == RUNNING)
4422 drbd_flush_workqueue(&connection->sender_work);
4426 if (!has_net_conf(peer_device->connection))
4461 struct drbd_connection *connection;
4463 for_each_connection(connection, resource) {
4464 if (connection->cstate > C_STANDALONE)
4482 list_for_each_entry(connection, &resource->connections, connections)
4483 drbd_thread_stop(&connection->worker);
4493 struct drbd_connection *connection;
4507 for_each_connection(connection, resource) {
4510 idr_for_each_entry(&connection->peer_devices, peer_device, i) {
4518 retcode = conn_try_disconnect(connection, 0);
4724 struct drbd_connection *connection,
4748 if (nla_put_drbd_cfg_context(skb, connection->resource, connection, NULL) ||
4753 connection_statistics.conn_congested = test_bit(NET_CONGESTED, &connection->flags);
4767 drbd_err(connection, "Error %d while broadcasting event. Event seq:%u\n",
4799 if (nla_put_drbd_cfg_context(skb, resource, peer_device->connection, peer_device->device) ||
4824 struct drbd_device *device, struct drbd_connection *connection,
4827 struct drbd_resource *resource = device ? device->resource : connection->resource;
4850 if (nla_put_drbd_cfg_context(skb, resource, connection, device) ||