aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Axboe <jens.axboe@oracle.com>2007-10-24 07:21:21 -0400
committerJens Axboe <jens.axboe@oracle.com>2007-10-24 07:21:21 -0400
commit3d1266c7042e696704e22085a0f55c714bc06194 (patch)
tree537e14b96d331d5918fc090eaf9b0561b299be02
parent23464ffa47689e46985fb10ae9e34bbc9e83f387 (diff)
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 <jens.axboe@oracle.com>
-rw-r--r--drivers/block/virtio_blk.c10
-rw-r--r--drivers/cdrom/viocd.c3
-rw-r--r--drivers/message/i2o/i2o_block.c1
3 files changed, 9 insertions, 5 deletions
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index a901eee64ba5..3cf7129d83e6 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -4,7 +4,9 @@
4#include <linux/hdreg.h> 4#include <linux/hdreg.h>
5#include <linux/virtio.h> 5#include <linux/virtio.h>
6#include <linux/virtio_blk.h> 6#include <linux/virtio_blk.h>
7#include <linux/virtio_blk.h> 7#include <linux/scatterlist.h>
8
9#define VIRTIO_MAX_SG (3+MAX_PHYS_SEGMENTS)
8 10
9static unsigned char virtblk_index = 'a'; 11static unsigned char virtblk_index = 'a';
10struct virtio_blk 12struct virtio_blk
@@ -23,7 +25,7 @@ struct virtio_blk
23 mempool_t *pool; 25 mempool_t *pool;
24 26
25 /* Scatterlist: can be too big for stack. */ 27 /* Scatterlist: can be too big for stack. */
26 struct scatterlist sg[3+MAX_PHYS_SEGMENTS]; 28 struct scatterlist sg[VIRTIO_MAX_SG];
27}; 29};
28 30
29struct virtblk_req 31struct virtblk_req
@@ -94,8 +96,8 @@ static bool do_req(struct request_queue *q, struct virtio_blk *vblk,
94 if (blk_barrier_rq(vbr->req)) 96 if (blk_barrier_rq(vbr->req))
95 vbr->out_hdr.type |= VIRTIO_BLK_T_BARRIER; 97 vbr->out_hdr.type |= VIRTIO_BLK_T_BARRIER;
96 98
97 /* We have to zero this, otherwise blk_rq_map_sg gets upset. */ 99 /* This init could be done at vblk creation time */
98 memset(vblk->sg, 0, sizeof(vblk->sg)); 100 sg_init_table(vblk->sg, VIRTIO_MAX_SG);
99 sg_set_buf(&vblk->sg[0], &vbr->out_hdr, sizeof(vbr->out_hdr)); 101 sg_set_buf(&vblk->sg[0], &vbr->out_hdr, sizeof(vbr->out_hdr));
100 num = blk_rq_map_sg(q, vbr->req, vblk->sg+1); 102 num = blk_rq_map_sg(q, vbr->req, vblk->sg+1);
101 sg_set_buf(&vblk->sg[num+1], &vbr->in_hdr, sizeof(vbr->in_hdr)); 103 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 880b5dce3a62..d8bb44b98a6a 100644
--- a/drivers/cdrom/viocd.c
+++ b/drivers/cdrom/viocd.c
@@ -41,9 +41,9 @@
41#include <linux/completion.h> 41#include <linux/completion.h>
42#include <linux/proc_fs.h> 42#include <linux/proc_fs.h>
43#include <linux/seq_file.h> 43#include <linux/seq_file.h>
44#include <linux/scatterlist.h>
44 45
45#include <asm/vio.h> 46#include <asm/vio.h>
46#include <asm/scatterlist.h>
47#include <asm/iseries/hv_types.h> 47#include <asm/iseries/hv_types.h>
48#include <asm/iseries/hv_lp_event.h> 48#include <asm/iseries/hv_lp_event.h>
49#include <asm/iseries/vio.h> 49#include <asm/iseries/vio.h>
@@ -258,6 +258,7 @@ static int send_request(struct request *req)
258 cmd = viomajorsubtype_cdio | viocdwrite; 258 cmd = viomajorsubtype_cdio | viocdwrite;
259 } 259 }
260 260
261 sg_init_table(&sg, 1);
261 if (blk_rq_map_sg(req->q, req, &sg) == 0) { 262 if (blk_rq_map_sg(req->q, req, &sg) == 0) {
262 printk(VIOCD_KERN_WARNING 263 printk(VIOCD_KERN_WARNING
263 "error setting up scatter/gather list\n"); 264 "error setting up scatter/gather list\n");
diff --git a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c
index d602ba6d5417..682406168de9 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)
284 return ERR_PTR(-ENOMEM); 284 return ERR_PTR(-ENOMEM);
285 285
286 INIT_LIST_HEAD(&ireq->queue); 286 INIT_LIST_HEAD(&ireq->queue);
287 sg_init_table(ireq->sg_table, I2O_MAX_PHYS_SEGMENTS);
287 288
288 return ireq; 289 return ireq;
289}; 290};