diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2008-05-02 22:50:45 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2008-05-02 07:50:45 -0400 |
commit | cb38fa23c17519faf46a76d2f71a8430705fe474 (patch) | |
tree | 8a2a4ac0c4d8091cc15216871bc74e98337bfa41 | |
parent | 81473132878f8a1d0c6a78cffa0cf84c8a19c1be (diff) |
virtio: de-structify virtio_block status byte
Ron Minnich points out that a struct containing a char is not always
sizeof(char); simplest to remove the structure to avoid confusion.
Cc: "ron minnich" <rminnich@gmail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
-rw-r--r-- | Documentation/lguest/lguest.c | 12 | ||||
-rw-r--r-- | drivers/block/virtio_blk.c | 6 | ||||
-rw-r--r-- | include/linux/virtio_blk.h | 7 |
3 files changed, 10 insertions, 15 deletions
diff --git a/Documentation/lguest/lguest.c b/Documentation/lguest/lguest.c index 4c1fc65a8b3d..5cd705c3d75b 100644 --- a/Documentation/lguest/lguest.c +++ b/Documentation/lguest/lguest.c | |||
@@ -1398,7 +1398,7 @@ static bool service_io(struct device *dev) | |||
1398 | struct vblk_info *vblk = dev->priv; | 1398 | struct vblk_info *vblk = dev->priv; |
1399 | unsigned int head, out_num, in_num, wlen; | 1399 | unsigned int head, out_num, in_num, wlen; |
1400 | int ret; | 1400 | int ret; |
1401 | struct virtio_blk_inhdr *in; | 1401 | u8 *in; |
1402 | struct virtio_blk_outhdr *out; | 1402 | struct virtio_blk_outhdr *out; |
1403 | struct iovec iov[dev->vq->vring.num]; | 1403 | struct iovec iov[dev->vq->vring.num]; |
1404 | off64_t off; | 1404 | off64_t off; |
@@ -1416,7 +1416,7 @@ static bool service_io(struct device *dev) | |||
1416 | head, out_num, in_num); | 1416 | head, out_num, in_num); |
1417 | 1417 | ||
1418 | out = convert(&iov[0], struct virtio_blk_outhdr); | 1418 | out = convert(&iov[0], struct virtio_blk_outhdr); |
1419 | in = convert(&iov[out_num+in_num-1], struct virtio_blk_inhdr); | 1419 | in = convert(&iov[out_num+in_num-1], u8); |
1420 | off = out->sector * 512; | 1420 | off = out->sector * 512; |
1421 | 1421 | ||
1422 | /* The block device implements "barriers", where the Guest indicates | 1422 | /* The block device implements "barriers", where the Guest indicates |
@@ -1430,7 +1430,7 @@ static bool service_io(struct device *dev) | |||
1430 | * It'd be nice if we supported eject, for example, but we don't. */ | 1430 | * It'd be nice if we supported eject, for example, but we don't. */ |
1431 | if (out->type & VIRTIO_BLK_T_SCSI_CMD) { | 1431 | if (out->type & VIRTIO_BLK_T_SCSI_CMD) { |
1432 | fprintf(stderr, "Scsi commands unsupported\n"); | 1432 | fprintf(stderr, "Scsi commands unsupported\n"); |
1433 | in->status = VIRTIO_BLK_S_UNSUPP; | 1433 | *in = VIRTIO_BLK_S_UNSUPP; |
1434 | wlen = sizeof(*in); | 1434 | wlen = sizeof(*in); |
1435 | } else if (out->type & VIRTIO_BLK_T_OUT) { | 1435 | } else if (out->type & VIRTIO_BLK_T_OUT) { |
1436 | /* Write */ | 1436 | /* Write */ |
@@ -1453,7 +1453,7 @@ static bool service_io(struct device *dev) | |||
1453 | errx(1, "Write past end %llu+%u", off, ret); | 1453 | errx(1, "Write past end %llu+%u", off, ret); |
1454 | } | 1454 | } |
1455 | wlen = sizeof(*in); | 1455 | wlen = sizeof(*in); |
1456 | in->status = (ret >= 0 ? VIRTIO_BLK_S_OK : VIRTIO_BLK_S_IOERR); | 1456 | *in = (ret >= 0 ? VIRTIO_BLK_S_OK : VIRTIO_BLK_S_IOERR); |
1457 | } else { | 1457 | } else { |
1458 | /* Read */ | 1458 | /* Read */ |
1459 | 1459 | ||
@@ -1466,10 +1466,10 @@ static bool service_io(struct device *dev) | |||
1466 | verbose("READ from sector %llu: %i\n", out->sector, ret); | 1466 | verbose("READ from sector %llu: %i\n", out->sector, ret); |
1467 | if (ret >= 0) { | 1467 | if (ret >= 0) { |
1468 | wlen = sizeof(*in) + ret; | 1468 | wlen = sizeof(*in) + ret; |
1469 | in->status = VIRTIO_BLK_S_OK; | 1469 | *in = VIRTIO_BLK_S_OK; |
1470 | } else { | 1470 | } else { |
1471 | wlen = sizeof(*in); | 1471 | wlen = sizeof(*in); |
1472 | in->status = VIRTIO_BLK_S_IOERR; | 1472 | *in = VIRTIO_BLK_S_IOERR; |
1473 | } | 1473 | } |
1474 | } | 1474 | } |
1475 | 1475 | ||
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 0cfbe8c594a5..fb283af38023 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c | |||
@@ -35,7 +35,7 @@ struct virtblk_req | |||
35 | struct list_head list; | 35 | struct list_head list; |
36 | struct request *req; | 36 | struct request *req; |
37 | struct virtio_blk_outhdr out_hdr; | 37 | struct virtio_blk_outhdr out_hdr; |
38 | struct virtio_blk_inhdr in_hdr; | 38 | u8 status; |
39 | }; | 39 | }; |
40 | 40 | ||
41 | static void blk_done(struct virtqueue *vq) | 41 | static void blk_done(struct virtqueue *vq) |
@@ -48,7 +48,7 @@ static void blk_done(struct virtqueue *vq) | |||
48 | spin_lock_irqsave(&vblk->lock, flags); | 48 | spin_lock_irqsave(&vblk->lock, flags); |
49 | while ((vbr = vblk->vq->vq_ops->get_buf(vblk->vq, &len)) != NULL) { | 49 | while ((vbr = vblk->vq->vq_ops->get_buf(vblk->vq, &len)) != NULL) { |
50 | int uptodate; | 50 | int uptodate; |
51 | switch (vbr->in_hdr.status) { | 51 | switch (vbr->status) { |
52 | case VIRTIO_BLK_S_OK: | 52 | case VIRTIO_BLK_S_OK: |
53 | uptodate = 1; | 53 | uptodate = 1; |
54 | break; | 54 | break; |
@@ -101,7 +101,7 @@ static bool do_req(struct request_queue *q, struct virtio_blk *vblk, | |||
101 | sg_init_table(vblk->sg, VIRTIO_MAX_SG); | 101 | sg_init_table(vblk->sg, VIRTIO_MAX_SG); |
102 | sg_set_buf(&vblk->sg[0], &vbr->out_hdr, sizeof(vbr->out_hdr)); | 102 | sg_set_buf(&vblk->sg[0], &vbr->out_hdr, sizeof(vbr->out_hdr)); |
103 | num = blk_rq_map_sg(q, vbr->req, vblk->sg+1); | 103 | num = blk_rq_map_sg(q, vbr->req, vblk->sg+1); |
104 | sg_set_buf(&vblk->sg[num+1], &vbr->in_hdr, sizeof(vbr->in_hdr)); | 104 | sg_set_buf(&vblk->sg[num+1], &vbr->status, sizeof(vbr->status)); |
105 | 105 | ||
106 | if (rq_data_dir(vbr->req) == WRITE) { | 106 | if (rq_data_dir(vbr->req) == WRITE) { |
107 | vbr->out_hdr.type |= VIRTIO_BLK_T_OUT; | 107 | vbr->out_hdr.type |= VIRTIO_BLK_T_OUT; |
diff --git a/include/linux/virtio_blk.h b/include/linux/virtio_blk.h index bca0b10d7947..c75a9e82b924 100644 --- a/include/linux/virtio_blk.h +++ b/include/linux/virtio_blk.h | |||
@@ -41,13 +41,8 @@ struct virtio_blk_outhdr | |||
41 | __u64 sector; | 41 | __u64 sector; |
42 | }; | 42 | }; |
43 | 43 | ||
44 | /* And this is the final byte of the write scatter-gather list. */ | ||
44 | #define VIRTIO_BLK_S_OK 0 | 45 | #define VIRTIO_BLK_S_OK 0 |
45 | #define VIRTIO_BLK_S_IOERR 1 | 46 | #define VIRTIO_BLK_S_IOERR 1 |
46 | #define VIRTIO_BLK_S_UNSUPP 2 | 47 | #define VIRTIO_BLK_S_UNSUPP 2 |
47 | |||
48 | /* This is the first element of the write scatter-gather list */ | ||
49 | struct virtio_blk_inhdr | ||
50 | { | ||
51 | unsigned char status; | ||
52 | }; | ||
53 | #endif /* _LINUX_VIRTIO_BLK_H */ | 48 | #endif /* _LINUX_VIRTIO_BLK_H */ |