diff mbox

[18/20] block: Remove bdrv_parse_cache_flags()

Message ID 1458325289-17848-19-git-send-email-kwolf@redhat.com
State New
Headers show

Commit Message

Kevin Wolf March 18, 2016, 6:21 p.m. UTC
All users are converted to bdrv_parse_cache_mode() now.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block.c               | 29 +++++++----------------------
 include/block/block.h |  1 -
 2 files changed, 7 insertions(+), 23 deletions(-)

Comments

Max Reitz March 26, 2016, 9:06 p.m. UTC | #1
On 18.03.2016 19:21, Kevin Wolf wrote:
> All users are converted to bdrv_parse_cache_mode() now.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  block.c               | 29 +++++++----------------------
>  include/block/block.h |  1 -
>  2 files changed, 7 insertions(+), 23 deletions(-)

Reviewed-by: Max Reitz <mreitz@redhat.com>
diff mbox

Patch

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,