-
Notifications
You must be signed in to change notification settings - Fork 2
/
blkback-blkif-flush.diff
63 lines (55 loc) · 1.51 KB
/
blkback-blkif-flush.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
blkback: Flush bdev during close and open.
Open, so outstanding buffer I/O is flushed.
Close, so that stale buffers are reread.
Signed-off-by: Daniel Stodden <[email protected]>
diff -r 8bafdb313b79 drivers/xen/blkback/blkback.c
--- a/drivers/xen/blkback/blkback.c Sun May 23 02:00:46 2010 -0700
+++ b/drivers/xen/blkback/blkback.c Sun May 23 02:00:55 2010 -0700
@@ -117,6 +117,17 @@
static void make_response(blkif_t *blkif, u64 id,
unsigned short op, int st);
+static int
+blkif_bdev_flush(blkif_t *blkif)
+{
+ int err = -EBADF;
+
+ if (blkif->bdev)
+ err = ioctl_by_bdev(blkif->bdev, BLKFLSBUF, 0);
+
+ return err;
+}
+
int
blkif_bdev_open(blkif_t *blkif, dev_t dev, int mode, int cdrom)
{
@@ -133,6 +144,8 @@
blkif->cdrom = cdrom;
blkif->bdev = bdev;
+ blkif_bdev_flush(blkif);
+
return 0;
}
@@ -142,6 +155,8 @@
struct block_device *bdev = blkif->bdev;
if (bdev) {
+ blkif_bdev_flush(blkif);
+
blkdev_put(bdev);
blkif->bdev = NULL;
}
diff -r 8bafdb313b79 drivers/xen/blkback/xenbus.c
--- a/drivers/xen/blkback/xenbus.c Sun May 23 02:00:46 2010 -0700
+++ b/drivers/xen/blkback/xenbus.c Sun May 23 02:00:55 2010 -0700
@@ -99,13 +99,6 @@
return;
}
- err = filemap_write_and_wait(blkif->bdev->bd_inode->i_mapping);
- if (err) {
- xenbus_dev_error(blkif->be->dev, err, "block flush");
- return;
- }
- invalidate_inode_pages2(blkif->bdev->bd_inode->i_mapping);
-
blkif->xenblkd = kthread_run(blkif_schedule, blkif, name);
if (IS_ERR(blkif->xenblkd)) {
err = PTR_ERR(blkif->xenblkd);