Re: [PATCH 3/5] lguest: replace VIRTIO_F_BARRIER support with VIRTIO_F_FLUSH support

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Tejun Heo
Date: Thursday, August 19, 2010 - 8:15 am

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>
---
FUA support dropped as suggested by Christoph.  Rusty, can you please
ack this version too?  I tested it with the updated virtio_blk and it
works fine.

Thanks.

 Documentation/lguest/lguest.c |   29 +++++++++--------------------
 1 file changed, 9 insertions(+), 20 deletions(-)

Index: block/Documentation/lguest/lguest.c
===================================================================
--- block.orig/Documentation/lguest/lguest.c
+++ block/Documentation/lguest/lguest.c
@@ -1639,15 +1639,6 @@ static void blk_request(struct virtqueue
 	off = out->sector * 512;

 	/*
-	 * The block device implements "barriers", where the Guest indicates
-	 * that it wants all previous writes to occur before this write.  We
-	 * don't have a way of asking our kernel to do a barrier, so we just
-	 * synchronize all the data in the file.  Pretty poor, no?
-	 */
-	if (out->type & VIRTIO_BLK_T_BARRIER)
-		fdatasync(vblk->fd);
-
-	/*
 	 * In general the virtio block driver is allowed to try SCSI commands.
 	 * It'd be nice if we supported eject, for example, but we don't.
 	 */
@@ -1679,6 +1670,13 @@ static void blk_request(struct virtqueue
 			/* Die, bad Guest, die. */
 			errx(1, "Write past end %llu+%u", off, ret);
 		}
+
+		wlen = sizeof(*in);
+		*in = (ret >= 0 ? VIRTIO_BLK_S_OK : VIRTIO_BLK_S_IOERR);
+	} else if (out->type & VIRTIO_BLK_T_FLUSH) {
+		/* Flush */
+		ret = fdatasync(vblk->fd);
+		verbose("FLUSH fdatasync: %i\n", ret);
 		wlen = sizeof(*in);
 		*in = (ret >= 0 ? VIRTIO_BLK_S_OK : VIRTIO_BLK_S_IOERR);
 	} else {
@@ -1702,15 +1700,6 @@ static void blk_request(struct virtqueue
 		}
 	}

-	/*
-	 * OK, so we noted that it was pretty poor to use an fdatasync as a
-	 * barrier.  But Christoph Hellwig points out that we need a sync
-	 * *afterwards* as well: "Barriers specify no reordering to the front
-	 * or the back."  And Jens Axboe confirmed it, so here we are:
-	 */
-	if (out->type & VIRTIO_BLK_T_BARRIER)
-		fdatasync(vblk->fd);
-
 	/* Finished that request. */
 	add_used(vq, head, wlen);
 }
@@ -1735,8 +1724,8 @@ static void setup_block_file(const char
 	vblk->fd = open_or_die(filename, O_RDWR|O_LARGEFILE);
 	vblk->len = lseek64(vblk->fd, 0, SEEK_END);

-	/* We support barriers. */
-	add_feature(dev, VIRTIO_BLK_F_BARRIER);
+	/* We support FLUSH. */
+	add_feature(dev, VIRTIO_BLK_F_FLUSH);

 	/* Tell Guest how many sectors this device has. */
 	conf.capacity = cpu_to_le64(vblk->len / 512);
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 5/5] dm: implement REQ_FLUSH/FUA support, Tejun Heo, (Mon Aug 16, 9:52 am)
Re: [PATCH 5/5] dm: implement REQ_FLUSH/FUA support, Mike Snitzer, (Mon Aug 16, 12:02 pm)
Re: [PATCH 5/5] dm: implement REQ_FLUSH/FUA support, Tejun Heo, (Tue Aug 17, 2:33 am)
Re: [PATCH 5/5] dm: implement REQ_FLUSH/FUA support, Christoph Hellwig, (Tue Aug 17, 6:13 am)
Re: [PATCH 5/5] dm: implement REQ_FLUSH/FUA support, Mike Snitzer, (Tue Aug 17, 7:07 am)
Re: [PATCH 5/5] dm: implement REQ_FLUSH/FUA support, Tejun Heo, (Tue Aug 17, 9:51 am)
Re: [PATCH 5/5] dm: implement REQ_FLUSH/FUA support, Mike Snitzer, (Tue Aug 17, 11:21 am)
Re: [PATCH 5/5] dm: implement REQ_FLUSH/FUA support, Tejun Heo, (Tue Aug 17, 11:32 pm)
Re: [PATCH 5/5] dm: implement REQ_FLUSH/FUA support, Kiyoshi Ueda, (Thu Aug 19, 3:32 am)
Re: [PATCH 3/5] lguest: replace VIRTIO_F_BARRIER support w ..., Tejun Heo, (Thu Aug 19, 8:15 am)
Re: [PATCH 5/5] dm: implement REQ_FLUSH/FUA support, Tejun Heo, (Thu Aug 19, 8:45 am)
Re: [RFC PATCHSET block#for-2.6.36-post] block: convert to ..., Christoph Hellwig, (Mon Aug 23, 9:47 am)
[GIT PULL] convert DRBD to REQ_FLUSH/FUA, Philipp Reisner, (Sat Oct 23, 4:18 am)
Re: [GIT PULL] convert DRBD to REQ_FLUSH/FUA, Christoph Hellwig, (Sat Oct 23, 4:21 am)
Re: [GIT PULL] convert DRBD to REQ_FLUSH/FUA, Jens Axboe, (Sat Oct 23, 9:48 am)
[PATCH] block: remove REQ_HARDBARRIER, Christoph Hellwig, (Sat Oct 23, 9:59 am)
Re: [PATCH] block: remove REQ_HARDBARRIER, Matthew Wilcox, (Sat Oct 23, 10:17 am)
Re: [PATCH] block: remove REQ_HARDBARRIER, Jens Axboe, (Sat Oct 23, 12:07 pm)
Re: [PATCH] block: remove REQ_HARDBARRIER, Jens Axboe, (Sat Oct 23, 12:08 pm)
Re: [PATCH] block: remove REQ_HARDBARRIER, Christoph Hellwig, (Sun Oct 24, 4:58 am)
Re: [PATCH] block: remove REQ_HARDBARRIER, Tejun Heo, (Mon Oct 25, 1:54 am)
Re: [PATCH] block: remove REQ_HARDBARRIER, Christoph Hellwig, (Wed Nov 10, 6:42 am)
Re: [PATCH] block: remove REQ_HARDBARRIER, Jens Axboe, (Wed Nov 10, 6:59 am)