From 6a244f2e95b09603507782061ac08b7e0c28fd64 Mon Sep 17 00:00:00 2001 From: Pavan Sondur Date: Mon, 4 Oct 2010 08:18:19 +0000 Subject: cluster/pump: mgmt/glusterd: Misc fixes for replace-brick Signed-off-by: Pavan Vilas Sondur Signed-off-by: Vijay Bellur BUG: 1235 (Bug for all pump/migrate commits) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1235 --- xlators/cluster/afr/src/afr-common.c | 3 ++ xlators/cluster/afr/src/pump.c | 77 ++++++++++++++++++++++++++++++++++-- 2 files changed, 77 insertions(+), 3 deletions(-) (limited to 'xlators/cluster/afr/src') diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c index ee5fa3a60..53b5ca199 100644 --- a/xlators/cluster/afr/src/afr-common.c +++ b/xlators/cluster/afr/src/afr-common.c @@ -2539,6 +2539,9 @@ afr_notify (xlator_t *this, int32_t event, case GF_EVENT_CHILD_UP: i = find_child_index (this, data); + gf_log (this->name, GF_LOG_DEBUG, + "child=%d up", i); + afr_attempt_lock_recovery (this, i); child_up[i] = 1; diff --git a/xlators/cluster/afr/src/pump.c b/xlators/cluster/afr/src/pump.c index 39de7cbb9..dc2185577 100644 --- a/xlators/cluster/afr/src/pump.c +++ b/xlators/cluster/afr/src/pump.c @@ -619,6 +619,53 @@ pump_complete_migration (xlator_t *this) return 0; } +static int +pump_set_root_gfid (dict_t *dict) +{ + uuid_t gfid; + int ret = 0; + + memset (gfid, 0, 16); + gfid[15] = 1; + + ret = afr_set_dict_gfid (dict, gfid); + + return ret; +} + +static int +pump_lookup_sink (loc_t *loc) +{ + xlator_t *this = NULL; + struct iatt iatt, parent; + dict_t *xattr_rsp; + dict_t *xattr_req = NULL; + int ret = 0; + + this = THIS; + + xattr_req = dict_new (); + + ret = pump_set_root_gfid (xattr_req); + if (ret) + goto out; + + ret = syncop_lookup (PUMP_SINK_CHILD (this), loc, + xattr_req, &iatt, &xattr_rsp, &parent); + + if (ret) { + gf_log (this->name, GF_LOG_DEBUG, + "Lookup on sink child failed"); + goto out; + } + +out: + if (xattr_req) + dict_unref (xattr_req); + + return ret; +} + static int pump_task (void *data) { @@ -628,7 +675,8 @@ pump_task (void *data) loc_t loc; struct iatt iatt, parent; - dict_t *xattr_rsp; + dict_t *xattr_rsp = NULL; + dict_t *xattr_req = NULL; int ret = -1; @@ -638,8 +686,16 @@ pump_task (void *data) assert (priv->root_inode); build_root_loc (priv->root_inode, &loc); + xattr_req = dict_new (); + if (!xattr_req) { + gf_log (this->name, GF_LOG_DEBUG, + "Out of memory"); + ret = -1; + goto out; + } - ret = syncop_lookup (this, &loc, NULL, + pump_set_root_gfid (xattr_req); + ret = syncop_lookup (this, &loc, xattr_req, &iatt, &xattr_rsp, &parent); gf_log (this->name, GF_LOG_TRACE, @@ -654,10 +710,20 @@ pump_task (void *data) pump_update_resume_path (this); + pump_set_root_gfid (xattr_req); + ret = pump_lookup_sink (&loc); + if (ret) { + pump_update_resume_path (this); + goto out; + } + gf_pump_traverse_directory (&loc); pump_complete_migration (this); out: + if (xattr_req) + dict_unref (xattr_req); + return 0; } @@ -698,7 +764,8 @@ pump_start (call_frame_t *pump_frame, xlator_t *this) if (!pump_frame->root->lk_owner) pump_frame->root->lk_owner = PUMP_LK_OWNER; - ret = synctask_new (pump_priv->env, pump_task, pump_task_completion, + ret = synctask_new (pump_priv->env, pump_task, + pump_task_completion, pump_frame); if (ret == -1) { gf_log (this->name, GF_LOG_DEBUG, @@ -891,6 +958,8 @@ pump_cmd_start_getxattr_cbk (call_frame_t *frame, else { /* We're re-starting pump from a previous pause */ + gf_log (this->name, GF_LOG_DEBUG, + "about to start synctask"); ret = pump_start_synctask (this); need_unwind = 1; } @@ -2210,6 +2279,8 @@ notify (xlator_t *this, int32_t event, case GF_EVENT_CHILD_UP: if (is_xlator_pump_sink (child_xl)) if (is_pump_start_pending (this)) { + gf_log (this->name, GF_LOG_DEBUG, + "about to start synctask"); ret = pump_start_synctask (this); if (ret < 0) gf_log (this->name, GF_LOG_DEBUG, -- cgit