aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
authorBart Van Assche <bvanassche@acm.org>2011-12-25 07:18:12 -0500
committerRoland Dreier <roland@purestorage.com>2012-11-30 20:40:31 -0500
commit294c875a65269361defd7aeb97804ba99eb57cbf (patch)
tree64b3567dda8122a701516dfa432fee53f3b644ed /drivers/infiniband
parent4f0af69799b0e7b9805c4d174169f5ed7bf315c1 (diff)
IB/srp: Suppress superfluous error messages
Keep track of the connection state. Only report QP errors while connected. Only invoke ib_send_cm_dreq() when connected so that invoking srp_disconnect_target() after having received a DREQ does not cause an error message to be printed. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Acked-by: David Dillow <dillowda@ornl.gov> Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.c38
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.h1
2 files changed, 31 insertions, 8 deletions
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index f0843ef28e1..3c64bf400c2 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -428,17 +428,34 @@ static int srp_send_req(struct srp_target_port *target)
428 return status; 428 return status;
429} 429}
430 430
431static bool srp_change_conn_state(struct srp_target_port *target,
432 bool connected)
433{
434 bool changed = false;
435
436 spin_lock_irq(&target->lock);
437 if (target->connected != connected) {
438 target->connected = connected;
439 changed = true;
440 }
441 spin_unlock_irq(&target->lock);
442
443 return changed;
444}
445
431static void srp_disconnect_target(struct srp_target_port *target) 446static void srp_disconnect_target(struct srp_target_port *target)
432{ 447{
433 /* XXX should send SRP_I_LOGOUT request */ 448 if (srp_change_conn_state(target, false)) {
449 /* XXX should send SRP_I_LOGOUT request */
434 450
435 init_completion(&target->done); 451 init_completion(&target->done);
436 if (ib_send_cm_dreq(target->cm_id, NULL, 0)) { 452 if (ib_send_cm_dreq(target->cm_id, NULL, 0)) {
437 shost_printk(KERN_DEBUG, target->scsi_host, 453 shost_printk(KERN_DEBUG, target->scsi_host,
438 PFX "Sending CM DREQ failed\n"); 454 PFX "Sending CM DREQ failed\n");
439 return; 455 } else {
456 wait_for_completion(&target->done);
457 }
440 } 458 }
441 wait_for_completion(&target->done);
442} 459}
443 460
444static bool srp_change_state(struct srp_target_port *target, 461static bool srp_change_state(struct srp_target_port *target,
@@ -515,6 +532,8 @@ static int srp_connect_target(struct srp_target_port *target)
515 int retries = 3; 532 int retries = 3;
516 int ret; 533 int ret;
517 534
535 WARN_ON_ONCE(target->connected);
536
518 target->qp_in_error = false; 537 target->qp_in_error = false;
519 538
520 ret = srp_lookup_path(target); 539 ret = srp_lookup_path(target);
@@ -536,6 +555,7 @@ static int srp_connect_target(struct srp_target_port *target)
536 */ 555 */
537 switch (target->status) { 556 switch (target->status) {
538 case 0: 557 case 0:
558 srp_change_conn_state(target, true);
539 return 0; 559 return 0;
540 560
541 case SRP_PORT_REDIRECT: 561 case SRP_PORT_REDIRECT:
@@ -1274,7 +1294,7 @@ static void srp_handle_qp_err(enum ib_wc_status wc_status,
1274 enum ib_wc_opcode wc_opcode, 1294 enum ib_wc_opcode wc_opcode,
1275 struct srp_target_port *target) 1295 struct srp_target_port *target)
1276{ 1296{
1277 if (!target->qp_in_error) { 1297 if (target->connected && !target->qp_in_error) {
1278 shost_printk(KERN_ERR, target->scsi_host, 1298 shost_printk(KERN_ERR, target->scsi_host,
1279 PFX "failed %s status %d\n", 1299 PFX "failed %s status %d\n",
1280 wc_opcode & IB_WC_RECV ? "receive" : "send", 1300 wc_opcode & IB_WC_RECV ? "receive" : "send",
@@ -1630,6 +1650,7 @@ static int srp_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event)
1630 case IB_CM_DREQ_RECEIVED: 1650 case IB_CM_DREQ_RECEIVED:
1631 shost_printk(KERN_WARNING, target->scsi_host, 1651 shost_printk(KERN_WARNING, target->scsi_host,
1632 PFX "DREQ received - connection closed\n"); 1652 PFX "DREQ received - connection closed\n");
1653 srp_change_conn_state(target, false);
1633 if (ib_send_cm_drep(cm_id, NULL, 0)) 1654 if (ib_send_cm_drep(cm_id, NULL, 0))
1634 shost_printk(KERN_ERR, target->scsi_host, 1655 shost_printk(KERN_ERR, target->scsi_host,
1635 PFX "Sending CM DREP failed\n"); 1656 PFX "Sending CM DREP failed\n");
@@ -1942,6 +1963,7 @@ static int srp_add_target(struct srp_host *host, struct srp_target_port *target)
1942 spin_unlock(&host->target_lock); 1963 spin_unlock(&host->target_lock);
1943 1964
1944 target->state = SRP_TARGET_LIVE; 1965 target->state = SRP_TARGET_LIVE;
1966 target->connected = false;
1945 1967
1946 scsi_scan_target(&target->scsi_host->shost_gendev, 1968 scsi_scan_target(&target->scsi_host->shost_gendev,
1947 0, target->scsi_id, SCAN_WILD_CARD, 0); 1969 0, target->scsi_id, SCAN_WILD_CARD, 0);
diff --git a/drivers/infiniband/ulp/srp/ib_srp.h b/drivers/infiniband/ulp/srp/ib_srp.h
index 02dc3acb718..ef95fa4ca3e 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.h
+++ b/drivers/infiniband/ulp/srp/ib_srp.h
@@ -163,6 +163,7 @@ struct srp_target_port {
163 int path_query_id; 163 int path_query_id;
164 164
165 u32 rq_tmo_jiffies; 165 u32 rq_tmo_jiffies;
166 bool connected;
166 167
167 struct ib_cm_id *cm_id; 168 struct ib_cm_id *cm_id;
168 169