]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
scsi: libiscsi: Fix iscsi_prep_scsi_cmd_pdu() error handling
authorMike Christie <michael.christie@oracle.com>
Sun, 7 Feb 2021 04:46:00 +0000 (22:46 -0600)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 9 Feb 2021 03:39:03 +0000 (22:39 -0500)
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 clean up both
parts. So this has us just fail the cmd and go through the standard cleanup
routine and then have the SCSI midlayer retry it like is done when it fails
in the queuecommand path.

Link: https://lore.kernel.org/r/20210207044608.27585-2-michael.christie@oracle.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/libiscsi.c

index 4e668aafbcca0bd13d93a1b44237cfd23bc871e7..cee1dbaa1b9320584637ca86fa3cc3f0faf84bad 100644 (file)
@@ -1532,14 +1532,9 @@ check_mgmt:
                }
                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;