summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--xlators/cluster/dht/src/dht-common.c72
-rw-r--r--xlators/performance/readdir-ahead/src/readdir-ahead.c46
-rw-r--r--xlators/performance/readdir-ahead/src/readdir-ahead.h3
3 files changed, 60 insertions, 61 deletions
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
index a74de1488ab..a0302b67dfe 100644
--- a/xlators/cluster/dht/src/dht-common.c
+++ b/xlators/cluster/dht/src/dht-common.c
@@ -4871,6 +4871,9 @@ dht_opendir (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd,
int op_errno = -1;
int i = -1;
int ret = 0;
+ gf_boolean_t new_xdata = _gf_false;
+ xlator_t **subvolumes = NULL;
+ int call_count = 0;
VALIDATE_OR_GOTO (frame, err);
VALIDATE_OR_GOTO (this, err);
@@ -4882,46 +4885,59 @@ dht_opendir (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd,
local = dht_local_init (frame, loc, fd, GF_FOP_OPENDIR);
if (!local) {
op_errno = ENOMEM;
-
goto err;
}
+ if (!xdata) {
+ xdata = dict_new ();
+ if (!xdata) {
+ op_errno = ENOMEM;
+ goto err;
+ }
+ new_xdata = _gf_true;
+ }
+
+ ret = dict_set_uint32 (xdata, conf->link_xattr_name, 256);
+ if (ret)
+ gf_msg (this->name, GF_LOG_WARNING, 0, DHT_MSG_DICT_SET_FAILED,
+ "Failed to set dictionary value : key = %s",
+ conf->link_xattr_name);
+
if ((conf->defrag && conf->defrag->cmd == GF_DEFRAG_CMD_START_TIER) ||
(conf->defrag && conf->defrag->cmd ==
GF_DEFRAG_CMD_START_DETACH_TIER) ||
(!(conf->local_subvols_cnt) || !conf->defrag)) {
- local->call_cnt = conf->subvolume_cnt;
-
- for (i = 0; i < conf->subvolume_cnt; i++) {
- STACK_WIND_COOKIE (frame, dht_fd_cbk,
- conf->subvolumes[i],
- conf->subvolumes[i],
- conf->subvolumes[i]->fops->opendir,
- loc, fd, xdata);
- }
+ call_count = local->call_cnt = conf->subvolume_cnt;
+ subvolumes = conf->subvolumes;
} else {
- local->call_cnt = conf->local_subvols_cnt;
- for (i = 0; i < conf->local_subvols_cnt; i++) {
- if (conf->readdir_optimize == _gf_true) {
- if (conf->local_subvols[i] != local->first_up_subvol)
- ret = dict_set_int32 (local->xattr,
- GF_READDIR_SKIP_DIRS, 1);
- if (ret)
- gf_msg (this->name, GF_LOG_ERROR, 0,
- DHT_MSG_DICT_SET_FAILED,
- "Failed to set dictionary"
- " value :key = %s, ret:%d",
- GF_READDIR_SKIP_DIRS, ret);
+ call_count = local->call_cnt = conf->local_subvols_cnt;
+ subvolumes = conf->local_subvols;
+ }
- }
- STACK_WIND_COOKIE (frame, dht_fd_cbk,
- conf->local_subvols[i],
- conf->local_subvols[i],
- conf->local_subvols[i]->fops->opendir,
- loc, fd, xdata);
+ for (i = 0; i < call_count; i++) {
+ if (conf->readdir_optimize == _gf_true) {
+ if (subvolumes[i] != local->first_up_subvol)
+ ret = dict_set_int32 (xdata,
+ GF_READDIR_SKIP_DIRS, 1);
+ if (ret)
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_DICT_SET_FAILED,
+ "Failed to set dictionary"
+ " value :key = %s, ret:%d",
+ GF_READDIR_SKIP_DIRS, ret);
}
+
+ STACK_WIND_COOKIE (frame, dht_fd_cbk,
+ subvolumes[i],
+ subvolumes[i],
+ subvolumes[i]->fops->opendir,
+ loc, fd, xdata);
+ dict_del (xdata, GF_READDIR_SKIP_DIRS);
}
+ if (new_xdata)
+ dict_unref (xdata);
+
return 0;
err:
diff --git a/xlators/performance/readdir-ahead/src/readdir-ahead.c b/xlators/performance/readdir-ahead/src/readdir-ahead.c
index 9f129aa08d8..2ffcf25d8a7 100644
--- a/xlators/performance/readdir-ahead/src/readdir-ahead.c
+++ b/xlators/performance/readdir-ahead/src/readdir-ahead.c
@@ -415,7 +415,6 @@ rda_fill_fd(call_frame_t *frame, xlator_t *this, fd_t *fd)
struct rda_fd_ctx *ctx;
off_t offset;
struct rda_priv *priv = this->private;
- int ret = 0;
ctx = get_rda_fd_ctx(fd, this);
if (!ctx)
@@ -461,15 +460,6 @@ rda_fill_fd(call_frame_t *frame, xlator_t *this, fd_t *fd)
}
local->offset = offset;
- if (local->skip_dir) {
- ret = dict_set_int32 (ctx->xattrs, GF_READDIR_SKIP_DIRS, 1);
- if (ret < 0) {
- gf_msg (this->name, GF_LOG_ERROR,
- 0, READDIR_AHEAD_MSG_DICT_OP_FAILED,
- "Dict set of key:%s failed with :%d",
- GF_READDIR_SKIP_DIRS, ret);
- }
- }
UNLOCK(&ctx->lock);
@@ -547,27 +537,12 @@ rda_opendir(call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd,
dict_t *xdata_from_req = NULL;
if (xdata) {
- /*
- * Retrieve list of keys set by md-cache xlator and store it
- * in local to be consumed in rda_opendir_cbk
- */
- ret = dict_get_str (xdata, GF_MDC_LOADED_KEY_NAMES, &payload);
- if (ret)
- goto wind;
-
xdata_from_req = dict_new();
if (!xdata_from_req) {
op_errno = ENOMEM;
goto unwind;
}
- ret = rda_unpack_mdc_loaded_keys_to_dict((char *) payload,
- xdata_from_req);
- if (ret) {
- dict_unref(xdata_from_req);
- goto wind;
- }
-
local = mem_get0(this->local_pool);
if (!local) {
dict_unref(xdata_from_req);
@@ -575,16 +550,25 @@ rda_opendir(call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd,
goto unwind;
}
+ /*
+ * Retrieve list of keys set by md-cache xlator and store it
+ * in local to be consumed in rda_opendir_cbk
+ */
+ ret = dict_get_str (xdata, GF_MDC_LOADED_KEY_NAMES, &payload);
+ if (ret)
+ goto wind;
+ ret = rda_unpack_mdc_loaded_keys_to_dict((char *) payload,
+ xdata_from_req);
+ if (ret)
+ goto wind;
+
+ dict_copy (xdata, xdata_from_req);
+ dict_del (xdata_from_req, GF_MDC_LOADED_KEY_NAMES);
+
local->xattrs = xdata_from_req;
- ret = dict_get_int32 (xdata, GF_READDIR_SKIP_DIRS, &local->skip_dir);
frame->local = local;
}
-
wind:
- if (xdata)
- /* Remove the key after consumption. */
- dict_del (xdata, GF_MDC_LOADED_KEY_NAMES);
-
STACK_WIND(frame, rda_opendir_cbk, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->opendir, loc, fd, xdata);
return 0;
diff --git a/xlators/performance/readdir-ahead/src/readdir-ahead.h b/xlators/performance/readdir-ahead/src/readdir-ahead.h
index 9f9df05212e..8c663e091f1 100644
--- a/xlators/performance/readdir-ahead/src/readdir-ahead.h
+++ b/xlators/performance/readdir-ahead/src/readdir-ahead.h
@@ -36,8 +36,7 @@ struct rda_local {
struct rda_fd_ctx *ctx;
fd_t *fd;
off_t offset;
- dict_t *xattrs; /* md-cache keys to be sent in readdirp() */
- int32_t skip_dir;
+ dict_t *xattrs; /* xattrs to be sent in readdirp() */
};
struct rda_priv {