All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] REQ_BLOCK_PC only returns SCSI status byte
@ 2003-09-25 18:18 Patrick Mansfield
  2003-09-25 19:51 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Patrick Mansfield @ 2003-09-25 18:18 UTC (permalink / raw)
  To: Jens Axboe, James Bottomley; +Cc: linux-scsi

Jens/James -

Can you please apply or comment?

Only the low byte of the linux scsi result is being returned for
REQ_BLOCK_PC usage. This means driver errors such as DID_ERROR are not
returned to user space.

The ide-cd.c code looks like it should be OK with this patch, but I did
not test it. I tested using SG_IO to an sd, for the case of DID_ERROR
coming back from the qlogic adapter (with underflow set, it was returning
DID_ERROR).

diff -uprN -X /home/patman/dontdiff bl-25/drivers/block/scsi_ioctl.c bl-25-sg_io/drivers/block/scsi_ioctl.c
--- bl-25/drivers/block/scsi_ioctl.c	Mon Sep 22 13:08:35 2003
+++ bl-25-sg_io/drivers/block/scsi_ioctl.c	Wed Sep 24 16:50:07 2003
@@ -256,9 +256,9 @@ static int sg_io(request_queue_t *q, str
 	/* write to all output members */
 	hdr.status = rq->errors;	
 	hdr.masked_status = (hdr.status >> 1) & 0x1f;
-	hdr.msg_status = 0;
-	hdr.host_status = 0;
-	hdr.driver_status = 0;
+	hdr.msg_status = (rq->errors >> 8) & 0xff;
+	hdr.host_status = (rq->errors >> 16) & 0xff;
+	hdr.driver_status = (rq->errors >> 24) & 0xff;
 	hdr.info = 0;
 	if (hdr.masked_status || hdr.host_status || hdr.driver_status)
 		hdr.info |= SG_INFO_CHECK;
@@ -377,7 +377,7 @@ static int sg_scsi_ioctl(request_queue_t
 	rq->flags |= REQ_BLOCK_PC;
 
 	blk_do_rq(q, bdev, rq);
-	err = rq->errors & 0xff;	/* only 8 bit SCSI status */
+	err = rq->errors;
 	if (err) {
 		if (rq->sense_len && rq->sense) {
 			bytes = (OMAX_SB_LEN > rq->sense_len) ?
diff -uprN -X /home/patman/dontdiff bl-25/drivers/scsi/scsi_lib.c bl-25-sg_io/drivers/scsi/scsi_lib.c
--- bl-25/drivers/scsi/scsi_lib.c	Mon Sep 22 13:08:53 2003
+++ bl-25-sg_io/drivers/scsi/scsi_lib.c	Wed Sep 24 16:52:48 2003
@@ -675,7 +675,7 @@ void scsi_io_completion(struct scsi_cmnd
 
 	if (blk_pc_request(req)) { /* SG_IO ioctl from block level */
 		req->errors = (driver_byte(result) & DRIVER_SENSE) ?
-			      (CHECK_CONDITION << 1) : (result & 0xff);
+			      (CHECK_CONDITION << 1) : result;
 		if (result) {
 			clear_errors = 0;
 			if (cmd->sense_buffer[0] & 0x70) {

-- Patrick Mansfield

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] REQ_BLOCK_PC only returns SCSI status byte
  2003-09-25 18:18 [PATCH] REQ_BLOCK_PC only returns SCSI status byte Patrick Mansfield
@ 2003-09-25 19:51 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2003-09-25 19:51 UTC (permalink / raw)
  To: Patrick Mansfield; +Cc: James Bottomley, linux-scsi

On Thu, Sep 25 2003, Patrick Mansfield wrote:
> Jens/James -
> 
> Can you please apply or comment?
> 
> Only the low byte of the linux scsi result is being returned for
> REQ_BLOCK_PC usage. This means driver errors such as DID_ERROR are not
> returned to user space.
> 
> The ide-cd.c code looks like it should be OK with this patch, but I did
> not test it. I tested using SG_IO to an sd, for the case of DID_ERROR
> coming back from the qlogic adapter (with underflow set, it was returning
> DID_ERROR).

Patch looks fine to me, applied.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-09-25 19:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-25 18:18 [PATCH] REQ_BLOCK_PC only returns SCSI status byte Patrick Mansfield
2003-09-25 19:51 ` Jens Axboe

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.