@@ -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) {
@@ -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");
}
@@ -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);
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 <zhanghuan@chinac.com>