summaryrefslogtreecommitdiffstats
path: root/xlators/cluster
diff options
context:
space:
mode:
authorPavan Sondur <pavan@gluster.com>2010-08-15 12:39:05 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-08-16 00:38:51 -0700
commitcd8c7a98e0ccab7866c6deb9174b662584ef91c6 (patch)
tree301c59e736c574f453517f51f9b64d92457bfaa7 /xlators/cluster
parentc87c868f40f4c2f46892afebf9557cf3003dabe4 (diff)
cluster/pump: Save path (/) when abort is received in pump.
Signed-off-by: Pavan Vilas Sondur <pavan@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 1235 (Bug for all pump/migrate commits) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1235
Diffstat (limited to 'xlators/cluster')
-rw-r--r--xlators/cluster/afr/src/afr.h1
-rw-r--r--xlators/cluster/afr/src/pump.c260
-rw-r--r--xlators/cluster/afr/src/pump.h3
3 files changed, 50 insertions, 214 deletions
diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h
index 284eb7a1b3d..416cda5eb7c 100644
--- a/xlators/cluster/afr/src/afr.h
+++ b/xlators/cluster/afr/src/afr.h
@@ -81,7 +81,6 @@ typedef struct _afr_private {
uint64_t down_count; /* number of CHILD_DOWNs we have seen */
struct _pump_private *pump_private; /* Set if we are loaded as pump */
- gf_boolean_t pump_loaded;
} afr_private_t;
typedef struct {
diff --git a/xlators/cluster/afr/src/pump.c b/xlators/cluster/afr/src/pump.c
index b62b079aa1b..5b31d389b28 100644
--- a/xlators/cluster/afr/src/pump.c
+++ b/xlators/cluster/afr/src/pump.c
@@ -213,6 +213,48 @@ build_file_path (loc_t *loc, gf_dirent_t *entry)
}
static int
+pump_save_path (xlator_t *this, const char *path)
+{
+ afr_private_t *priv = NULL;
+ pump_private_t *pump_priv = NULL;
+ pump_state_t state;
+ dict_t *dict = NULL;
+ loc_t loc;
+ int dict_ret = 0;
+ int ret = -1;
+
+ state = pump_get_state ();
+ if (state == PUMP_STATE_RESUME)
+ return 0;
+
+ priv = this->private;
+ pump_priv = priv->pump_private;
+
+ assert (priv->root_inode);
+
+ build_root_loc (priv->root_inode, &loc);
+
+ dict = dict_new ();
+ dict_ret = dict_set_str (dict, PUMP_PATH, (char *)path);
+
+ ret = syncop_setxattr (PUMP_SOURCE_CHILD (this), &loc, dict, 0);
+
+ if (ret < 0) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "setxattr failed - could not save path=%s", path);
+ } else {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "setxattr succeeded - saved path=%s", path);
+ gf_log (this->name, GF_LOG_DEBUG,
+ "Saving path for status info");
+ }
+
+ dict_unref (dict);
+
+ return 0;
+}
+
+static int
pump_check_and_update_status (xlator_t *this)
{
pump_state_t state;
@@ -229,8 +271,13 @@ pump_check_and_update_status (xlator_t *this)
break;
}
case PUMP_STATE_PAUSE:
+ {
+ ret = -1;
+ break;
+ }
case PUMP_STATE_ABORT:
{
+ pump_save_path (this, "/");
ret = -1;
break;
}
@@ -350,47 +397,6 @@ pump_save_file_stats (xlator_t *this, const char *path)
return 0;
}
-static int
-pump_save_path (xlator_t *this, const char *path)
-{
- afr_private_t *priv = NULL;
- pump_private_t *pump_priv = NULL;
- pump_state_t state;
- dict_t *dict = NULL;
- loc_t loc;
- int dict_ret = 0;
- int ret = -1;
-
- state = pump_get_state ();
- if (state != PUMP_STATE_RUNNING)
- return 0;
-
- priv = this->private;
- pump_priv = priv->pump_private;
-
- assert (priv->root_inode);
-
- build_root_loc (priv->root_inode, &loc);
-
- dict = dict_new ();
- dict_ret = dict_set_str (dict, PUMP_PATH, (char *)path);
-
-// ret = syncop_setxattr (PUMP_SOURCE_CHILD (this), &loc, dict, 0);
- ret = 0;
- if (ret < 0) {
- gf_log (this->name, GF_LOG_DEBUG,
- "setxattr failed - could not save path=%s", path);
- } else {
- gf_log (this->name, GF_LOG_DEBUG,
- "setxattr succeeded - saved path=%s", path);
- gf_log (this->name, GF_LOG_DEBUG,
- "Saving path for status info");
- }
-
- dict_unref (dict);
-
- return 0;
-}
static int
gf_pump_traverse_directory (loc_t *loc)
@@ -694,31 +700,6 @@ pump_start (call_frame_t *pump_frame, xlator_t *this)
return ret;
}
-gf_boolean_t
-is_pump_loaded (xlator_t *this)
-{
- afr_private_t *priv = NULL;
- pump_private_t *pump_priv = NULL;
-
- gf_boolean_t ret;
-
- priv = this->private;
- pump_priv = priv->pump_private;
-
- if (priv->pump_loaded) {
- gf_log (this->name, GF_LOG_DEBUG,
- "Pump is already started");
- ret = _gf_true;
- } else {
- gf_log (this->name, GF_LOG_DEBUG,
- "Pump is not started");
- ret = _gf_false;
- }
-
- return ret;
-
-}
-
static int
pump_start_synctask (xlator_t *this)
{
@@ -835,86 +816,6 @@ out:
return ret;
}
-int32_t
-pump_cmd_abort_setxattr_cbk (call_frame_t *frame,
- void *cookie,
- xlator_t *this,
- int32_t op_ret,
- int32_t op_errno)
-
-{
- afr_local_t *local = NULL;
- int ret = 0;
-
- local = frame->local;
-
- if (op_ret < 0) {
- gf_log (this->name, GF_LOG_ERROR,
- "Could not initiate destination "
- "brick disconnect");
- ret = op_ret;
- goto out;
- }
-
- gf_log (this->name, GF_LOG_DEBUG,
- "Successfully initiated destination "
- "brick disconnect");
- ret = 0;
-
-out:
- local->op_ret = ret;
- pump_command_reply (frame, this);
- return 0;
-}
-
-static int
-pump_initiate_sink_disconnect (call_frame_t *frame, xlator_t *this)
-{
- afr_local_t *local = NULL;
- afr_private_t *priv = NULL;
- dict_t *dict = NULL;
- loc_t loc;
-
- int ret = 0;
-
- priv = this->private;
- local = frame->local;
-
- GF_ASSERT (priv->root_inode);
-
- build_root_loc (priv->root_inode, &loc);
-
- dict = dict_new ();
- if (!dict) {
- gf_log (this->name, GF_LOG_ERROR,
- "Out of memory");
- ret = -1;
- goto out;
- }
-
- ret = dict_set_str (dict, CLIENT_CMD_DISCONNECT, "jargon");
- if (ret < 0) {
- gf_log (this->name, GF_LOG_ERROR,
- "Could not inititiate destination brick "
- "disconnect");
- goto out;
- }
-
- STACK_WIND (frame,
- pump_cmd_abort_setxattr_cbk,
- PUMP_SINK_CHILD(this),
- PUMP_SINK_CHILD(this)->fops->setxattr,
- &loc,
- dict,
- 0);
-
- ret = 0;
-
- dict_unref (dict);
-out:
- return ret;
-}
-
static int
is_pump_aborted (xlator_t *this)
{
@@ -1108,80 +1009,19 @@ out:
return 0;
}
-int32_t
-pump_cmd_abort_removexattr_cbk (call_frame_t *frame,
- void *cookie,
- xlator_t *this,
- int32_t op_ret,
- int32_t op_errno)
-{
- afr_local_t *local = NULL;
- int ret = 0;
-
- local = frame->local;
-
- if (op_ret < 0) {
- gf_log (this->name, GF_LOG_ERROR,
- "Aborting pump failed. Please remove xattr"
- PUMP_PATH "of the source child's '/'");
- ret = op_ret;
- goto out;
- }
-
- gf_log (this->name, GF_LOG_DEBUG,
- "remove xattr succeeded");
-
-
- pump_change_state (this, PUMP_STATE_ABORT);
- ret = pump_initiate_sink_disconnect (frame, this);
-
-out:
- if (ret < 0) {
- local->op_ret = ret;
- pump_command_reply (frame, this);
- }
-
- return 0;
-}
-
int
pump_execute_abort (call_frame_t *frame, xlator_t *this)
{
afr_private_t *priv = NULL;
afr_local_t *local = NULL;
- pump_private_t *pump_priv = NULL;
- loc_t root_loc;
- int ret = 0;
priv = this->private;
local = frame->local;
- pump_priv = priv->pump_private;
-
- if (!priv->pump_loaded) {
- gf_log (this->name, GF_LOG_ERROR,
- "Trying to abort pump xlator which is not loaded");
- ret = -1;
- goto out;
- }
-
- GF_ASSERT (priv->root_inode);
-
- build_root_loc (priv->root_inode, &root_loc);
- STACK_WIND (frame,
- pump_cmd_abort_removexattr_cbk,
- PUMP_SOURCE_CHILD (this),
- PUMP_SOURCE_CHILD (this)->fops->removexattr,
- &root_loc,
- PUMP_PATH);
-
- ret = 0;
+ pump_change_state (this, PUMP_STATE_ABORT);
-out:
- if (ret < 0) {
- local->op_ret = ret;
- pump_command_reply (frame, this);
- }
+ local->op_ret = 0;
+ pump_command_reply (frame, this);
return 0;
}
diff --git a/xlators/cluster/afr/src/pump.h b/xlators/cluster/afr/src/pump.h
index e786fb0ded0..65cfcb55b5b 100644
--- a/xlators/cluster/afr/src/pump.h
+++ b/xlators/cluster/afr/src/pump.h
@@ -94,7 +94,4 @@ pump_command_status (xlator_t *this, dict_t *dict);
int
pump_execute_status (call_frame_t *frame, xlator_t *this);
-gf_boolean_t
-is_pump_loaded (xlator_t *this);
-
#endif /* __PUMP_H__ */