]>
Commit | Line | Data |
---|---|---|
ef808895 AD |
1 | Signed-off-by: Josh Durgin <address@hidden> |
2 | --- | |
3 | block/rbd.c | 19 +++++++++++++++++++ | |
4 | 1 files changed, 19 insertions(+), 0 deletions(-) | |
5 | ||
6 | diff --git a/block/rbd.c b/block/rbd.c | |
7 | index 1280d66..eebc334 100644 | |
8 | --- a/block/rbd.c | |
9 | +++ b/block/rbd.c | |
10 | @@ -476,6 +476,25 @@ static int qemu_rbd_open(BlockDriverState *bs, const char *filename, int flags) | |
11 | s->snap = g_strdup(snap_buf); | |
12 | } | |
13 | ||
14 | + /* | |
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. | |
20 | + */ | |
21 | + if (flags & BDRV_O_NOCACHE) { | |
22 | + rados_conf_set(s->cluster, "rbd_cache", "false"); | |
23 | + } else { | |
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"); | |
27 | + if (r < 0) { | |
28 | + rados_conf_set(s->cluster, "rbd_cache", "false"); | |
29 | + } | |
30 | + } | |
31 | + } | |
32 | + | |
33 | if (strstr(conf, "conf=") == NULL) { | |
34 | /* try default location, but ignore failure */ | |
35 | rados_conf_read_file(s->cluster, NULL); | |
36 | -- | |
37 | 1.7.5.4 |