glusterd: volume set changes for lock migration
Change-Id: I48c6f9cdda47503615ba65882acd5eedf0a70c89 BUG: 1326085 Signed-off-by: Susant Palai <spalai@redhat.com> Reviewed-on: http://review.gluster.org/14024 Smoke: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Niels de Vos <ndevos@redhat.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
This commit is contained in:
parent
2f4733657b
commit
3ff1861546
34
tests/features/lock-migration/lkmigration-set-option.t
Normal file
34
tests/features/lock-migration/lkmigration-set-option.t
Normal file
@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
# Test to check
|
||||
. $(dirname $0)/../../include.rc
|
||||
. $(dirname $0)/../../volume.rc
|
||||
|
||||
#Check lock-migration set option sanity
|
||||
cleanup;
|
||||
|
||||
TEST glusterd
|
||||
TEST pidof glusterd
|
||||
TEST $CLI volume create $V0 $H0:$B0/brick1 $H0:$B0/brick2
|
||||
TEST $CLI volume start $V0
|
||||
|
||||
TEST $CLI volume set $V0 lock-migration on
|
||||
EXPECT "on" echo `$CLI volume info | grep lock-migration | awk '{print $2}'`
|
||||
TEST $CLI volume set $V0 lock-migration off
|
||||
EXPECT "off" echo `$CLI volume info | grep lock-migration | awk '{print $2}'`
|
||||
TEST ! $CLI volume set $V0 lock-migration garbage
|
||||
#make sure it is still off
|
||||
EXPECT "off" echo `$CLI volume info | grep lock-migration | awk '{print $2}'`
|
||||
|
||||
|
||||
TEST $CLI volume stop $V0;
|
||||
TEST $CLI volume delete $V0;
|
||||
|
||||
|
||||
#create a afr volume and make sure option setting fails
|
||||
|
||||
TEST $CLI volume create $V0 replica 2 $H0:$B0/brick1 $H0:$B0/brick2
|
||||
TEST $CLI volume start $V0
|
||||
|
||||
TEST ! $CLI volume set $V0 lock-migration on
|
||||
|
||||
cleanup;
|
@ -444,6 +444,9 @@ struct gf_defrag_info_ {
|
||||
|
||||
/* Hard link handle requirement */
|
||||
synclock_t link_lock;
|
||||
|
||||
/* lock migration flag */
|
||||
gf_boolean_t lock_migration_enabled;
|
||||
};
|
||||
|
||||
typedef struct gf_defrag_info_ gf_defrag_info_t;
|
||||
@ -535,6 +538,10 @@ struct dht_conf {
|
||||
*/
|
||||
uint32_t vol_commit_hash;
|
||||
gf_boolean_t vch_forced;
|
||||
|
||||
/* lock migration */
|
||||
|
||||
gf_boolean_t lock_migration_enabled;
|
||||
};
|
||||
typedef struct dht_conf dht_conf_t;
|
||||
|
||||
|
@ -455,7 +455,13 @@ dht_reconfigure (xlator_t *this, dict_t *options)
|
||||
GF_OPTION_RECONF ("rebal-throttle", conf->dthrottle, options,
|
||||
str, out);
|
||||
|
||||
GF_OPTION_RECONF ("lock-migration", conf->lock_migration_enabled,
|
||||
options, bool, out);
|
||||
|
||||
if (conf->defrag) {
|
||||
conf->defrag->lock_migration_enabled =
|
||||
conf->lock_migration_enabled;
|
||||
|
||||
GF_DECIDE_DEFRAG_THROTTLE_COUNT (throttle_count, conf);
|
||||
gf_msg ("DHT", GF_LOG_INFO, 0,
|
||||
DHT_MSG_REBAL_THROTTLE_INFO,
|
||||
@ -588,8 +594,6 @@ err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
dht_init (xlator_t *this)
|
||||
{
|
||||
@ -722,8 +726,14 @@ dht_init (xlator_t *this)
|
||||
|
||||
GF_OPTION_INIT ("readdir-optimize", conf->readdir_optimize, bool, err);
|
||||
|
||||
|
||||
GF_OPTION_INIT ("lock-migration", conf->lock_migration_enabled,
|
||||
bool, err);
|
||||
|
||||
if (defrag) {
|
||||
GF_OPTION_INIT ("rebalance-stats", defrag->stats, bool, err);
|
||||
defrag->lock_migration_enabled = conf->lock_migration_enabled;
|
||||
|
||||
GF_OPTION_INIT ("rebalance-stats", defrag->stats, bool, err);
|
||||
if (dict_get_str (this->options, "rebalance-filter", &temp_str)
|
||||
== 0) {
|
||||
if (gf_defrag_pattern_list_fill (this, defrag, temp_str)
|
||||
@ -1066,5 +1076,12 @@ struct volume_options options[] = {
|
||||
"max of [($(processing units) - 4) / 2), 4]"
|
||||
},
|
||||
|
||||
{ .key = {"lock-migration"},
|
||||
.type = GF_OPTION_TYPE_BOOL,
|
||||
.default_value = "off",
|
||||
.description = " If enabled this feature will migrate the posix locks"
|
||||
" associated with a file during rebalance"
|
||||
},
|
||||
|
||||
{ .key = {NULL} },
|
||||
};
|
||||
|
@ -816,6 +816,53 @@ validate_disperse_heal_enable_disable (glusterd_volinfo_t *volinfo,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
validate_lock_migration_option (glusterd_volinfo_t *volinfo, dict_t *dict,
|
||||
char *key, char *value, char **op_errstr)
|
||||
{
|
||||
char errstr[2048] = "";
|
||||
glusterd_conf_t *priv = NULL;
|
||||
int ret = 0;
|
||||
xlator_t *this = NULL;
|
||||
gf_boolean_t b = _gf_false;
|
||||
|
||||
this = THIS;
|
||||
GF_ASSERT (this);
|
||||
|
||||
if (volinfo->replica_count > 1 || volinfo->disperse_count ||
|
||||
volinfo->type == GF_CLUSTER_TYPE_TIER) {
|
||||
snprintf (errstr, sizeof (errstr), "Lock migration is "
|
||||
"a experimental feature. Currently works with"
|
||||
" pure distribute volume only");
|
||||
ret = -1;
|
||||
|
||||
gf_msg (this->name, GF_LOG_ERROR, EINVAL,
|
||||
GD_MSG_INVALID_ENTRY, "%s", errstr);
|
||||
|
||||
*op_errstr = gf_strdup (errstr);
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = gf_string2boolean (value, &b);
|
||||
if (ret) {
|
||||
snprintf (errstr, sizeof (errstr), "Invalid value"
|
||||
" for volume set command. Use on/off only.");
|
||||
ret = -1;
|
||||
|
||||
gf_msg (this->name, GF_LOG_ERROR, EINVAL,
|
||||
GD_MSG_INVALID_ENTRY, "%s", errstr);
|
||||
|
||||
*op_errstr = gf_strdup (errstr);
|
||||
|
||||
goto out;
|
||||
}
|
||||
|
||||
gf_msg_debug (this->name, 0, "Returning %d", ret);
|
||||
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* dispatch table for VOLUME SET
|
||||
* -----------------------------
|
||||
*
|
||||
@ -951,6 +998,16 @@ struct volopt_map_entry glusterd_volopt_map[] = {
|
||||
.validate_fn = validate_defrag_throttle_option,
|
||||
.flags = OPT_FLAG_CLIENT_OPT,
|
||||
},
|
||||
|
||||
{ .key = "cluster.lock-migration",
|
||||
.voltype = "cluster/distribute",
|
||||
.option = "lock-migration",
|
||||
.value = "off",
|
||||
.op_version = GD_OP_VERSION_3_8_0,
|
||||
.validate_fn = validate_lock_migration_option,
|
||||
.flags = OPT_FLAG_CLIENT_OPT,
|
||||
},
|
||||
|
||||
/* NUFA xlator options (Distribute special case) */
|
||||
{ .key = "cluster.nufa",
|
||||
.voltype = "cluster/distribute",
|
||||
|
Loading…
Reference in New Issue
Block a user