virtio: de-structify virtio_block status byte
Subsystems (4)
PATCH 5/6 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" <[email protected]>
Signed-off-by Rusty Russell <[email protected]>
--- Documentation/lguest/lguest.c | 12 ++++++------ drivers/block/virtio_blk.c | 6 +++--- include/linux/virtio_blk.h | 7 +------ 3 files changed, 10 insertions(+), 15 deletions(-)
Documentation/lguest/lguest.c +6 -6
@@ -1859,7 +1859,7 @@ static bool service_io(struct device *destruct vblk_info *vblk = dev->priv;unsigned int out_num, in_num, wlen;int head, ret; -struct virtio_blk_inhdr *in; +u8 *in;struct virtio_blk_outhdr *out;struct iovec iov[dev->vq->vqi.vring.num];off64_t off;
@@ -1877,7 +1877,7 @@ static bool service_io(struct device *de head, out_num, in_num); out = convert(&iov[0], struct virtio_blk_outhdr); - in = convert(&iov[out_num+in_num-1], struct virtio_blk_inhdr); + in =convert (&iov[out_num+in_num-1 ], u8); off = out->sector *512 ;/* The block device implements "barriers", where the Guest indicates
@@ -1891,7 +1891,7 @@ static bool service_io(struct device *de* It'd be nice if we supported eject, for example, but we don't. */ if (out->type &VIRTIO_BLK_T_SCSI_CMD ) {fprintf (stderr,"Scsi commands unsupported\n" ); - in->status =VIRTIO_BLK_S_UNSUPP ; + *in =VIRTIO_BLK_S_UNSUPP ; wlen =sizeof (*in); }else if (out->type &VIRTIO_BLK_T_OUT ) {/* Write */
@@ -1914,7 +1914,7 @@ static bool service_io(struct device *deerrx (1 ,"Write past end %llu+%u" , off, ret); } wlen =sizeof (*in); - in->status = (ret >=0 ?VIRTIO_BLK_S_OK :VIRTIO_BLK_S_IOERR ); + *in = (ret >=0 ?VIRTIO_BLK_S_OK :VIRTIO_BLK_S_IOERR ); }else {/* Read */
@@ -1927,10 +1927,10 @@ static bool service_io(struct device *deverbose ("READ from sector %llu: %i\n" , out->sector, ret);if (ret >=0 ) { wlen =sizeof (*in) + ret; - in->status =VIRTIO_BLK_S_OK ; + *in =VIRTIO_BLK_S_OK ; }else { wlen =sizeof (*in); - in->status =VIRTIO_BLK_S_IOERR ; + *in =VIRTIO_BLK_S_IOERR ; } }
drivers/block/virtio_blk.c +3 -3
@@ -35,7 +35,7 @@ struct virtblk_reqstruct list_head list;struct request *req;struct virtio_blk_outhdr out_hdr; -struct virtio_blk_inhdr in_hdr; +u8 status; };static void blk_done (struct virtqueue *vq)
@@ -48,7 +48,7 @@ static void blk_done(struct virtqueue *vspin_lock_irqsave (&vblk->lock, flags);while ((vbr = vblk->vq->vq_ops->get_buf (vblk->vq, &len)) !=NULL ) {int uptodate; -switch (vbr->in_hdr.status) { +switch (vbr->status) {case VIRTIO_BLK_S_OK : uptodate =1 ;break ;
@@ -101,7 +101,7 @@ static bool do_req(struct request_queuesg_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)); +sg_set_buf (&vblk->sg[num+1 ], &vbr->status,sizeof (vbr->status));if (rq_data_dir (vbr->req) ==WRITE ) { vbr->out_hdr.type |=VIRTIO_BLK_T_OUT ;
include/linux/virtio_blk.h +1 -6
@@ -48,13 +48,8 @@ struct virtio_blk_outhdr __u64 sector; }; +/* And this is the final byte of the write scatter-gather list. */ #define VIRTIO_BLK_S_OK 0#define VIRTIO_BLK_S_IOERR 1#define VIRTIO_BLK_S_UNSUPP 2 - -/* This is the first element of the write scatter-gather list */ -struct virtio_blk_inhdr -{ -unsigned char status; -};#endif /* _LINUX_VIRTIO_BLK_H */