Commit 54952b34 authored by Jens Axboe's avatar Jens Axboe Committed by Linus Torvalds

[PATCH] misc scsi bits

Various small bits that make SCSI work well with REQ_BLOCK_PC.

o Use ->errors as the scsi status byte for REQ_BLOCK_PC

o Always call end_io completion, even if 0 sectors, as long as the
  status is good. Otherwise we risk hanging this device if a
  REQ_BLOCK_PC user command didn't specify a transfer size for a command
  that did.

o Remove bouncing checks in scsi_merge for REQ_BLOCK_PC, bio_map_user()
  correctly bounces pages now.

o Decrement req->data_len, it's our residual data count.

o sr/sd: set right transfer and underflow size.
parent 38487531
......@@ -514,6 +514,12 @@ void scsi_io_completion(Scsi_Cmnd * SCpnt, int good_sectors,
}
}
if (blk_pc_request(req)) {
req->errors = result & 0xff;
if (!result)
req->data_len -= SCpnt->bufflen;
}
/*
* Zero these out. They now point to freed memory, and it is
* dangerous to hang onto the pointers.
......@@ -527,7 +533,7 @@ void scsi_io_completion(Scsi_Cmnd * SCpnt, int good_sectors,
* Next deal with any sectors which we were able to correctly
* handle.
*/
if (good_sectors > 0) {
if (good_sectors >= 0) {
SCSI_LOG_HLCOMPLETE(1, printk("%ld sectors total, %d sectors done.\n",
req->nr_sectors, good_sectors));
SCSI_LOG_HLCOMPLETE(1, printk("use_sg is %d\n ", SCpnt->use_sg));
......
......@@ -62,15 +62,9 @@ int scsi_init_io(Scsi_Cmnd *SCpnt)
int count, gfp_mask;
/*
* non-sg block request. FIXME: check bouncing for isa hosts!
* if this is a rq->data based REQ_BLOCK_PC, setup for a non-sg xfer
*/
if ((req->flags & REQ_BLOCK_PC) && !req->bio) {
/*
* FIXME: isa bouncing
*/
if (SCpnt->host->unchecked_isa_dma)
goto fail;
SCpnt->request_bufflen = req->data_len;
SCpnt->request_buffer = req->data;
req->buffer = req->data;
......@@ -100,6 +94,8 @@ int scsi_init_io(Scsi_Cmnd *SCpnt)
SCpnt->request_buffer = (char *) sgpnt;
SCpnt->request_bufflen = req->nr_sectors << 9;
if (blk_pc_request(req))
SCpnt->request_bufflen = req->data_len;
req->buffer = NULL;
/*
......@@ -123,7 +119,6 @@ int scsi_init_io(Scsi_Cmnd *SCpnt)
/*
* kill it. there should be no leftover blocks in this request
*/
fail:
SCpnt = scsi_end_request(SCpnt, 0, req->nr_sectors);
BUG_ON(SCpnt);
return 0;
......
......@@ -308,6 +308,8 @@ static int sd_init_command(Scsi_Cmnd * SCpnt)
if (rq->timeout)
timeout = rq->timeout;
SCpnt->transfersize = rq->data_len;
SCpnt->underflow = rq->data_len;
goto queue;
}
......@@ -431,10 +433,10 @@ static int sd_init_command(Scsi_Cmnd * SCpnt)
* host adapter, it's safe to assume that we can at least transfer
* this many bytes between each connect / disconnect.
*/
queue:
SCpnt->transfersize = sdp->sector_size;
SCpnt->underflow = this_count << 9;
queue:
SCpnt->allowed = MAX_RETRIES;
SCpnt->timeout_per_command = timeout;
......
......@@ -287,6 +287,8 @@ static int sr_init_command(Scsi_Cmnd * SCpnt)
if (rq->timeout)
timeout = rq->timeout;
SCpnt->transfersize = rq->data_len;
SCpnt->underflow = rq->data_len;
goto queue;
}
......@@ -360,10 +362,10 @@ static int sr_init_command(Scsi_Cmnd * SCpnt)
* host adapter, it's safe to assume that we can at least transfer
* this many bytes between each connect / disconnect.
*/
queue:
SCpnt->transfersize = cd->device->sector_size;
SCpnt->underflow = this_count << 9;
queue:
SCpnt->allowed = MAX_RETRIES;
SCpnt->timeout_per_command = timeout;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment