1 Signed-off-by: Josh Durgin <address@hidden>
3 block/rbd.c | 19 +++++++++++++++++++
4 1 files changed, 19 insertions(+), 0 deletions(-)
6 diff --git a/block/rbd.c b/block/rbd.c
7 index 1280d66..eebc334 100644
10 @@ -476,6 +476,25 @@ static int qemu_rbd_open(BlockDriverState *bs, const char *filename, int flags)
11 s->snap = g_strdup(snap_buf);
15 + * Fallback to more conservative semantics if setting cache
16 + * options fails. Ignore errors from setting rbd_cache because the
17 + * only possible error is that the option does not exist, and
18 + * librbd defaults to no caching. If write through caching cannot
19 + * be set up, fall back to no caching.
21 + if (flags & BDRV_O_NOCACHE) {
22 + rados_conf_set(s->cluster, "rbd_cache", "false");
24 + rados_conf_set(s->cluster, "rbd_cache", "true");
25 + if (!(flags & BDRV_O_CACHE_WB)) {
26 + r = rados_conf_set(s->cluster, "rbd_cache_max_dirty", "0");
28 + rados_conf_set(s->cluster, "rbd_cache", "false");
33 if (strstr(conf, "conf=") == NULL) {
34 /* try default location, but ignore failure */
35 rados_conf_read_file(s->cluster, NULL);