aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorRoland Dreier <rolandd@cisco.com>2005-11-15 03:19:21 -0500
committerRoland Dreier <rolandd@cisco.com>2005-11-15 03:19:21 -0500
commit47f2bce9021b4974ed33b072ebb8348c8145c946 (patch)
tree2d17f2cdc77646d07cb2a598e3d2bcbdf94675ad /drivers
parent5f068992a1bccda5574b4f6d33458ef806686d7f (diff)
[IB] srp: don't post receive if no send buf available
Have __srp_get_tx_iu() fail if the target port's request limit will not allow the initiator to post a send. This avoids continuing on and posting a receive, and then failing to post a corresponding send. If that happens, then the initiator will end up with an extra receive posted, and if this happens to much, the receive queue will overflow. Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index a3645303cb99..ee9fe226ae99 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -802,13 +802,21 @@ static int srp_post_recv(struct srp_target_port *target)
802 802
803/* 803/*
804 * Must be called with target->scsi_host->host_lock held to protect 804 * Must be called with target->scsi_host->host_lock held to protect
805 * req_lim and tx_head. 805 * req_lim and tx_head. Lock cannot be dropped between call here and
806 * call to __srp_post_send().
806 */ 807 */
807static struct srp_iu *__srp_get_tx_iu(struct srp_target_port *target) 808static struct srp_iu *__srp_get_tx_iu(struct srp_target_port *target)
808{ 809{
809 if (target->tx_head - target->tx_tail >= SRP_SQ_SIZE) 810 if (target->tx_head - target->tx_tail >= SRP_SQ_SIZE)
810 return NULL; 811 return NULL;
811 812
813 if (unlikely(target->req_lim < 1)) {
814 if (printk_ratelimit())
815 printk(KERN_DEBUG PFX "Target has req_lim %d\n",
816 target->req_lim);
817 return NULL;
818 }
819
812 return target->tx_ring[target->tx_head & SRP_SQ_SIZE]; 820 return target->tx_ring[target->tx_head & SRP_SQ_SIZE];
813} 821}
814 822
@@ -823,11 +831,6 @@ static int __srp_post_send(struct srp_target_port *target,
823 struct ib_send_wr wr, *bad_wr; 831 struct ib_send_wr wr, *bad_wr;
824 int ret = 0; 832 int ret = 0;
825 833
826 if (target->req_lim < 1) {
827 printk(KERN_ERR PFX "Target has req_lim %d\n", target->req_lim);
828 return -EAGAIN;
829 }
830
831 list.addr = iu->dma; 834 list.addr = iu->dma;
832 list.length = len; 835 list.length = len;
833 list.lkey = target->srp_host->mr->lkey; 836 list.lkey = target->srp_host->mr->lkey;