Skip to contentSkip to conversation

REQ_BLOCK_PC only returns SCSI status byte

PATCH In review Patrick Mansfield 2 participants 2 messages Sep 25, 2003

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 REQ_BLOCK_PC only returns SCSI status byte

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).

drivers/block/scsi_ioctl.c +4 -4
diff -uprN -X /home/patman/dontdiff bl-25/drivers/block/scsi_ioctl.c bl-25-sg_io/drivers/block/scsi_ioctl.c
@@ -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) ?
drivers/scsi/scsi_lib.c +1 -1
diff -uprN -X /home/patman/dontdiff bl-25/drivers/scsi/scsi_lib.c bl-25-sg_io/drivers/scsi/scsi_lib.c
@@ -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

#1 lore raw
Quoted 4 lines · Patrick Mansfield

Jens/James -

Can you please apply or comment?

Quoted 8 lines

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.

Signature · 1 line
Jens Axboe