forked from Minki/linux
ide-scsi: sg chaining support
Acked-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
This commit is contained in:
parent
2f08fe5221
commit
d274a9878b
@ -70,6 +70,7 @@ typedef struct idescsi_pc_s {
|
||||
u8 *buffer; /* Data buffer */
|
||||
u8 *current_position; /* Pointer into the above buffer */
|
||||
struct scatterlist *sg; /* Scatter gather table */
|
||||
struct scatterlist *last_sg; /* Last sg element */
|
||||
int b_count; /* Bytes transferred from current entry */
|
||||
struct scsi_cmnd *scsi_cmd; /* SCSI command */
|
||||
void (*done)(struct scsi_cmnd *); /* Scsi completion routine */
|
||||
@ -173,12 +174,6 @@ static void idescsi_input_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsigne
|
||||
char *buf;
|
||||
|
||||
while (bcount) {
|
||||
if (pc->sg - scsi_sglist(pc->scsi_cmd) >
|
||||
scsi_sg_count(pc->scsi_cmd)) {
|
||||
printk (KERN_ERR "ide-scsi: scatter gather table too small, discarding data\n");
|
||||
idescsi_discard_data (drive, bcount);
|
||||
return;
|
||||
}
|
||||
count = min(pc->sg->length - pc->b_count, bcount);
|
||||
if (PageHighMem(pc->sg->page)) {
|
||||
unsigned long flags;
|
||||
@ -197,10 +192,17 @@ static void idescsi_input_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsigne
|
||||
}
|
||||
bcount -= count; pc->b_count += count;
|
||||
if (pc->b_count == pc->sg->length) {
|
||||
pc->sg++;
|
||||
if (pc->sg == pc->last_sg)
|
||||
break;
|
||||
pc->sg = sg_next(pc->sg);
|
||||
pc->b_count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (bcount) {
|
||||
printk (KERN_ERR "ide-scsi: scatter gather table too small, discarding data\n");
|
||||
idescsi_discard_data (drive, bcount);
|
||||
}
|
||||
}
|
||||
|
||||
static void idescsi_output_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsigned int bcount)
|
||||
@ -209,12 +211,6 @@ static void idescsi_output_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsign
|
||||
char *buf;
|
||||
|
||||
while (bcount) {
|
||||
if (pc->sg - scsi_sglist(pc->scsi_cmd) >
|
||||
scsi_sg_count(pc->scsi_cmd)) {
|
||||
printk (KERN_ERR "ide-scsi: scatter gather table too small, padding with zeros\n");
|
||||
idescsi_output_zeros (drive, bcount);
|
||||
return;
|
||||
}
|
||||
count = min(pc->sg->length - pc->b_count, bcount);
|
||||
if (PageHighMem(pc->sg->page)) {
|
||||
unsigned long flags;
|
||||
@ -233,10 +229,17 @@ static void idescsi_output_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsign
|
||||
}
|
||||
bcount -= count; pc->b_count += count;
|
||||
if (pc->b_count == pc->sg->length) {
|
||||
pc->sg++;
|
||||
if (pc->sg == pc->last_sg)
|
||||
break;
|
||||
pc->sg = sg_next(pc->sg);
|
||||
pc->b_count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (bcount) {
|
||||
printk (KERN_ERR "ide-scsi: scatter gather table too small, padding with zeros\n");
|
||||
idescsi_output_zeros (drive, bcount);
|
||||
}
|
||||
}
|
||||
|
||||
static void hexdump(u8 *x, int len)
|
||||
@ -804,6 +807,7 @@ static int idescsi_queue (struct scsi_cmnd *cmd,
|
||||
memcpy (pc->c, cmd->cmnd, cmd->cmd_len);
|
||||
pc->buffer = NULL;
|
||||
pc->sg = scsi_sglist(cmd);
|
||||
pc->last_sg = sg_last(pc->sg, cmd->use_sg);
|
||||
pc->b_count = 0;
|
||||
pc->request_transfer = pc->buffer_size = scsi_bufflen(cmd);
|
||||
pc->scsi_cmd = cmd;
|
||||
|
Loading…
Reference in New Issue
Block a user