[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH-Block] rbd:disable we if rbd cache is off
From: |
张欢 |
Subject: |
[Qemu-devel] [PATCH-Block] rbd:disable we if rbd cache is off |
Date: |
Mon, 20 Jun 2016 18:43:01 +0800 |
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 <address@hidden>
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 <rbd/librbd.h>
+#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);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemu-devel] [PATCH-Block] rbd:disable we if rbd cache is off,
张欢 <=