Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=3d1266c7042e696704e22085a0f55c714bc06194
Commit:     3d1266c7042e696704e22085a0f55c714bc06194
Parent:     23464ffa47689e46985fb10ae9e34bbc9e83f387
Author:     Jens Axboe <[EMAIL PROTECTED]>
AuthorDate: Wed Oct 24 13:21:21 2007 +0200
Committer:  Jens Axboe <[EMAIL PROTECTED]>
CommitDate: Wed Oct 24 13:21:21 2007 +0200

    SG: audit of drivers that use blk_rq_map_sg()
    
    They need to properly init the sg table, or blk_rq_map_sg() will
    complain if CONFIG_DEBUG_SG is set.
    
    Signed-off-by: Jens Axboe <[EMAIL PROTECTED]>
---
 drivers/block/virtio_blk.c      |   10 ++++++----
 drivers/cdrom/viocd.c           |    3 ++-
 drivers/message/i2o/i2o_block.c |    1 +
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index a901eee..3cf7129 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -4,7 +4,9 @@
 #include <linux/hdreg.h>
 #include <linux/virtio.h>
 #include <linux/virtio_blk.h>
-#include <linux/virtio_blk.h>
+#include <linux/scatterlist.h>
+
+#define VIRTIO_MAX_SG  (3+MAX_PHYS_SEGMENTS)
 
 static unsigned char virtblk_index = 'a';
 struct virtio_blk
@@ -23,7 +25,7 @@ struct virtio_blk
        mempool_t *pool;
 
        /* Scatterlist: can be too big for stack. */
-       struct scatterlist sg[3+MAX_PHYS_SEGMENTS];
+       struct scatterlist sg[VIRTIO_MAX_SG];
 };
 
 struct virtblk_req
@@ -94,8 +96,8 @@ static bool do_req(struct request_queue *q, struct virtio_blk 
*vblk,
        if (blk_barrier_rq(vbr->req))
                vbr->out_hdr.type |= VIRTIO_BLK_T_BARRIER;
 
-       /* We have to zero this, otherwise blk_rq_map_sg gets upset. */
-       memset(vblk->sg, 0, sizeof(vblk->sg));
+       /* This init could be done at vblk creation time */
+       sg_init_table(vblk->sg, VIRTIO_MAX_SG);
        sg_set_buf(&vblk->sg[0], &vbr->out_hdr, sizeof(vbr->out_hdr));
        num = blk_rq_map_sg(q, vbr->req, vblk->sg+1);
        sg_set_buf(&vblk->sg[num+1], &vbr->in_hdr, sizeof(vbr->in_hdr));
diff --git a/drivers/cdrom/viocd.c b/drivers/cdrom/viocd.c
index 880b5dc..d8bb44b 100644
--- a/drivers/cdrom/viocd.c
+++ b/drivers/cdrom/viocd.c
@@ -41,9 +41,9 @@
 #include <linux/completion.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
+#include <linux/scatterlist.h>
 
 #include <asm/vio.h>
-#include <asm/scatterlist.h>
 #include <asm/iseries/hv_types.h>
 #include <asm/iseries/hv_lp_event.h>
 #include <asm/iseries/vio.h>
@@ -258,6 +258,7 @@ static int send_request(struct request *req)
                cmd = viomajorsubtype_cdio | viocdwrite;
        }
 
+       sg_init_table(&sg, 1);
         if (blk_rq_map_sg(req->q, req, &sg) == 0) {
                printk(VIOCD_KERN_WARNING
                                "error setting up scatter/gather list\n");
diff --git a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c
index d602ba6..6824061 100644
--- a/drivers/message/i2o/i2o_block.c
+++ b/drivers/message/i2o/i2o_block.c
@@ -284,6 +284,7 @@ static inline struct i2o_block_request 
*i2o_block_request_alloc(void)
                return ERR_PTR(-ENOMEM);
 
        INIT_LIST_HEAD(&ireq->queue);
+       sg_init_table(ireq->sg_table, I2O_MAX_PHYS_SEGMENTS);
 
        return ireq;
 };
-
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