]> xenbits.xensource.com Git - people/ssmith/nc2-2.6.27.git/commitdiff
Close block devices when the pv drivers take over and flush the buffer cache.
authorSteven Smith <ssmith@weybridge.uk.xensource.com>
Tue, 30 Jun 2009 11:55:47 +0000 (12:55 +0100)
committerSteven Smith <ssmith@weybridge.uk.xensource.com>
Tue, 30 Jun 2009 11:55:47 +0000 (12:55 +0100)
- close and free the block devices in qemu when we switch to pv drivers in
  the guest
- use BLKFLSBUF to flush the buffer cache, both in qemu and in blkback

drivers/xen/blkback/vbd.c

index 8729176f3e1519e4695a7fb3024f32362af1389f..a0c16e891f7493c381d19c57c4b7e4d55c5e85bf 100644 (file)
@@ -31,6 +31,8 @@
  */
 
 #include "common.h"
+#include <linux/fs.h>
+#include <linux/buffer_head.h>
 
 #define vbd_sz(_v)   ((_v)->bdev->bd_part ?                            \
        (_v)->bdev->bd_part->nr_sects : (_v)->bdev->bd_disk->capacity)
@@ -93,6 +95,13 @@ int vbd_create(blkif_t *blkif, blkif_vdev_t handle, unsigned major,
 
 void vbd_free(struct vbd *vbd)
 {
+       if (vbd->bdev) {
+               /* BLKFLSBUF */
+               lock_kernel();
+               fsync_bdev(vbd->bdev);
+               invalidate_bdev(vbd->bdev);
+               unlock_kernel();
+       }
        if (vbd->bdev)
                blkdev_put(vbd->bdev);
        vbd->bdev = NULL;