diff options
author | Tejun Heo <tj@kernel.org> | 2010-09-03 05:56:18 -0400 |
---|---|---|
committer | Jens Axboe <jaxboe@fusionio.com> | 2010-09-10 06:35:38 -0400 |
commit | 7bc9fddab074d6bb630344e1969e28d20b140621 (patch) | |
tree | 3f0799bb2f1a4c12fa564f2538aea54de552a108 /Documentation/lguest | |
parent | 02c42b7a68695c2c3e3fecf9f6b9a4ea43abe52f (diff) |
lguest: replace VIRTIO_F_BARRIER support with VIRTIO_F_FLUSH support
VIRTIO_F_BARRIER is deprecated. Replace it with VIRTIO_F_FLUSH
support.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
Diffstat (limited to 'Documentation/lguest')
-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 e9ce3c554514..fbc64b331436 100644 --- a/Documentation/lguest/lguest.c +++ b/Documentation/lguest/lguest.c | |||
@@ -1639,15 +1639,6 @@ static void blk_request(struct virtqueue *vq) | |||
1639 | off = out->sector * 512; | 1639 | off = out->sector * 512; |
1640 | 1640 | ||
1641 | /* | 1641 | /* |
1642 | * The block device implements "barriers", where the Guest indicates | ||
1643 | * that it wants all previous writes to occur before this write. We | ||
1644 | * don't have a way of asking our kernel to do a barrier, so we just | ||
1645 | * synchronize all the data in the file. Pretty poor, no? | ||
1646 | */ | ||
1647 | if (out->type & VIRTIO_BLK_T_BARRIER) | ||
1648 | fdatasync(vblk->fd); | ||
1649 | |||
1650 | /* | ||
1651 | * In general the virtio block driver is allowed to try SCSI commands. | 1642 | * In general the virtio block driver is allowed to try SCSI commands. |
1652 | * It'd be nice if we supported eject, for example, but we don't. | 1643 | * It'd be nice if we supported eject, for example, but we don't. |
1653 | */ | 1644 | */ |
@@ -1679,6 +1670,13 @@ static void blk_request(struct virtqueue *vq) | |||
1679 | /* Die, bad Guest, die. */ | 1670 | /* Die, bad Guest, die. */ |
1680 | errx(1, "Write past end %llu+%u", off, ret); | 1671 | errx(1, "Write past end %llu+%u", off, ret); |
1681 | } | 1672 | } |
1673 | |||
1674 | wlen = sizeof(*in); | ||
1675 | *in = (ret >= 0 ? VIRTIO_BLK_S_OK : VIRTIO_BLK_S_IOERR); | ||
1676 | } else if (out->type & VIRTIO_BLK_T_FLUSH) { | ||
1677 | /* Flush */ | ||
1678 | ret = fdatasync(vblk->fd); | ||
1679 | verbose("FLUSH fdatasync: %i\n", ret); | ||
1682 | wlen = sizeof(*in); | 1680 | wlen = sizeof(*in); |
1683 | *in = (ret >= 0 ? VIRTIO_BLK_S_OK : VIRTIO_BLK_S_IOERR); | 1681 | *in = (ret >= 0 ? VIRTIO_BLK_S_OK : VIRTIO_BLK_S_IOERR); |
1684 | } else { | 1682 | } else { |
@@ -1702,15 +1700,6 @@ static void blk_request(struct virtqueue *vq) | |||
1702 | } | 1700 | } |
1703 | } | 1701 | } |
1704 | 1702 | ||
1705 | /* | ||
1706 | * OK, so we noted that it was pretty poor to use an fdatasync as a | ||
1707 | * barrier. But Christoph Hellwig points out that we need a sync | ||
1708 | * *afterwards* as well: "Barriers specify no reordering to the front | ||
1709 | * or the back." And Jens Axboe confirmed it, so here we are: | ||
1710 | */ | ||
1711 | if (out->type & VIRTIO_BLK_T_BARRIER) | ||
1712 | fdatasync(vblk->fd); | ||
1713 | |||
1714 | /* Finished that request. */ | 1703 | /* Finished that request. */ |
1715 | add_used(vq, head, wlen); | 1704 | add_used(vq, head, wlen); |
1716 | } | 1705 | } |
@@ -1735,8 +1724,8 @@ static void setup_block_file(const char *filename) | |||
1735 | vblk->fd = open_or_die(filename, O_RDWR|O_LARGEFILE); | 1724 | vblk->fd = open_or_die(filename, O_RDWR|O_LARGEFILE); |
1736 | vblk->len = lseek64(vblk->fd, 0, SEEK_END); | 1725 | vblk->len = lseek64(vblk->fd, 0, SEEK_END); |
1737 | 1726 | ||
1738 | /* We support barriers. */ | 1727 | /* We support FLUSH. */ |
1739 | add_feature(dev, VIRTIO_BLK_F_BARRIER); | 1728 | add_feature(dev, VIRTIO_BLK_F_FLUSH); |
1740 | 1729 | ||
1741 | /* Tell Guest how many sectors this device has. */ | 1730 | /* Tell Guest how many sectors this device has. */ |
1742 | conf.capacity = cpu_to_le64(vblk->len / 512); | 1731 | conf.capacity = cpu_to_le64(vblk->len / 512); |