From: Akinobu Mita <akinobu.mita@gmail.com>
To: linux-scsi@vger.kernel.org
Cc: Akinobu Mita <akinobu.mita@gmail.com>,
"James E.J. Bottomley" <JBottomley@parallels.com>,
Douglas Gilbert <dgilbert@interlog.com>
Subject: [PATCH 4/6] scsi_debug: fix resp_xdwriteread() return value when running out of memory
Date: Mon, 6 Jan 2014 08:33:10 +0900 [thread overview]
Message-ID: <1388964792-3546-5-git-send-email-akinobu.mita@gmail.com> (raw)
In-Reply-To: <1388964792-3546-1-git-send-email-akinobu.mita@gmail.com>
When resp_xdwriteread() can't allocate temporary buffer, it returns -1.
But the return value is used as scsi status code and -1 is not
interpreted as correct code.
target_core_mod has similar xdwriteread emulation code. So this mimics
what target_core_mod does for xdwriteread when running out of memory.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: "James E.J. Bottomley" <JBottomley@parallels.com>
Cc: Douglas Gilbert <dgilbert@interlog.com>
Cc: linux-scsi@vger.kernel.org
---
drivers/scsi/scsi_debug.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 1a42880..a102519 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -64,6 +64,7 @@ static const char * scsi_debug_version_date = "20100324";
/* Additional Sense Code (ASC) */
#define NO_ADDITIONAL_SENSE 0x0
#define LOGICAL_UNIT_NOT_READY 0x4
+#define LOGICAL_UNIT_COMMUNICATION_FAILURE 0x8
#define UNRECOVERED_READ_ERR 0x11
#define PARAMETER_LIST_LENGTH_ERR 0x1a
#define INVALID_OPCODE 0x20
@@ -2318,8 +2319,11 @@ static int resp_xdwriteread(struct scsi_cmnd *scp, unsigned long long lba,
/* better not to use temporary buffer. */
buf = kmalloc(scsi_bufflen(scp), GFP_ATOMIC);
- if (!buf)
- return ret;
+ if (!buf) {
+ mk_sense_buffer(devip, NOT_READY,
+ LOGICAL_UNIT_COMMUNICATION_FAILURE, 0);
+ return check_condition_result;
+ }
scsi_sg_copy_to_buffer(scp, buf, scsi_bufflen(scp));
--
1.8.3.2
next prev parent reply other threads:[~2014-01-05 23:33 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-05 23:33 [PATCH 0/6] scsi_debug: a few bug fixes and enable clustering support Akinobu Mita
2014-01-05 23:33 ` [PATCH 1/6] scsi_debug: fix false positive logical block reference tag check fail Akinobu Mita
2014-01-10 21:32 ` Martin K. Petersen
2014-01-05 23:33 ` [PATCH 2/6] scsi_debug: make pseudo_primary static Akinobu Mita
2014-01-05 23:33 ` [PATCH 3/6] scsi_debug: fix duplicate dif_errors increment Akinobu Mita
2014-01-10 21:30 ` Martin K. Petersen
2014-01-05 23:33 ` Akinobu Mita [this message]
2014-01-05 23:33 ` [PATCH 5/6] scsi_debug: prepare to enable clustering Akinobu Mita
2014-01-10 21:41 ` Martin K. Petersen
2014-01-12 1:28 ` Akinobu Mita
2014-01-05 23:33 ` [PATCH 6/6] scsi_debug: add ability " Akinobu Mita
2014-01-06 1:14 ` Douglas Gilbert
2014-01-06 13:00 ` Akinobu Mita
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1388964792-3546-5-git-send-email-akinobu.mita@gmail.com \
--to=akinobu.mita@gmail.com \
--cc=JBottomley@parallels.com \
--cc=dgilbert@interlog.com \
--cc=linux-scsi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.