diff options
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/virtio_blk.c | 10 |
1 files changed, 6 insertions, 4 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 | ||
9 | static unsigned char virtblk_index = 'a'; | 11 | static unsigned char virtblk_index = 'a'; |
10 | struct virtio_blk | 12 | struct 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 | ||
29 | struct virtblk_req | 31 | struct 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)); |