@@ -345,31 +345,6 @@ rpcrdma_create_id(struct rpcrdma_xprt *xprt, struct rpcrdma_ia *ia)
345
345
* Exported functions.
346
346
*/
347
347
348
- /**
349
- * rpcrdma_ia_open - Open and initialize an Interface Adapter.
350
- * @xprt: transport with IA to (re)initialize
351
- *
352
- * Returns 0 on success, negative errno if an appropriate
353
- * Interface Adapter could not be found and opened.
354
- */
355
- int
356
- rpcrdma_ia_open (struct rpcrdma_xprt * xprt )
357
- {
358
- struct rpcrdma_ia * ia = & xprt -> rx_ia ;
359
- int rc ;
360
-
361
- ia -> ri_id = rpcrdma_create_id (xprt , ia );
362
- if (IS_ERR (ia -> ri_id )) {
363
- rc = PTR_ERR (ia -> ri_id );
364
- goto out_err ;
365
- }
366
- return 0 ;
367
-
368
- out_err :
369
- rpcrdma_ia_close (ia );
370
- return rc ;
371
- }
372
-
373
348
/**
374
349
* rpcrdma_ia_remove - Handle device driver unload
375
350
* @ia: interface adapter being removed
@@ -401,34 +376,26 @@ rpcrdma_ia_remove(struct rpcrdma_ia *ia)
401
376
trace_xprtrdma_remove (r_xprt );
402
377
}
403
378
404
- /**
405
- * rpcrdma_ia_close - Clean up/close an IA.
406
- * @ia: interface adapter to close
407
- *
408
- */
409
- void
410
- rpcrdma_ia_close (struct rpcrdma_ia * ia )
411
- {
412
- if (ia -> ri_id && !IS_ERR (ia -> ri_id ))
413
- rdma_destroy_id (ia -> ri_id );
414
- ia -> ri_id = NULL ;
415
- }
416
-
417
- static int rpcrdma_ep_create (struct rpcrdma_xprt * r_xprt ,
418
- struct rdma_cm_id * id )
379
+ static int rpcrdma_ep_create (struct rpcrdma_xprt * r_xprt )
419
380
{
420
381
struct rpcrdma_ep * ep = & r_xprt -> rx_ep ;
421
382
struct rpcrdma_ia * ia = & r_xprt -> rx_ia ;
422
383
struct rpcrdma_connect_private * pmsg = & ep -> rep_cm_private ;
384
+ struct rdma_cm_id * id ;
423
385
int rc ;
424
386
387
+ id = rpcrdma_create_id (r_xprt , ia );
388
+ if (IS_ERR (id ))
389
+ return PTR_ERR (id );
390
+
425
391
ep -> rep_max_requests = r_xprt -> rx_xprt .max_reqs ;
426
392
ep -> rep_inline_send = xprt_rdma_max_inline_write ;
427
393
ep -> rep_inline_recv = xprt_rdma_max_inline_read ;
428
394
429
395
rc = frwr_query_device (r_xprt , id -> device );
430
396
if (rc )
431
- return rc ;
397
+ goto out_destroy ;
398
+
432
399
r_xprt -> rx_buf .rb_max_requests = cpu_to_be32 (ep -> rep_max_requests );
433
400
434
401
ep -> rep_attr .event_handler = rpcrdma_qp_event_handler ;
@@ -507,10 +474,12 @@ static int rpcrdma_ep_create(struct rpcrdma_xprt *r_xprt,
507
474
rc = rdma_create_qp (id , ia -> ri_pd , & ep -> rep_attr );
508
475
if (rc )
509
476
goto out_destroy ;
477
+ ia -> ri_id = id ;
510
478
return 0 ;
511
479
512
480
out_destroy :
513
481
rpcrdma_ep_destroy (r_xprt );
482
+ rdma_destroy_id (id );
514
483
return rc ;
515
484
}
516
485
@@ -536,79 +505,8 @@ static void rpcrdma_ep_destroy(struct rpcrdma_xprt *r_xprt)
536
505
ia -> ri_pd = NULL ;
537
506
}
538
507
539
- /* Re-establish a connection after a device removal event.
540
- * Unlike a normal reconnection, a fresh PD and a new set
541
- * of MRs and buffers is needed.
542
- */
543
- static int rpcrdma_ep_recreate_xprt (struct rpcrdma_xprt * r_xprt )
544
- {
545
- struct rpcrdma_ia * ia = & r_xprt -> rx_ia ;
546
- int rc , err ;
547
-
548
- trace_xprtrdma_reinsert (r_xprt );
549
-
550
- rc = - EHOSTUNREACH ;
551
- if (rpcrdma_ia_open (r_xprt ))
552
- goto out1 ;
553
-
554
- rc = - ENETUNREACH ;
555
- err = rpcrdma_ep_create (r_xprt , ia -> ri_id );
556
- if (err )
557
- goto out2 ;
558
- return 0 ;
559
-
560
- out2 :
561
- rpcrdma_ia_close (ia );
562
- out1 :
563
- return rc ;
564
- }
565
-
566
- static int rpcrdma_ep_reconnect (struct rpcrdma_xprt * r_xprt )
567
- {
568
- struct rpcrdma_ia * ia = & r_xprt -> rx_ia ;
569
- struct rdma_cm_id * id , * old ;
570
- int err , rc ;
571
-
572
- rc = - EHOSTUNREACH ;
573
- id = rpcrdma_create_id (r_xprt , ia );
574
- if (IS_ERR (id ))
575
- goto out ;
576
-
577
- /* As long as the new ID points to the same device as the
578
- * old ID, we can reuse the transport's existing PD and all
579
- * previously allocated MRs. Also, the same device means
580
- * the transport's previous DMA mappings are still valid.
581
- *
582
- * This is a sanity check only. There should be no way these
583
- * point to two different devices here.
584
- */
585
- old = id ;
586
- rc = - ENETUNREACH ;
587
- if (ia -> ri_id -> device != id -> device ) {
588
- pr_err ("rpcrdma: can't reconnect on different device!\n" );
589
- goto out_destroy ;
590
- }
591
-
592
- err = rpcrdma_ep_create (r_xprt , id );
593
- if (err )
594
- goto out_destroy ;
595
-
596
- /* Atomically replace the transport's ID. */
597
- rc = 0 ;
598
- old = ia -> ri_id ;
599
- ia -> ri_id = id ;
600
-
601
- out_destroy :
602
- rdma_destroy_id (old );
603
- out :
604
- return rc ;
605
- }
606
-
607
- /**
608
- * rpcrdma_xprt_connect - Connect an unconnected transport
609
- * @r_xprt: controlling transport instance
610
- *
611
- * Returns 0 on success or a negative errno.
508
+ /*
509
+ * Connect unconnected endpoint.
612
510
*/
613
511
int rpcrdma_xprt_connect (struct rpcrdma_xprt * r_xprt )
614
512
{
@@ -618,25 +516,10 @@ int rpcrdma_xprt_connect(struct rpcrdma_xprt *r_xprt)
618
516
int rc ;
619
517
620
518
retry :
621
- switch (ep -> rep_connected ) {
622
- case 0 :
623
- rc = - ENETUNREACH ;
624
- if (rpcrdma_ep_create (r_xprt , ia -> ri_id ))
625
- goto out_noupdate ;
626
- break ;
627
- case - ENODEV :
628
- rc = rpcrdma_ep_recreate_xprt (r_xprt );
629
- if (rc )
630
- goto out_noupdate ;
631
- break ;
632
- case 1 :
633
- rpcrdma_xprt_disconnect (r_xprt );
634
- /* fall through */
635
- default :
636
- rc = rpcrdma_ep_reconnect (r_xprt );
637
- if (rc )
638
- goto out ;
639
- }
519
+ rpcrdma_xprt_disconnect (r_xprt );
520
+ rc = rpcrdma_ep_create (r_xprt );
521
+ if (rc )
522
+ goto out_noupdate ;
640
523
641
524
ep -> rep_connected = 0 ;
642
525
xprt_clear_connected (xprt );
@@ -712,6 +595,10 @@ void rpcrdma_xprt_disconnect(struct rpcrdma_xprt *r_xprt)
712
595
rpcrdma_sendctxs_destroy (r_xprt );
713
596
714
597
rpcrdma_ep_destroy (r_xprt );
598
+
599
+ if (ia -> ri_id )
600
+ rdma_destroy_id (ia -> ri_id );
601
+ ia -> ri_id = NULL ;
715
602
}
716
603
717
604
/* Fixed-size circular FIFO queue. This implementation is wait-free and
0 commit comments