Commit 09be70a2 authored by Bart Van Assche's avatar Bart Van Assche Committed by Roland Dreier

IB/srp: Eliminate state SRP_TARGET_CONNECTING

Block the SCSI host while reconnecting instead of representing the
reconnection activity as a distinct SRP target state.  This allows us
to eliminate the target state SRP_TARGET_CONNECTING.
Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
Acked-by: default avatarDavid Dillow <dillowda@ornl.gov>
Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
parent c9b03c1a
...@@ -646,13 +646,16 @@ static void srp_reset_req(struct srp_target_port *target, struct srp_request *re ...@@ -646,13 +646,16 @@ static void srp_reset_req(struct srp_target_port *target, struct srp_request *re
static int srp_reconnect_target(struct srp_target_port *target) static int srp_reconnect_target(struct srp_target_port *target)
{ {
struct Scsi_Host *shost = target->scsi_host;
struct ib_qp_attr qp_attr; struct ib_qp_attr qp_attr;
struct ib_wc wc; struct ib_wc wc;
int i, ret; int i, ret;
if (!srp_change_state(target, SRP_TARGET_LIVE, SRP_TARGET_CONNECTING)) if (target->state != SRP_TARGET_LIVE)
return -EAGAIN; return -EAGAIN;
scsi_target_block(&shost->shost_gendev);
srp_disconnect_target(target); srp_disconnect_target(target);
/* /*
* Now get a new local CM ID so that we avoid confusing the * Now get a new local CM ID so that we avoid confusing the
...@@ -660,16 +663,16 @@ static int srp_reconnect_target(struct srp_target_port *target) ...@@ -660,16 +663,16 @@ static int srp_reconnect_target(struct srp_target_port *target)
*/ */
ret = srp_new_cm_id(target); ret = srp_new_cm_id(target);
if (ret) if (ret)
goto err; goto unblock;
qp_attr.qp_state = IB_QPS_RESET; qp_attr.qp_state = IB_QPS_RESET;
ret = ib_modify_qp(target->qp, &qp_attr, IB_QP_STATE); ret = ib_modify_qp(target->qp, &qp_attr, IB_QP_STATE);
if (ret) if (ret)
goto err; goto unblock;
ret = srp_init_qp(target, target->qp); ret = srp_init_qp(target, target->qp);
if (ret) if (ret)
goto err; goto unblock;
while (ib_poll_cq(target->recv_cq, 1, &wc) > 0) while (ib_poll_cq(target->recv_cq, 1, &wc) > 0)
; /* nothing */ ; /* nothing */
...@@ -688,11 +691,15 @@ static int srp_reconnect_target(struct srp_target_port *target) ...@@ -688,11 +691,15 @@ static int srp_reconnect_target(struct srp_target_port *target)
target->qp_in_error = 0; target->qp_in_error = 0;
ret = srp_connect_target(target); ret = srp_connect_target(target);
unblock:
scsi_target_unblock(&shost->shost_gendev, ret == 0 ? SDEV_RUNNING :
SDEV_TRANSPORT_OFFLINE);
if (ret) if (ret)
goto err; goto err;
if (!srp_change_state(target, SRP_TARGET_CONNECTING, SRP_TARGET_LIVE)) shost_printk(KERN_INFO, target->scsi_host, PFX "reconnect succeeded\n");
ret = -EAGAIN;
return ret; return ret;
...@@ -710,7 +717,7 @@ static int srp_reconnect_target(struct srp_target_port *target) ...@@ -710,7 +717,7 @@ static int srp_reconnect_target(struct srp_target_port *target)
* the flush_scheduled_work() in srp_remove_one(). * the flush_scheduled_work() in srp_remove_one().
*/ */
spin_lock_irq(&target->lock); spin_lock_irq(&target->lock);
if (target->state == SRP_TARGET_CONNECTING) { if (target->state == SRP_TARGET_LIVE) {
target->state = SRP_TARGET_DEAD; target->state = SRP_TARGET_DEAD;
INIT_WORK(&target->work, srp_remove_work); INIT_WORK(&target->work, srp_remove_work);
queue_work(ib_wq, &target->work); queue_work(ib_wq, &target->work);
...@@ -1311,9 +1318,6 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd) ...@@ -1311,9 +1318,6 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd)
unsigned long flags; unsigned long flags;
int len; int len;
if (target->state == SRP_TARGET_CONNECTING)
goto err;
if (target->state == SRP_TARGET_DEAD || if (target->state == SRP_TARGET_DEAD ||
target->state == SRP_TARGET_REMOVED) { target->state == SRP_TARGET_REMOVED) {
scmnd->result = DID_BAD_TARGET << 16; scmnd->result = DID_BAD_TARGET << 16;
...@@ -1377,7 +1381,6 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd) ...@@ -1377,7 +1381,6 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd)
err_unlock: err_unlock:
spin_unlock_irqrestore(&target->lock, flags); spin_unlock_irqrestore(&target->lock, flags);
err:
return SCSI_MLQUEUE_HOST_BUSY; return SCSI_MLQUEUE_HOST_BUSY;
} }
......
...@@ -80,7 +80,6 @@ enum { ...@@ -80,7 +80,6 @@ enum {
enum srp_target_state { enum srp_target_state {
SRP_TARGET_LIVE, SRP_TARGET_LIVE,
SRP_TARGET_CONNECTING,
SRP_TARGET_DEAD, SRP_TARGET_DEAD,
SRP_TARGET_REMOVED SRP_TARGET_REMOVED
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment