summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/dht/src/dht-common.c
diff options
context:
space:
mode:
authorMohammed Rafi KC <rkavunga@redhat.com>2015-10-15 12:01:14 +0530
committerRaghavendra G <rgowdapp@redhat.com>2015-11-09 02:52:34 -0800
commit87c877c93c399863b6afcc642d015627217b79f8 (patch)
tree6e9e2cb41cb110cb26b3505e990dcc77f65084cf /xlators/cluster/dht/src/dht-common.c
parent42e23211fcc1f7da320a318a6b212e2af60214f6 (diff)
dht: heal directory path if the directory is not present
back port of http://review.gluster.org/#/c/12376/ After a successful nameless lookup if the directory is not present on any of the subvol, then we will get the path of the directory and will recursively send a named lookp on each parent directory. This will help particularly for the scenarios like add brick and attach-tier. Change-Id: I97f3178adb08b88910f709f0acf1d86c147be017 BUG: 1279095 Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com> Reviewed-on: http://review.gluster.org/12539 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: N Balachandran <nbalacha@redhat.com> Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Diffstat (limited to 'xlators/cluster/dht/src/dht-common.c')
-rw-r--r--xlators/cluster/dht/src/dht-common.c76
1 files changed, 69 insertions, 7 deletions
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
index e042ff6ee4a..86c45b1648a 100644
--- a/xlators/cluster/dht/src/dht-common.c
+++ b/xlators/cluster/dht/src/dht-common.c
@@ -217,17 +217,22 @@ out:
return ret;
}
-
int
dht_discover_complete (xlator_t *this, call_frame_t *discover_frame)
{
- dht_local_t *local = NULL;
- call_frame_t *main_frame = NULL;
- int op_errno = 0;
- int ret = -1;
- dht_layout_t *layout = NULL;
- dht_conf_t *conf = NULL;
+ dht_local_t *local = NULL;
+ dht_local_t *heal_local = NULL;
+ call_frame_t *main_frame = NULL;
+ call_frame_t *heal_frame = NULL;
+ int op_errno = 0;
+ int ret = -1;
+ dht_layout_t *layout = NULL;
+ dht_conf_t *conf = NULL;
uint32_t vol_commit_hash = 0;
+ xlator_t *source = NULL;
+ int heal_path = 0;
+ int i = 0;
+ loc_t loc = {0 };
local = discover_frame->local;
layout = local->layout;
@@ -306,6 +311,63 @@ dht_discover_complete (xlator_t *this, call_frame_t *discover_frame)
}
}
+ if (IA_ISDIR (local->stbuf.ia_type)) {
+ for (i = 0; i < layout->cnt; i++) {
+ if (!source && !layout->list[i].err)
+ source = layout->list[i].xlator;
+ if (layout->list[i].err == ENOENT ||
+ layout->list[i].err == ESTALE) {
+ heal_path = 1;
+ }
+ if (source && heal_path)
+ break;
+ }
+ }
+ if (source && heal_path) {
+ gf_uuid_copy (loc.gfid, local->gfid);
+ if (gf_uuid_is_null (loc.gfid)) {
+ goto done;
+ }
+
+ if (local->inode)
+ loc.inode = inode_ref (local->inode);
+ else
+ goto done;
+
+ heal_frame = create_frame (this, this->ctx->pool);
+ if (heal_frame) {
+ heal_local = dht_local_init (heal_frame, &loc,
+ NULL, 0);
+ if (!heal_local)
+ goto cleanup;
+
+ gf_uuid_copy (heal_local->gfid, local->gfid);
+ heal_frame->cookie = source;
+ heal_local->xattr = dict_ref (local->xattr);
+ heal_local->stbuf = local->stbuf;
+ heal_local->postparent = local->postparent;
+ heal_local->inode = inode_ref (loc.inode);
+ heal_local->main_frame = main_frame;
+ FRAME_SU_DO (heal_frame, dht_local_t);
+ ret = synctask_new (this->ctx->env,
+ dht_heal_full_path,
+ dht_heal_full_path_done,
+ heal_frame, heal_frame);
+ if (!ret) {
+ loc_wipe (&loc);
+ return 0;
+ }
+ /*
+ * Failed to spawn the synctask. Returning
+ * with out doing heal.
+ */
+cleanup:
+ loc_wipe (&loc);
+ DHT_STACK_DESTROY (heal_frame);
+ }
+
+ }
+done:
DHT_STACK_UNWIND (lookup, main_frame, local->op_ret, local->op_errno,
local->inode, &local->stbuf, local->xattr,
&local->postparent);