thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-rbd-make-qemu-s-cache-setting-override-any-ceph-sett.patch

9ae3a8
From 23bc583f18eb8ffc28604a4ae42e2f7a55b31c3e Mon Sep 17 00:00:00 2001
9ae3a8
From: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
Date: Thu, 5 Nov 2015 15:20:57 +0100
9ae3a8
Subject: [PATCH 2/6] rbd: make qemu's cache setting override any ceph setting
9ae3a8
9ae3a8
Message-id: <1446736858-29005-2-git-send-email-stefanha@redhat.com>
9ae3a8
Patchwork-id: 68293
9ae3a8
O-Subject: [RHEL-7.2.z qemu-kvm PATCH 1/2] rbd: make qemu's cache setting override any ceph setting
9ae3a8
Bugzilla: 1277248
9ae3a8
RH-Acked-by: Max Reitz <mreitz@redhat.com>
9ae3a8
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
9ae3a8
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
9ae3a8
From: Josh Durgin <jdurgin@redhat.com>
9ae3a8
9ae3a8
To be safe, when cache=none is used ceph settings should not be able
9ae3a8
to override it to turn on caching. This was previously possible with
9ae3a8
rbd_cache=true in the rbd device configuration or a ceph configuration
9ae3a8
file. Similarly, rbd settings could have turned off caching when qemu
9ae3a8
requested it, although this would just be a performance problem.
9ae3a8
9ae3a8
Fix this by changing rbd's cache setting to match qemu after all other
9ae3a8
ceph settings have been applied.
9ae3a8
9ae3a8
Signed-off-by: Josh Durgin <jdurgin@redhat.com>
9ae3a8
Reviewed-by: Jeff Cody <jcody@redhat.com>
9ae3a8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
(cherry picked from commit 99a3c89d5d538dc6c360e35dffb797cfe06e9cda)
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
9ae3a8
Conflicts:
9ae3a8
	block/rbd.c - downstream doesn't use Error **errp
9ae3a8
9ae3a8
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
---
9ae3a8
 block/rbd.c | 26 +++++++++++++-------------
9ae3a8
 1 file changed, 13 insertions(+), 13 deletions(-)
9ae3a8
9ae3a8
diff --git a/block/rbd.c b/block/rbd.c
9ae3a8
index 4eea455..11a39ac 100644
9ae3a8
--- a/block/rbd.c
9ae3a8
+++ b/block/rbd.c
9ae3a8
@@ -501,19 +501,6 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
9ae3a8
         s->snap = g_strdup(snap_buf);
9ae3a8
     }
9ae3a8
 
9ae3a8
-    /*
9ae3a8
-     * Fallback to more conservative semantics if setting cache
9ae3a8
-     * options fails. Ignore errors from setting rbd_cache because the
9ae3a8
-     * only possible error is that the option does not exist, and
9ae3a8
-     * librbd defaults to no caching. If write through caching cannot
9ae3a8
-     * be set up, fall back to no caching.
9ae3a8
-     */
9ae3a8
-    if (flags & BDRV_O_NOCACHE) {
9ae3a8
-        rados_conf_set(s->cluster, "rbd_cache", "false");
9ae3a8
-    } else {
9ae3a8
-        rados_conf_set(s->cluster, "rbd_cache", "true");
9ae3a8
-    }
9ae3a8
-
9ae3a8
     if (strstr(conf, "conf=") == NULL) {
9ae3a8
         /* try default location, but ignore failure */
9ae3a8
         rados_conf_read_file(s->cluster, NULL);
9ae3a8
@@ -527,6 +514,19 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
9ae3a8
         }
9ae3a8
     }
9ae3a8
 
9ae3a8
+    /*
9ae3a8
+     * Fallback to more conservative semantics if setting cache
9ae3a8
+     * options fails. Ignore errors from setting rbd_cache because the
9ae3a8
+     * only possible error is that the option does not exist, and
9ae3a8
+     * librbd defaults to no caching. If write through caching cannot
9ae3a8
+     * be set up, fall back to no caching.
9ae3a8
+     */
9ae3a8
+    if (flags & BDRV_O_NOCACHE) {
9ae3a8
+        rados_conf_set(s->cluster, "rbd_cache", "false");
9ae3a8
+    } else {
9ae3a8
+        rados_conf_set(s->cluster, "rbd_cache", "true");
9ae3a8
+    }
9ae3a8
+
9ae3a8
     r = rados_connect(s->cluster);
9ae3a8
     if (r < 0) {
9ae3a8
         error_report("error connecting");
9ae3a8
-- 
9ae3a8
1.8.3.1
9ae3a8