]> xenbits.xensource.com Git - xenclient/kernel.git/commitdiff
Close block devices when the pv drivers take over and flush the buffer cache. CA-15999-blkback-pause-unpause
authort_jeang <devnull@localhost>
Tue, 6 Jan 2009 12:06:01 +0000 (12:06 +0000)
committert_jeang <devnull@localhost>
Tue, 6 Jan 2009 12:06:01 +0000 (12:06 +0000)
- 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..8aa6b67276d43b3f1112d1ab56cbcaf7c3b9cb88 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, 0);
+               unlock_kernel();
+       }
        if (vbd->bdev)
                blkdev_put(vbd->bdev);
        vbd->bdev = NULL;