IB/srp fixes
Subsystems (2)
v4 cover IB/srp fixes
This patch series avoids that SCSI error handling triggers an endless loop and also restores reporting of QP errors in the kernel log.
Changes between v4 and v3:
- Added a patch that ensures that the SCSI host gets removed in time when a user space process keeps queueing I/O during removal, e.g. an older version of multipathd.
- Added "Cc: <[email protected]> # 3.8" tag.
Changes between v3 and v2:
- As proposed by Dave, added a patch that prevents sending of a task management function over a closed connection.
Changes between v2 and v1:
- Track connection state properly.
- Make srp_reset_host() reset requests even if reconnecting fails --
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v4 1/4 IB/srp: Track connection state properly
Remove an assignment that incorrectly overwrites the connection state update by srp_connect_target().
--- drivers/infiniband/ulp/srp/ib_srp.c | 1 - 1 file changed, 1 deletion(-)
drivers/infiniband/ulp/srp/ib_srp.c +0 -1
@@ -1972,7 +1972,6 @@ static int srp_add_target(struct srp_host *host, struct srp_target_port *target)spin_unlock (&host->target_lock); target->state =SRP_TARGET_LIVE ; - target->connected = false;scsi_scan_target (&target->scsi_host->shost_gendev,0 , target->scsi_id,SCAN_WILD_CARD ,0 );
Signature · 6 lines
1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v4 2/4 IB/srp: Avoid sending a task management function needlessly
In reply to a message not in the archiveDo not send a task management function if sending will fail anyway because either there is no RDMA/RC connection or the QP is in the error state.
--- drivers/infiniband/ulp/srp/ib_srp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/infiniband/ulp/srp/ib_srp.c +3 -2
@@ -1695,6 +1695,9 @@ static int srp_send_tsk_mgmt(struct srp_target_port *target,struct srp_iu *iu;struct srp_tsk_mgmt *tsk_mgmt; +if (!target->connected || target->qp_in_error) +return -1 ; +init_completion (&target->tsk_mgmt_done);spin_lock_irq (&target->lock);
@@ -1754,8 +1757,6 @@ static int srp_reset_device(struct scsi_cmnd *scmnd)shost_printk (KERN_ERR , target->scsi_host,"SRP reset_device called\n" ); -if (target->qp_in_error) -return FAILED ;if (srp_send_tsk_mgmt (target,SRP_TAG_NO_REQ , scmnd->device->lun,SRP_TSK_LUN_RESET ))return FAILED ;
Signature · 6 lines
1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v4 3/4 IB/srp: Avoid endless SCSI error handling loop
In reply to a message not in the archiveIf a SCSI command times out it is passed to the SCSI error handler. The SCSI error handler will try to abort the commands that timed out. If aborting failed a device reset will be attempted. If the device reset also fails a host reset will be attempted. If the host reset also fails the whole procedure will be repeated.
srp_abort() and srp_reset_device() fail for a QP in the error state. srp_reset_host() fails after host removal has started. Hence if the SCSI error handler gets invoked after host removal has started and with the QP in the error state an endless loop will be triggered.
Modify the SCSI error handling functions in ib_srp as follows:
- Abort SCSI commands properly even if the QP is in the error state.
- Make srp_reset_host() reset SCSI requests even after host removal has already started or if reconnecting fails.
--- drivers/infiniband/ulp/srp/ib_srp.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-)
drivers/infiniband/ulp/srp/ib_srp.c +15 -14
@@ -700,23 +700,24 @@ static int srp_reconnect_target(struct srp_target_port *target)struct Scsi_Host *shost = target->scsi_host;int i, ret; -if (target->state !=SRP_TARGET_LIVE ) -return -EAGAIN ; -scsi_target_block (&shost->shost_gendev);srp_disconnect_target (target);/* -* Now get a new local CM ID so that we avoid confusing the -* target in case things are really fouled up. +* Now get a new local CM ID so that we avoid confusing the target in +* case things are really fouled up. Doing so also ensures that all CM +* callbacks will have finished before a new QP is allocated. */ ret =srp_new_cm_id (target); -if (ret) - goto unblock; - - ret =srp_create_target_ib (target); -if (ret) - goto unblock; +/* +* Whether or not creating a new CM ID succeeded, create a new +* QP. This guarantees that all completion callback function +* invocations have finished before request resetting starts. +*/ +if (ret ==0 ) + ret =srp_create_target_ib (target); +else +srp_create_target_ib (target);for (i =0 ; i <SRP_CMD_SQ_SIZE ; ++i) {struct srp_request *req = &target->req_ring[i];
@@ -728,9 +729,9 @@ static int srp_reconnect_target(struct srp_target_port *target)for (i =0 ; i <SRP_SQ_SIZE ; ++i)list_add (&target->tx_ring[i]->list, &target->free_tx); - ret =srp_connect_target (target); +if (ret ==0 ) + ret =srp_connect_target (target); -unblock:scsi_target_unblock (&shost->shost_gendev, ret ==0 ?SDEV_RUNNING :SDEV_TRANSPORT_OFFLINE );
@@ -1739,7 +1740,7 @@ static int srp_abort(struct scsi_cmnd *scmnd)shost_printk (KERN_ERR , target->scsi_host,"SRP abort called\n" ); -if (!req || target->qp_in_error || !srp_claim_req (target, req, scmnd)) +if (!req || !srp_claim_req (target, req, scmnd))return FAILED ;srp_send_tsk_mgmt (target, req->index, scmnd->device->lun,SRP_TSK_ABORT_TASK );
Signature · 6 lines
1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v4 4/4 IB/srp: Fail I/O requests if the transport is offline
In reply to a message not in the archiveIf an SRP target is no longer reachable and srp_reset_host() fails to reconnect then ib_srp will invoke scsi_remove_host(). That function will invoke __scsi_remove_device() for each LUN. And that last function will change the device state from SDEV_TRANSPORT_OFFLINE into SDEV_CANCEL. Certain user space software, e.g. older versions of multipathd, continue queueing I/O to SCSI devices that are in the SDEV_CANCEL state. If these I/O requests are submitted as SG_IO that means that the REQ_PREEMPT flag will be set and hence that these requests will be passed to srp_queuecommand(). These requests will time out. If new requests are queued fast enough from user space these active requests will prevent __scsi_remove_device() to finish. Avoid this by failing I/O requests in the SDEV_CANCEL state if the transport is offline. Introduce a new variable to keep track of the transport state instead of failing requests if (!target->connected || target->qp_in_error) such that the SCSI error handler has a chance to retry commands after a transport layer failure occurred.
--- drivers/infiniband/ulp/srp/ib_srp.c | 7 +++++++ drivers/infiniband/ulp/srp/ib_srp.h | 1 + 2 files changed, 8 insertions(+)
drivers/infiniband/ulp/srp/ib_srp.c +7 -0
@@ -734,6 +734,7 @@ static int srp_reconnect_target(struct srp_target_port *target)scsi_target_unblock (&shost->shost_gendev, ret ==0 ?SDEV_RUNNING :SDEV_TRANSPORT_OFFLINE ); + target->transport_offline = !!ret;if (ret) goto err;
@@ -1353,6 +1354,12 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd)unsigned long flags;int len; +if (unlikely (target->transport_offline)) { + scmnd->result =DID_NO_CONNECT <<16 ; + scmnd->scsi_done (scmnd); +return 0 ; + } +spin_lock_irqsave (&target->lock, flags); iu =__srp_get_tx_iu (target,SRP_IU_CMD );if (!iu)
drivers/infiniband/ulp/srp/ib_srp.h +1 -0
@@ -140,6 +140,7 @@ struct srp_target_port {unsigned int cmd_sg_cnt;unsigned int indirect_size;bool allow_ext_sg; +bool transport_offline;/* Everything above this point is used in the hot path of * command processing. Try to keep them packed into cachelines.
Signature · 6 lines
1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
All look good, applied for 3.9, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): CAL1RGDXJecgywr-xrD8r6kC4mUDECTvbhKgX3QjuC1VWGjz_kQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 2 lines · Roland Dreier
All look good, applied for 3.9, thanks.
Roland, could you add a CC to -stable so they can get to 3.8-stable too? --
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): CAJZOPZJR4SSkOEd_zEDnt4bZC-YkNPijZwQ-W=8-dSQuM_4Avw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 4 lines · Or Gerlitz
Quoted 1 line · Roland Dreier
All look good, applied for 3.9, thanks.
Roland, could you add a CC to -stable so they can get to 3.8-stable too?
Oh, I see its just there, thanks!
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html