From patchwork Mon Jun 20 10:43:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5byg5qyi?= X-Patchwork-Id: 9187105 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7527C607D1 for ; Mon, 20 Jun 2016 10:44:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5FD6F23B24 for ; Mon, 20 Jun 2016 10:44:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 54A92267F1; Mon, 20 Jun 2016 10:44:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 91E3623B24 for ; Mon, 20 Jun 2016 10:44:54 +0000 (UTC) Received: from localhost ([::1]:42556 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEwhJ-0001d1-Md for patchwork-qemu-devel@patchwork.kernel.org; Mon, 20 Jun 2016 06:44:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49351) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEwfY-000827-VS for qemu-devel@nongnu.org; Mon, 20 Jun 2016 06:43:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bEwfV-00060Z-2n for qemu-devel@nongnu.org; Mon, 20 Jun 2016 06:43:04 -0400 Received: from m0.chinacmail.com ([220.231.160.40]:57275) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEwfU-0005sM-Ak for qemu-devel@nongnu.org; Mon, 20 Jun 2016 06:43:00 -0400 Received: from smtp.h0.chinacmail.com ([127.0.0.1]) by m0.chinacmail.com (ESTMP @chinac.com) with ESMTP id 8077.235.1466419369.477031; for ; Mon, 20 Jun 2016 18:42:50 +0800 X-HY-TRUST: YES X-HY-SID: 8077.235.1466419369.477031 X-HY-SPAM: NO Received: by smtp.h0.chinacmail.com (Postfix, from userid 12301) id 433ACC0F88; Mon, 20 Jun 2016 18:42:49 +0800 (CST) Received: from [10.10.10.11] (unknown [218.90.171.226]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.h0.chinacmail.com (Postfix) with ESMTPSA id C9043C0F84; Mon, 20 Jun 2016 18:42:48 +0800 (CST) From: =?gb2312?B?1cW7tg==?= Message-Id: <2BCF477A-579C-45A0-8A11-8B5AC3D2B7B2@chinac.com> Date: Mon, 20 Jun 2016 18:43:01 +0800 To: jdurgin@redhat.com, kwolf@redhat.com, qemu-devel@nongnu.org Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) X-Mailer: Apple Mail (2.2104) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 220.231.160.40 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 Subject: [Qemu-devel] [PATCH-Block] rbd:disable we if rbd cache is off X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP rbd: disable wce if rbd cache is off wce will be enabled when cachemode is 'none', disable wce will NOT impact data consistency but will extremely improve the guest os db workload (write/fsync) performance since fsync will wait all in-flight io to complete introduced by 'rbd asynchronous flush' commit. Signed-off-by: Huan Zhang diff --git a/block/block-backend.c b/block/block-backend.c index 34500e6..ce1aff4 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -76,7 +76,7 @@ static const AIOCBInfo block_backend_aiocb_info = { }; static void drive_info_del(DriveInfo *dinfo); -static BlockBackend *bdrv_first_blk(BlockDriverState *bs); +BlockBackend *bdrv_first_blk(BlockDriverState *bs); /* All BlockBackends */ static QTAILQ_HEAD(, BlockBackend) block_backends = @@ -389,7 +389,7 @@ BlockDriverState *blk_bs(BlockBackend *blk) return blk->root ? blk->root->bs : NULL; } -static BlockBackend *bdrv_first_blk(BlockDriverState *bs) +BlockBackend *bdrv_first_blk(BlockDriverState *bs) { BdrvChild *child; QLIST_FOREACH(child, &bs->parents, next_parent) { diff --git a/block/rbd.c b/block/rbd.c index 5226b6f..514cd98 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -20,6 +20,7 @@ #include "qemu/cutils.h" #include +#include "sysemu/block-backend.h" /* * When specifying the image filename use: @@ -547,7 +548,16 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags, * be set up, fall back to no caching. */ if (flags & BDRV_O_NOCACHE) { + /* + * Disable Guest WCE if rbd cache is off. + * disable wce will NOT impact data consistency bu will + * extremely improve the db workload(write/fsync) performance. + */ rados_conf_set(s->cluster, "rbd_cache", "false"); + if (bdrv_has_blk(bs)) { + blk_set_enable_write_cache(bdrv_first_blk(bs), false); + } + } else { rados_conf_set(s->cluster, "rbd_cache", "true"); } diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index c04af8e..9f9a34d 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -93,6 +93,7 @@ void monitor_remove_blk(BlockBackend *blk); BlockBackendPublic *blk_get_public(BlockBackend *blk); BlockBackend *blk_by_public(BlockBackendPublic *public); +BlockBackend *bdrv_first_blk(BlockDriverState *bs); BlockDriverState *blk_bs(BlockBackend *blk); void blk_remove_bs(BlockBackend *blk);