summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorRaghavendra G <rgowdapp@redhat.com>2017-09-18 16:01:34 +0530
committerShyamsundar Ranganathan <srangana@redhat.com>2017-12-11 04:55:06 +0000
commitdd8b4832588bcfcb73a74673bef196b87a7c16d3 (patch)
tree61a1552c4ad09158492afbcf6aa0b3bfd15b7078 /xlators
parentaf59eedfb8185fefe4cc3d73e88211893da69d51 (diff)
cluster/dht: don't overfill the buffer in readdir(p)
Superflous dentries that cannot be fit in the buffer size provided by kernel are thrown away by fuse-bridge. This means, * the next readdir(p) seen by readdir-ahead would have an offset of a dentry returned in a previous readdir(p) response. When readdir-ahead detects non-monotonic offset it turns itself off which can result in poor readdir performance. * readdirp can be cpu-intensive on brick and there is no point to read all those dentries just to be thrown away by fuse-bridge. So, the best strategy would be to fill the buffer optimally - neither overfill nor underfill. >Change-Id: Idb3d85dd4c08fdc4526b2df801d49e69e439ba84 >BUG: 1492625 >Signed-off-by: Raghavendra G <rgowdapp@redhat.com> (cherry picked from commit e785faead91f74dce7c832848f2e8f3f43bd0be5) Change-Id: Idb3d85dd4c08fdc4526b2df801d49e69e439ba84 BUG: 1522710 Signed-off-by: Raghavendra G <rgowdapp@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/cluster/dht/src/dht-common.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
index f6d480a..9db6173 100644
--- a/xlators/cluster/dht/src/dht-common.c
+++ b/xlators/cluster/dht/src/dht-common.c
@@ -6424,6 +6424,13 @@ list:
}
done:
+ if ((op_ret == 0) && op_errno != ENOENT) {
+ /* remaining buffer size is not enough to hold even one
+ * dentry
+ */
+ goto unwind;
+ }
+
if ((count == 0) || (local && (local->filled < local->size))) {
if ((next_offset == 0) || (op_errno == ENOENT)) {
next_offset = 0;
@@ -6454,8 +6461,8 @@ done:
STACK_WIND_COOKIE (frame, dht_readdirp_cbk, next_subvol,
next_subvol, next_subvol->fops->readdirp,
- local->fd, local->size, next_offset,
- local->xattr);
+ local->fd, (local->size - local->filled),
+ next_offset, local->xattr);
return 0;
}
@@ -6545,6 +6552,13 @@ dht_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
done:
+ if ((op_ret == 0) && op_errno != ENOENT) {
+ /* remaining buffer size is not enough to hold even one
+ * dentry
+ */
+ goto unwind;
+ }
+
if ((count == 0) || (local && (local->filled < local->size))) {
if ((op_ret <= 0) || (op_errno == ENOENT)) {
next_subvol = dht_subvol_next (this, prev);
@@ -6558,7 +6572,8 @@ done:
STACK_WIND_COOKIE (frame, dht_readdir_cbk, next_subvol,
next_subvol, next_subvol->fops->readdir,
- local->fd, local->size, next_offset, NULL);
+ local->fd, (local->size - local->filled),
+ next_offset, NULL);
return 0;
}