* [Qemu-devel] [PATCH 1/7] scsi-generic: Handle queue full
@ 2010-06-15 15:16 Hannes Reinecke
2010-06-16 8:57 ` [Qemu-devel] " Nicholas A. Bellinger
0 siblings, 1 reply; 2+ messages in thread
From: Hannes Reinecke @ 2010-06-15 15:16 UTC (permalink / raw)
To: Nicholas A.Bellinger; +Cc: qemu-devel
The sg driver currently has a hardcoded limit of commands it
can handle simultaneously. When this limit is reached the
driver will return -EDOM. So we need to capture this to
enable proper return values here.
And we shouldn't forget we're using linux-style status codes,
which are shift by one.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
hw/scsi-generic.c | 20 +++++++++++++-------
1 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/hw/scsi-generic.c b/hw/scsi-generic.c
index 6c58742..af76826 100644
--- a/hw/scsi-generic.c
+++ b/hw/scsi-generic.c
@@ -96,13 +96,19 @@ static void scsi_command_complete(void *opaque, int ret)
s->senselen = r->io_header.sb_len_wr;
if (ret != 0) {
- scsi_req_print(&r->req);
- fprintf(stderr, "%s: ret %d (%s)\n", __FUNCTION__,
- ret, strerror(-ret));
- s->senselen = scsi_build_sense(SENSE_CODE(INVALID_FIELD),
- s->sensebuf, SCSI_SENSE_BUF_SIZE, 0);
- s->driver_status = SG_ERR_DRIVER_SENSE;
- r->req.status = CHECK_CONDITION;
+ if (ret == -EDOM) {
+ /* sg driver uses EDOM to signal queue busy */
+ fprintf(stderr, "%s: sg queue busy\n", __FUNCTION__);
+ r->req.status = QUEUE_FULL << 1;
+ } else {
+ scsi_req_print(&r->req);
+ fprintf(stderr, "%s: ret %d (%s)\n", __FUNCTION__,
+ ret, strerror(-ret));
+ s->senselen = scsi_build_sense(SENSE_CODE(INVALID_FIELD),
+ s->sensebuf, SCSI_SENSE_BUF_SIZE, 0);
+ s->driver_status = SG_ERR_DRIVER_SENSE;
+ r->req.status = CHECK_CONDITION << 1;
+ }
} else {
if (s->driver_status & SG_ERR_DRIVER_TIMEOUT) {
scsi_req_print(&r->req);
--
1.6.6.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [Qemu-devel] Re: [PATCH 1/7] scsi-generic: Handle queue full
2010-06-15 15:16 [Qemu-devel] [PATCH 1/7] scsi-generic: Handle queue full Hannes Reinecke
@ 2010-06-16 8:57 ` Nicholas A. Bellinger
0 siblings, 0 replies; 2+ messages in thread
From: Nicholas A. Bellinger @ 2010-06-16 8:57 UTC (permalink / raw)
To: Hannes Reinecke; +Cc: qemu-devel
On Tue, 2010-06-15 at 17:16 +0200, Hannes Reinecke wrote:
> The sg driver currently has a hardcoded limit of commands it
> can handle simultaneously. When this limit is reached the
> driver will return -EDOM. So we need to capture this to
> enable proper return values here.
> And we shouldn't forget we're using linux-style status codes,
> which are shift by one.
>
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> ---
> hw/scsi-generic.c | 20 +++++++++++++-------
> 1 files changed, 13 insertions(+), 7 deletions(-)
>
Commited, thanks Hannes!
--nab
> diff --git a/hw/scsi-generic.c b/hw/scsi-generic.c
> index 6c58742..af76826 100644
> --- a/hw/scsi-generic.c
> +++ b/hw/scsi-generic.c
> @@ -96,13 +96,19 @@ static void scsi_command_complete(void *opaque, int ret)
> s->senselen = r->io_header.sb_len_wr;
>
> if (ret != 0) {
> - scsi_req_print(&r->req);
> - fprintf(stderr, "%s: ret %d (%s)\n", __FUNCTION__,
> - ret, strerror(-ret));
> - s->senselen = scsi_build_sense(SENSE_CODE(INVALID_FIELD),
> - s->sensebuf, SCSI_SENSE_BUF_SIZE, 0);
> - s->driver_status = SG_ERR_DRIVER_SENSE;
> - r->req.status = CHECK_CONDITION;
> + if (ret == -EDOM) {
> + /* sg driver uses EDOM to signal queue busy */
> + fprintf(stderr, "%s: sg queue busy\n", __FUNCTION__);
> + r->req.status = QUEUE_FULL << 1;
> + } else {
> + scsi_req_print(&r->req);
> + fprintf(stderr, "%s: ret %d (%s)\n", __FUNCTION__,
> + ret, strerror(-ret));
> + s->senselen = scsi_build_sense(SENSE_CODE(INVALID_FIELD),
> + s->sensebuf, SCSI_SENSE_BUF_SIZE, 0);
> + s->driver_status = SG_ERR_DRIVER_SENSE;
> + r->req.status = CHECK_CONDITION << 1;
> + }
> } else {
> if (s->driver_status & SG_ERR_DRIVER_TIMEOUT) {
> scsi_req_print(&r->req);
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-06-16 8:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-15 15:16 [Qemu-devel] [PATCH 1/7] scsi-generic: Handle queue full Hannes Reinecke
2010-06-16 8:57 ` [Qemu-devel] " Nicholas A. Bellinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).