diff options
Diffstat (limited to 'Documentation/lguest/lguest.c')
-rw-r--r-- | Documentation/lguest/lguest.c | 29 |
1 files changed, 9 insertions, 20 deletions
diff --git a/Documentation/lguest/lguest.c b/Documentation/lguest/lguest.c index 8a6a8c6d4980..dc73bc54cc4e 100644 --- a/Documentation/lguest/lguest.c +++ b/Documentation/lguest/lguest.c | |||
@@ -1640,15 +1640,6 @@ static void blk_request(struct virtqueue *vq) | |||
1640 | off = out->sector * 512; | 1640 | off = out->sector * 512; |
1641 | 1641 | ||
1642 | /* | 1642 | /* |
1643 | * The block device implements "barriers", where the Guest indicates | ||
1644 | * that it wants all previous writes to occur before this write. We | ||
1645 | * don't have a way of asking our kernel to do a barrier, so we just | ||
1646 | * synchronize all the data in the file. Pretty poor, no? | ||
1647 | */ | ||
1648 | if (out->type & VIRTIO_BLK_T_BARRIER) | ||
1649 | fdatasync(vblk->fd); | ||
1650 | |||
1651 | /* | ||
1652 | * In general the virtio block driver is allowed to try SCSI commands. | 1643 | * In general the virtio block driver is allowed to try SCSI commands. |
1653 | * It'd be nice if we supported eject, for example, but we don't. | 1644 | * It'd be nice if we supported eject, for example, but we don't. |
1654 | */ | 1645 | */ |
@@ -1680,6 +1671,13 @@ static void blk_request(struct virtqueue *vq) | |||
1680 | /* Die, bad Guest, die. */ | 1671 | /* Die, bad Guest, die. */ |
1681 | errx(1, "Write past end %llu+%u", off, ret); | 1672 | errx(1, "Write past end %llu+%u", off, ret); |
1682 | } | 1673 | } |
1674 | |||
1675 | wlen = sizeof(*in); | ||
1676 | *in = (ret >= 0 ? VIRTIO_BLK_S_OK : VIRTIO_BLK_S_IOERR); | ||
1677 | } else if (out->type & VIRTIO_BLK_T_FLUSH) { | ||
1678 | /* Flush */ | ||
1679 | ret = fdatasync(vblk->fd); | ||
1680 | verbose("FLUSH fdatasync: %i\n", ret); | ||
1683 | wlen = sizeof(*in); | 1681 | wlen = sizeof(*in); |
1684 | *in = (ret >= 0 ? VIRTIO_BLK_S_OK : VIRTIO_BLK_S_IOERR); | 1682 | *in = (ret >= 0 ? VIRTIO_BLK_S_OK : VIRTIO_BLK_S_IOERR); |
1685 | } else { | 1683 | } else { |
@@ -1703,15 +1701,6 @@ static void blk_request(struct virtqueue *vq) | |||
1703 | } | 1701 | } |
1704 | } | 1702 | } |
1705 | 1703 | ||
1706 | /* | ||
1707 | * OK, so we noted that it was pretty poor to use an fdatasync as a | ||
1708 | * barrier. But Christoph Hellwig points out that we need a sync | ||
1709 | * *afterwards* as well: "Barriers specify no reordering to the front | ||
1710 | * or the back." And Jens Axboe confirmed it, so here we are: | ||
1711 | */ | ||
1712 | if (out->type & VIRTIO_BLK_T_BARRIER) | ||
1713 | fdatasync(vblk->fd); | ||
1714 | |||
1715 | /* Finished that request. */ | 1704 | /* Finished that request. */ |
1716 | add_used(vq, head, wlen); | 1705 | add_used(vq, head, wlen); |
1717 | } | 1706 | } |
@@ -1736,8 +1725,8 @@ static void setup_block_file(const char *filename) | |||
1736 | vblk->fd = open_or_die(filename, O_RDWR|O_LARGEFILE); | 1725 | vblk->fd = open_or_die(filename, O_RDWR|O_LARGEFILE); |
1737 | vblk->len = lseek64(vblk->fd, 0, SEEK_END); | 1726 | vblk->len = lseek64(vblk->fd, 0, SEEK_END); |
1738 | 1727 | ||
1739 | /* We support barriers. */ | 1728 | /* We support FLUSH. */ |
1740 | add_feature(dev, VIRTIO_BLK_F_BARRIER); | 1729 | add_feature(dev, VIRTIO_BLK_F_FLUSH); |
1741 | 1730 | ||
1742 | /* Tell Guest how many sectors this device has. */ | 1731 | /* Tell Guest how many sectors this device has. */ |
1743 | conf.capacity = cpu_to_le64(vblk->len / 512); | 1732 | conf.capacity = cpu_to_le64(vblk->len / 512); |