lguest: barrier me harder
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 31 Mar 2009 03:55:25 +0000 (21:55 -0600)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 30 Mar 2009 11:25:26 +0000 (21:55 +1030)
Impact: barrier correctness in example launcher

I doubt either lguest user will complain about performance.

Reported-by: Christoph Hellwig <hch@infradead.org>
Cc: Jens Axboe <jens.axboe@oracle.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Documentation/lguest/lguest.c

index f2dbbf3bdeaba7a5c6d58e1ccb3f8a686ade88ed..d36fcc0f2715c705d0f70d1aa9c13e20b8aaa917 100644 (file)
@@ -1630,6 +1630,13 @@ static bool service_io(struct device *dev)
                }
        }
 
+       /* 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);
+
        /* We can't trigger an IRQ, because we're not the Launcher.  It does
         * that when we tell it we're done. */
        add_used(dev->vq, head, wlen);