From patchwork Thu May 17 20:42:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Durgin X-Patchwork-Id: 160026 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 491BAB6FDA for ; Fri, 18 May 2012 08:24:27 +1000 (EST) Received: from localhost ([::1]:55074 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SV97Q-0006QE-HK for incoming@patchwork.ozlabs.org; Thu, 17 May 2012 18:24:24 -0400 Received: from eggs.gnu.org ([208.118.235.92]:40538) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SV7Xm-0000xt-UP for qemu-devel@nongnu.org; Thu, 17 May 2012 16:43:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SV7Xl-0007pK-6g for qemu-devel@nongnu.org; Thu, 17 May 2012 16:43:30 -0400 Received: from mail.hq.newdream.net ([66.33.206.127]:53969) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SV7Xl-0007of-0j for qemu-devel@nongnu.org; Thu, 17 May 2012 16:43:29 -0400 Received: from mail.hq.newdream.net (localhost [127.0.0.1]) by mail.hq.newdream.net (Postfix) with ESMTP id 275F624838; Thu, 17 May 2012 13:43:33 -0700 (PDT) Received: from plana62.front.sepia.ceph.com (ip-64-90-32-34.dreamhost.com [64.90.32.34]) by mail.hq.newdream.net (Postfix) with ESMTPSA id 110D32454A; Thu, 17 May 2012 13:43:33 -0700 (PDT) From: Josh Durgin To: qemu-devel@nongnu.org Date: Thu, 17 May 2012 13:42:29 -0700 Message-Id: <1337287349-7664-1-git-send-email-josh.durgin@inktank.com> X-Mailer: git-send-email 1.7.5.4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 66.33.206.127 X-Mailman-Approved-At: Thu, 17 May 2012 18:24:17 -0400 Cc: kwolf@redhat.com Subject: [Qemu-devel] [PATCH] rbd: hook up cache options X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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);