diff mbox series

[01/15] libiscsi: fix iscsi_prep_scsi_cmd_pdu error handling

Message ID 1606858196-5421-2-git-send-email-michael.christie@oracle.com
State Superseded
Headers show
Series libiscsi: lock clean ups | expand

Commit Message

Mike Christie Dec. 1, 2020, 9:29 p.m. UTC
If iscsi_prep_scsi_cmd_pdu fails we try to add it back to the
cmdqueue, but we leave it partially setup. We don't have functions
that can undo the pdu and init task setup. We only have cleanup_task
which can cleanup both parts. So this has us just fail the cmd and
go through the standard cleanup routine and then have scsi-ml retry
it like is done when it fails in the queuecommand path.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
 drivers/scsi/libiscsi.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

Comments

Lee Duncan Dec. 2, 2020, 5:04 p.m. UTC | #1
On 12/1/20 1:29 PM, Mike Christie wrote:
> If iscsi_prep_scsi_cmd_pdu fails we try to add it back to the

> cmdqueue, but we leave it partially setup. We don't have functions

> that can undo the pdu and init task setup. We only have cleanup_task

> which can cleanup both parts. So this has us just fail the cmd and

> go through the standard cleanup routine and then have scsi-ml retry

> it like is done when it fails in the queuecommand path.

> 

> Signed-off-by: Mike Christie <michael.christie@oracle.com>

> ---

>  drivers/scsi/libiscsi.c | 11 +++--------

>  1 file changed, 3 insertions(+), 8 deletions(-)

> 

> diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c

> index f9314f1..ee0786b 100644

> --- a/drivers/scsi/libiscsi.c

> +++ b/drivers/scsi/libiscsi.c

> @@ -1532,14 +1532,9 @@ static int iscsi_data_xmit(struct iscsi_conn *conn)

>  		}

>  		rc = iscsi_prep_scsi_cmd_pdu(conn->task);

>  		if (rc) {

> -			if (rc == -ENOMEM || rc == -EACCES) {

> -				spin_lock_bh(&conn->taskqueuelock);

> -				list_add_tail(&conn->task->running,

> -					      &conn->cmdqueue);

> -				conn->task = NULL;

> -				spin_unlock_bh(&conn->taskqueuelock);

> -				goto done;

> -			} else

> +			if (rc == -ENOMEM || rc == -EACCES)

> +				fail_scsi_task(conn->task, DID_IMM_RETRY);

> +			else

>  				fail_scsi_task(conn->task, DID_ABORT);

>  			spin_lock_bh(&conn->taskqueuelock);

>  			continue;

> 


Reviewed-by: Lee Duncan <lduncan@suse.com>
diff mbox series

Patch

diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index f9314f1..ee0786b 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -1532,14 +1532,9 @@  static int iscsi_data_xmit(struct iscsi_conn *conn)
 		}
 		rc = iscsi_prep_scsi_cmd_pdu(conn->task);
 		if (rc) {
-			if (rc == -ENOMEM || rc == -EACCES) {
-				spin_lock_bh(&conn->taskqueuelock);
-				list_add_tail(&conn->task->running,
-					      &conn->cmdqueue);
-				conn->task = NULL;
-				spin_unlock_bh(&conn->taskqueuelock);
-				goto done;
-			} else
+			if (rc == -ENOMEM || rc == -EACCES)
+				fail_scsi_task(conn->task, DID_IMM_RETRY);
+			else
 				fail_scsi_task(conn->task, DID_ABORT);
 			spin_lock_bh(&conn->taskqueuelock);
 			continue;