From patchwork Fri Mar 18 18:21:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 8623071 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 35B74C0553 for ; Fri, 18 Mar 2016 18:31:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EF3C320225 for ; Fri, 18 Mar 2016 18:31:34 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 3AA88201FE for ; Fri, 18 Mar 2016 18:31:34 +0000 (UTC) Received: from localhost ([::1]:45655 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agzBN-0004zI-IV for patchwork-qemu-devel@patchwork.kernel.org; Fri, 18 Mar 2016 14:31:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36834) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agz2I-0004Y9-8f for qemu-devel@nongnu.org; Fri, 18 Mar 2016 14:22:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1agz2H-0007Gi-BP for qemu-devel@nongnu.org; Fri, 18 Mar 2016 14:22:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33873) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agz2D-0007Er-OR; Fri, 18 Mar 2016 14:22:05 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 67A8B689; Fri, 18 Mar 2016 18:22:05 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-83.ams2.redhat.com [10.36.116.83]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2IILZO9021202; Fri, 18 Mar 2016 14:22:04 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 18 Mar 2016 19:21:27 +0100 Message-Id: <1458325289-17848-19-git-send-email-kwolf@redhat.com> In-Reply-To: <1458325289-17848-1-git-send-email-kwolf@redhat.com> References: <1458325289-17848-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-devel] [PATCH 18/20] block: Remove bdrv_parse_cache_flags() 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP All users are converted to bdrv_parse_cache_mode() now. Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --- block.c | 29 +++++++---------------------- include/block/block.h | 1 - 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/block.c b/block.c index 3775e65..7cae704 100644 --- a/block.c +++ b/block.c @@ -639,21 +639,23 @@ int bdrv_parse_discard_flags(const char *mode, int *flags) * * Return 0 on success, -1 if the cache mode was invalid. */ -int bdrv_parse_cache_flags(const char *mode, int *flags) +int bdrv_parse_cache_mode(const char *mode, int *flags, bool *writethrough) { *flags &= ~BDRV_O_CACHE_MASK; if (!strcmp(mode, "off") || !strcmp(mode, "none")) { - *flags |= BDRV_O_NOCACHE | BDRV_O_CACHE_WB; + *writethrough = false; + *flags |= BDRV_O_NOCACHE; } else if (!strcmp(mode, "directsync")) { + *writethrough = true; *flags |= BDRV_O_NOCACHE; } else if (!strcmp(mode, "writeback")) { - *flags |= BDRV_O_CACHE_WB; + *writethrough = false; } else if (!strcmp(mode, "unsafe")) { - *flags |= BDRV_O_CACHE_WB; + *writethrough = false; *flags |= BDRV_O_NO_FLUSH; } else if (!strcmp(mode, "writethrough")) { - /* this is the default */ + *writethrough = true; } else { return -1; } @@ -661,23 +663,6 @@ int bdrv_parse_cache_flags(const char *mode, int *flags) return 0; } -int bdrv_parse_cache_mode(const char *mode, int *flags, bool *writethrough) -{ - int ret = bdrv_parse_cache_flags(mode, flags); - if (ret < 0) { - return ret; - } - - if (*flags & BDRV_O_CACHE_WB) { - *flags &= ~BDRV_O_CACHE_WB; - *writethrough = false; - } else { - *writethrough = true; - } - - return 0; -} - /* * Returns the options and flags that a temporary snapshot should get, based on * the originally requested flags (the originally requested image will have diff --git a/include/block/block.h b/include/block/block.h index 1b8a1c7..c69204a 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -206,7 +206,6 @@ void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top); void bdrv_replace_in_backing_chain(BlockDriverState *old, BlockDriverState *new); -int bdrv_parse_cache_flags(const char *mode, int *flags); int bdrv_parse_cache_mode(const char *mode, int *flags, bool *writethrough); int bdrv_parse_discard_flags(const char *mode, int *flags); BdrvChild *bdrv_open_child(const char *filename,