Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=d274a9878bcd028712ea4f3d96db72b63d3eba4d
Commit:     d274a9878bcd028712ea4f3d96db72b63d3eba4d
Parent:     2f08fe5221b79aa1e240aa3938e9de6ab0baf1d3
Author:     Jens Axboe <[EMAIL PROTECTED]>
AuthorDate: Tue Oct 16 11:20:52 2007 +0200
Committer:  Jens Axboe <[EMAIL PROTECTED]>
CommitDate: Tue Oct 16 11:20:52 2007 +0200

    ide-scsi: sg chaining support
    
    Acked-by: Bartlomiej Zolnierkiewicz <[EMAIL PROTECTED]>
    Signed-off-by: Jens Axboe <[EMAIL PROTECTED]>
---
 drivers/scsi/ide-scsi.c |   32 ++++++++++++++++++--------------
 1 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index d81bb07..d297f64 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -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;
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to