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

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