From a87abbd42e8b02deabbdfe290b16ed0d2f2e4c45 Mon Sep 17 00:00:00 2001 From: Ashish Pandey Date: Mon, 18 Sep 2017 14:07:31 +0530 Subject: cluster/ec: Keep last written strip in in-memory cache Problem: Consider an EC volume with configuration 4 + 2. The stripe size for this would be 512 * 4 = 2048. That means, 2048 bytes of user data stored in one stripe. Let's say 2048 + 512 = 2560 bytes are already written on this volume. 512 Bytes would be in second stripe. Now, if there are sequential writes with offset 2560 and of size 1 Byte, we have to read the whole stripe, encode it with 1 Byte and then again have to write it back. Next, write with offset 2561 and size of 1 Byte will again READ-MODIFY-WRITE the whole stripe. This is causing bad performance because of lots of READ request travelling over the network. There are some tools and scenario's where such kind of load is coming and users are not aware of that. Example: fio and zip Solution: One possible solution to deal with this issue is to keep last stripe in memory. This way, we need not to read it again and we can save READ fop going over the network. Considering the above example, we have to keep last 2048 bytes (maximum) in memory per file. Change-Id: I3f95e6fc3ff81953646d374c445a40c6886b0b85 BUG: 1471753 Signed-off-by: Ashish Pandey --- xlators/cluster/ec/src/ec-helpers.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'xlators/cluster/ec/src/ec-helpers.c') diff --git a/xlators/cluster/ec/src/ec-helpers.c b/xlators/cluster/ec/src/ec-helpers.c index 122fe24b5d3..fe610748f0f 100644 --- a/xlators/cluster/ec/src/ec-helpers.c +++ b/xlators/cluster/ec/src/ec-helpers.c @@ -706,6 +706,17 @@ void ec_owner_copy(call_frame_t *frame, gf_lkowner_t *owner) lk_owner_copy (&frame->root->lk_owner, owner); } +static void +ec_stripe_cache_init (ec_t *ec, ec_inode_t *ctx) +{ + ec_stripe_list_t *stripe_cache = NULL; + + stripe_cache = &(ctx->stripe_cache); + if (stripe_cache->max == 0) { + stripe_cache->max = ec->stripe_cache; + } +} + ec_inode_t * __ec_inode_get(inode_t * inode, xlator_t * xl) { ec_inode_t * ctx = NULL; @@ -718,7 +729,7 @@ ec_inode_t * __ec_inode_get(inode_t * inode, xlator_t * xl) { memset(ctx, 0, sizeof(*ctx)); INIT_LIST_HEAD(&ctx->heal); - + INIT_LIST_HEAD(&ctx->stripe_cache.lru); value = (uint64_t)(uintptr_t)ctx; if (__inode_ctx_set(inode, xl, &value) != 0) { @@ -732,6 +743,8 @@ ec_inode_t * __ec_inode_get(inode_t * inode, xlator_t * xl) { ctx = (ec_inode_t *)(uintptr_t)value; } + if (ctx) + ec_stripe_cache_init (xl->private, ctx); return ctx; } -- cgit