[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v2 06/18] block/pcache: skip large aio read
From: |
Pavel Butsykin |
Subject: |
[Qemu-block] [PATCH v2 06/18] block/pcache: skip large aio read |
Date: |
Fri, 30 Dec 2016 17:31:30 +0300 |
This change will allow more efficient use of cache memory and filter the case
for which the pcache isn't efficient. We skip requests that are not required in
the optimization and thereby reducing the number of unnecessary readaheads.
Signed-off-by: Pavel Butsykin <address@hidden>
---
block/pcache.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/block/pcache.c b/block/pcache.c
index 296ae382b0..1f3200af63 100644
--- a/block/pcache.c
+++ b/block/pcache.c
@@ -16,6 +16,7 @@
#include "qemu/rbcache.h"
#define PCACHE_OPT_STATS_SIZE "pcache-stats-size"
+#define PCACHE_OPT_MAX_AIO_SIZE "pcache-max-aio-size"
static QemuOptsList runtime_opts = {
.name = "pcache",
@@ -26,15 +27,23 @@ static QemuOptsList runtime_opts = {
.type = QEMU_OPT_SIZE,
.help = "Total volume of requests for statistics",
},
+ {
+ .name = PCACHE_OPT_MAX_AIO_SIZE,
+ .type = QEMU_OPT_SIZE,
+ .help = "Maximum size of aio which is handled by pcache",
+ },
{ /* end of list */ }
},
};
+#define KB_BITS 10
#define MB_BITS 20
#define PCACHE_DEFAULT_STATS_SIZE (3 << MB_BITS)
+#define PCACHE_DEFAULT_MAX_AIO_SIZE (64 << KB_BITS)
typedef struct BDRVPCacheState {
RBCache *req_stats;
+ uint64_t max_aio_size;
} BDRVPCacheState;
static coroutine_fn int pcache_co_preadv(BlockDriverState *bs, uint64_t offset,
@@ -43,7 +52,9 @@ static coroutine_fn int pcache_co_preadv(BlockDriverState
*bs, uint64_t offset,
{
BDRVPCacheState *s = bs->opaque;
- rbcache_search_and_insert(s->req_stats, offset, bytes);
+ if (s->max_aio_size >= bytes) {
+ rbcache_search_and_insert(s->req_stats, offset, bytes);
+ }
return bdrv_co_preadv(bs->file, offset, bytes, qiov, flags);
}
@@ -60,6 +71,9 @@ static void pcache_state_init(QemuOpts *opts, BDRVPCacheState
*s)
uint64_t stats_size = qemu_opt_get_size(opts, PCACHE_OPT_STATS_SIZE,
PCACHE_DEFAULT_STATS_SIZE);
s->req_stats = rbcache_create(NULL, NULL, stats_size, RBCACHE_FIFO, s);
+
+ s->max_aio_size = qemu_opt_get_size(opts, PCACHE_OPT_MAX_AIO_SIZE,
+ PCACHE_DEFAULT_MAX_AIO_SIZE);
}
static int pcache_file_open(BlockDriverState *bs, QDict *options, int flags,
--
2.11.0
- [Qemu-block] [PATCH v2 02/18] util/rbtree: add rbtree from linux kernel, (continued)
- [Qemu-block] [PATCH v2 02/18] util/rbtree: add rbtree from linux kernel, Pavel Butsykin, 2016/12/30
- [Qemu-block] [PATCH v2 18/18] block/pcache: add tracepoints, Pavel Butsykin, 2016/12/30
- [Qemu-block] [PATCH v2 15/18] block/pcache: pick up parts of the cache, Pavel Butsykin, 2016/12/30
- [Qemu-block] [PATCH v2 03/18] util/rbcache: range-based cache core, Pavel Butsykin, 2016/12/30
- [Qemu-block] [PATCH v2 08/18] block/pcache: add AIO readahead, Pavel Butsykin, 2016/12/30
- [Qemu-block] [PATCH v2 07/18] block/pcache: updating statistics for overlapping requests, Pavel Butsykin, 2016/12/30
- [Qemu-block] [PATCH v2 14/18] block/pcache: up-to-date cache for removed nodes, Pavel Butsykin, 2016/12/30
- [Qemu-block] [PATCH v2 17/18] qapi: allow blockdev-add for pcache, Pavel Butsykin, 2016/12/30
- [Qemu-block] [PATCH v2 05/18] block/pcache: statistics collection read requests, Pavel Butsykin, 2016/12/30
- [Qemu-block] [PATCH v2 10/18] block/pcache: cache invalidation on write requests, Pavel Butsykin, 2016/12/30
- [Qemu-block] [PATCH v2 06/18] block/pcache: skip large aio read,
Pavel Butsykin <=
- [Qemu-block] [PATCH v2 04/18] tests/test-rbcache: add test cases, Pavel Butsykin, 2016/12/30
- [Qemu-block] [PATCH v2 01/18] block/pcache: empty pcache driver filter, Pavel Butsykin, 2016/12/30
- [Qemu-block] [PATCH v2 09/18] block/pcache: skip readahead for unallocated clusters, Pavel Butsykin, 2016/12/30
- [Qemu-block] [PATCH v2 13/18] block/pcache: write through, Pavel Butsykin, 2016/12/30