From 0ef60a5c371359d2a5d0d8684a8a58f1f5801525 Mon Sep 17 00:00:00 2001 From: N Balachandran Date: Fri, 4 Dec 2015 10:34:37 +0530 Subject: cluster/tier: fix loading tier.so into glusterd The glusterd process loads the shared libraries of client translators. This failed for tiering due to a reference to dht_methods which is defined as a global variable which is not necessary. The global variable has been removed and this is now a member of dht_conf and is now initialised in the *_init calls. > Change-Id: Ifa0a21e3962b5cd8d9b927ef1d087d3b25312953 > Signed-off-by: N Balachandran > Reviewed-on: http://review.gluster.org/12863 > Tested-by: NetBSD Build System > Tested-by: Gluster Build System > Reviewed-by: Dan Lambright >Tested-by: Dan Lambright (cherry picked from commit 96fc7f64da2ef09e82845a7ab97574f511a9aae5) Change-Id: If3cc908ebfcd1f165504f15db2e3079d97f3132e BUG: 1288352 Signed-off-by: N Balachandran Reviewed-on: http://review.gluster.org/12877 Tested-by: NetBSD Build System Tested-by: Gluster Build System Reviewed-by: Dan Lambright Tested-by: Dan Lambright --- tests/basic/tier/file_with_spaces.t | 4 ++-- xlators/cluster/dht/src/dht-common.c | 20 +++++----------- xlators/cluster/dht/src/dht-common.h | 2 +- xlators/cluster/dht/src/dht-helper.c | 3 +-- xlators/cluster/dht/src/dht-rebalance.c | 11 ++------- xlators/cluster/dht/src/dht-shared.c | 29 ++++++++++++++++++++++- xlators/cluster/dht/src/dht.c | 6 ----- xlators/cluster/dht/src/tier.c | 42 ++++++++++++++++++++++++++------- 8 files changed, 74 insertions(+), 43 deletions(-) diff --git a/tests/basic/tier/file_with_spaces.t b/tests/basic/tier/file_with_spaces.t index 7492804da1b..3e3c34da725 100755 --- a/tests/basic/tier/file_with_spaces.t +++ b/tests/basic/tier/file_with_spaces.t @@ -26,8 +26,8 @@ function create_dist_tier_vol () { TEST $CLI volume attach-tier $V0 $H0:$B0/hot/${V0}{0..$1} TEST $CLI volume set $V0 cluster.tier-demote-frequency $DEMOTE_FREQ TEST $CLI volume set $V0 cluster.tier-promote-frequency $PROMOTE_FREQ - TEST $CLI volume set $V0 cluster.read-freq-threshold 50 - TEST $CLI volume set $V0 cluster.write-freq-threshold 50 + TEST $CLI volume set $V0 cluster.read-freq-threshold 0 + TEST $CLI volume set $V0 cluster.write-freq-threshold 0 TEST $CLI volume set $V0 cluster.tier-mode test } diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index e664b576f92..6a717678ba4 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -3708,8 +3708,7 @@ dht_setxattr (call_frame_t *frame, xlator_t *this, conf = this->private; GF_VALIDATE_OR_GOTO (this->name, conf, err); - methods = conf->methods; - GF_VALIDATE_OR_GOTO (this->name, conf->methods, err); + methods = &(conf->methods); /* Rebalance daemon is allowed to set internal keys */ if (!conf->defrag) @@ -4594,8 +4593,7 @@ dht_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, conf = this->private; GF_VALIDATE_OR_GOTO(this->name, conf, unwind); - methods = conf->methods; - GF_VALIDATE_OR_GOTO(this->name, conf->methods, done); + methods = &(conf->methods); if (op_ret < 0) goto done; @@ -4815,8 +4813,7 @@ dht_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, conf = this->private; GF_VALIDATE_OR_GOTO (this->name, conf, done); - methods = conf->methods; - GF_VALIDATE_OR_GOTO (this->name, conf->methods, done); + methods = &(conf->methods); if (op_ret < 0) goto done; @@ -5280,9 +5277,7 @@ dht_mknod_do (call_frame_t *frame) GF_VALIDATE_OR_GOTO (this->name, conf, err); - methods = conf->methods; - - GF_VALIDATE_OR_GOTO (this->name, conf->methods, err); + methods = &(conf->methods); /* We don't need parent_loc anymore */ loc_wipe (&local->loc); @@ -6231,9 +6226,7 @@ dht_create_do (call_frame_t *frame) GF_VALIDATE_OR_GOTO (this->name, conf, err); - methods = conf->methods; - - GF_VALIDATE_OR_GOTO (this->name, conf->methods, err); + methods = &(conf->methods); /* We don't need parent_loc anymore */ loc_wipe (&local->loc); @@ -7664,8 +7657,7 @@ dht_notify (xlator_t *this, int event, void *data, ...) conf = this->private; GF_VALIDATE_OR_GOTO (this->name, conf, out); - methods = conf->methods; - GF_VALIDATE_OR_GOTO (this->name, methods, out); + methods = &(conf->methods); /* had all subvolumes reported status once till now? */ had_heard_from_all = 1; diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h index 79a7e980df2..4e185c73bc5 100644 --- a/xlators/cluster/dht/src/dht-common.h +++ b/xlators/cluster/dht/src/dht-common.h @@ -487,7 +487,7 @@ struct dht_conf { gf_boolean_t randomize_by_gfid; char *dthrottle; - dht_methods_t *methods; + dht_methods_t methods; struct mem_pool *lock_pool; diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c index 96e58c4212d..ca427a0625a 100644 --- a/xlators/cluster/dht/src/dht-helper.c +++ b/xlators/cluster/dht/src/dht-helper.c @@ -587,8 +587,7 @@ dht_subvol_get_hashed (xlator_t *this, loc_t *loc) conf = this->private; GF_VALIDATE_OR_GOTO (this->name, conf, out); - methods = conf->methods; - GF_VALIDATE_OR_GOTO (this->name, conf->methods, out); + methods = &(conf->methods); if (__is_root_gfid (loc->gfid)) { subvol = dht_first_up_subvol (this); diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c index 027e74ac9f4..1c5ef80c3bf 100644 --- a/xlators/cluster/dht/src/dht-rebalance.c +++ b/xlators/cluster/dht/src/dht-rebalance.c @@ -3244,15 +3244,8 @@ gf_defrag_start_crawl (void *data) } if (defrag->cmd == GF_DEFRAG_CMD_START_TIER) { - methods = conf->methods; - if (!methods) { - gf_msg (this->name, GF_LOG_ERROR, 0, - DHT_MSG_LOG_TIER_ERROR, - "Methods invalid for translator."); - defrag->defrag_status = GF_DEFRAG_STATUS_FAILED; - ret = -1; - goto out; - } + methods = &(conf->methods); + methods->migration_other(this, defrag); if (defrag->cmd == GF_DEFRAG_CMD_START_DETACH_TIER) { diff --git a/xlators/cluster/dht/src/dht-shared.c b/xlators/cluster/dht/src/dht-shared.c index 75957d587e5..9d869e39f0e 100644 --- a/xlators/cluster/dht/src/dht-shared.c +++ b/xlators/cluster/dht/src/dht-shared.c @@ -569,6 +569,32 @@ out: return ret; } + + +int +dht_init_methods (xlator_t *this) +{ + int ret = -1; + dht_conf_t *conf = NULL; + dht_methods_t *methods = NULL; + + GF_VALIDATE_OR_GOTO ("dht", this, err); + + conf = this->private; + methods = &(conf->methods); + + methods->migration_get_dst_subvol = dht_migration_get_dst_subvol; + methods->migration_needed = dht_migration_needed; + methods->migration_other = NULL; + methods->layout_search = dht_layout_search; + + ret = 0; +err: + return ret; +} + + + int dht_init (xlator_t *this) { @@ -808,7 +834,8 @@ dht_init (xlator_t *this) if (dht_set_subvol_range(this)) goto err; - conf->methods = &dht_methods; + if (dht_init_methods (this)) + goto err; return 0; diff --git a/xlators/cluster/dht/src/dht.c b/xlators/cluster/dht/src/dht.c index 3934df5ec64..c67172cc926 100644 --- a/xlators/cluster/dht/src/dht.c +++ b/xlators/cluster/dht/src/dht.c @@ -17,12 +17,6 @@ #include "statedump.h" #include "dht-common.h" -dht_methods_t dht_methods = { - .migration_get_dst_subvol = dht_migration_get_dst_subvol, - .migration_needed = dht_migration_needed, - .layout_search = dht_layout_search, -}; - class_methods_t class_methods = { .init = dht_init, .fini = dht_fini, diff --git a/xlators/cluster/dht/src/tier.c b/xlators/cluster/dht/src/tier.c index 476d3323087..0a4ccb23d2a 100644 --- a/xlators/cluster/dht/src/tier.c +++ b/xlators/cluster/dht/src/tier.c @@ -1572,12 +1572,6 @@ tier_search (xlator_t *this, dht_layout_t *layout, const char *name) return subvol; } -dht_methods_t tier_methods = { - .migration_get_dst_subvol = tier_migration_get_dst, - .migration_other = tier_start, - .migration_needed = tier_migration_needed, - .layout_search = tier_search, -}; static int tier_load_externals (xlator_t *this) @@ -1631,6 +1625,32 @@ int tier_validate_mode (char *mode) return ret; } + +int +tier_init_methods (xlator_t *this) +{ + int ret = -1; + dht_conf_t *conf = NULL; + dht_methods_t *methods = NULL; + + GF_VALIDATE_OR_GOTO ("tier", this, err); + + conf = this->private; + + methods = &(conf->methods); + + methods->migration_get_dst_subvol = tier_migration_get_dst; + methods->migration_other = tier_start; + methods->migration_needed = tier_migration_needed; + methods->layout_search = tier_search; + + ret = 0; +err: + return ret; +} + + + int tier_init (xlator_t *this) { @@ -1646,13 +1666,19 @@ tier_init (xlator_t *this) if (ret) { gf_msg (this->name, GF_LOG_ERROR, 0, DHT_MSG_LOG_TIER_ERROR, - "dht_init failed"); + "tier_init failed"); goto out; } conf = this->private; - conf->methods = &tier_methods; + ret = tier_init_methods (this); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, + DHT_MSG_LOG_TIER_ERROR, + "tier_init_methods failed"); + goto out; + } if (conf->subvolume_cnt != 2) { gf_msg (this->name, GF_LOG_ERROR, 0, -- cgit