From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:44788) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfWf9-0000x6-HO for qemu-devel@nongnu.org; Fri, 15 Jun 2012 09:34:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SfWf2-0004i4-T5 for qemu-devel@nongnu.org; Fri, 15 Jun 2012 09:34:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8581) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfWf2-0004hf-L4 for qemu-devel@nongnu.org; Fri, 15 Jun 2012 09:34:00 -0400 From: Kevin Wolf Date: Fri, 15 Jun 2012 15:33:12 +0200 Message-Id: <1339767219-24297-13-git-send-email-kwolf@redhat.com> In-Reply-To: <1339767219-24297-1-git-send-email-kwolf@redhat.com> References: <1339767219-24297-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 12/39] rbd: hook up cache options List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Josh Durgin Writeback caching was added in Ceph 0.46, and writethrough will be in 0.47. These are controlled by general config options, so there's no need to check for librbd version. Signed-off-by: Josh Durgin Signed-off-by: Kevin Wolf --- block/rbd.c | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/block/rbd.c b/block/rbd.c index 1280d66..eebc334 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -476,6 +476,25 @@ static int qemu_rbd_open(BlockDriverState *bs, const char *filename, int flags) s->snap = g_strdup(snap_buf); } + /* + * Fallback to more conservative semantics if setting cache + * options fails. Ignore errors from setting rbd_cache because the + * only possible error is that the option does not exist, and + * librbd defaults to no caching. If write through caching cannot + * be set up, fall back to no caching. + */ + if (flags & BDRV_O_NOCACHE) { + rados_conf_set(s->cluster, "rbd_cache", "false"); + } else { + rados_conf_set(s->cluster, "rbd_cache", "true"); + if (!(flags & BDRV_O_CACHE_WB)) { + r = rados_conf_set(s->cluster, "rbd_cache_max_dirty", "0"); + if (r < 0) { + rados_conf_set(s->cluster, "rbd_cache", "false"); + } + } + } + if (strstr(conf, "conf=") == NULL) { /* try default location, but ignore failure */ rados_conf_read_file(s->cluster, NULL); -- 1.7.6.5