2016-04-05 15:18:15 +02:00
|
|
|
From: Bruce Rogers <brogers@suse.com>
|
|
|
|
Date: Wed, 9 Mar 2016 15:18:11 -0700
|
2019-01-04 22:08:16 +01:00
|
|
|
Subject: xen_disk: Add suse specific flush disable handling and map to QEMU
|
|
|
|
equiv
|
2016-04-05 15:18:15 +02:00
|
|
|
|
|
|
|
Add code to read the suse specific suse-diskcache-disable-flush flag out
|
|
|
|
of xenstore, and set the equivalent flag within QEMU.
|
|
|
|
|
|
|
|
Patch taken from Xen's patch queue, Olaf Hering being the original author.
|
|
|
|
[bsc#879425]
|
|
|
|
|
2018-12-06 22:20:59 +01:00
|
|
|
[BR: minor edits to pass qemu's checkpatch script]
|
2016-04-05 15:18:15 +02:00
|
|
|
Signed-off-by: Bruce Rogers <brogers@suse.com>
|
|
|
|
Signed-off-by: Olaf Hering <olaf@aepfle.de>
|
|
|
|
---
|
2018-12-06 22:20:59 +01:00
|
|
|
hw/block/xen_disk.c | 19 +++++++++++++++++++
|
|
|
|
1 file changed, 19 insertions(+)
|
2016-04-05 15:18:15 +02:00
|
|
|
|
|
|
|
diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c
|
2018-12-06 22:20:59 +01:00
|
|
|
index 36eff94f84..ddd5c7cbfd 100644
|
2016-04-05 15:18:15 +02:00
|
|
|
--- a/hw/block/xen_disk.c
|
|
|
|
+++ b/hw/block/xen_disk.c
|
2018-08-22 16:58:18 +02:00
|
|
|
@@ -90,6 +90,8 @@ struct XenBlkDev {
|
2016-04-05 15:18:15 +02:00
|
|
|
int requests_finished;
|
2017-08-31 00:22:50 +02:00
|
|
|
unsigned int max_requests;
|
2016-04-05 15:18:15 +02:00
|
|
|
|
|
|
|
+ gboolean cache_unsafe;
|
2018-08-22 16:58:18 +02:00
|
|
|
+ /* Persistent grants extension */
|
2016-04-05 15:18:15 +02:00
|
|
|
gboolean feature_discard;
|
2018-08-22 16:58:18 +02:00
|
|
|
|
|
|
|
/* qemu block driver */
|
2018-12-06 22:20:59 +01:00
|
|
|
@@ -642,6 +644,18 @@ static void blk_parse_discard(struct XenBlkDev *blkdev)
|
2016-04-05 15:18:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+static void blk_parse_cache_unsafe(struct XenBlkDev *blkdev)
|
|
|
|
+{
|
|
|
|
+ int enable;
|
|
|
|
+
|
|
|
|
+ blkdev->cache_unsafe = false;
|
|
|
|
+
|
2018-12-06 22:20:59 +01:00
|
|
|
+ if (xenstore_read_be_int(&blkdev->xendev, "suse-diskcache-disable-flush",
|
|
|
|
+ &enable) == 0) {
|
|
|
|
+ blkdev->cache_unsafe = !!enable;
|
|
|
|
+ }
|
2016-04-05 15:18:15 +02:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
static int blk_init(struct XenDevice *xendev)
|
|
|
|
{
|
|
|
|
struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev);
|
2018-12-06 22:20:59 +01:00
|
|
|
@@ -717,6 +731,7 @@ static int blk_init(struct XenDevice *xendev)
|
2017-08-31 00:22:50 +02:00
|
|
|
MAX_RING_PAGE_ORDER);
|
2016-04-05 15:18:15 +02:00
|
|
|
|
|
|
|
blk_parse_discard(blkdev);
|
|
|
|
+ blk_parse_cache_unsafe(blkdev);
|
|
|
|
|
|
|
|
g_free(directiosafe);
|
|
|
|
return 0;
|
2018-12-06 22:20:59 +01:00
|
|
|
@@ -764,6 +779,10 @@ static int blk_connect(struct XenDevice *xendev)
|
2016-04-05 15:18:15 +02:00
|
|
|
qflags |= BDRV_O_UNMAP;
|
|
|
|
}
|
|
|
|
|
2018-12-06 22:20:59 +01:00
|
|
|
+ if (blkdev->cache_unsafe) {
|
2016-04-05 15:18:15 +02:00
|
|
|
+ qflags |= BDRV_O_NO_FLUSH;
|
2018-12-06 22:20:59 +01:00
|
|
|
+ }
|
2016-04-05 15:18:15 +02:00
|
|
|
+
|
|
|
|
/* init qemu block driver */
|
2018-08-22 16:58:18 +02:00
|
|
|
index = (xendev->dev - 202 * 256) / 16;
|
2016-04-05 15:18:15 +02:00
|
|
|
blkdev->dinfo = drive_get(IF_XEN, 0, index);
|