summaryrefslogtreecommitdiffstats
path: root/xlators/cluster
diff options
context:
space:
mode:
authorshishir gowda <sgowda@redhat.com>2012-08-13 11:20:17 +0530
committerVijay Bellur <vijay@gluster.com>2012-08-17 11:58:14 +0530
commit34a51c2e44fb8356c0259e25206510d2d627e53e (patch)
tree31b879e4d57f68ec87ce0e39a08d53c5697a029c /xlators/cluster
parent32cb6d60ca5a40a15fee892aa0da9b373f6ca02e (diff)
cluster/dht: Optimize readdirp calls in DHT
Bring in option which is supported by posix xlator to filter out directory's entries from being returned. DHT would now request non-first subvols to filter out directory entries. dht xlator-option readdir-optimize will enable this optimization Change-Id: Ibf99f1bef501f285ff44a1cecfbebee9e16063b6 BUG: 838199 Signed-off-by: shishir gowda <sgowda@redhat.com> Reviewed-on: http://review.gluster.com/3806 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators/cluster')
-rw-r--r--xlators/cluster/dht/src/dht-common.c24
-rw-r--r--xlators/cluster/dht/src/dht-common.h4
-rw-r--r--xlators/cluster/dht/src/dht.c8
3 files changed, 35 insertions, 1 deletions
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
index 5da0c10bba2..ade05f38d3c 100644
--- a/xlators/cluster/dht/src/dht-common.c
+++ b/xlators/cluster/dht/src/dht-common.c
@@ -2766,6 +2766,7 @@ dht_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret,
dht_layout_t *layout = 0;
dht_conf_t *conf = NULL;
xlator_t *subvol = 0;
+ int ret = 0;
INIT_LIST_HEAD (&entries.list);
prev = cookie;
@@ -2843,6 +2844,16 @@ done:
goto unwind;
}
+ if (conf->readdir_optimize == _gf_true) {
+ if (next_subvol != dht_first_up_subvol (this)) {
+ ret = dict_set_int32 (local->xattr,
+ GF_READDIR_SKIP_DIRS, 1);
+ if (ret)
+ gf_log (this->name, GF_LOG_ERROR,
+ "dict set failed");
+ }
+ }
+
STACK_WIND (frame, dht_readdirp_cbk,
next_subvol, next_subvol->fops->readdirp,
local->fd, local->size, next_offset,
@@ -2968,11 +2979,14 @@ dht_do_readdir (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
xlator_t *xvol = NULL;
off_t xoff = 0;
int ret = 0;
+ dht_conf_t *conf = NULL;
VALIDATE_OR_GOTO (frame, err);
VALIDATE_OR_GOTO (this, err);
VALIDATE_OR_GOTO (fd, err);
+ conf = this->private;
+
local = dht_local_init (frame, NULL, NULL, whichop);
if (!local) {
op_errno = ENOMEM;
@@ -3000,6 +3014,16 @@ dht_do_readdir (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
gf_log (this->name, GF_LOG_WARNING,
"failed to set 'glusterfs.dht.linkto'"
" key");
+ if (conf->readdir_optimize == _gf_true) {
+ if (xvol != dht_first_up_subvol (this)) {
+ ret = dict_set_int32 (local->xattr,
+ GF_READDIR_SKIP_DIRS, 1);
+ if (ret)
+ gf_log (this->name,
+ GF_LOG_ERROR,
+ "Dict set failed");
+ }
+ }
}
STACK_WIND (frame, dht_readdirp_cbk, xvol, xvol->fops->readdirp,
diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h
index 9f7723fdbde..da83967e76d 100644
--- a/xlators/cluster/dht/src/dht-common.h
+++ b/xlators/cluster/dht/src/dht-common.h
@@ -246,6 +246,10 @@ struct dht_conf {
/* defrag related */
gf_defrag_info_t *defrag;
+
+ /* Request to filter directory entries in readdir request */
+
+ gf_boolean_t readdir_optimize;
};
typedef struct dht_conf dht_conf_t;
diff --git a/xlators/cluster/dht/src/dht.c b/xlators/cluster/dht/src/dht.c
index e3930e2af3f..68a8efcde88 100644
--- a/xlators/cluster/dht/src/dht.c
+++ b/xlators/cluster/dht/src/dht.c
@@ -331,7 +331,8 @@ reconfigure (xlator_t *this, dict_t *options)
percent, out);
GF_OPTION_RECONF ("directory-layout-spread", conf->dir_spread_cnt,
options, uint32, out);
-
+ GF_OPTION_RECONF ("readdir-optimize", conf->readdir_optimize, options,
+ bool, out);
if (dict_get_str (options, "decommissioned-bricks", &temp_str) == 0) {
ret = dht_parse_decommissioned_bricks (this, conf, temp_str);
if (ret == -1)
@@ -431,6 +432,7 @@ init (xlator_t *this)
GF_OPTION_INIT ("assert-no-child-down", conf->assert_no_child_down,
bool, err);
+ GF_OPTION_INIT ("readdir-optimize", conf->readdir_optimize, bool, err);
ret = dht_init_subvolumes (this, conf);
if (ret == -1) {
@@ -593,6 +595,10 @@ struct volume_options options[] = {
{ .key = {"node-uuid"},
.type = GF_OPTION_TYPE_STR,
},
+ { .key = {"readdir-optimize"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "off",
+ },
{ .key = {NULL} },
};