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;
1201 if (first_peer_device(device)->connection->agreed_pro_version < 94)
1208 if (first_peer_device(device)->connection->agreed_pro_version == 94)
1214 if (first_peer_device(device)->connection->agreed_pro_version < 100)
1219 static unsigned int drbd_max_discard_sectors(struct drbd_connection *connection)
1223 if (connection->agreed_features & DRBD_FF_WSAME)
1229 static bool drbd_discard_supported(struct drbd_connection *connection,
1235 if (connection->cstate >= C_CONNECTED &&
1236 !(connection->agreed_features & DRBD_FF_TRIM)) {
1237 drbd_info(connection,
1262 struct drbd_connection *connection =
1263 first_peer_device(device)->connection;
1312 if (drbd_discard_supported(connection, bdev)) {
1315 drbd_max_discard_sectors(connection);
1329 if (connection->agreed_features & DRBD_FF_WZEROES)
1345 static void conn_reconfig_start(struct drbd_connection *connection)
1347 drbd_thread_start(&connection->worker);
1348 drbd_flush_workqueue(&connection->sender_work);
1352 static void conn_reconfig_done(struct drbd_connection *connection)
1355 spin_lock_irq(&connection->resource->req_lock);
1356 stop_threads = conn_all_vols_unconf(connection) &&
1357 connection->cstate == C_STANDALONE;
1358 spin_unlock_irq(&connection->resource->req_lock);
1362 drbd_thread_stop(&connection->receiver);
1363 drbd_thread_stop(&connection->worker);
1721 struct drbd_connection *connection;
1744 connection = peer_device->connection;
1745 conn_reconfig_start(connection);
1806 nc = rcu_dereference(connection->net_conf);
1896 drbd_flush_workqueue(&connection->sender_work);
1999 * Now, if I had no connection before that crash
2113 conn_reconfig_done(connection);
2124 conn_reconfig_done(connection);
2186 static bool conn_resync_running(struct drbd_connection *connection)
2193 idr_for_each_entry(&connection->peer_devices, peer_device, vnr) {
2208 static bool conn_ov_running(struct drbd_connection *connection)
2215 idr_for_each_entry(&connection->peer_devices, peer_device, vnr) {
2229 _check_net_options(struct drbd_connection *connection, struct net_conf *old_net_conf, struct net_conf *new_net_conf)
2234 if (old_net_conf && connection->cstate == C_WF_REPORT_PARAMS && connection->agreed_pro_version < 100) {
2246 conn_highest_role(connection) == R_PRIMARY &&
2247 conn_highest_peer(connection) == R_PRIMARY)
2254 idr_for_each_entry(&connection->peer_devices, peer_device, i) {
2273 check_net_options(struct drbd_connection *connection, struct net_conf *new_net_conf)
2280 rv = _check_net_options(connection, rcu_dereference(connection->net_conf), new_net_conf);
2283 /* connection->peer_devices protected by genl_lock() here */
2284 idr_for_each_entry(&connection->peer_devices, peer_device, i) {
2358 struct drbd_connection *connection;
2371 connection = adm_ctx.connection;
2380 conn_reconfig_start(connection);
2382 mutex_lock(&connection->data.mutex);
2383 mutex_lock(&connection->resource->conf_update);
2384 old_net_conf = connection->net_conf;
2403 retcode = check_net_options(connection, new_net_conf);
2408 rsr = conn_resync_running(connection);
2415 ovr = conn_ov_running(connection);
2425 rcu_assign_pointer(connection->net_conf, new_net_conf);
2428 crypto_free_shash(connection->csums_tfm);
2429 connection->csums_tfm = crypto.csums_tfm;
2433 crypto_free_shash(connection->verify_tfm);
2434 connection->verify_tfm = crypto.verify_tfm;
2438 crypto_free_shash(connection->integrity_tfm);
2439 connection->integrity_tfm = crypto.integrity_tfm;
2440 if (connection->cstate >= C_WF_REPORT_PARAMS && connection->agreed_pro_version >= 100)
2441 /* Do this without trying to take connection->data.mutex again. */
2442 __drbd_send_protocol(connection, P_PROTOCOL_UPDATE);
2444 crypto_free_shash(connection->cram_hmac_tfm);
2445 connection->cram_hmac_tfm = crypto.cram_hmac_tfm;
2447 mutex_unlock(&connection->resource->conf_update);
2448 mutex_unlock(&connection->data.mutex);
2451 if (connection->cstate >= C_WF_REPORT_PARAMS) {
2455 idr_for_each_entry(&connection->peer_devices, peer_device, vnr)
2462 mutex_unlock(&connection->resource->conf_update);
2463 mutex_unlock(&connection->data.mutex);
2467 conn_reconfig_done(connection);
2476 struct drbd_connection *connection)
2478 info->conn_connection_state = connection->cstate;
2479 info->conn_role = conn_highest_peer(connection);
2505 struct drbd_connection *connection;
2518 drbd_msg_put_info(adm_ctx.reply_skb, "connection endpoint(s) missing");
2527 for_each_connection(connection, resource) {
2528 if (nla_len(adm_ctx.my_addr) == connection->my_addr_len &&
2529 !memcmp(nla_data(adm_ctx.my_addr), &connection->my_addr,
2530 connection->my_addr_len)) {
2535 if (nla_len(adm_ctx.peer_addr) == connection->peer_addr_len &&
2536 !memcmp(nla_data(adm_ctx.peer_addr), &connection->peer_addr,
2537 connection->peer_addr_len)) {
2545 connection = first_connection(adm_ctx.resource);
2546 conn_reconfig_start(connection);
2548 if (connection->cstate > C_STANDALONE) {
2569 retcode = check_net_options(connection, new_net_conf);
2579 drbd_flush_workqueue(&connection->sender_work);
2582 old_net_conf = connection->net_conf;
2588 rcu_assign_pointer(connection->net_conf, new_net_conf);
2590 conn_free_crypto(connection);
2591 connection->cram_hmac_tfm = crypto.cram_hmac_tfm;
2592 connection->integrity_tfm = crypto.integrity_tfm;
2593 connection->csums_tfm = crypto.csums_tfm;
2594 connection->verify_tfm = crypto.verify_tfm;
2596 connection->my_addr_len = nla_len(adm_ctx.my_addr);
2597 memcpy(&connection->my_addr, nla_data(adm_ctx.my_addr), connection->my_addr_len);
2598 connection->peer_addr_len = nla_len(adm_ctx.peer_addr);
2599 memcpy(&connection->peer_addr, nla_data(adm_ctx.peer_addr), connection->peer_addr_len);
2601 idr_for_each_entry(&connection->peer_devices, peer_device, i) {
2605 connection_to_info(&connection_info, connection);
2608 notify_connection_state(NULL, 0, connection, &connection_info, NOTIFY_CREATE | flags);
2609 idr_for_each_entry(&connection->peer_devices, peer_device, i) {
2620 idr_for_each_entry(&connection->peer_devices, peer_device, i) {
2627 rv = conn_request_state(connection, NS(conn, C_UNCONNECTED), CS_VERBOSE);
2629 conn_reconfig_done(connection);
2638 conn_reconfig_done(connection);
2645 static enum drbd_state_rv conn_try_disconnect(struct drbd_connection *connection, bool force)
2651 rv = conn_request_state(connection, NS(conn, C_DISCONNECTING),
2661 rv = conn_request_state(connection, NS2(conn, C_DISCONNECTING, pdsk, D_OUTDATED), 0);
2663 if (rv == SS_OUTDATE_WO_CONN) /* lost connection before graceful disconnect succeeded */
2664 rv = conn_request_state(connection, NS(conn, C_DISCONNECTING), CS_VERBOSE);
2668 spin_lock_irq(&connection->resource->req_lock);
2669 cstate = connection->cstate;
2670 spin_unlock_irq(&connection->resource->req_lock);
2674 rv = conn_request_state(connection, NS2(conn, C_DISCONNECTING,
2677 rv = conn_request_state(connection, NS(conn, C_DISCONNECTING),
2691 drbd_thread_stop(&connection->receiver);
2699 rv2 = conn_request_state(connection, NS(conn, C_STANDALONE),
2702 drbd_err(connection,
2706 * NOTIFY_DESTROY events before clearing connection->net_conf. */
2715 struct drbd_connection *connection;
2726 connection = adm_ctx.connection;
2738 rv = conn_try_disconnect(connection, parms.force_disconnect);
2758 iass = test_bit(RESOLVE_CONFLICTS, &first_peer_device(device)->connection->flags);
2815 if (rs.no_resync && first_peer_device(device)->connection->agreed_pro_version < 93) {
2965 drbd_flush_workqueue(&first_peer_device(device)->connection->sender_work);
3043 drbd_flush_workqueue(&first_peer_device(device)->connection->sender_work);
3143 * lost the replication connection, and are configured
3145 * So we still don't have a replication connection.
3167 tl_clear(first_peer_device(device)->connection);
3169 tl_restart(first_peer_device(device)->connection, FAIL_FROZEN_DISK_IO);
3185 struct drbd_connection *connection,
3197 if (connection) {
3198 if (connection->my_addr_len &&
3199 nla_put(skb, T_ctx_my_addr, connection->my_addr_len, &connection->my_addr))
3201 if (connection->peer_addr_len &&
3202 nla_put(skb, T_ctx_peer_addr, connection->peer_addr_len, &connection->peer_addr))
3438 struct drbd_connection *connection;
3471 for_each_connection_rcu(connection, resource)
3472 if (connection == (struct drbd_connection *)cb->args[2])
3474 /* connection was probably deleted */
3477 connection = list_entry(&resource->connections, struct drbd_connection, connections);
3480 list_for_each_entry_continue_rcu(connection, &resource->connections, connections) {
3481 if (!has_net_conf(connection))
3521 err = nla_put_drbd_cfg_context(skb, resource, connection, NULL);
3524 net_conf = rcu_dereference(connection->net_conf);
3530 connection_to_info(&connection_info, connection);
3534 connection_statistics.conn_congested = test_bit(NET_CONGESTED, &connection->flags);
3538 cb->args[2] = (long)connection;
3644 if (!has_net_conf(peer_device->connection))
3665 err = nla_put_drbd_cfg_context(skb, device->resource, peer_device->connection, device);
3689 * Return the connection of @resource if @resource has exactly one connection.
3725 /* We need to add connection name and volume number information still.
3743 nc = rcu_dereference(first_peer_device(device)->connection->net_conf);
3858 * connection = "first connection of resource or undefined";
3920 /* This is a connection without a single volume.
3923 struct drbd_connection *connection;
3927 connection = the_only_connection(resource);
3928 if (nla_put_drbd_cfg_context(skb, resource, connection, NULL))
3930 if (connection) {
3933 nc = rcu_dereference(connection->net_conf);
4019 * only dump this connection. */
4138 first_peer_device(device)->connection->agreed_pro_version >= 90 &&
4207 struct drbd_connection *connection;
4242 connection = conn_create(adm_ctx.resource_name, &res_opts);
4245 if (connection) {
4249 resource_to_info(&resource_info, connection->resource);
4250 notify_resource_state(NULL, 0, connection->resource,
4292 * that first_peer_device(device)->connection and device->vnr match the request. */
4311 if (!has_net_conf(peer_device->connection))
4323 if (!has_net_conf(peer_device->connection))
4347 struct drbd_connection *connection =
4356 if (get_t_state(&connection->worker) == RUNNING)
4357 drbd_flush_workqueue(&connection->sender_work);
4361 if (!has_net_conf(peer_device->connection))
4396 struct drbd_connection *connection;
4398 for_each_connection(connection, resource) {
4399 if (connection->cstate > C_STANDALONE)
4417 list_for_each_entry(connection, &resource->connections, connections)
4418 drbd_thread_stop(&connection->worker);
4428 struct drbd_connection *connection;
4442 for_each_connection(connection, resource) {
4445 idr_for_each_entry(&connection->peer_devices, peer_device, i) {
4453 retcode = conn_try_disconnect(connection, 0);
4659 struct drbd_connection *connection,
4683 if (nla_put_drbd_cfg_context(skb, connection->resource, connection, NULL) ||
4688 connection_statistics.conn_congested = test_bit(NET_CONGESTED, &connection->flags);
4702 drbd_err(connection, "Error %d while broadcasting event. Event seq:%u\n",
4734 if (nla_put_drbd_cfg_context(skb, resource, peer_device->connection, peer_device->device) ||
4759 struct drbd_device *device, struct drbd_connection *connection,
4762 struct drbd_resource *resource = device ? device->resource : connection->resource;
4785 if (nla_put_drbd_cfg_context(skb, resource, connection, device) ||