[PATCH AUTOSEL 5.11 49/52] scsi: libiscsi: Fix iscsi_prep_scsi_cmd_pdu() error handling

2 views
Skip to first unread message

Sasha Levin

unread,
Mar 2, 2021, 6:56:44 AM3/2/21
to linux-...@vger.kernel.org, sta...@vger.kernel.org, Mike Christie, Lee Duncan, Martin K . Petersen, Sasha Levin, open-...@googlegroups.com, linux...@vger.kernel.org
From: Mike Christie <michael....@oracle.com>

[ Upstream commit d28d48c699779973ab9a3bd0e5acfa112bd4fdef ]

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.2758...@oracle.com
Reviewed-by: Lee Duncan <ldu...@suse.com>
Signed-off-by: Mike Christie <michael....@oracle.com>
Signed-off-by: Martin K. Petersen <martin....@oracle.com>
Signed-off-by: Sasha Levin <sas...@kernel.org>
---
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 4e668aafbcca..cee1dbaa1b93 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -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;
--
2.30.1

Sasha Levin

unread,
Mar 2, 2021, 6:57:49 AM3/2/21
to linux-...@vger.kernel.org, sta...@vger.kernel.org, Mike Christie, Lee Duncan, Martin K . Petersen, Sasha Levin, open-...@googlegroups.com, linux...@vger.kernel.org
From: Mike Christie <michael....@oracle.com>

[ Upstream commit d28d48c699779973ab9a3bd0e5acfa112bd4fdef ]

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.2758...@oracle.com
Reviewed-by: Lee Duncan <ldu...@suse.com>
Signed-off-by: Mike Christie <michael....@oracle.com>
Signed-off-by: Martin K. Petersen <martin....@oracle.com>
Signed-off-by: Sasha Levin <sas...@kernel.org>
---
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 f9314f1393fb..ee0786bab4fc 100644

Sasha Levin

unread,
Mar 2, 2021, 6:58:32 AM3/2/21
to linux-...@vger.kernel.org, sta...@vger.kernel.org, Mike Christie, Lee Duncan, Martin K . Petersen, Sasha Levin, open-...@googlegroups.com, linux...@vger.kernel.org
From: Mike Christie <michael....@oracle.com>

[ Upstream commit d28d48c699779973ab9a3bd0e5acfa112bd4fdef ]

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.2758...@oracle.com
Reviewed-by: Lee Duncan <ldu...@suse.com>
Signed-off-by: Mike Christie <michael....@oracle.com>
Signed-off-by: Martin K. Petersen <martin....@oracle.com>
Signed-off-by: Sasha Levin <sas...@kernel.org>
---
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 f954be3d5ee2..0b7449de1b53 100644

Sasha Levin

unread,
Mar 2, 2021, 6:59:02 AM3/2/21
to linux-...@vger.kernel.org, sta...@vger.kernel.org, Mike Christie, Lee Duncan, Martin K . Petersen, Sasha Levin, open-...@googlegroups.com, linux...@vger.kernel.org
From: Mike Christie <michael....@oracle.com>

[ Upstream commit d28d48c699779973ab9a3bd0e5acfa112bd4fdef ]

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.2758...@oracle.com
Reviewed-by: Lee Duncan <ldu...@suse.com>
Signed-off-by: Mike Christie <michael....@oracle.com>
Signed-off-by: Martin K. Petersen <martin....@oracle.com>
Signed-off-by: Sasha Levin <sas...@kernel.org>
---
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 1c69515e870c..5e373a3752ba 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -1569,14 +1569,9 @@ check_mgmt:

Sasha Levin

unread,
Mar 2, 2021, 6:59:23 AM3/2/21
to linux-...@vger.kernel.org, sta...@vger.kernel.org, Mike Christie, Lee Duncan, Martin K . Petersen, Sasha Levin, open-...@googlegroups.com, linux...@vger.kernel.org
From: Mike Christie <michael....@oracle.com>

[ Upstream commit d28d48c699779973ab9a3bd0e5acfa112bd4fdef ]

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.2758...@oracle.com
Reviewed-by: Lee Duncan <ldu...@suse.com>
Signed-off-by: Mike Christie <michael....@oracle.com>
Signed-off-by: Martin K. Petersen <martin....@oracle.com>
Signed-off-by: Sasha Levin <sas...@kernel.org>
---
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 f7e1af90849b..fffaf9b3476d 100644

Sasha Levin

unread,
Mar 2, 2021, 6:59:36 AM3/2/21
to linux-...@vger.kernel.org, sta...@vger.kernel.org, Mike Christie, Lee Duncan, Martin K . Petersen, Sasha Levin, open-...@googlegroups.com, linux...@vger.kernel.org
From: Mike Christie <michael....@oracle.com>

[ Upstream commit d28d48c699779973ab9a3bd0e5acfa112bd4fdef ]

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.2758...@oracle.com
Reviewed-by: Lee Duncan <ldu...@suse.com>
Signed-off-by: Mike Christie <michael....@oracle.com>
Signed-off-by: Martin K. Petersen <martin....@oracle.com>
Signed-off-by: Sasha Levin <sas...@kernel.org>
---
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 a84b473d4a08..c0c8b97f6e90 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -1568,14 +1568,9 @@ check_mgmt:

Sasha Levin

unread,
Mar 2, 2021, 6:59:49 AM3/2/21
to linux-...@vger.kernel.org, sta...@vger.kernel.org, Mike Christie, Lee Duncan, Martin K . Petersen, Sasha Levin, open-...@googlegroups.com, linux...@vger.kernel.org
From: Mike Christie <michael....@oracle.com>

[ Upstream commit d28d48c699779973ab9a3bd0e5acfa112bd4fdef ]

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.2758...@oracle.com
Reviewed-by: Lee Duncan <ldu...@suse.com>
Signed-off-by: Mike Christie <michael....@oracle.com>
Signed-off-by: Martin K. Petersen <martin....@oracle.com>
Signed-off-by: Sasha Levin <sas...@kernel.org>
---
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 36e415487fe5..444f58589f33 100644
Reply all
Reply to author
Forward
0 new messages