IB/srp: Don't wait for response when QP is in error state.

When there is a call to send_tsk_mgmt SRP posts a send and waits for 5
seconds to get a response.

When the QP is in the error state it is obvious that there will be no
response so it is quite useless to wait.  In fact, the timeout causes
SRP to wait a long time to reconnect when a QP error occurs. (Each
abort and each reset_device calls send_tsk_mgmt, which waits for the
timeout).  The following patch solves this problem by identifying the
failure and returning an immediate error code.

Signed-off-by: Ishai Rabinovitz <ishai@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
This commit is contained in:
Ishai Rabinovitz 2007-01-16 17:26:22 +02:00 коммит произвёл Roland Dreier
Родитель 062dbb69f3
Коммит 1033ff670d
2 изменённых файлов: 8 добавлений и 0 удалений

Просмотреть файл

@ -548,6 +548,7 @@ static int srp_reconnect_target(struct srp_target_port *target)
target->tx_head = 0; target->tx_head = 0;
target->tx_tail = 0; target->tx_tail = 0;
target->qp_in_error = 0;
ret = srp_connect_target(target); ret = srp_connect_target(target);
if (ret) if (ret)
goto err; goto err;
@ -878,6 +879,7 @@ static void srp_completion(struct ib_cq *cq, void *target_ptr)
printk(KERN_ERR PFX "failed %s status %d\n", printk(KERN_ERR PFX "failed %s status %d\n",
wc.wr_id & SRP_OP_RECV ? "receive" : "send", wc.wr_id & SRP_OP_RECV ? "receive" : "send",
wc.status); wc.status);
target->qp_in_error = 1;
break; break;
} }
@ -1337,6 +1339,8 @@ static int srp_abort(struct scsi_cmnd *scmnd)
printk(KERN_ERR "SRP abort called\n"); printk(KERN_ERR "SRP abort called\n");
if (target->qp_in_error)
return FAILED;
if (srp_find_req(target, scmnd, &req)) if (srp_find_req(target, scmnd, &req))
return FAILED; return FAILED;
if (srp_send_tsk_mgmt(target, req, SRP_TSK_ABORT_TASK)) if (srp_send_tsk_mgmt(target, req, SRP_TSK_ABORT_TASK))
@ -1365,6 +1369,8 @@ static int srp_reset_device(struct scsi_cmnd *scmnd)
printk(KERN_ERR "SRP reset_device called\n"); printk(KERN_ERR "SRP reset_device called\n");
if (target->qp_in_error)
return FAILED;
if (srp_find_req(target, scmnd, &req)) if (srp_find_req(target, scmnd, &req))
return FAILED; return FAILED;
if (srp_send_tsk_mgmt(target, req, SRP_TSK_LUN_RESET)) if (srp_send_tsk_mgmt(target, req, SRP_TSK_LUN_RESET))
@ -1801,6 +1807,7 @@ static ssize_t srp_create_target(struct class_device *class_dev,
goto err_free; goto err_free;
} }
target->qp_in_error = 0;
ret = srp_connect_target(target); ret = srp_connect_target(target);
if (ret) { if (ret) {
printk(KERN_ERR PFX "Connection failed\n"); printk(KERN_ERR PFX "Connection failed\n");

Просмотреть файл

@ -158,6 +158,7 @@ struct srp_target_port {
struct completion done; struct completion done;
int status; int status;
enum srp_target_state state; enum srp_target_state state;
int qp_in_error;
}; };
struct srp_iu { struct srp_iu {