From: t_jeang Date: Tue, 6 Jan 2009 12:06:01 +0000 (+0000) Subject: Close block devices when the pv drivers take over and flush the buffer cache. X-Git-Tag: CA-15999-blkback-pause-unpause X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=9067dfe9d2f8632940d387b175803d5f6dbe075c;p=xenclient%2Fkernel.git Close block devices when the pv drivers take over and flush the buffer cache. - 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 --- diff --git a/drivers/xen/blkback/vbd.c b/drivers/xen/blkback/vbd.c index 8729176f..8aa6b672 100644 --- a/drivers/xen/blkback/vbd.c +++ b/drivers/xen/blkback/vbd.c @@ -31,6 +31,8 @@ */ #include "common.h" +#include +#include #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;