- 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
*/
#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)
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;