aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
authorBart Van Assche <bvanassche@acm.org>2010-11-26 13:58:27 -0500
committerDavid Dillow <dillowda@ornl.gov>2011-01-10 15:44:42 -0500
commit536ae14e7588e85203d4b4147c041309be5b3efb (patch)
tree9a7e459a914e138d0b02487c7ab40ae9ffe6c05c /drivers/infiniband
parentdcb4cb85f4b7caac9769bce464fef16306a4758c (diff)
IB/srp: don't move active requests to their own list
We use req->scmnd != NULL to indicate an active request, so there's no need to keep a separate list for them. We can afford the array iteration during error handling, and dropping it gives us one less item that needs lock protection. Signed-off-by: Bart Van Assche <bvanassche@acm.org> [ broken out and small cleanups by David Dillow ] Signed-off-by: David Dillow <dillowda@ornl.gov>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.c23
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.h1
2 files changed, 13 insertions, 11 deletions
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index aa78d2615c8d..2aff8814f2c5 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -553,7 +553,7 @@ static void srp_remove_req(struct srp_target_port *target, struct srp_request *r
553{ 553{
554 srp_unmap_data(req->scmnd, target, req); 554 srp_unmap_data(req->scmnd, target, req);
555 req->scmnd = NULL; 555 req->scmnd = NULL;
556 list_move_tail(&req->list, &target->free_reqs); 556 list_add_tail(&req->list, &target->free_reqs);
557} 557}
558 558
559static void srp_reset_req(struct srp_target_port *target, struct srp_request *req) 559static void srp_reset_req(struct srp_target_port *target, struct srp_request *req)
@@ -566,7 +566,6 @@ static void srp_reset_req(struct srp_target_port *target, struct srp_request *re
566static int srp_reconnect_target(struct srp_target_port *target) 566static int srp_reconnect_target(struct srp_target_port *target)
567{ 567{
568 struct ib_qp_attr qp_attr; 568 struct ib_qp_attr qp_attr;
569 struct srp_request *req, *tmp;
570 struct ib_wc wc; 569 struct ib_wc wc;
571 int i, ret; 570 int i, ret;
572 571
@@ -597,13 +596,16 @@ static int srp_reconnect_target(struct srp_target_port *target)
597 ; /* nothing */ 596 ; /* nothing */
598 597
599 spin_lock_irq(target->scsi_host->host_lock); 598 spin_lock_irq(target->scsi_host->host_lock);
600 list_for_each_entry_safe(req, tmp, &target->req_queue, list) 599 for (i = 0; i < SRP_CMD_SQ_SIZE; ++i) {
601 srp_reset_req(target, req); 600 struct srp_request *req = &target->req_ring[i];
601 if (req->scmnd)
602 srp_reset_req(target, req);
603 }
602 spin_unlock_irq(target->scsi_host->host_lock); 604 spin_unlock_irq(target->scsi_host->host_lock);
603 605
604 list_del_init(&target->free_tx); 606 INIT_LIST_HEAD(&target->free_tx);
605 for (i = 0; i < SRP_SQ_SIZE; ++i) 607 for (i = 0; i < SRP_SQ_SIZE; ++i)
606 list_move(&target->tx_ring[i]->list, &target->free_tx); 608 list_add(&target->tx_ring[i]->list, &target->free_tx);
607 609
608 target->qp_in_error = 0; 610 target->qp_in_error = 0;
609 ret = srp_connect_target(target); 611 ret = srp_connect_target(target);
@@ -1165,7 +1167,7 @@ static int srp_queuecommand_lck(struct scsi_cmnd *scmnd,
1165 goto err_unmap; 1167 goto err_unmap;
1166 } 1168 }
1167 1169
1168 list_move_tail(&req->list, &target->req_queue); 1170 list_del(&req->list);
1169 1171
1170 return 0; 1172 return 0;
1171 1173
@@ -1504,7 +1506,7 @@ static int srp_abort(struct scsi_cmnd *scmnd)
1504static int srp_reset_device(struct scsi_cmnd *scmnd) 1506static int srp_reset_device(struct scsi_cmnd *scmnd)
1505{ 1507{
1506 struct srp_target_port *target = host_to_target(scmnd->device->host); 1508 struct srp_target_port *target = host_to_target(scmnd->device->host);
1507 struct srp_request *req, *tmp; 1509 int i;
1508 1510
1509 shost_printk(KERN_ERR, target->scsi_host, "SRP reset_device called\n"); 1511 shost_printk(KERN_ERR, target->scsi_host, "SRP reset_device called\n");
1510 1512
@@ -1518,9 +1520,11 @@ static int srp_reset_device(struct scsi_cmnd *scmnd)
1518 1520
1519 spin_lock_irq(target->scsi_host->host_lock); 1521 spin_lock_irq(target->scsi_host->host_lock);
1520 1522
1521 list_for_each_entry_safe(req, tmp, &target->req_queue, list) 1523 for (i = 0; i < SRP_CMD_SQ_SIZE; ++i) {
1524 struct srp_request *req = &target->req_ring[i];
1522 if (req->scmnd && req->scmnd->device == scmnd->device) 1525 if (req->scmnd && req->scmnd->device == scmnd->device)
1523 srp_reset_req(target, req); 1526 srp_reset_req(target, req);
1527 }
1524 1528
1525 spin_unlock_irq(target->scsi_host->host_lock); 1529 spin_unlock_irq(target->scsi_host->host_lock);
1526 1530
@@ -1954,7 +1958,6 @@ static ssize_t srp_create_target(struct device *dev,
1954 1958
1955 INIT_LIST_HEAD(&target->free_tx); 1959 INIT_LIST_HEAD(&target->free_tx);
1956 INIT_LIST_HEAD(&target->free_reqs); 1960 INIT_LIST_HEAD(&target->free_reqs);
1957 INIT_LIST_HEAD(&target->req_queue);
1958 for (i = 0; i < SRP_CMD_SQ_SIZE; ++i) { 1961 for (i = 0; i < SRP_CMD_SQ_SIZE; ++i) {
1959 target->req_ring[i].index = i; 1962 target->req_ring[i].index = i;
1960 list_add_tail(&target->req_ring[i].list, &target->free_reqs); 1963 list_add_tail(&target->req_ring[i].list, &target->free_reqs);
diff --git a/drivers/infiniband/ulp/srp/ib_srp.h b/drivers/infiniband/ulp/srp/ib_srp.h
index 41ecb46adf15..924d8e9c6672 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.h
+++ b/drivers/infiniband/ulp/srp/ib_srp.h
@@ -148,7 +148,6 @@ struct srp_target_port {
148 struct srp_iu *tx_ring[SRP_SQ_SIZE]; 148 struct srp_iu *tx_ring[SRP_SQ_SIZE];
149 149
150 struct list_head free_reqs; 150 struct list_head free_reqs;
151 struct list_head req_queue;
152 struct srp_request req_ring[SRP_CMD_SQ_SIZE]; 151 struct srp_request req_ring[SRP_CMD_SQ_SIZE];
153 152
154 struct work_struct work; 153 struct work_struct work;