d1681e
From 712e62721d7d95c05d87510eb1fbe5d12381e1ab Mon Sep 17 00:00:00 2001
d1681e
From: Raghavendra G <rgowdapp@redhat.com>
d1681e
Date: Mon, 18 Sep 2017 16:01:34 +0530
d1681e
Subject: [PATCH 111/128] cluster/dht: don't overfill the buffer in readdir(p)
d1681e
d1681e
Superflous dentries that cannot be fit in the buffer size provided by
d1681e
kernel are thrown away by fuse-bridge. This means,
d1681e
d1681e
* the next readdir(p) seen by readdir-ahead would have an offset of a
d1681e
dentry returned in a previous readdir(p) response. When readdir-ahead
d1681e
detects non-monotonic offset it turns itself off which can result in
d1681e
poor readdir performance.
d1681e
d1681e
* readdirp can be cpu-intensive on brick and there is no point to read
d1681e
 all those dentries just to be thrown away by fuse-bridge.
d1681e
d1681e
So, the best strategy would be to fill the buffer optimally - neither
d1681e
overfill nor underfill.
d1681e
d1681e
Change-Id: Idb3d85dd4c08fdc4526b2df801d49e69e439ba84
d1681e
BUG: 1264911
d1681e
Signed-off-by: Raghavendra G <rgowdapp@redhat.com>
d1681e
upstream patch: https://review.gluster.org/18312
d1681e
Reviewed-on: https://code.engineering.redhat.com/gerrit/126504
d1681e
Tested-by: RHGS Build Bot <nigelb@redhat.com>
d1681e
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
d1681e
---
d1681e
 xlators/cluster/dht/src/dht-common.c | 21 ++++++++++++++++++---
d1681e
 1 file changed, 18 insertions(+), 3 deletions(-)
d1681e
d1681e
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
d1681e
index f611278..b55cb36 100644
d1681e
--- a/xlators/cluster/dht/src/dht-common.c
d1681e
+++ b/xlators/cluster/dht/src/dht-common.c
d1681e
@@ -5238,6 +5238,13 @@ list:
d1681e
         }
d1681e
 
d1681e
 done:
d1681e
+        if ((op_ret == 0) && op_errno != ENOENT) {
d1681e
+                /* remaining buffer size is not enough to hold even one
d1681e
+                 * dentry
d1681e
+                 */
d1681e
+                goto unwind;
d1681e
+        }
d1681e
+
d1681e
         if ((count == 0) || (local && (local->filled < local->size))) {
d1681e
                 if ((next_offset == 0) || (op_errno == ENOENT)) {
d1681e
                         next_offset = 0;
d1681e
@@ -5268,8 +5275,8 @@ done:
d1681e
 
d1681e
                 STACK_WIND_COOKIE (frame, dht_readdirp_cbk, next_subvol,
d1681e
                                    next_subvol, next_subvol->fops->readdirp,
d1681e
-                                   local->fd, local->size, next_offset,
d1681e
-                                   local->xattr);
d1681e
+                                   local->fd, (local->size - local->filled),
d1681e
+                                   next_offset, local->xattr);
d1681e
                 return 0;
d1681e
         }
d1681e
 
d1681e
@@ -5359,6 +5366,13 @@ dht_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
d1681e
         }
d1681e
 
d1681e
 done:
d1681e
+        if ((op_ret == 0) && op_errno != ENOENT) {
d1681e
+                /* remaining buffer size is not enough to hold even one
d1681e
+                 * dentry
d1681e
+                 */
d1681e
+                goto unwind;
d1681e
+        }
d1681e
+
d1681e
         if ((count == 0) || (local && (local->filled < local->size))) {
d1681e
                 if ((op_ret <= 0) || (op_errno == ENOENT)) {
d1681e
                         next_subvol = dht_subvol_next (this, prev);
d1681e
@@ -5372,7 +5386,8 @@ done:
d1681e
 
d1681e
                 STACK_WIND_COOKIE (frame, dht_readdir_cbk, next_subvol,
d1681e
                                    next_subvol, next_subvol->fops->readdir,
d1681e
-                                   local->fd, local->size, next_offset, NULL);
d1681e
+                                   local->fd, (local->size - local->filled),
d1681e
+                                   next_offset, NULL);
d1681e
                 return 0;
d1681e
         }
d1681e
 
d1681e
-- 
d1681e
1.8.3.1
d1681e