21ab4e
From a68b0bf00a1f646f25cdedecd084e9e02afc5943 Mon Sep 17 00:00:00 2001
21ab4e
From: Poornima G <pgurusid@redhat.com>
21ab4e
Date: Mon, 27 Mar 2017 11:38:28 +0530
21ab4e
Subject: [PATCH 370/375] reddir-ahead: Fix EOD propagation problem
21ab4e
21ab4e
In readdirp fop, op_errno is overloaded to indicate the EOD detection.
21ab4e
If op_errno contains ENOENT, then it indicates that there are no
21ab4e
further entries pending read in the directory. Currently NFS uses the
21ab4e
ENOENT to identify the EOD.
21ab4e
21ab4e
Issue:
21ab4e
NFS clients issues a 4K buffer for readdirp, readdir-ahead converts it
21ab4e
to 128K buffer as its reading ahead. If there are 100 entries in the
21ab4e
bricks, 128K can get all 100 and store in readdir-ahead, but only 23
21ab4e
entries that can be fit in 4K will be sent to NFS. Since the whole
21ab4e
100 entries were read from brick, the op_errno is set to ENOENT, and
21ab4e
the op_errno is propagated as is when sent to NFS. Hence NFS client
21ab4e
in reading 23 entries thinks it reached EOD.
21ab4e
21ab4e
Solution:
21ab4e
Do not propogate ENOENT errno, unless all the entries are read
21ab4e
from the readdir ahead buffer.
21ab4e
21ab4e
> Reviewed-on: https://review.gluster.org/16953
21ab4e
> Smoke: Gluster Build System <jenkins@build.gluster.org>
21ab4e
> Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
21ab4e
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
21ab4e
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
21ab4e
> Signed-off-by: Poornima G <pgurusid@redhat.com>
21ab4e
21ab4e
Change-Id: I4f173a77b21ab9e98ae35e291a45b8fc0cde65bd
21ab4e
BUG: 1427096
21ab4e
Signed-off-by: Poornima G <pgurusid@redhat.com>
21ab4e
Reviewed-on: https://code.engineering.redhat.com/gerrit/102516
21ab4e
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
21ab4e
---
21ab4e
 xlators/performance/readdir-ahead/src/readdir-ahead.c | 8 ++++++++
21ab4e
 1 file changed, 8 insertions(+)
21ab4e
21ab4e
diff --git a/xlators/performance/readdir-ahead/src/readdir-ahead.c b/xlators/performance/readdir-ahead/src/readdir-ahead.c
21ab4e
index 13e3a43..f95be50 100644
21ab4e
--- a/xlators/performance/readdir-ahead/src/readdir-ahead.c
21ab4e
+++ b/xlators/performance/readdir-ahead/src/readdir-ahead.c
21ab4e
@@ -236,6 +236,10 @@ rda_readdirp(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
21ab4e
                 ret = __rda_serve_readdirp (this, ctx, size, &entries,
21ab4e
                                             &op_errno);
21ab4e
                 serve = _gf_true;
21ab4e
+
21ab4e
+                if (op_errno == ENOENT && !((ctx->state & RDA_FD_EOD) &&
21ab4e
+                                            (ctx->cur_size == 0)))
21ab4e
+                        op_errno = 0;
21ab4e
         } else {
21ab4e
                 ctx->stub = fop_readdirp_stub (frame, NULL, fd, size, off,
21ab4e
                                                xdata);
21ab4e
@@ -380,6 +384,10 @@ out:
21ab4e
 		ctx->fill_frame = NULL;
21ab4e
 	}
21ab4e
 
21ab4e
+        if (op_errno == ENOENT && !((ctx->state & RDA_FD_EOD) &&
21ab4e
+                                    (ctx->cur_size == 0)))
21ab4e
+                op_errno = 0;
21ab4e
+
21ab4e
 	UNLOCK(&ctx->lock);
21ab4e
 
21ab4e
         if (serve) {
21ab4e
-- 
21ab4e
1.8.3.1
21ab4e