aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/drbd/drbd_nl.c
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@linbit.com>2011-05-30 10:32:41 -0400
committerPhilipp Reisner <philipp.reisner@linbit.com>2014-02-17 10:44:47 -0500
commitbde89a9e151b482765ed40e04307a6190236b387 (patch)
tree1154a0261466fa426dede7cce2b9370d48133b61 /drivers/block/drbd/drbd_nl.c
parentb30ab7913b0a7b1d3b1091c8cb3abb1a9f1e0824 (diff)
drbd: Rename drbd_tconn -> drbd_connection
sed -i -e 's:all_tconn:connections:g' -e 's:tconn:connection:g' Signed-off-by: Andreas Gruenbacher <agruen@linbit.com> Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Diffstat (limited to 'drivers/block/drbd/drbd_nl.c')
-rw-r--r--drivers/block/drbd/drbd_nl.c519
1 files changed, 259 insertions, 260 deletions
diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
index bc160ae80798..1b5b7ea7f7cc 100644
--- a/drivers/block/drbd/drbd_nl.c
+++ b/drivers/block/drbd/drbd_nl.c
@@ -104,7 +104,7 @@ static struct drbd_config_context {
104 struct drbd_genlmsghdr *reply_dh; 104 struct drbd_genlmsghdr *reply_dh;
105 /* resolved from attributes, if possible */ 105 /* resolved from attributes, if possible */
106 struct drbd_device *device; 106 struct drbd_device *device;
107 struct drbd_tconn *tconn; 107 struct drbd_connection *connection;
108} adm_ctx; 108} adm_ctx;
109 109
110static void drbd_adm_send_reply(struct sk_buff *skb, struct genl_info *info) 110static void drbd_adm_send_reply(struct sk_buff *skb, struct genl_info *info)
@@ -203,9 +203,9 @@ static int drbd_adm_prepare(struct sk_buff *skb, struct genl_info *info,
203 adm_ctx.my_addr = nested_attr_tb[__nla_type(T_ctx_my_addr)]; 203 adm_ctx.my_addr = nested_attr_tb[__nla_type(T_ctx_my_addr)];
204 adm_ctx.peer_addr = nested_attr_tb[__nla_type(T_ctx_peer_addr)]; 204 adm_ctx.peer_addr = nested_attr_tb[__nla_type(T_ctx_peer_addr)];
205 if ((adm_ctx.my_addr && 205 if ((adm_ctx.my_addr &&
206 nla_len(adm_ctx.my_addr) > sizeof(adm_ctx.tconn->my_addr)) || 206 nla_len(adm_ctx.my_addr) > sizeof(adm_ctx.connection->my_addr)) ||
207 (adm_ctx.peer_addr && 207 (adm_ctx.peer_addr &&
208 nla_len(adm_ctx.peer_addr) > sizeof(adm_ctx.tconn->peer_addr))) { 208 nla_len(adm_ctx.peer_addr) > sizeof(adm_ctx.connection->peer_addr))) {
209 err = -EINVAL; 209 err = -EINVAL;
210 goto fail; 210 goto fail;
211 } 211 }
@@ -213,19 +213,19 @@ static int drbd_adm_prepare(struct sk_buff *skb, struct genl_info *info,
213 213
214 adm_ctx.minor = d_in->minor; 214 adm_ctx.minor = d_in->minor;
215 adm_ctx.device = minor_to_device(d_in->minor); 215 adm_ctx.device = minor_to_device(d_in->minor);
216 adm_ctx.tconn = conn_get_by_name(adm_ctx.resource_name); 216 adm_ctx.connection = conn_get_by_name(adm_ctx.resource_name);
217 217
218 if (!adm_ctx.device && (flags & DRBD_ADM_NEED_MINOR)) { 218 if (!adm_ctx.device && (flags & DRBD_ADM_NEED_MINOR)) {
219 drbd_msg_put_info("unknown minor"); 219 drbd_msg_put_info("unknown minor");
220 return ERR_MINOR_INVALID; 220 return ERR_MINOR_INVALID;
221 } 221 }
222 if (!adm_ctx.tconn && (flags & DRBD_ADM_NEED_RESOURCE)) { 222 if (!adm_ctx.connection && (flags & DRBD_ADM_NEED_RESOURCE)) {
223 drbd_msg_put_info("unknown resource"); 223 drbd_msg_put_info("unknown resource");
224 return ERR_INVALID_REQUEST; 224 return ERR_INVALID_REQUEST;
225 } 225 }
226 226
227 if (flags & DRBD_ADM_NEED_CONNECTION) { 227 if (flags & DRBD_ADM_NEED_CONNECTION) {
228 if (adm_ctx.tconn && !(flags & DRBD_ADM_NEED_RESOURCE)) { 228 if (adm_ctx.connection && !(flags & DRBD_ADM_NEED_RESOURCE)) {
229 drbd_msg_put_info("no resource name expected"); 229 drbd_msg_put_info("no resource name expected");
230 return ERR_INVALID_REQUEST; 230 return ERR_INVALID_REQUEST;
231 } 231 }
@@ -234,22 +234,22 @@ static int drbd_adm_prepare(struct sk_buff *skb, struct genl_info *info,
234 return ERR_INVALID_REQUEST; 234 return ERR_INVALID_REQUEST;
235 } 235 }
236 if (adm_ctx.my_addr && adm_ctx.peer_addr) 236 if (adm_ctx.my_addr && adm_ctx.peer_addr)
237 adm_ctx.tconn = conn_get_by_addrs(nla_data(adm_ctx.my_addr), 237 adm_ctx.connection = conn_get_by_addrs(nla_data(adm_ctx.my_addr),
238 nla_len(adm_ctx.my_addr), 238 nla_len(adm_ctx.my_addr),
239 nla_data(adm_ctx.peer_addr), 239 nla_data(adm_ctx.peer_addr),
240 nla_len(adm_ctx.peer_addr)); 240 nla_len(adm_ctx.peer_addr));
241 if (!adm_ctx.tconn) { 241 if (!adm_ctx.connection) {
242 drbd_msg_put_info("unknown connection"); 242 drbd_msg_put_info("unknown connection");
243 return ERR_INVALID_REQUEST; 243 return ERR_INVALID_REQUEST;
244 } 244 }
245 } 245 }
246 246
247 /* some more paranoia, if the request was over-determined */ 247 /* some more paranoia, if the request was over-determined */
248 if (adm_ctx.device && adm_ctx.tconn && 248 if (adm_ctx.device && adm_ctx.connection &&
249 adm_ctx.device->tconn != adm_ctx.tconn) { 249 adm_ctx.device->connection != adm_ctx.connection) {
250 pr_warning("request: minor=%u, resource=%s; but that minor belongs to connection %s\n", 250 pr_warning("request: minor=%u, resource=%s; but that minor belongs to connection %s\n",
251 adm_ctx.minor, adm_ctx.resource_name, 251 adm_ctx.minor, adm_ctx.resource_name,
252 adm_ctx.device->tconn->name); 252 adm_ctx.device->connection->name);
253 drbd_msg_put_info("minor exists in different resource"); 253 drbd_msg_put_info("minor exists in different resource");
254 return ERR_INVALID_REQUEST; 254 return ERR_INVALID_REQUEST;
255 } 255 }
@@ -258,7 +258,7 @@ static int drbd_adm_prepare(struct sk_buff *skb, struct genl_info *info,
258 adm_ctx.volume != adm_ctx.device->vnr) { 258 adm_ctx.volume != adm_ctx.device->vnr) {
259 pr_warning("request: minor=%u, volume=%u; but that minor is volume %u in %s\n", 259 pr_warning("request: minor=%u, volume=%u; but that minor is volume %u in %s\n",
260 adm_ctx.minor, adm_ctx.volume, 260 adm_ctx.minor, adm_ctx.volume,
261 adm_ctx.device->vnr, adm_ctx.device->tconn->name); 261 adm_ctx.device->vnr, adm_ctx.device->connection->name);
262 drbd_msg_put_info("minor exists as different volume"); 262 drbd_msg_put_info("minor exists as different volume");
263 return ERR_INVALID_REQUEST; 263 return ERR_INVALID_REQUEST;
264 } 264 }
@@ -273,9 +273,9 @@ fail:
273 273
274static int drbd_adm_finish(struct genl_info *info, int retcode) 274static int drbd_adm_finish(struct genl_info *info, int retcode)
275{ 275{
276 if (adm_ctx.tconn) { 276 if (adm_ctx.connection) {
277 kref_put(&adm_ctx.tconn->kref, &conn_destroy); 277 kref_put(&adm_ctx.connection->kref, &conn_destroy);
278 adm_ctx.tconn = NULL; 278 adm_ctx.connection = NULL;
279 } 279 }
280 280
281 if (!adm_ctx.reply_skb) 281 if (!adm_ctx.reply_skb)
@@ -286,29 +286,29 @@ static int drbd_adm_finish(struct genl_info *info, int retcode)
286 return 0; 286 return 0;
287} 287}
288 288
289static void setup_khelper_env(struct drbd_tconn *tconn, char **envp) 289static void setup_khelper_env(struct drbd_connection *connection, char **envp)
290{ 290{
291 char *afs; 291 char *afs;
292 292
293 /* FIXME: A future version will not allow this case. */ 293 /* FIXME: A future version will not allow this case. */
294 if (tconn->my_addr_len == 0 || tconn->peer_addr_len == 0) 294 if (connection->my_addr_len == 0 || connection->peer_addr_len == 0)
295 return; 295 return;
296 296
297 switch (((struct sockaddr *)&tconn->peer_addr)->sa_family) { 297 switch (((struct sockaddr *)&connection->peer_addr)->sa_family) {
298 case AF_INET6: 298 case AF_INET6:
299 afs = "ipv6"; 299 afs = "ipv6";
300 snprintf(envp[4], 60, "DRBD_PEER_ADDRESS=%pI6", 300 snprintf(envp[4], 60, "DRBD_PEER_ADDRESS=%pI6",
301 &((struct sockaddr_in6 *)&tconn->peer_addr)->sin6_addr); 301 &((struct sockaddr_in6 *)&connection->peer_addr)->sin6_addr);
302 break; 302 break;
303 case AF_INET: 303 case AF_INET:
304 afs = "ipv4"; 304 afs = "ipv4";
305 snprintf(envp[4], 60, "DRBD_PEER_ADDRESS=%pI4", 305 snprintf(envp[4], 60, "DRBD_PEER_ADDRESS=%pI4",
306 &((struct sockaddr_in *)&tconn->peer_addr)->sin_addr); 306 &((struct sockaddr_in *)&connection->peer_addr)->sin_addr);
307 break; 307 break;
308 default: 308 default:
309 afs = "ssocks"; 309 afs = "ssocks";
310 snprintf(envp[4], 60, "DRBD_PEER_ADDRESS=%pI4", 310 snprintf(envp[4], 60, "DRBD_PEER_ADDRESS=%pI4",
311 &((struct sockaddr_in *)&tconn->peer_addr)->sin_addr); 311 &((struct sockaddr_in *)&connection->peer_addr)->sin_addr);
312 } 312 }
313 snprintf(envp[3], 20, "DRBD_PEER_AF=%s", afs); 313 snprintf(envp[3], 20, "DRBD_PEER_AF=%s", afs);
314} 314}
@@ -323,15 +323,15 @@ int drbd_khelper(struct drbd_device *device, char *cmd)
323 NULL }; 323 NULL };
324 char mb[12]; 324 char mb[12];
325 char *argv[] = {usermode_helper, cmd, mb, NULL }; 325 char *argv[] = {usermode_helper, cmd, mb, NULL };
326 struct drbd_tconn *tconn = device->tconn; 326 struct drbd_connection *connection = device->connection;
327 struct sib_info sib; 327 struct sib_info sib;
328 int ret; 328 int ret;
329 329
330 if (current == tconn->worker.task) 330 if (current == connection->worker.task)
331 set_bit(CALLBACK_PENDING, &tconn->flags); 331 set_bit(CALLBACK_PENDING, &connection->flags);
332 332
333 snprintf(mb, 12, "minor-%d", device_to_minor(device)); 333 snprintf(mb, 12, "minor-%d", device_to_minor(device));
334 setup_khelper_env(tconn, envp); 334 setup_khelper_env(connection, envp);
335 335
336 /* The helper may take some time. 336 /* The helper may take some time.
337 * write out any unsynced meta data changes now */ 337 * write out any unsynced meta data changes now */
@@ -354,8 +354,8 @@ int drbd_khelper(struct drbd_device *device, char *cmd)
354 sib.helper_exit_code = ret; 354 sib.helper_exit_code = ret;
355 drbd_bcast_event(device, &sib); 355 drbd_bcast_event(device, &sib);
356 356
357 if (current == tconn->worker.task) 357 if (current == connection->worker.task)
358 clear_bit(CALLBACK_PENDING, &tconn->flags); 358 clear_bit(CALLBACK_PENDING, &connection->flags);
359 359
360 if (ret < 0) /* Ignore any ERRNOs we got. */ 360 if (ret < 0) /* Ignore any ERRNOs we got. */
361 ret = 0; 361 ret = 0;
@@ -363,7 +363,7 @@ int drbd_khelper(struct drbd_device *device, char *cmd)
363 return ret; 363 return ret;
364} 364}
365 365
366static int conn_khelper(struct drbd_tconn *tconn, char *cmd) 366static int conn_khelper(struct drbd_connection *connection, char *cmd)
367{ 367{
368 char *envp[] = { "HOME=/", 368 char *envp[] = { "HOME=/",
369 "TERM=linux", 369 "TERM=linux",
@@ -371,23 +371,23 @@ static int conn_khelper(struct drbd_tconn *tconn, char *cmd)
371 (char[20]) { }, /* address family */ 371 (char[20]) { }, /* address family */
372 (char[60]) { }, /* address */ 372 (char[60]) { }, /* address */
373 NULL }; 373 NULL };
374 char *argv[] = {usermode_helper, cmd, tconn->name, NULL }; 374 char *argv[] = {usermode_helper, cmd, connection->name, NULL };
375 int ret; 375 int ret;
376 376
377 setup_khelper_env(tconn, envp); 377 setup_khelper_env(connection, envp);
378 conn_md_sync(tconn); 378 conn_md_sync(connection);
379 379
380 conn_info(tconn, "helper command: %s %s %s\n", usermode_helper, cmd, tconn->name); 380 conn_info(connection, "helper command: %s %s %s\n", usermode_helper, cmd, connection->name);
381 /* TODO: conn_bcast_event() ?? */ 381 /* TODO: conn_bcast_event() ?? */
382 382
383 ret = call_usermodehelper(usermode_helper, argv, envp, UMH_WAIT_PROC); 383 ret = call_usermodehelper(usermode_helper, argv, envp, UMH_WAIT_PROC);
384 if (ret) 384 if (ret)
385 conn_warn(tconn, "helper command: %s %s %s exit code %u (0x%x)\n", 385 conn_warn(connection, "helper command: %s %s %s exit code %u (0x%x)\n",
386 usermode_helper, cmd, tconn->name, 386 usermode_helper, cmd, connection->name,
387 (ret >> 8) & 0xff, ret); 387 (ret >> 8) & 0xff, ret);
388 else 388 else
389 conn_info(tconn, "helper command: %s %s %s exit code %u (0x%x)\n", 389 conn_info(connection, "helper command: %s %s %s exit code %u (0x%x)\n",
390 usermode_helper, cmd, tconn->name, 390 usermode_helper, cmd, connection->name,
391 (ret >> 8) & 0xff, ret); 391 (ret >> 8) & 0xff, ret);
392 /* TODO: conn_bcast_event() ?? */ 392 /* TODO: conn_bcast_event() ?? */
393 393
@@ -397,14 +397,14 @@ static int conn_khelper(struct drbd_tconn *tconn, char *cmd)
397 return ret; 397 return ret;
398} 398}
399 399
400static enum drbd_fencing_p highest_fencing_policy(struct drbd_tconn *tconn) 400static enum drbd_fencing_p highest_fencing_policy(struct drbd_connection *connection)
401{ 401{
402 enum drbd_fencing_p fp = FP_NOT_AVAIL; 402 enum drbd_fencing_p fp = FP_NOT_AVAIL;
403 struct drbd_device *device; 403 struct drbd_device *device;
404 int vnr; 404 int vnr;
405 405
406 rcu_read_lock(); 406 rcu_read_lock();
407 idr_for_each_entry(&tconn->volumes, device, vnr) { 407 idr_for_each_entry(&connection->volumes, device, vnr) {
408 if (get_ldev_if_state(device, D_CONSISTENT)) { 408 if (get_ldev_if_state(device, D_CONSISTENT)) {
409 fp = max_t(enum drbd_fencing_p, fp, 409 fp = max_t(enum drbd_fencing_p, fp,
410 rcu_dereference(device->ldev->disk_conf)->fencing); 410 rcu_dereference(device->ldev->disk_conf)->fencing);
@@ -416,7 +416,7 @@ static enum drbd_fencing_p highest_fencing_policy(struct drbd_tconn *tconn)
416 return fp; 416 return fp;
417} 417}
418 418
419bool conn_try_outdate_peer(struct drbd_tconn *tconn) 419bool conn_try_outdate_peer(struct drbd_connection *connection)
420{ 420{
421 unsigned int connect_cnt; 421 unsigned int connect_cnt;
422 union drbd_state mask = { }; 422 union drbd_state mask = { };
@@ -425,26 +425,26 @@ bool conn_try_outdate_peer(struct drbd_tconn *tconn)
425 char *ex_to_string; 425 char *ex_to_string;
426 int r; 426 int r;
427 427
428 if (tconn->cstate >= C_WF_REPORT_PARAMS) { 428 if (connection->cstate >= C_WF_REPORT_PARAMS) {
429 conn_err(tconn, "Expected cstate < C_WF_REPORT_PARAMS\n"); 429 conn_err(connection, "Expected cstate < C_WF_REPORT_PARAMS\n");
430 return false; 430 return false;
431 } 431 }
432 432
433 spin_lock_irq(&tconn->req_lock); 433 spin_lock_irq(&connection->req_lock);
434 connect_cnt = tconn->connect_cnt; 434 connect_cnt = connection->connect_cnt;
435 spin_unlock_irq(&tconn->req_lock); 435 spin_unlock_irq(&connection->req_lock);
436 436
437 fp = highest_fencing_policy(tconn); 437 fp = highest_fencing_policy(connection);
438 switch (fp) { 438 switch (fp) {
439 case FP_NOT_AVAIL: 439 case FP_NOT_AVAIL:
440 conn_warn(tconn, "Not fencing peer, I'm not even Consistent myself.\n"); 440 conn_warn(connection, "Not fencing peer, I'm not even Consistent myself.\n");
441 goto out; 441 goto out;
442 case FP_DONT_CARE: 442 case FP_DONT_CARE:
443 return true; 443 return true;
444 default: ; 444 default: ;
445 } 445 }
446 446
447 r = conn_khelper(tconn, "fence-peer"); 447 r = conn_khelper(connection, "fence-peer");
448 448
449 switch ((r>>8) & 0xff) { 449 switch ((r>>8) & 0xff) {
450 case 3: /* peer is inconsistent */ 450 case 3: /* peer is inconsistent */
@@ -458,7 +458,7 @@ bool conn_try_outdate_peer(struct drbd_tconn *tconn)
458 val.pdsk = D_OUTDATED; 458 val.pdsk = D_OUTDATED;
459 break; 459 break;
460 case 5: /* peer was down */ 460 case 5: /* peer was down */
461 if (conn_highest_disk(tconn) == D_UP_TO_DATE) { 461 if (conn_highest_disk(connection) == D_UP_TO_DATE) {
462 /* we will(have) create(d) a new UUID anyways... */ 462 /* we will(have) create(d) a new UUID anyways... */
463 ex_to_string = "peer is unreachable, assumed to be dead"; 463 ex_to_string = "peer is unreachable, assumed to be dead";
464 mask.pdsk = D_MASK; 464 mask.pdsk = D_MASK;
@@ -471,65 +471,65 @@ bool conn_try_outdate_peer(struct drbd_tconn *tconn)
471 * This is useful when an unconnected R_SECONDARY is asked to 471 * This is useful when an unconnected R_SECONDARY is asked to
472 * become R_PRIMARY, but finds the other peer being active. */ 472 * become R_PRIMARY, but finds the other peer being active. */
473 ex_to_string = "peer is active"; 473 ex_to_string = "peer is active";
474 conn_warn(tconn, "Peer is primary, outdating myself.\n"); 474 conn_warn(connection, "Peer is primary, outdating myself.\n");
475 mask.disk = D_MASK; 475 mask.disk = D_MASK;
476 val.disk = D_OUTDATED; 476 val.disk = D_OUTDATED;
477 break; 477 break;
478 case 7: 478 case 7:
479 if (fp != FP_STONITH) 479 if (fp != FP_STONITH)
480 conn_err(tconn, "fence-peer() = 7 && fencing != Stonith !!!\n"); 480 conn_err(connection, "fence-peer() = 7 && fencing != Stonith !!!\n");
481 ex_to_string = "peer was stonithed"; 481 ex_to_string = "peer was stonithed";
482 mask.pdsk = D_MASK; 482 mask.pdsk = D_MASK;
483 val.pdsk = D_OUTDATED; 483 val.pdsk = D_OUTDATED;
484 break; 484 break;
485 default: 485 default:
486 /* The script is broken ... */ 486 /* The script is broken ... */
487 conn_err(tconn, "fence-peer helper broken, returned %d\n", (r>>8)&0xff); 487 conn_err(connection, "fence-peer helper broken, returned %d\n", (r>>8)&0xff);
488 return false; /* Eventually leave IO frozen */ 488 return false; /* Eventually leave IO frozen */
489 } 489 }
490 490
491 conn_info(tconn, "fence-peer helper returned %d (%s)\n", 491 conn_info(connection, "fence-peer helper returned %d (%s)\n",
492 (r>>8) & 0xff, ex_to_string); 492 (r>>8) & 0xff, ex_to_string);
493 493
494 out: 494 out:
495 495
496 /* Not using 496 /* Not using
497 conn_request_state(tconn, mask, val, CS_VERBOSE); 497 conn_request_state(connection, mask, val, CS_VERBOSE);
498 here, because we might were able to re-establish the connection in the 498 here, because we might were able to re-establish the connection in the
499 meantime. */ 499 meantime. */
500 spin_lock_irq(&tconn->req_lock); 500 spin_lock_irq(&connection->req_lock);
501 if (tconn->cstate < C_WF_REPORT_PARAMS && !test_bit(STATE_SENT, &tconn->flags)) { 501 if (connection->cstate < C_WF_REPORT_PARAMS && !test_bit(STATE_SENT, &connection->flags)) {
502 if (tconn->connect_cnt != connect_cnt) 502 if (connection->connect_cnt != connect_cnt)
503 /* In case the connection was established and droped 503 /* In case the connection was established and droped
504 while the fence-peer handler was running, ignore it */ 504 while the fence-peer handler was running, ignore it */
505 conn_info(tconn, "Ignoring fence-peer exit code\n"); 505 conn_info(connection, "Ignoring fence-peer exit code\n");
506 else 506 else
507 _conn_request_state(tconn, mask, val, CS_VERBOSE); 507 _conn_request_state(connection, mask, val, CS_VERBOSE);
508 } 508 }
509 spin_unlock_irq(&tconn->req_lock); 509 spin_unlock_irq(&connection->req_lock);
510 510
511 return conn_highest_pdsk(tconn) <= D_OUTDATED; 511 return conn_highest_pdsk(connection) <= D_OUTDATED;
512} 512}
513 513
514static int _try_outdate_peer_async(void *data) 514static int _try_outdate_peer_async(void *data)
515{ 515{
516 struct drbd_tconn *tconn = (struct drbd_tconn *)data; 516 struct drbd_connection *connection = (struct drbd_connection *)data;
517 517
518 conn_try_outdate_peer(tconn); 518 conn_try_outdate_peer(connection);
519 519
520 kref_put(&tconn->kref, &conn_destroy); 520 kref_put(&connection->kref, &conn_destroy);
521 return 0; 521 return 0;
522} 522}
523 523
524void conn_try_outdate_peer_async(struct drbd_tconn *tconn) 524void conn_try_outdate_peer_async(struct drbd_connection *connection)
525{ 525{
526 struct task_struct *opa; 526 struct task_struct *opa;
527 527
528 kref_get(&tconn->kref); 528 kref_get(&connection->kref);
529 opa = kthread_run(_try_outdate_peer_async, tconn, "drbd_async_h"); 529 opa = kthread_run(_try_outdate_peer_async, connection, "drbd_async_h");
530 if (IS_ERR(opa)) { 530 if (IS_ERR(opa)) {
531 conn_err(tconn, "out of mem, failed to invoke fence-peer helper\n"); 531 conn_err(connection, "out of mem, failed to invoke fence-peer helper\n");
532 kref_put(&tconn->kref, &conn_destroy); 532 kref_put(&connection->kref, &conn_destroy);
533 } 533 }
534} 534}
535 535
@@ -544,7 +544,7 @@ drbd_set_role(struct drbd_device *device, enum drbd_role new_role, int force)
544 union drbd_state mask, val; 544 union drbd_state mask, val;
545 545
546 if (new_role == R_PRIMARY) 546 if (new_role == R_PRIMARY)
547 request_ping(device->tconn); /* Detect a dead peer ASAP */ 547 request_ping(device->connection); /* Detect a dead peer ASAP */
548 548
549 mutex_lock(device->state_mutex); 549 mutex_lock(device->state_mutex);
550 550
@@ -575,7 +575,7 @@ drbd_set_role(struct drbd_device *device, enum drbd_role new_role, int force)
575 device->state.disk == D_CONSISTENT && mask.pdsk == 0) { 575 device->state.disk == D_CONSISTENT && mask.pdsk == 0) {
576 D_ASSERT(device->state.pdsk == D_UNKNOWN); 576 D_ASSERT(device->state.pdsk == D_UNKNOWN);
577 577
578 if (conn_try_outdate_peer(device->tconn)) { 578 if (conn_try_outdate_peer(device->connection)) {
579 val.disk = D_UP_TO_DATE; 579 val.disk = D_UP_TO_DATE;
580 mask.disk = D_MASK; 580 mask.disk = D_MASK;
581 } 581 }
@@ -585,7 +585,7 @@ drbd_set_role(struct drbd_device *device, enum drbd_role new_role, int force)
585 if (rv == SS_NOTHING_TO_DO) 585 if (rv == SS_NOTHING_TO_DO)
586 goto out; 586 goto out;
587 if (rv == SS_PRIMARY_NOP && mask.pdsk == 0) { 587 if (rv == SS_PRIMARY_NOP && mask.pdsk == 0) {
588 if (!conn_try_outdate_peer(device->tconn) && force) { 588 if (!conn_try_outdate_peer(device->connection) && force) {
589 dev_warn(DEV, "Forced into split brain situation!\n"); 589 dev_warn(DEV, "Forced into split brain situation!\n");
590 mask.pdsk = D_MASK; 590 mask.pdsk = D_MASK;
591 val.pdsk = D_OUTDATED; 591 val.pdsk = D_OUTDATED;
@@ -598,7 +598,7 @@ drbd_set_role(struct drbd_device *device, enum drbd_role new_role, int force)
598 retry at most once more in this case. */ 598 retry at most once more in this case. */
599 int timeo; 599 int timeo;
600 rcu_read_lock(); 600 rcu_read_lock();
601 nc = rcu_dereference(device->tconn->net_conf); 601 nc = rcu_dereference(device->connection->net_conf);
602 timeo = nc ? (nc->ping_timeo + 1) * HZ / 10 : 1; 602 timeo = nc ? (nc->ping_timeo + 1) * HZ / 10 : 1;
603 rcu_read_unlock(); 603 rcu_read_unlock();
604 schedule_timeout_interruptible(timeo); 604 schedule_timeout_interruptible(timeo);
@@ -633,11 +633,11 @@ drbd_set_role(struct drbd_device *device, enum drbd_role new_role, int force)
633 put_ldev(device); 633 put_ldev(device);
634 } 634 }
635 } else { 635 } else {
636 mutex_lock(&device->tconn->conf_update); 636 mutex_lock(&device->connection->conf_update);
637 nc = device->tconn->net_conf; 637 nc = device->connection->net_conf;
638 if (nc) 638 if (nc)
639 nc->discard_my_data = 0; /* without copy; single bit op is atomic */ 639 nc->discard_my_data = 0; /* without copy; single bit op is atomic */
640 mutex_unlock(&device->tconn->conf_update); 640 mutex_unlock(&device->connection->conf_update);
641 641
642 set_disk_ro(device->vdisk, false); 642 set_disk_ro(device->vdisk, false);
643 if (get_ldev(device)) { 643 if (get_ldev(device)) {
@@ -1134,12 +1134,12 @@ void drbd_reconsider_max_bio_size(struct drbd_device *device)
1134 Because new from 8.3.8 onwards the peer can use multiple 1134 Because new from 8.3.8 onwards the peer can use multiple
1135 BIOs for a single peer_request */ 1135 BIOs for a single peer_request */
1136 if (device->state.conn >= C_WF_REPORT_PARAMS) { 1136 if (device->state.conn >= C_WF_REPORT_PARAMS) {
1137 if (device->tconn->agreed_pro_version < 94) 1137 if (device->connection->agreed_pro_version < 94)
1138 peer = min(device->peer_max_bio_size, DRBD_MAX_SIZE_H80_PACKET); 1138 peer = min(device->peer_max_bio_size, DRBD_MAX_SIZE_H80_PACKET);
1139 /* Correct old drbd (up to 8.3.7) if it believes it can do more than 32KiB */ 1139 /* Correct old drbd (up to 8.3.7) if it believes it can do more than 32KiB */
1140 else if (device->tconn->agreed_pro_version == 94) 1140 else if (device->connection->agreed_pro_version == 94)
1141 peer = DRBD_MAX_SIZE_H80_PACKET; 1141 peer = DRBD_MAX_SIZE_H80_PACKET;
1142 else if (device->tconn->agreed_pro_version < 100) 1142 else if (device->connection->agreed_pro_version < 100)
1143 peer = DRBD_MAX_BIO_SIZE_P95; /* drbd 8.3.8 onwards, before 8.4.0 */ 1143 peer = DRBD_MAX_BIO_SIZE_P95; /* drbd 8.3.8 onwards, before 8.4.0 */
1144 else 1144 else
1145 peer = DRBD_MAX_BIO_SIZE; 1145 peer = DRBD_MAX_BIO_SIZE;
@@ -1157,25 +1157,25 @@ void drbd_reconsider_max_bio_size(struct drbd_device *device)
1157} 1157}
1158 1158
1159/* Starts the worker thread */ 1159/* Starts the worker thread */
1160static void conn_reconfig_start(struct drbd_tconn *tconn) 1160static void conn_reconfig_start(struct drbd_connection *connection)
1161{ 1161{
1162 drbd_thread_start(&tconn->worker); 1162 drbd_thread_start(&connection->worker);
1163 conn_flush_workqueue(tconn); 1163 conn_flush_workqueue(connection);
1164} 1164}
1165 1165
1166/* if still unconfigured, stops worker again. */ 1166/* if still unconfigured, stops worker again. */
1167static void conn_reconfig_done(struct drbd_tconn *tconn) 1167static void conn_reconfig_done(struct drbd_connection *connection)
1168{ 1168{
1169 bool stop_threads; 1169 bool stop_threads;
1170 spin_lock_irq(&tconn->req_lock); 1170 spin_lock_irq(&connection->req_lock);
1171 stop_threads = conn_all_vols_unconf(tconn) && 1171 stop_threads = conn_all_vols_unconf(connection) &&
1172 tconn->cstate == C_STANDALONE; 1172 connection->cstate == C_STANDALONE;
1173 spin_unlock_irq(&tconn->req_lock); 1173 spin_unlock_irq(&connection->req_lock);
1174 if (stop_threads) { 1174 if (stop_threads) {
1175 /* asender is implicitly stopped by receiver 1175 /* asender is implicitly stopped by receiver
1176 * in conn_disconnect() */ 1176 * in conn_disconnect() */
1177 drbd_thread_stop(&tconn->receiver); 1177 drbd_thread_stop(&connection->receiver);
1178 drbd_thread_stop(&tconn->worker); 1178 drbd_thread_stop(&connection->worker);
1179 } 1179 }
1180} 1180}
1181 1181
@@ -1190,10 +1190,10 @@ static void drbd_suspend_al(struct drbd_device *device)
1190 } 1190 }
1191 1191
1192 drbd_al_shrink(device); 1192 drbd_al_shrink(device);
1193 spin_lock_irq(&device->tconn->req_lock); 1193 spin_lock_irq(&device->connection->req_lock);
1194 if (device->state.conn < C_CONNECTED) 1194 if (device->state.conn < C_CONNECTED)
1195 s = !test_and_set_bit(AL_SUSPENDED, &device->flags); 1195 s = !test_and_set_bit(AL_SUSPENDED, &device->flags);
1196 spin_unlock_irq(&device->tconn->req_lock); 1196 spin_unlock_irq(&device->connection->req_lock);
1197 lc_unlock(device->act_log); 1197 lc_unlock(device->act_log);
1198 1198
1199 if (s) 1199 if (s)
@@ -1264,7 +1264,7 @@ int drbd_adm_disk_opts(struct sk_buff *skb, struct genl_info *info)
1264 goto fail; 1264 goto fail;
1265 } 1265 }
1266 1266
1267 mutex_lock(&device->tconn->conf_update); 1267 mutex_lock(&device->connection->conf_update);
1268 old_disk_conf = device->ldev->disk_conf; 1268 old_disk_conf = device->ldev->disk_conf;
1269 *new_disk_conf = *old_disk_conf; 1269 *new_disk_conf = *old_disk_conf;
1270 if (should_set_defaults(info)) 1270 if (should_set_defaults(info))
@@ -1327,7 +1327,7 @@ int drbd_adm_disk_opts(struct sk_buff *skb, struct genl_info *info)
1327 rcu_assign_pointer(device->rs_plan_s, new_plan); 1327 rcu_assign_pointer(device->rs_plan_s, new_plan);
1328 } 1328 }
1329 1329
1330 mutex_unlock(&device->tconn->conf_update); 1330 mutex_unlock(&device->connection->conf_update);
1331 1331
1332 if (new_disk_conf->al_updates) 1332 if (new_disk_conf->al_updates)
1333 device->ldev->md.flags &= ~MDF_AL_DISABLED; 1333 device->ldev->md.flags &= ~MDF_AL_DISABLED;
@@ -1339,7 +1339,7 @@ int drbd_adm_disk_opts(struct sk_buff *skb, struct genl_info *info)
1339 else 1339 else
1340 set_bit(MD_NO_FUA, &device->flags); 1340 set_bit(MD_NO_FUA, &device->flags);
1341 1341
1342 drbd_bump_write_ordering(device->tconn, WO_bdev_flush); 1342 drbd_bump_write_ordering(device->connection, WO_bdev_flush);
1343 1343
1344 drbd_md_sync(device); 1344 drbd_md_sync(device);
1345 1345
@@ -1353,7 +1353,7 @@ int drbd_adm_disk_opts(struct sk_buff *skb, struct genl_info *info)
1353 goto success; 1353 goto success;
1354 1354
1355fail_unlock: 1355fail_unlock:
1356 mutex_unlock(&device->tconn->conf_update); 1356 mutex_unlock(&device->connection->conf_update);
1357 fail: 1357 fail:
1358 kfree(new_disk_conf); 1358 kfree(new_disk_conf);
1359 kfree(new_plan); 1359 kfree(new_plan);
@@ -1388,7 +1388,7 @@ int drbd_adm_attach(struct sk_buff *skb, struct genl_info *info)
1388 goto finish; 1388 goto finish;
1389 1389
1390 device = adm_ctx.device; 1390 device = adm_ctx.device;
1391 conn_reconfig_start(device->tconn); 1391 conn_reconfig_start(device->connection);
1392 1392
1393 /* if you want to reconfigure, please tear down first */ 1393 /* if you want to reconfigure, please tear down first */
1394 if (device->state.disk > D_DISKLESS) { 1394 if (device->state.disk > D_DISKLESS) {
@@ -1455,7 +1455,7 @@ int drbd_adm_attach(struct sk_buff *skb, struct genl_info *info)
1455 goto fail; 1455 goto fail;
1456 1456
1457 rcu_read_lock(); 1457 rcu_read_lock();
1458 nc = rcu_dereference(device->tconn->net_conf); 1458 nc = rcu_dereference(device->connection->net_conf);
1459 if (nc) { 1459 if (nc) {
1460 if (new_disk_conf->fencing == FP_STONITH && nc->wire_protocol == DRBD_PROT_A) { 1460 if (new_disk_conf->fencing == FP_STONITH && nc->wire_protocol == DRBD_PROT_A) {
1461 rcu_read_unlock(); 1461 rcu_read_unlock();
@@ -1636,7 +1636,7 @@ int drbd_adm_attach(struct sk_buff *skb, struct genl_info *info)
1636 new_disk_conf = NULL; 1636 new_disk_conf = NULL;
1637 new_plan = NULL; 1637 new_plan = NULL;
1638 1638
1639 drbd_bump_write_ordering(device->tconn, WO_bdev_flush); 1639 drbd_bump_write_ordering(device->connection, WO_bdev_flush);
1640 1640
1641 if (drbd_md_test_flag(device->ldev, MDF_CRASHED_PRIMARY)) 1641 if (drbd_md_test_flag(device->ldev, MDF_CRASHED_PRIMARY))
1642 set_bit(CRASHED_PRIMARY, &device->flags); 1642 set_bit(CRASHED_PRIMARY, &device->flags);
@@ -1644,7 +1644,7 @@ int drbd_adm_attach(struct sk_buff *skb, struct genl_info *info)
1644 clear_bit(CRASHED_PRIMARY, &device->flags); 1644 clear_bit(CRASHED_PRIMARY, &device->flags);
1645 1645
1646 if (drbd_md_test_flag(device->ldev, MDF_PRIMARY_IND) && 1646 if (drbd_md_test_flag(device->ldev, MDF_PRIMARY_IND) &&
1647 !(device->state.role == R_PRIMARY && device->tconn->susp_nod)) 1647 !(device->state.role == R_PRIMARY && device->connection->susp_nod))
1648 set_bit(CRASHED_PRIMARY, &device->flags); 1648 set_bit(CRASHED_PRIMARY, &device->flags);
1649 1649
1650 device->send_cnt = 0; 1650 device->send_cnt = 0;
@@ -1702,7 +1702,7 @@ int drbd_adm_attach(struct sk_buff *skb, struct genl_info *info)
1702 if (_drbd_bm_total_weight(device) == drbd_bm_bits(device)) 1702 if (_drbd_bm_total_weight(device) == drbd_bm_bits(device))
1703 drbd_suspend_al(device); /* IO is still suspended here... */ 1703 drbd_suspend_al(device); /* IO is still suspended here... */
1704 1704
1705 spin_lock_irq(&device->tconn->req_lock); 1705 spin_lock_irq(&device->connection->req_lock);
1706 os = drbd_read_state(device); 1706 os = drbd_read_state(device);
1707 ns = os; 1707 ns = os;
1708 /* If MDF_CONSISTENT is not set go into inconsistent state, 1708 /* If MDF_CONSISTENT is not set go into inconsistent state,
@@ -1754,7 +1754,7 @@ int drbd_adm_attach(struct sk_buff *skb, struct genl_info *info)
1754 } 1754 }
1755 1755
1756 rv = _drbd_set_state(device, ns, CS_VERBOSE, NULL); 1756 rv = _drbd_set_state(device, ns, CS_VERBOSE, NULL);
1757 spin_unlock_irq(&device->tconn->req_lock); 1757 spin_unlock_irq(&device->connection->req_lock);
1758 1758
1759 if (rv < SS_SUCCESS) 1759 if (rv < SS_SUCCESS)
1760 goto force_diskless_dec; 1760 goto force_diskless_dec;
@@ -1771,7 +1771,7 @@ int drbd_adm_attach(struct sk_buff *skb, struct genl_info *info)
1771 1771
1772 kobject_uevent(&disk_to_dev(device->vdisk)->kobj, KOBJ_CHANGE); 1772 kobject_uevent(&disk_to_dev(device->vdisk)->kobj, KOBJ_CHANGE);
1773 put_ldev(device); 1773 put_ldev(device);
1774 conn_reconfig_done(device->tconn); 1774 conn_reconfig_done(device->connection);
1775 drbd_adm_finish(info, retcode); 1775 drbd_adm_finish(info, retcode);
1776 return 0; 1776 return 0;
1777 1777
@@ -1781,7 +1781,7 @@ int drbd_adm_attach(struct sk_buff *skb, struct genl_info *info)
1781 drbd_force_state(device, NS(disk, D_DISKLESS)); 1781 drbd_force_state(device, NS(disk, D_DISKLESS));
1782 drbd_md_sync(device); 1782 drbd_md_sync(device);
1783 fail: 1783 fail:
1784 conn_reconfig_done(device->tconn); 1784 conn_reconfig_done(device->connection);
1785 if (nbc) { 1785 if (nbc) {
1786 if (nbc->backing_bdev) 1786 if (nbc->backing_bdev)
1787 blkdev_put(nbc->backing_bdev, 1787 blkdev_put(nbc->backing_bdev,
@@ -1860,14 +1860,14 @@ out:
1860 return 0; 1860 return 0;
1861} 1861}
1862 1862
1863static bool conn_resync_running(struct drbd_tconn *tconn) 1863static bool conn_resync_running(struct drbd_connection *connection)
1864{ 1864{
1865 struct drbd_device *device; 1865 struct drbd_device *device;
1866 bool rv = false; 1866 bool rv = false;
1867 int vnr; 1867 int vnr;
1868 1868
1869 rcu_read_lock(); 1869 rcu_read_lock();
1870 idr_for_each_entry(&tconn->volumes, device, vnr) { 1870 idr_for_each_entry(&connection->volumes, device, vnr) {
1871 if (device->state.conn == C_SYNC_SOURCE || 1871 if (device->state.conn == C_SYNC_SOURCE ||
1872 device->state.conn == C_SYNC_TARGET || 1872 device->state.conn == C_SYNC_TARGET ||
1873 device->state.conn == C_PAUSED_SYNC_S || 1873 device->state.conn == C_PAUSED_SYNC_S ||
@@ -1881,14 +1881,14 @@ static bool conn_resync_running(struct drbd_tconn *tconn)
1881 return rv; 1881 return rv;
1882} 1882}
1883 1883
1884static bool conn_ov_running(struct drbd_tconn *tconn) 1884static bool conn_ov_running(struct drbd_connection *connection)
1885{ 1885{
1886 struct drbd_device *device; 1886 struct drbd_device *device;
1887 bool rv = false; 1887 bool rv = false;
1888 int vnr; 1888 int vnr;
1889 1889
1890 rcu_read_lock(); 1890 rcu_read_lock();
1891 idr_for_each_entry(&tconn->volumes, device, vnr) { 1891 idr_for_each_entry(&connection->volumes, device, vnr) {
1892 if (device->state.conn == C_VERIFY_S || 1892 if (device->state.conn == C_VERIFY_S ||
1893 device->state.conn == C_VERIFY_T) { 1893 device->state.conn == C_VERIFY_T) {
1894 rv = true; 1894 rv = true;
@@ -1901,12 +1901,12 @@ static bool conn_ov_running(struct drbd_tconn *tconn)
1901} 1901}
1902 1902
1903static enum drbd_ret_code 1903static enum drbd_ret_code
1904_check_net_options(struct drbd_tconn *tconn, struct net_conf *old_conf, struct net_conf *new_conf) 1904_check_net_options(struct drbd_connection *connection, struct net_conf *old_conf, struct net_conf *new_conf)
1905{ 1905{
1906 struct drbd_device *device; 1906 struct drbd_device *device;
1907 int i; 1907 int i;
1908 1908
1909 if (old_conf && tconn->cstate == C_WF_REPORT_PARAMS && tconn->agreed_pro_version < 100) { 1909 if (old_conf && connection->cstate == C_WF_REPORT_PARAMS && connection->agreed_pro_version < 100) {
1910 if (new_conf->wire_protocol != old_conf->wire_protocol) 1910 if (new_conf->wire_protocol != old_conf->wire_protocol)
1911 return ERR_NEED_APV_100; 1911 return ERR_NEED_APV_100;
1912 1912
@@ -1918,15 +1918,15 @@ _check_net_options(struct drbd_tconn *tconn, struct net_conf *old_conf, struct n
1918 } 1918 }
1919 1919
1920 if (!new_conf->two_primaries && 1920 if (!new_conf->two_primaries &&
1921 conn_highest_role(tconn) == R_PRIMARY && 1921 conn_highest_role(connection) == R_PRIMARY &&
1922 conn_highest_peer(tconn) == R_PRIMARY) 1922 conn_highest_peer(connection) == R_PRIMARY)
1923 return ERR_NEED_ALLOW_TWO_PRI; 1923 return ERR_NEED_ALLOW_TWO_PRI;
1924 1924
1925 if (new_conf->two_primaries && 1925 if (new_conf->two_primaries &&
1926 (new_conf->wire_protocol != DRBD_PROT_C)) 1926 (new_conf->wire_protocol != DRBD_PROT_C))
1927 return ERR_NOT_PROTO_C; 1927 return ERR_NOT_PROTO_C;
1928 1928
1929 idr_for_each_entry(&tconn->volumes, device, i) { 1929 idr_for_each_entry(&connection->volumes, device, i) {
1930 if (get_ldev(device)) { 1930 if (get_ldev(device)) {
1931 enum drbd_fencing_p fp = rcu_dereference(device->ldev->disk_conf)->fencing; 1931 enum drbd_fencing_p fp = rcu_dereference(device->ldev->disk_conf)->fencing;
1932 put_ldev(device); 1932 put_ldev(device);
@@ -1944,18 +1944,18 @@ _check_net_options(struct drbd_tconn *tconn, struct net_conf *old_conf, struct n
1944} 1944}
1945 1945
1946static enum drbd_ret_code 1946static enum drbd_ret_code
1947check_net_options(struct drbd_tconn *tconn, struct net_conf *new_conf) 1947check_net_options(struct drbd_connection *connection, struct net_conf *new_conf)
1948{ 1948{
1949 static enum drbd_ret_code rv; 1949 static enum drbd_ret_code rv;
1950 struct drbd_device *device; 1950 struct drbd_device *device;
1951 int i; 1951 int i;
1952 1952
1953 rcu_read_lock(); 1953 rcu_read_lock();
1954 rv = _check_net_options(tconn, rcu_dereference(tconn->net_conf), new_conf); 1954 rv = _check_net_options(connection, rcu_dereference(connection->net_conf), new_conf);
1955 rcu_read_unlock(); 1955 rcu_read_unlock();
1956 1956
1957 /* tconn->volumes protected by genl_lock() here */ 1957 /* connection->volumes protected by genl_lock() here */
1958 idr_for_each_entry(&tconn->volumes, device, i) { 1958 idr_for_each_entry(&connection->volumes, device, i) {
1959 if (!device->bitmap) { 1959 if (!device->bitmap) {
1960 if (drbd_bm_init(device)) 1960 if (drbd_bm_init(device))
1961 return ERR_NOMEM; 1961 return ERR_NOMEM;
@@ -2027,7 +2027,7 @@ static void free_crypto(struct crypto *crypto)
2027int drbd_adm_net_opts(struct sk_buff *skb, struct genl_info *info) 2027int drbd_adm_net_opts(struct sk_buff *skb, struct genl_info *info)
2028{ 2028{
2029 enum drbd_ret_code retcode; 2029 enum drbd_ret_code retcode;
2030 struct drbd_tconn *tconn; 2030 struct drbd_connection *connection;
2031 struct net_conf *old_conf, *new_conf = NULL; 2031 struct net_conf *old_conf, *new_conf = NULL;
2032 int err; 2032 int err;
2033 int ovr; /* online verify running */ 2033 int ovr; /* online verify running */
@@ -2040,7 +2040,7 @@ int drbd_adm_net_opts(struct sk_buff *skb, struct genl_info *info)
2040 if (retcode != NO_ERROR) 2040 if (retcode != NO_ERROR)
2041 goto out; 2041 goto out;
2042 2042
2043 tconn = adm_ctx.tconn; 2043 connection = adm_ctx.connection;
2044 2044
2045 new_conf = kzalloc(sizeof(struct net_conf), GFP_KERNEL); 2045 new_conf = kzalloc(sizeof(struct net_conf), GFP_KERNEL);
2046 if (!new_conf) { 2046 if (!new_conf) {
@@ -2048,11 +2048,11 @@ int drbd_adm_net_opts(struct sk_buff *skb, struct genl_info *info)
2048 goto out; 2048 goto out;
2049 } 2049 }
2050 2050
2051 conn_reconfig_start(tconn); 2051 conn_reconfig_start(connection);
2052 2052
2053 mutex_lock(&tconn->data.mutex); 2053 mutex_lock(&connection->data.mutex);
2054 mutex_lock(&tconn->conf_update); 2054 mutex_lock(&connection->conf_update);
2055 old_conf = tconn->net_conf; 2055 old_conf = connection->net_conf;
2056 2056
2057 if (!old_conf) { 2057 if (!old_conf) {
2058 drbd_msg_put_info("net conf missing, try connect"); 2058 drbd_msg_put_info("net conf missing, try connect");
@@ -2071,19 +2071,19 @@ int drbd_adm_net_opts(struct sk_buff *skb, struct genl_info *info)
2071 goto fail; 2071 goto fail;
2072 } 2072 }
2073 2073
2074 retcode = check_net_options(tconn, new_conf); 2074 retcode = check_net_options(connection, new_conf);
2075 if (retcode != NO_ERROR) 2075 if (retcode != NO_ERROR)
2076 goto fail; 2076 goto fail;
2077 2077
2078 /* re-sync running */ 2078 /* re-sync running */
2079 rsr = conn_resync_running(tconn); 2079 rsr = conn_resync_running(connection);
2080 if (rsr && strcmp(new_conf->csums_alg, old_conf->csums_alg)) { 2080 if (rsr && strcmp(new_conf->csums_alg, old_conf->csums_alg)) {
2081 retcode = ERR_CSUMS_RESYNC_RUNNING; 2081 retcode = ERR_CSUMS_RESYNC_RUNNING;
2082 goto fail; 2082 goto fail;
2083 } 2083 }
2084 2084
2085 /* online verify running */ 2085 /* online verify running */
2086 ovr = conn_ov_running(tconn); 2086 ovr = conn_ov_running(connection);
2087 if (ovr && strcmp(new_conf->verify_alg, old_conf->verify_alg)) { 2087 if (ovr && strcmp(new_conf->verify_alg, old_conf->verify_alg)) {
2088 retcode = ERR_VERIFY_RUNNING; 2088 retcode = ERR_VERIFY_RUNNING;
2089 goto fail; 2089 goto fail;
@@ -2093,45 +2093,45 @@ int drbd_adm_net_opts(struct sk_buff *skb, struct genl_info *info)
2093 if (retcode != NO_ERROR) 2093 if (retcode != NO_ERROR)
2094 goto fail; 2094 goto fail;
2095 2095
2096 rcu_assign_pointer(tconn->net_conf, new_conf); 2096 rcu_assign_pointer(connection->net_conf, new_conf);
2097 2097
2098 if (!rsr) { 2098 if (!rsr) {
2099 crypto_free_hash(tconn->csums_tfm); 2099 crypto_free_hash(connection->csums_tfm);
2100 tconn->csums_tfm = crypto.csums_tfm; 2100 connection->csums_tfm = crypto.csums_tfm;
2101 crypto.csums_tfm = NULL; 2101 crypto.csums_tfm = NULL;
2102 } 2102 }
2103 if (!ovr) { 2103 if (!ovr) {
2104 crypto_free_hash(tconn->verify_tfm); 2104 crypto_free_hash(connection->verify_tfm);
2105 tconn->verify_tfm = crypto.verify_tfm; 2105 connection->verify_tfm = crypto.verify_tfm;
2106 crypto.verify_tfm = NULL; 2106 crypto.verify_tfm = NULL;
2107 } 2107 }
2108 2108
2109 crypto_free_hash(tconn->integrity_tfm); 2109 crypto_free_hash(connection->integrity_tfm);
2110 tconn->integrity_tfm = crypto.integrity_tfm; 2110 connection->integrity_tfm = crypto.integrity_tfm;
2111 if (tconn->cstate >= C_WF_REPORT_PARAMS && tconn->agreed_pro_version >= 100) 2111 if (connection->cstate >= C_WF_REPORT_PARAMS && connection->agreed_pro_version >= 100)
2112 /* Do this without trying to take tconn->data.mutex again. */ 2112 /* Do this without trying to take connection->data.mutex again. */
2113 __drbd_send_protocol(tconn, P_PROTOCOL_UPDATE); 2113 __drbd_send_protocol(connection, P_PROTOCOL_UPDATE);
2114 2114
2115 crypto_free_hash(tconn->cram_hmac_tfm); 2115 crypto_free_hash(connection->cram_hmac_tfm);
2116 tconn->cram_hmac_tfm = crypto.cram_hmac_tfm; 2116 connection->cram_hmac_tfm = crypto.cram_hmac_tfm;
2117 2117
2118 mutex_unlock(&tconn->conf_update); 2118 mutex_unlock(&connection->conf_update);
2119 mutex_unlock(&tconn->data.mutex); 2119 mutex_unlock(&connection->data.mutex);
2120 synchronize_rcu(); 2120 synchronize_rcu();
2121 kfree(old_conf); 2121 kfree(old_conf);
2122 2122
2123 if (tconn->cstate >= C_WF_REPORT_PARAMS) 2123 if (connection->cstate >= C_WF_REPORT_PARAMS)
2124 drbd_send_sync_param(minor_to_device(conn_lowest_minor(tconn))); 2124 drbd_send_sync_param(minor_to_device(conn_lowest_minor(connection)));
2125 2125
2126 goto done; 2126 goto done;
2127 2127
2128 fail: 2128 fail:
2129 mutex_unlock(&tconn->conf_update); 2129 mutex_unlock(&connection->conf_update);
2130 mutex_unlock(&tconn->data.mutex); 2130 mutex_unlock(&connection->data.mutex);
2131 free_crypto(&crypto); 2131 free_crypto(&crypto);
2132 kfree(new_conf); 2132 kfree(new_conf);
2133 done: 2133 done:
2134 conn_reconfig_done(tconn); 2134 conn_reconfig_done(connection);
2135 out: 2135 out:
2136 drbd_adm_finish(info, retcode); 2136 drbd_adm_finish(info, retcode);
2137 return 0; 2137 return 0;
@@ -2142,7 +2142,7 @@ int drbd_adm_connect(struct sk_buff *skb, struct genl_info *info)
2142 struct drbd_device *device; 2142 struct drbd_device *device;
2143 struct net_conf *old_conf, *new_conf = NULL; 2143 struct net_conf *old_conf, *new_conf = NULL;
2144 struct crypto crypto = { }; 2144 struct crypto crypto = { };
2145 struct drbd_tconn *tconn; 2145 struct drbd_connection *connection;
2146 enum drbd_ret_code retcode; 2146 enum drbd_ret_code retcode;
2147 int i; 2147 int i;
2148 int err; 2148 int err;
@@ -2162,24 +2162,24 @@ int drbd_adm_connect(struct sk_buff *skb, struct genl_info *info)
2162 /* No need for _rcu here. All reconfiguration is 2162 /* No need for _rcu here. All reconfiguration is
2163 * strictly serialized on genl_lock(). We are protected against 2163 * strictly serialized on genl_lock(). We are protected against
2164 * concurrent reconfiguration/addition/deletion */ 2164 * concurrent reconfiguration/addition/deletion */
2165 list_for_each_entry(tconn, &drbd_tconns, all_tconn) { 2165 list_for_each_entry(connection, &drbd_connections, connections) {
2166 if (nla_len(adm_ctx.my_addr) == tconn->my_addr_len && 2166 if (nla_len(adm_ctx.my_addr) == connection->my_addr_len &&
2167 !memcmp(nla_data(adm_ctx.my_addr), &tconn->my_addr, tconn->my_addr_len)) { 2167 !memcmp(nla_data(adm_ctx.my_addr), &connection->my_addr, connection->my_addr_len)) {
2168 retcode = ERR_LOCAL_ADDR; 2168 retcode = ERR_LOCAL_ADDR;
2169 goto out; 2169 goto out;
2170 } 2170 }
2171 2171
2172 if (nla_len(adm_ctx.peer_addr) == tconn->peer_addr_len && 2172 if (nla_len(adm_ctx.peer_addr) == connection->peer_addr_len &&
2173 !memcmp(nla_data(adm_ctx.peer_addr), &tconn->peer_addr, tconn->peer_addr_len)) { 2173 !memcmp(nla_data(adm_ctx.peer_addr), &connection->peer_addr, connection->peer_addr_len)) {
2174 retcode = ERR_PEER_ADDR; 2174 retcode = ERR_PEER_ADDR;
2175 goto out; 2175 goto out;
2176 } 2176 }
2177 } 2177 }
2178 2178
2179 tconn = adm_ctx.tconn; 2179 connection = adm_ctx.connection;
2180 conn_reconfig_start(tconn); 2180 conn_reconfig_start(connection);
2181 2181
2182 if (tconn->cstate > C_STANDALONE) { 2182 if (connection->cstate > C_STANDALONE) {
2183 retcode = ERR_NET_CONFIGURED; 2183 retcode = ERR_NET_CONFIGURED;
2184 goto fail; 2184 goto fail;
2185 } 2185 }
@@ -2200,7 +2200,7 @@ int drbd_adm_connect(struct sk_buff *skb, struct genl_info *info)
2200 goto fail; 2200 goto fail;
2201 } 2201 }
2202 2202
2203 retcode = check_net_options(tconn, new_conf); 2203 retcode = check_net_options(connection, new_conf);
2204 if (retcode != NO_ERROR) 2204 if (retcode != NO_ERROR)
2205 goto fail; 2205 goto fail;
2206 2206
@@ -2210,40 +2210,40 @@ int drbd_adm_connect(struct sk_buff *skb, struct genl_info *info)
2210 2210
2211 ((char *)new_conf->shared_secret)[SHARED_SECRET_MAX-1] = 0; 2211 ((char *)new_conf->shared_secret)[SHARED_SECRET_MAX-1] = 0;
2212 2212
2213 conn_flush_workqueue(tconn); 2213 conn_flush_workqueue(connection);
2214 2214
2215 mutex_lock(&tconn->conf_update); 2215 mutex_lock(&connection->conf_update);
2216 old_conf = tconn->net_conf; 2216 old_conf = connection->net_conf;
2217 if (old_conf) { 2217 if (old_conf) {
2218 retcode = ERR_NET_CONFIGURED; 2218 retcode = ERR_NET_CONFIGURED;
2219 mutex_unlock(&tconn->conf_update); 2219 mutex_unlock(&connection->conf_update);
2220 goto fail; 2220 goto fail;
2221 } 2221 }
2222 rcu_assign_pointer(tconn->net_conf, new_conf); 2222 rcu_assign_pointer(connection->net_conf, new_conf);
2223 2223
2224 conn_free_crypto(tconn); 2224 conn_free_crypto(connection);
2225 tconn->cram_hmac_tfm = crypto.cram_hmac_tfm; 2225 connection->cram_hmac_tfm = crypto.cram_hmac_tfm;
2226 tconn->integrity_tfm = crypto.integrity_tfm; 2226 connection->integrity_tfm = crypto.integrity_tfm;
2227 tconn->csums_tfm = crypto.csums_tfm; 2227 connection->csums_tfm = crypto.csums_tfm;
2228 tconn->verify_tfm = crypto.verify_tfm; 2228 connection->verify_tfm = crypto.verify_tfm;
2229 2229
2230 tconn->my_addr_len = nla_len(adm_ctx.my_addr); 2230 connection->my_addr_len = nla_len(adm_ctx.my_addr);
2231 memcpy(&tconn->my_addr, nla_data(adm_ctx.my_addr), tconn->my_addr_len); 2231 memcpy(&connection->my_addr, nla_data(adm_ctx.my_addr), connection->my_addr_len);
2232 tconn->peer_addr_len = nla_len(adm_ctx.peer_addr); 2232 connection->peer_addr_len = nla_len(adm_ctx.peer_addr);
2233 memcpy(&tconn->peer_addr, nla_data(adm_ctx.peer_addr), tconn->peer_addr_len); 2233 memcpy(&connection->peer_addr, nla_data(adm_ctx.peer_addr), connection->peer_addr_len);
2234 2234
2235 mutex_unlock(&tconn->conf_update); 2235 mutex_unlock(&connection->conf_update);
2236 2236
2237 rcu_read_lock(); 2237 rcu_read_lock();
2238 idr_for_each_entry(&tconn->volumes, device, i) { 2238 idr_for_each_entry(&connection->volumes, device, i) {
2239 device->send_cnt = 0; 2239 device->send_cnt = 0;
2240 device->recv_cnt = 0; 2240 device->recv_cnt = 0;
2241 } 2241 }
2242 rcu_read_unlock(); 2242 rcu_read_unlock();
2243 2243
2244 retcode = conn_request_state(tconn, NS(conn, C_UNCONNECTED), CS_VERBOSE); 2244 retcode = conn_request_state(connection, NS(conn, C_UNCONNECTED), CS_VERBOSE);
2245 2245
2246 conn_reconfig_done(tconn); 2246 conn_reconfig_done(connection);
2247 drbd_adm_finish(info, retcode); 2247 drbd_adm_finish(info, retcode);
2248 return 0; 2248 return 0;
2249 2249
@@ -2251,17 +2251,17 @@ fail:
2251 free_crypto(&crypto); 2251 free_crypto(&crypto);
2252 kfree(new_conf); 2252 kfree(new_conf);
2253 2253
2254 conn_reconfig_done(tconn); 2254 conn_reconfig_done(connection);
2255out: 2255out:
2256 drbd_adm_finish(info, retcode); 2256 drbd_adm_finish(info, retcode);
2257 return 0; 2257 return 0;
2258} 2258}
2259 2259
2260static enum drbd_state_rv conn_try_disconnect(struct drbd_tconn *tconn, bool force) 2260static enum drbd_state_rv conn_try_disconnect(struct drbd_connection *connection, bool force)
2261{ 2261{
2262 enum drbd_state_rv rv; 2262 enum drbd_state_rv rv;
2263 2263
2264 rv = conn_request_state(tconn, NS(conn, C_DISCONNECTING), 2264 rv = conn_request_state(connection, NS(conn, C_DISCONNECTING),
2265 force ? CS_HARD : 0); 2265 force ? CS_HARD : 0);
2266 2266
2267 switch (rv) { 2267 switch (rv) {
@@ -2271,18 +2271,18 @@ static enum drbd_state_rv conn_try_disconnect(struct drbd_tconn *tconn, bool for
2271 return SS_SUCCESS; 2271 return SS_SUCCESS;
2272 case SS_PRIMARY_NOP: 2272 case SS_PRIMARY_NOP:
2273 /* Our state checking code wants to see the peer outdated. */ 2273 /* Our state checking code wants to see the peer outdated. */
2274 rv = conn_request_state(tconn, NS2(conn, C_DISCONNECTING, pdsk, D_OUTDATED), 0); 2274 rv = conn_request_state(connection, NS2(conn, C_DISCONNECTING, pdsk, D_OUTDATED), 0);
2275 2275
2276 if (rv == SS_OUTDATE_WO_CONN) /* lost connection before graceful disconnect succeeded */ 2276 if (rv == SS_OUTDATE_WO_CONN) /* lost connection before graceful disconnect succeeded */
2277 rv = conn_request_state(tconn, NS(conn, C_DISCONNECTING), CS_VERBOSE); 2277 rv = conn_request_state(connection, NS(conn, C_DISCONNECTING), CS_VERBOSE);
2278 2278
2279 break; 2279 break;
2280 case SS_CW_FAILED_BY_PEER: 2280 case SS_CW_FAILED_BY_PEER:
2281 /* The peer probably wants to see us outdated. */ 2281 /* The peer probably wants to see us outdated. */
2282 rv = conn_request_state(tconn, NS2(conn, C_DISCONNECTING, 2282 rv = conn_request_state(connection, NS2(conn, C_DISCONNECTING,
2283 disk, D_OUTDATED), 0); 2283 disk, D_OUTDATED), 0);
2284 if (rv == SS_IS_DISKLESS || rv == SS_LOWER_THAN_OUTDATED) { 2284 if (rv == SS_IS_DISKLESS || rv == SS_LOWER_THAN_OUTDATED) {
2285 rv = conn_request_state(tconn, NS(conn, C_DISCONNECTING), 2285 rv = conn_request_state(connection, NS(conn, C_DISCONNECTING),
2286 CS_HARD); 2286 CS_HARD);
2287 } 2287 }
2288 break; 2288 break;
@@ -2296,7 +2296,7 @@ static enum drbd_state_rv conn_try_disconnect(struct drbd_tconn *tconn, bool for
2296 * The state handling only uses drbd_thread_stop_nowait(), 2296 * The state handling only uses drbd_thread_stop_nowait(),
2297 * we want to really wait here until the receiver is no more. 2297 * we want to really wait here until the receiver is no more.
2298 */ 2298 */
2299 drbd_thread_stop(&adm_ctx.tconn->receiver); 2299 drbd_thread_stop(&adm_ctx.connection->receiver);
2300 2300
2301 /* Race breaker. This additional state change request may be 2301 /* Race breaker. This additional state change request may be
2302 * necessary, if this was a forced disconnect during a receiver 2302 * necessary, if this was a forced disconnect during a receiver
@@ -2304,10 +2304,10 @@ static enum drbd_state_rv conn_try_disconnect(struct drbd_tconn *tconn, bool for
2304 * after drbdd_init() returned. Typically, we should be 2304 * after drbdd_init() returned. Typically, we should be
2305 * C_STANDALONE already, now, and this becomes a no-op. 2305 * C_STANDALONE already, now, and this becomes a no-op.
2306 */ 2306 */
2307 rv2 = conn_request_state(tconn, NS(conn, C_STANDALONE), 2307 rv2 = conn_request_state(connection, NS(conn, C_STANDALONE),
2308 CS_VERBOSE | CS_HARD); 2308 CS_VERBOSE | CS_HARD);
2309 if (rv2 < SS_SUCCESS) 2309 if (rv2 < SS_SUCCESS)
2310 conn_err(tconn, 2310 conn_err(connection,
2311 "unexpected rv2=%d in conn_try_disconnect()\n", 2311 "unexpected rv2=%d in conn_try_disconnect()\n",
2312 rv2); 2312 rv2);
2313 } 2313 }
@@ -2317,7 +2317,7 @@ static enum drbd_state_rv conn_try_disconnect(struct drbd_tconn *tconn, bool for
2317int drbd_adm_disconnect(struct sk_buff *skb, struct genl_info *info) 2317int drbd_adm_disconnect(struct sk_buff *skb, struct genl_info *info)
2318{ 2318{
2319 struct disconnect_parms parms; 2319 struct disconnect_parms parms;
2320 struct drbd_tconn *tconn; 2320 struct drbd_connection *connection;
2321 enum drbd_state_rv rv; 2321 enum drbd_state_rv rv;
2322 enum drbd_ret_code retcode; 2322 enum drbd_ret_code retcode;
2323 int err; 2323 int err;
@@ -2328,7 +2328,7 @@ int drbd_adm_disconnect(struct sk_buff *skb, struct genl_info *info)
2328 if (retcode != NO_ERROR) 2328 if (retcode != NO_ERROR)
2329 goto fail; 2329 goto fail;
2330 2330
2331 tconn = adm_ctx.tconn; 2331 connection = adm_ctx.connection;
2332 memset(&parms, 0, sizeof(parms)); 2332 memset(&parms, 0, sizeof(parms));
2333 if (info->attrs[DRBD_NLA_DISCONNECT_PARMS]) { 2333 if (info->attrs[DRBD_NLA_DISCONNECT_PARMS]) {
2334 err = disconnect_parms_from_attrs(&parms, info); 2334 err = disconnect_parms_from_attrs(&parms, info);
@@ -2339,7 +2339,7 @@ int drbd_adm_disconnect(struct sk_buff *skb, struct genl_info *info)
2339 } 2339 }
2340 } 2340 }
2341 2341
2342 rv = conn_try_disconnect(tconn, parms.force_disconnect); 2342 rv = conn_try_disconnect(connection, parms.force_disconnect);
2343 if (rv < SS_SUCCESS) 2343 if (rv < SS_SUCCESS)
2344 retcode = rv; /* FIXME: Type mismatch. */ 2344 retcode = rv; /* FIXME: Type mismatch. */
2345 else 2345 else
@@ -2357,7 +2357,7 @@ void resync_after_online_grow(struct drbd_device *device)
2357 if (device->state.role != device->state.peer) 2357 if (device->state.role != device->state.peer)
2358 iass = (device->state.role == R_PRIMARY); 2358 iass = (device->state.role == R_PRIMARY);
2359 else 2359 else
2360 iass = test_bit(RESOLVE_CONFLICTS, &device->tconn->flags); 2360 iass = test_bit(RESOLVE_CONFLICTS, &device->connection->flags);
2361 2361
2362 if (iass) 2362 if (iass)
2363 drbd_start_resync(device, C_SYNC_SOURCE); 2363 drbd_start_resync(device, C_SYNC_SOURCE);
@@ -2412,7 +2412,7 @@ int drbd_adm_resize(struct sk_buff *skb, struct genl_info *info)
2412 goto fail_ldev; 2412 goto fail_ldev;
2413 } 2413 }
2414 2414
2415 if (rs.no_resync && device->tconn->agreed_pro_version < 93) { 2415 if (rs.no_resync && device->connection->agreed_pro_version < 93) {
2416 retcode = ERR_NEED_APV_93; 2416 retcode = ERR_NEED_APV_93;
2417 goto fail_ldev; 2417 goto fail_ldev;
2418 } 2418 }
@@ -2454,12 +2454,12 @@ int drbd_adm_resize(struct sk_buff *skb, struct genl_info *info)
2454 device->ldev->known_size = drbd_get_capacity(device->ldev->backing_bdev); 2454 device->ldev->known_size = drbd_get_capacity(device->ldev->backing_bdev);
2455 2455
2456 if (new_disk_conf) { 2456 if (new_disk_conf) {
2457 mutex_lock(&device->tconn->conf_update); 2457 mutex_lock(&device->connection->conf_update);
2458 old_disk_conf = device->ldev->disk_conf; 2458 old_disk_conf = device->ldev->disk_conf;
2459 *new_disk_conf = *old_disk_conf; 2459 *new_disk_conf = *old_disk_conf;
2460 new_disk_conf->disk_size = (sector_t)rs.resize_size; 2460 new_disk_conf->disk_size = (sector_t)rs.resize_size;
2461 rcu_assign_pointer(device->ldev->disk_conf, new_disk_conf); 2461 rcu_assign_pointer(device->ldev->disk_conf, new_disk_conf);
2462 mutex_unlock(&device->tconn->conf_update); 2462 mutex_unlock(&device->connection->conf_update);
2463 synchronize_rcu(); 2463 synchronize_rcu();
2464 kfree(old_disk_conf); 2464 kfree(old_disk_conf);
2465 } 2465 }
@@ -2499,7 +2499,7 @@ int drbd_adm_resize(struct sk_buff *skb, struct genl_info *info)
2499int drbd_adm_resource_opts(struct sk_buff *skb, struct genl_info *info) 2499int drbd_adm_resource_opts(struct sk_buff *skb, struct genl_info *info)
2500{ 2500{
2501 enum drbd_ret_code retcode; 2501 enum drbd_ret_code retcode;
2502 struct drbd_tconn *tconn; 2502 struct drbd_connection *connection;
2503 struct res_opts res_opts; 2503 struct res_opts res_opts;
2504 int err; 2504 int err;
2505 2505
@@ -2508,9 +2508,9 @@ int drbd_adm_resource_opts(struct sk_buff *skb, struct genl_info *info)
2508 return retcode; 2508 return retcode;
2509 if (retcode != NO_ERROR) 2509 if (retcode != NO_ERROR)
2510 goto fail; 2510 goto fail;
2511 tconn = adm_ctx.tconn; 2511 connection = adm_ctx.connection;
2512 2512
2513 res_opts = tconn->res_opts; 2513 res_opts = connection->res_opts;
2514 if (should_set_defaults(info)) 2514 if (should_set_defaults(info))
2515 set_res_opts_defaults(&res_opts); 2515 set_res_opts_defaults(&res_opts);
2516 2516
@@ -2521,7 +2521,7 @@ int drbd_adm_resource_opts(struct sk_buff *skb, struct genl_info *info)
2521 goto fail; 2521 goto fail;
2522 } 2522 }
2523 2523
2524 err = set_resource_options(tconn, &res_opts); 2524 err = set_resource_options(connection, &res_opts);
2525 if (err) { 2525 if (err) {
2526 retcode = ERR_INVALID_REQUEST; 2526 retcode = ERR_INVALID_REQUEST;
2527 if (err == -ENOMEM) 2527 if (err == -ENOMEM)
@@ -2710,9 +2710,9 @@ int drbd_adm_resume_io(struct sk_buff *skb, struct genl_info *info)
2710 retcode = drbd_request_state(device, NS3(susp, 0, susp_nod, 0, susp_fen, 0)); 2710 retcode = drbd_request_state(device, NS3(susp, 0, susp_nod, 0, susp_fen, 0));
2711 if (retcode == SS_SUCCESS) { 2711 if (retcode == SS_SUCCESS) {
2712 if (device->state.conn < C_CONNECTED) 2712 if (device->state.conn < C_CONNECTED)
2713 tl_clear(device->tconn); 2713 tl_clear(device->connection);
2714 if (device->state.disk == D_DISKLESS || device->state.disk == D_FAILED) 2714 if (device->state.disk == D_DISKLESS || device->state.disk == D_FAILED)
2715 tl_restart(device->tconn, FAIL_FROZEN_DISK_IO); 2715 tl_restart(device->connection, FAIL_FROZEN_DISK_IO);
2716 } 2716 }
2717 drbd_resume_io(device); 2717 drbd_resume_io(device);
2718 2718
@@ -2726,8 +2726,7 @@ int drbd_adm_outdate(struct sk_buff *skb, struct genl_info *info)
2726 return drbd_adm_simple_request_state(skb, info, NS(disk, D_OUTDATED)); 2726 return drbd_adm_simple_request_state(skb, info, NS(disk, D_OUTDATED));
2727} 2727}
2728 2728
2729static int nla_put_drbd_cfg_context(struct sk_buff *skb, 2729static int nla_put_drbd_cfg_context(struct sk_buff *skb, struct drbd_connection *connection, unsigned vnr)
2730 struct drbd_tconn *tconn, unsigned vnr)
2731{ 2730{
2732 struct nlattr *nla; 2731 struct nlattr *nla;
2733 nla = nla_nest_start(skb, DRBD_NLA_CFG_CONTEXT); 2732 nla = nla_nest_start(skb, DRBD_NLA_CFG_CONTEXT);
@@ -2736,13 +2735,13 @@ static int nla_put_drbd_cfg_context(struct sk_buff *skb,
2736 if (vnr != VOLUME_UNSPECIFIED && 2735 if (vnr != VOLUME_UNSPECIFIED &&
2737 nla_put_u32(skb, T_ctx_volume, vnr)) 2736 nla_put_u32(skb, T_ctx_volume, vnr))
2738 goto nla_put_failure; 2737 goto nla_put_failure;
2739 if (nla_put_string(skb, T_ctx_resource_name, tconn->name)) 2738 if (nla_put_string(skb, T_ctx_resource_name, connection->name))
2740 goto nla_put_failure; 2739 goto nla_put_failure;
2741 if (tconn->my_addr_len && 2740 if (connection->my_addr_len &&
2742 nla_put(skb, T_ctx_my_addr, tconn->my_addr_len, &tconn->my_addr)) 2741 nla_put(skb, T_ctx_my_addr, connection->my_addr_len, &connection->my_addr))
2743 goto nla_put_failure; 2742 goto nla_put_failure;
2744 if (tconn->peer_addr_len && 2743 if (connection->peer_addr_len &&
2745 nla_put(skb, T_ctx_peer_addr, tconn->peer_addr_len, &tconn->peer_addr)) 2744 nla_put(skb, T_ctx_peer_addr, connection->peer_addr_len, &connection->peer_addr))
2746 goto nla_put_failure; 2745 goto nla_put_failure;
2747 nla_nest_end(skb, nla); 2746 nla_nest_end(skb, nla);
2748 return 0; 2747 return 0;
@@ -2779,10 +2778,10 @@ static int nla_put_status_info(struct sk_buff *skb, struct drbd_device *device,
2779 2778
2780 /* We need to add connection name and volume number information still. 2779 /* We need to add connection name and volume number information still.
2781 * Minor number is in drbd_genlmsghdr. */ 2780 * Minor number is in drbd_genlmsghdr. */
2782 if (nla_put_drbd_cfg_context(skb, device->tconn, device->vnr)) 2781 if (nla_put_drbd_cfg_context(skb, device->connection, device->vnr))
2783 goto nla_put_failure; 2782 goto nla_put_failure;
2784 2783
2785 if (res_opts_to_skb(skb, &device->tconn->res_opts, exclude_sensitive)) 2784 if (res_opts_to_skb(skb, &device->connection->res_opts, exclude_sensitive))
2786 goto nla_put_failure; 2785 goto nla_put_failure;
2787 2786
2788 rcu_read_lock(); 2787 rcu_read_lock();
@@ -2795,7 +2794,7 @@ static int nla_put_status_info(struct sk_buff *skb, struct drbd_device *device,
2795 if (!err) { 2794 if (!err) {
2796 struct net_conf *nc; 2795 struct net_conf *nc;
2797 2796
2798 nc = rcu_dereference(device->tconn->net_conf); 2797 nc = rcu_dereference(device->connection->net_conf);
2799 if (nc) 2798 if (nc)
2800 err = net_conf_to_skb(skb, nc, exclude_sensitive); 2799 err = net_conf_to_skb(skb, nc, exclude_sensitive);
2801 } 2800 }
@@ -2899,18 +2898,18 @@ static int get_one_status(struct sk_buff *skb, struct netlink_callback *cb)
2899{ 2898{
2900 struct drbd_device *device; 2899 struct drbd_device *device;
2901 struct drbd_genlmsghdr *dh; 2900 struct drbd_genlmsghdr *dh;
2902 struct drbd_tconn *pos = (struct drbd_tconn*)cb->args[0]; 2901 struct drbd_connection *pos = (struct drbd_connection *)cb->args[0];
2903 struct drbd_tconn *tconn = NULL; 2902 struct drbd_connection *connection = NULL;
2904 struct drbd_tconn *tmp; 2903 struct drbd_connection *tmp;
2905 unsigned volume = cb->args[1]; 2904 unsigned volume = cb->args[1];
2906 2905
2907 /* Open coded, deferred, iteration: 2906 /* Open coded, deferred, iteration:
2908 * list_for_each_entry_safe(tconn, tmp, &drbd_tconns, all_tconn) { 2907 * list_for_each_entry_safe(connection, tmp, &drbd_connections, connections) {
2909 * idr_for_each_entry(&tconn->volumes, device, i) { 2908 * idr_for_each_entry(&connection->volumes, device, i) {
2910 * ... 2909 * ...
2911 * } 2910 * }
2912 * } 2911 * }
2913 * where tconn is cb->args[0]; 2912 * where connection is cb->args[0];
2914 * and i is cb->args[1]; 2913 * and i is cb->args[1];
2915 * 2914 *
2916 * cb->args[2] indicates if we shall loop over all resources, 2915 * cb->args[2] indicates if we shall loop over all resources,
@@ -2927,36 +2926,36 @@ static int get_one_status(struct sk_buff *skb, struct netlink_callback *cb)
2927 /* synchronize with conn_create()/conn_destroy() */ 2926 /* synchronize with conn_create()/conn_destroy() */
2928 rcu_read_lock(); 2927 rcu_read_lock();
2929 /* revalidate iterator position */ 2928 /* revalidate iterator position */
2930 list_for_each_entry_rcu(tmp, &drbd_tconns, all_tconn) { 2929 list_for_each_entry_rcu(tmp, &drbd_connections, connections) {
2931 if (pos == NULL) { 2930 if (pos == NULL) {
2932 /* first iteration */ 2931 /* first iteration */
2933 pos = tmp; 2932 pos = tmp;
2934 tconn = pos; 2933 connection = pos;
2935 break; 2934 break;
2936 } 2935 }
2937 if (tmp == pos) { 2936 if (tmp == pos) {
2938 tconn = pos; 2937 connection = pos;
2939 break; 2938 break;
2940 } 2939 }
2941 } 2940 }
2942 if (tconn) { 2941 if (connection) {
2943next_tconn: 2942next_connection:
2944 device = idr_get_next(&tconn->volumes, &volume); 2943 device = idr_get_next(&connection->volumes, &volume);
2945 if (!device) { 2944 if (!device) {
2946 /* No more volumes to dump on this tconn. 2945 /* No more volumes to dump on this connection.
2947 * Advance tconn iterator. */ 2946 * Advance connection iterator. */
2948 pos = list_entry_rcu(tconn->all_tconn.next, 2947 pos = list_entry_rcu(connection->connections.next,
2949 struct drbd_tconn, all_tconn); 2948 struct drbd_connection, connections);
2950 /* Did we dump any volume on this tconn yet? */ 2949 /* Did we dump any volume on this connection yet? */
2951 if (volume != 0) { 2950 if (volume != 0) {
2952 /* If we reached the end of the list, 2951 /* If we reached the end of the list,
2953 * or only a single resource dump was requested, 2952 * or only a single resource dump was requested,
2954 * we are done. */ 2953 * we are done. */
2955 if (&pos->all_tconn == &drbd_tconns || cb->args[2]) 2954 if (&pos->connections == &drbd_connections || cb->args[2])
2956 goto out; 2955 goto out;
2957 volume = 0; 2956 volume = 0;
2958 tconn = pos; 2957 connection = pos;
2959 goto next_tconn; 2958 goto next_connection;
2960 } 2959 }
2961 } 2960 }
2962 2961
@@ -2967,22 +2966,22 @@ next_tconn:
2967 goto out; 2966 goto out;
2968 2967
2969 if (!device) { 2968 if (!device) {
2970 /* This is a tconn without a single volume. 2969 /* This is a connection without a single volume.
2971 * Suprisingly enough, it may have a network 2970 * Suprisingly enough, it may have a network
2972 * configuration. */ 2971 * configuration. */
2973 struct net_conf *nc; 2972 struct net_conf *nc;
2974 dh->minor = -1U; 2973 dh->minor = -1U;
2975 dh->ret_code = NO_ERROR; 2974 dh->ret_code = NO_ERROR;
2976 if (nla_put_drbd_cfg_context(skb, tconn, VOLUME_UNSPECIFIED)) 2975 if (nla_put_drbd_cfg_context(skb, connection, VOLUME_UNSPECIFIED))
2977 goto cancel; 2976 goto cancel;
2978 nc = rcu_dereference(tconn->net_conf); 2977 nc = rcu_dereference(connection->net_conf);
2979 if (nc && net_conf_to_skb(skb, nc, 1) != 0) 2978 if (nc && net_conf_to_skb(skb, nc, 1) != 0)
2980 goto cancel; 2979 goto cancel;
2981 goto done; 2980 goto done;
2982 } 2981 }
2983 2982
2984 D_ASSERT(device->vnr == volume); 2983 D_ASSERT(device->vnr == volume);
2985 D_ASSERT(device->tconn == tconn); 2984 D_ASSERT(device->connection == connection);
2986 2985
2987 dh->minor = device_to_minor(device); 2986 dh->minor = device_to_minor(device);
2988 dh->ret_code = NO_ERROR; 2987 dh->ret_code = NO_ERROR;
@@ -2994,15 +2993,15 @@ cancel:
2994 } 2993 }
2995done: 2994done:
2996 genlmsg_end(skb, dh); 2995 genlmsg_end(skb, dh);
2997 } 2996 }
2998 2997
2999out: 2998out:
3000 rcu_read_unlock(); 2999 rcu_read_unlock();
3001 /* where to start the next iteration */ 3000 /* where to start the next iteration */
3002 cb->args[0] = (long)pos; 3001 cb->args[0] = (long)pos;
3003 cb->args[1] = (pos == tconn) ? volume + 1 : 0; 3002 cb->args[1] = (pos == connection) ? volume + 1 : 0;
3004 3003
3005 /* No more tconns/volumes/minors found results in an empty skb. 3004 /* No more connections/volumes/minors found results in an empty skb.
3006 * Which will terminate the dump. */ 3005 * Which will terminate the dump. */
3007 return skb->len; 3006 return skb->len;
3008} 3007}
@@ -3022,7 +3021,7 @@ int drbd_adm_get_status_all(struct sk_buff *skb, struct netlink_callback *cb)
3022 const unsigned hdrlen = GENL_HDRLEN + GENL_MAGIC_FAMILY_HDRSZ; 3021 const unsigned hdrlen = GENL_HDRLEN + GENL_MAGIC_FAMILY_HDRSZ;
3023 struct nlattr *nla; 3022 struct nlattr *nla;
3024 const char *resource_name; 3023 const char *resource_name;
3025 struct drbd_tconn *tconn; 3024 struct drbd_connection *connection;
3026 int maxtype; 3025 int maxtype;
3027 3026
3028 /* Is this a followup call? */ 3027 /* Is this a followup call? */
@@ -3051,18 +3050,18 @@ int drbd_adm_get_status_all(struct sk_buff *skb, struct netlink_callback *cb)
3051 if (!nla) 3050 if (!nla)
3052 return -EINVAL; 3051 return -EINVAL;
3053 resource_name = nla_data(nla); 3052 resource_name = nla_data(nla);
3054 tconn = conn_get_by_name(resource_name); 3053 connection = conn_get_by_name(resource_name);
3055 3054
3056 if (!tconn) 3055 if (!connection)
3057 return -ENODEV; 3056 return -ENODEV;
3058 3057
3059 kref_put(&tconn->kref, &conn_destroy); /* get_one_status() (re)validates tconn by itself */ 3058 kref_put(&connection->kref, &conn_destroy); /* get_one_status() (re)validates connection by itself */
3060 3059
3061 /* prime iterators, and set "filter" mode mark: 3060 /* prime iterators, and set "filter" mode mark:
3062 * only dump this tconn. */ 3061 * only dump this connection. */
3063 cb->args[0] = (long)tconn; 3062 cb->args[0] = (long)connection;
3064 /* cb->args[1] = 0; passed in this way. */ 3063 /* cb->args[1] = 0; passed in this way. */
3065 cb->args[2] = (long)tconn; 3064 cb->args[2] = (long)connection;
3066 3065
3067dump: 3066dump:
3068 return get_one_status(skb, cb); 3067 return get_one_status(skb, cb);
@@ -3169,7 +3168,7 @@ int drbd_adm_new_c_uuid(struct sk_buff *skb, struct genl_info *info)
3169 } 3168 }
3170 3169
3171 /* this is "skip initial sync", assume to be clean */ 3170 /* this is "skip initial sync", assume to be clean */
3172 if (device->state.conn == C_CONNECTED && device->tconn->agreed_pro_version >= 90 && 3171 if (device->state.conn == C_CONNECTED && device->connection->agreed_pro_version >= 90 &&
3173 device->ldev->md.uuid[UI_CURRENT] == UUID_JUST_CREATED && args.clear_bm) { 3172 device->ldev->md.uuid[UI_CURRENT] == UUID_JUST_CREATED && args.clear_bm) {
3174 dev_info(DEV, "Preparing to skip initial sync\n"); 3173 dev_info(DEV, "Preparing to skip initial sync\n");
3175 skip_initial_sync = 1; 3174 skip_initial_sync = 1;
@@ -3192,10 +3191,10 @@ int drbd_adm_new_c_uuid(struct sk_buff *skb, struct genl_info *info)
3192 drbd_send_uuids_skip_initial_sync(device); 3191 drbd_send_uuids_skip_initial_sync(device);
3193 _drbd_uuid_set(device, UI_BITMAP, 0); 3192 _drbd_uuid_set(device, UI_BITMAP, 0);
3194 drbd_print_uuids(device, "cleared bitmap UUID"); 3193 drbd_print_uuids(device, "cleared bitmap UUID");
3195 spin_lock_irq(&device->tconn->req_lock); 3194 spin_lock_irq(&device->connection->req_lock);
3196 _drbd_set_state(_NS2(device, disk, D_UP_TO_DATE, pdsk, D_UP_TO_DATE), 3195 _drbd_set_state(_NS2(device, disk, D_UP_TO_DATE, pdsk, D_UP_TO_DATE),
3197 CS_VERBOSE, NULL); 3196 CS_VERBOSE, NULL);
3198 spin_unlock_irq(&device->tconn->req_lock); 3197 spin_unlock_irq(&device->connection->req_lock);
3199 } 3198 }
3200 } 3199 }
3201 3200
@@ -3249,7 +3248,7 @@ int drbd_adm_new_resource(struct sk_buff *skb, struct genl_info *info)
3249 if (retcode != NO_ERROR) 3248 if (retcode != NO_ERROR)
3250 goto out; 3249 goto out;
3251 3250
3252 if (adm_ctx.tconn) { 3251 if (adm_ctx.connection) {
3253 if (info->nlhdr->nlmsg_flags & NLM_F_EXCL) { 3252 if (info->nlhdr->nlmsg_flags & NLM_F_EXCL) {
3254 retcode = ERR_INVALID_REQUEST; 3253 retcode = ERR_INVALID_REQUEST;
3255 drbd_msg_put_info("resource exists"); 3254 drbd_msg_put_info("resource exists");
@@ -3288,7 +3287,7 @@ int drbd_adm_add_minor(struct sk_buff *skb, struct genl_info *info)
3288 } 3287 }
3289 3288
3290 /* drbd_adm_prepare made sure already 3289 /* drbd_adm_prepare made sure already
3291 * that device->tconn and device->vnr match the request. */ 3290 * that device->connection and device->vnr match the request. */
3292 if (adm_ctx.device) { 3291 if (adm_ctx.device) {
3293 if (info->nlhdr->nlmsg_flags & NLM_F_EXCL) 3292 if (info->nlhdr->nlmsg_flags & NLM_F_EXCL)
3294 retcode = ERR_MINOR_EXISTS; 3293 retcode = ERR_MINOR_EXISTS;
@@ -3296,7 +3295,7 @@ int drbd_adm_add_minor(struct sk_buff *skb, struct genl_info *info)
3296 goto out; 3295 goto out;
3297 } 3296 }
3298 3297
3299 retcode = conn_new_minor(adm_ctx.tconn, dh->minor, adm_ctx.volume); 3298 retcode = conn_new_minor(adm_ctx.connection, dh->minor, adm_ctx.volume);
3300out: 3299out:
3301 drbd_adm_finish(info, retcode); 3300 drbd_adm_finish(info, retcode);
3302 return 0; 3301 return 0;
@@ -3311,7 +3310,7 @@ static enum drbd_ret_code adm_delete_minor(struct drbd_device *device)
3311 device->state.role == R_SECONDARY) { 3310 device->state.role == R_SECONDARY) {
3312 _drbd_request_state(device, NS(conn, C_WF_REPORT_PARAMS), 3311 _drbd_request_state(device, NS(conn, C_WF_REPORT_PARAMS),
3313 CS_VERBOSE + CS_WAIT_COMPLETE); 3312 CS_VERBOSE + CS_WAIT_COMPLETE);
3314 idr_remove(&device->tconn->volumes, device->vnr); 3313 idr_remove(&device->connection->volumes, device->vnr);
3315 idr_remove(&minors, device_to_minor(device)); 3314 idr_remove(&minors, device_to_minor(device));
3316 destroy_workqueue(device->submit.wq); 3315 destroy_workqueue(device->submit.wq);
3317 del_gendisk(device->vdisk); 3316 del_gendisk(device->vdisk);
@@ -3350,13 +3349,13 @@ int drbd_adm_down(struct sk_buff *skb, struct genl_info *info)
3350 if (retcode != NO_ERROR) 3349 if (retcode != NO_ERROR)
3351 goto out; 3350 goto out;
3352 3351
3353 if (!adm_ctx.tconn) { 3352 if (!adm_ctx.connection) {
3354 retcode = ERR_RES_NOT_KNOWN; 3353 retcode = ERR_RES_NOT_KNOWN;
3355 goto out; 3354 goto out;
3356 } 3355 }
3357 3356
3358 /* demote */ 3357 /* demote */
3359 idr_for_each_entry(&adm_ctx.tconn->volumes, device, i) { 3358 idr_for_each_entry(&adm_ctx.connection->volumes, device, i) {
3360 retcode = drbd_set_role(device, R_SECONDARY, 0); 3359 retcode = drbd_set_role(device, R_SECONDARY, 0);
3361 if (retcode < SS_SUCCESS) { 3360 if (retcode < SS_SUCCESS) {
3362 drbd_msg_put_info("failed to demote"); 3361 drbd_msg_put_info("failed to demote");
@@ -3364,14 +3363,14 @@ int drbd_adm_down(struct sk_buff *skb, struct genl_info *info)
3364 } 3363 }
3365 } 3364 }
3366 3365
3367 retcode = conn_try_disconnect(adm_ctx.tconn, 0); 3366 retcode = conn_try_disconnect(adm_ctx.connection, 0);
3368 if (retcode < SS_SUCCESS) { 3367 if (retcode < SS_SUCCESS) {
3369 drbd_msg_put_info("failed to disconnect"); 3368 drbd_msg_put_info("failed to disconnect");
3370 goto out; 3369 goto out;
3371 } 3370 }
3372 3371
3373 /* detach */ 3372 /* detach */
3374 idr_for_each_entry(&adm_ctx.tconn->volumes, device, i) { 3373 idr_for_each_entry(&adm_ctx.connection->volumes, device, i) {
3375 retcode = adm_detach(device, 0); 3374 retcode = adm_detach(device, 0);
3376 if (retcode < SS_SUCCESS || retcode > NO_ERROR) { 3375 if (retcode < SS_SUCCESS || retcode > NO_ERROR) {
3377 drbd_msg_put_info("failed to detach"); 3376 drbd_msg_put_info("failed to detach");
@@ -3379,15 +3378,15 @@ int drbd_adm_down(struct sk_buff *skb, struct genl_info *info)
3379 } 3378 }
3380 } 3379 }
3381 3380
3382 /* If we reach this, all volumes (of this tconn) are Secondary, 3381 /* If we reach this, all volumes (of this connection) are Secondary,
3383 * Disconnected, Diskless, aka Unconfigured. Make sure all threads have 3382 * Disconnected, Diskless, aka Unconfigured. Make sure all threads have
3384 * actually stopped, state handling only does drbd_thread_stop_nowait(). */ 3383 * actually stopped, state handling only does drbd_thread_stop_nowait(). */
3385 drbd_thread_stop(&adm_ctx.tconn->worker); 3384 drbd_thread_stop(&adm_ctx.connection->worker);
3386 3385
3387 /* Now, nothing can fail anymore */ 3386 /* Now, nothing can fail anymore */
3388 3387
3389 /* delete volumes */ 3388 /* delete volumes */
3390 idr_for_each_entry(&adm_ctx.tconn->volumes, device, i) { 3389 idr_for_each_entry(&adm_ctx.connection->volumes, device, i) {
3391 retcode = adm_delete_minor(device); 3390 retcode = adm_delete_minor(device);
3392 if (retcode != NO_ERROR) { 3391 if (retcode != NO_ERROR) {
3393 /* "can not happen" */ 3392 /* "can not happen" */
@@ -3397,10 +3396,10 @@ int drbd_adm_down(struct sk_buff *skb, struct genl_info *info)
3397 } 3396 }
3398 3397
3399 /* delete connection */ 3398 /* delete connection */
3400 if (conn_lowest_minor(adm_ctx.tconn) < 0) { 3399 if (conn_lowest_minor(adm_ctx.connection) < 0) {
3401 list_del_rcu(&adm_ctx.tconn->all_tconn); 3400 list_del_rcu(&adm_ctx.connection->connections);
3402 synchronize_rcu(); 3401 synchronize_rcu();
3403 kref_put(&adm_ctx.tconn->kref, &conn_destroy); 3402 kref_put(&adm_ctx.connection->kref, &conn_destroy);
3404 3403
3405 retcode = NO_ERROR; 3404 retcode = NO_ERROR;
3406 } else { 3405 } else {
@@ -3424,10 +3423,10 @@ int drbd_adm_del_resource(struct sk_buff *skb, struct genl_info *info)
3424 if (retcode != NO_ERROR) 3423 if (retcode != NO_ERROR)
3425 goto out; 3424 goto out;
3426 3425
3427 if (conn_lowest_minor(adm_ctx.tconn) < 0) { 3426 if (conn_lowest_minor(adm_ctx.connection) < 0) {
3428 list_del_rcu(&adm_ctx.tconn->all_tconn); 3427 list_del_rcu(&adm_ctx.connection->connections);
3429 synchronize_rcu(); 3428 synchronize_rcu();
3430 kref_put(&adm_ctx.tconn->kref, &conn_destroy); 3429 kref_put(&adm_ctx.connection->kref, &conn_destroy);
3431 3430
3432 retcode = NO_ERROR; 3431 retcode = NO_ERROR;
3433 } else { 3432 } else {
@@ -3435,7 +3434,7 @@ int drbd_adm_del_resource(struct sk_buff *skb, struct genl_info *info)
3435 } 3434 }
3436 3435
3437 if (retcode == NO_ERROR) 3436 if (retcode == NO_ERROR)
3438 drbd_thread_stop(&adm_ctx.tconn->worker); 3437 drbd_thread_stop(&adm_ctx.connection->worker);
3439out: 3438out:
3440 drbd_adm_finish(info, retcode); 3439 drbd_adm_finish(info, retcode);
3441 return 0; 3440 return 0;