|
|
21ab4e |
From 58d704a88da8ddcc71f4f53126449e696bbc9859 Mon Sep 17 00:00:00 2001
|
|
|
21ab4e |
From: Poornima G <pgurusid@redhat.com>
|
|
|
21ab4e |
Date: Mon, 12 Jun 2017 10:59:04 +0530
|
|
|
21ab4e |
Subject: [PATCH 503/509] readdir-ahead: Fix duplicate listing and cache size
|
|
|
21ab4e |
calculation
|
|
|
21ab4e |
|
|
|
21ab4e |
Issue:
|
|
|
21ab4e |
If a opendir is followed by a closedir without readdir, though
|
|
|
21ab4e |
the prefetched entries were freed, the freed size was not accounted
|
|
|
21ab4e |
in priv->rda_cache_size. Thus the cache limit will exceed if there
|
|
|
21ab4e |
are multiple opendir followed by closedir.
|
|
|
21ab4e |
|
|
|
21ab4e |
Fix:
|
|
|
21ab4e |
Fix the pric->rda_cache_size calculation. Also have removed the
|
|
|
21ab4e |
inode_ctx_size. Each perf xlator has its own cache limit that
|
|
|
21ab4e |
it works with. Also the inode_ctx size can change, if a forget/
|
|
|
21ab4e |
invalidate or any other factor triggers the inode_ctx size.
|
|
|
21ab4e |
|
|
|
21ab4e |
> Reviewed-on: https://review.gluster.org/17504
|
|
|
21ab4e |
> Smoke: Gluster Build System <jenkins@build.gluster.org>
|
|
|
21ab4e |
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
|
|
|
21ab4e |
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
|
|
|
21ab4e |
> Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
|
|
|
21ab4e |
> (cherry picked from commit e97c32ee9913969a726f8a8286cf714f907729d6)
|
|
|
21ab4e |
|
|
|
21ab4e |
Change-Id: I9707ec558076ce046e58a55989ec9513c70ea029
|
|
|
21ab4e |
BUG: 1437960
|
|
|
21ab4e |
Signed-off-by: Poornima G <pgurusid@redhat.com>
|
|
|
21ab4e |
Reviewed-on: https://code.engineering.redhat.com/gerrit/108887
|
|
|
21ab4e |
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
21ab4e |
---
|
|
|
21ab4e |
.../performance/readdir-ahead/src/readdir-ahead.c | 35 ++++++++++------------
|
|
|
21ab4e |
1 file changed, 16 insertions(+), 19 deletions(-)
|
|
|
21ab4e |
|
|
|
21ab4e |
diff --git a/xlators/performance/readdir-ahead/src/readdir-ahead.c b/xlators/performance/readdir-ahead/src/readdir-ahead.c
|
|
|
21ab4e |
index 4e7f2b9..8827b8b 100644
|
|
|
21ab4e |
--- a/xlators/performance/readdir-ahead/src/readdir-ahead.c
|
|
|
21ab4e |
+++ b/xlators/performance/readdir-ahead/src/readdir-ahead.c
|
|
|
21ab4e |
@@ -74,14 +74,21 @@ out:
|
|
|
21ab4e |
* Reset the tracking state of the context.
|
|
|
21ab4e |
*/
|
|
|
21ab4e |
static void
|
|
|
21ab4e |
-rda_reset_ctx(struct rda_fd_ctx *ctx)
|
|
|
21ab4e |
+rda_reset_ctx(xlator_t *this, struct rda_fd_ctx *ctx)
|
|
|
21ab4e |
{
|
|
|
21ab4e |
+ struct rda_priv *priv = NULL;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ priv = this->private;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
ctx->state = RDA_FD_NEW;
|
|
|
21ab4e |
ctx->cur_offset = 0;
|
|
|
21ab4e |
- ctx->cur_size = 0;
|
|
|
21ab4e |
ctx->next_offset = 0;
|
|
|
21ab4e |
ctx->op_errno = 0;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
gf_dirent_free(&ctx->entries);
|
|
|
21ab4e |
+ priv->rda_cache_size -= ctx->cur_size;
|
|
|
21ab4e |
+ ctx->cur_size = 0;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
if (ctx->xattrs) {
|
|
|
21ab4e |
dict_unref (ctx->xattrs);
|
|
|
21ab4e |
ctx->xattrs = NULL;
|
|
|
21ab4e |
@@ -114,7 +121,7 @@ __rda_fill_readdirp (xlator_t *this, gf_dirent_t *entries, size_t request_size,
|
|
|
21ab4e |
struct rda_fd_ctx *ctx)
|
|
|
21ab4e |
{
|
|
|
21ab4e |
gf_dirent_t *dirent, *tmp;
|
|
|
21ab4e |
- size_t dirent_size, size = 0, inodectx_size = 0;
|
|
|
21ab4e |
+ size_t dirent_size, size = 0;
|
|
|
21ab4e |
int32_t count = 0;
|
|
|
21ab4e |
struct rda_priv *priv = NULL;
|
|
|
21ab4e |
|
|
|
21ab4e |
@@ -125,15 +132,11 @@ __rda_fill_readdirp (xlator_t *this, gf_dirent_t *entries, size_t request_size,
|
|
|
21ab4e |
if (size + dirent_size > request_size)
|
|
|
21ab4e |
break;
|
|
|
21ab4e |
|
|
|
21ab4e |
- inodectx_size = 0;
|
|
|
21ab4e |
-
|
|
|
21ab4e |
- inode_ctx_del (dirent->inode, this, (void *)&inodectx_size);
|
|
|
21ab4e |
-
|
|
|
21ab4e |
size += dirent_size;
|
|
|
21ab4e |
list_del_init(&dirent->list);
|
|
|
21ab4e |
ctx->cur_size -= dirent_size;
|
|
|
21ab4e |
|
|
|
21ab4e |
- priv->rda_cache_size -= (dirent_size + inodectx_size);
|
|
|
21ab4e |
+ priv->rda_cache_size -= dirent_size;
|
|
|
21ab4e |
|
|
|
21ab4e |
list_add_tail(&dirent->list, &entries->list);
|
|
|
21ab4e |
ctx->cur_offset = dirent->d_off;
|
|
|
21ab4e |
@@ -205,7 +208,7 @@ rda_readdirp(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
|
|
|
21ab4e |
* completed, reset the context and kickstart the filler again.
|
|
|
21ab4e |
*/
|
|
|
21ab4e |
if (!off && (ctx->state & RDA_FD_EOD) && (ctx->cur_size == 0)) {
|
|
|
21ab4e |
- rda_reset_ctx(ctx);
|
|
|
21ab4e |
+ rda_reset_ctx(this, ctx);
|
|
|
21ab4e |
/*
|
|
|
21ab4e |
* Unref and discard the 'list of xattrs to be fetched'
|
|
|
21ab4e |
* stored during opendir call. This is done above - inside
|
|
|
21ab4e |
@@ -251,6 +254,8 @@ rda_readdirp(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
|
|
|
21ab4e |
|
|
|
21ab4e |
if (!(ctx->state & RDA_FD_RUNNING)) {
|
|
|
21ab4e |
fill = 1;
|
|
|
21ab4e |
+ if (!ctx->xattrs)
|
|
|
21ab4e |
+ ctx->xattrs = dict_ref (xdata);
|
|
|
21ab4e |
ctx->state |= RDA_FD_RUNNING;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
}
|
|
|
21ab4e |
@@ -290,7 +295,6 @@ rda_fill_fd_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
|
|
21ab4e |
struct rda_fd_ctx *ctx = local->ctx;
|
|
|
21ab4e |
struct rda_priv *priv = this->private;
|
|
|
21ab4e |
int fill = 1;
|
|
|
21ab4e |
- size_t inodectx_size = 0;
|
|
|
21ab4e |
size_t dirent_size = 0;
|
|
|
21ab4e |
int ret = 0;
|
|
|
21ab4e |
gf_boolean_t serve = _gf_false;
|
|
|
21ab4e |
@@ -317,17 +321,10 @@ rda_fill_fd_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
|
|
21ab4e |
list_add_tail(&dirent->list, &ctx->entries.list);
|
|
|
21ab4e |
|
|
|
21ab4e |
dirent_size = gf_dirent_size (dirent->d_name);
|
|
|
21ab4e |
- inodectx_size = 0;
|
|
|
21ab4e |
-
|
|
|
21ab4e |
- if (dirent->inode) {
|
|
|
21ab4e |
- inodectx_size = inode_ctx_size (dirent->inode);
|
|
|
21ab4e |
- inode_ctx_set (dirent->inode, this,
|
|
|
21ab4e |
- (void *)inodectx_size);
|
|
|
21ab4e |
- }
|
|
|
21ab4e |
|
|
|
21ab4e |
ctx->cur_size += dirent_size;
|
|
|
21ab4e |
|
|
|
21ab4e |
- priv->rda_cache_size += (dirent_size + inodectx_size);
|
|
|
21ab4e |
+ priv->rda_cache_size += dirent_size;
|
|
|
21ab4e |
|
|
|
21ab4e |
ctx->next_offset = dirent->d_off;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
@@ -592,7 +589,7 @@ rda_releasedir(xlator_t *this, fd_t *fd)
|
|
|
21ab4e |
if (!ctx)
|
|
|
21ab4e |
return 0;
|
|
|
21ab4e |
|
|
|
21ab4e |
- rda_reset_ctx(ctx);
|
|
|
21ab4e |
+ rda_reset_ctx(this, ctx);
|
|
|
21ab4e |
|
|
|
21ab4e |
if (ctx->fill_frame)
|
|
|
21ab4e |
STACK_DESTROY(ctx->fill_frame->root);
|
|
|
21ab4e |
--
|
|
|
21ab4e |
1.8.3.1
|
|
|
21ab4e |
|