summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cli/src/cli-cmd-parser.c68
-rw-r--r--cli/src/cli-cmd-volume.c93
-rw-r--r--cli/src/cli-rpc-ops.c36
-rw-r--r--cli/src/cli.h4
-rw-r--r--libglusterfs/src/gfdb/gfdb_sqlite3.c26
-rw-r--r--rpc/rpc-lib/src/protocol-common.h1
-rwxr-xr-xtests/basic/tier/tier.t12
7 files changed, 214 insertions, 26 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index 54ab40d..bd931de 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -58,6 +58,9 @@ enum cli_snap_config_set_types {
};
typedef enum cli_snap_config_set_types cli_snap_config_set_types;
+int
+cli_cmd_validate_volume (char *volname);
+
static const char *
id_sel (void *wcon)
{
@@ -1688,6 +1691,71 @@ out:
}
int32_t
+cli_cmd_volume_tier_parse (const char **words, int wordcount,
+ dict_t **options)
+{
+ dict_t *dict = NULL;
+ char *volname = NULL;
+ char *word = NULL;
+ int ret = -1;
+ int32_t command = GF_OP_CMD_NONE;
+
+ GF_ASSERT (words);
+ GF_ASSERT (options);
+
+ dict = dict_new ();
+
+ if (!dict)
+ goto out;
+
+ if (wordcount != 4) {
+ gf_log ("cli", GF_LOG_ERROR, "Invalid Syntax");
+ ret = -1;
+ goto out;
+ }
+
+ volname = (char *)words[2];
+
+ GF_ASSERT (volname);
+
+ ret = cli_cmd_validate_volume (volname);
+ if (ret) {
+ gf_log ("cli", GF_LOG_ERROR, "Failed to validate volume name");
+ goto out;
+ }
+
+ ret = dict_set_str (dict, "volname", volname);
+
+ if (ret)
+ goto out;
+
+ volname = (char *)words[2];
+
+ word = (char *)words[3];
+ if (!strcmp(word, "status"))
+ command = GF_DEFRAG_CMD_STATUS_TIER;
+ else {
+ ret = -1;
+ goto out;
+ }
+
+ ret = dict_set_int32 (dict, "rebalance-command", command);
+ if (ret)
+ goto out;
+
+ *options = dict;
+out:
+
+ if (ret) {
+ gf_log ("cli", GF_LOG_ERROR, "Unable to parse tier CLI");
+ if (dict)
+ dict_destroy (dict);
+ }
+
+ return ret;
+}
+
+int32_t
cli_cmd_volume_detach_tier_parse (const char **words, int wordcount,
dict_t **options)
{
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index 040e255..ee9a09a 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -893,7 +893,7 @@ out:
}
int
-cli_cmd_volume_attach_tier_cbk (struct cli_state *state,
+do_cli_cmd_volume_attach_tier (struct cli_state *state,
struct cli_cmd_word *word, const char **words,
int wordcount)
{
@@ -975,7 +975,7 @@ out:
}
int
-cli_cmd_volume_detach_tier_cbk (struct cli_state *state,
+do_cli_cmd_volume_detach_tier (struct cli_state *state,
struct cli_cmd_word *word, const char **words,
int wordcount)
{
@@ -1040,6 +1040,77 @@ out:
return ret;
}
+int
+cli_cmd_volume_tier_cbk (struct cli_state *state,
+ struct cli_cmd_word *word, const char **words,
+ int wordcount)
+{
+ int ret = -1;
+ call_frame_t *frame = NULL;
+ dict_t *options = NULL;
+ char *volname = NULL;
+ rpc_clnt_procedure_t *proc = NULL;
+ cli_local_t *local = NULL;
+ int i = 0;
+
+ if (wordcount < 4) {
+ cli_usage_out (word->pattern);
+ goto out;
+ }
+
+ if (!strcmp(words[1], "detach-tier")) {
+ ret = do_cli_cmd_volume_detach_tier (state, word,
+ words, wordcount);
+ goto out;
+ } else if (!strcmp(words[3], "detach")) {
+ for (i = 3; i < wordcount; i++)
+ words[i] = words[i+1];
+
+ ret = do_cli_cmd_volume_detach_tier (state, word,
+ words, wordcount-1);
+ goto out;
+
+ } else if (!strcmp(words[1], "attach-tier")) {
+ ret = do_cli_cmd_volume_attach_tier (state, word,
+ words, wordcount);
+ goto out;
+ } else if (!strcmp(words[3], "attach")) {
+ for (i = 3; i < wordcount; i++)
+ words[i] = words[i+1];
+
+ ret = do_cli_cmd_volume_attach_tier (state, word,
+ words, wordcount-1);
+ goto out;
+ }
+
+ ret = cli_cmd_volume_tier_parse (words, wordcount, &options);
+ if (ret) {
+ cli_usage_out (word->pattern);
+ goto out;
+ }
+
+ proc = &cli_rpc_prog->proctable[GLUSTER_CLI_TIER];
+
+ frame = create_frame (THIS, THIS->ctx->pool);
+ if (!frame)
+ goto out;
+
+ CLI_LOCAL_INIT (local, words, frame, options);
+
+ if (proc->fn) {
+ ret = proc->fn (frame, THIS, options);
+ }
+
+out:
+ if (ret) {
+ cli_out ("Tier command failed");
+ }
+ if (options)
+ dict_unref (options);
+
+ return ret;
+}
+
static int
gf_cli_create_auxiliary_mount (char *volname)
{
@@ -2584,14 +2655,24 @@ struct cli_cmd volume_cmds[] = {
cli_cmd_volume_rename_cbk,
"rename volume <VOLNAME> to <NEW-VOLNAME>"},*/
+ { "volume tier <VOLNAME> status\n"
+ "volume tier <VOLNAME> attach [<replica COUNT>] <NEW-BRICK>...\n"
+ "volume tier <VOLNAME> detach <start|stop|status|commit|[force]>\n",
+ cli_cmd_volume_tier_cbk,
+ "Tier translator specific operations."},
+
{ "volume attach-tier <VOLNAME> [<replica COUNT>] <NEW-BRICK>...",
- cli_cmd_volume_attach_tier_cbk,
- "attach tier to volume <VOLNAME>"},
+ cli_cmd_volume_tier_cbk,
+ "NOTE: this is old syntax, will be depreciated in next release. "
+ "Please use gluster volume tier <vol> attach "
+ "[<replica COUNT>] <NEW-BRICK>..."},
{ "volume detach-tier <VOLNAME> "
" <start|stop|status|commit|[force]>",
- cli_cmd_volume_detach_tier_cbk,
- "detach tier from volume <VOLNAME>"},
+ cli_cmd_volume_tier_cbk,
+ "NOTE: this is old syntax, will be depreciated in next release. "
+ "Please use gluster volume tier <vol> detach "
+ "{start|stop|commit} [force]"},
{ "volume add-brick <VOLNAME> [<stripe|replica> <COUNT>] <NEW-BRICK> ... [force]",
cli_cmd_volume_add_brick_cbk,
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index 7a1fc75..c160339 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -4351,6 +4351,39 @@ out:
}
int32_t
+gf_cli_tier (call_frame_t *frame, xlator_t *this,
+ void *data)
+{
+ int ret = 0;
+ int32_t command = 0;
+ int32_t cmd = 0;
+ gf_cli_req req = { {0,} };
+ gf_cli_req status_req = { {0,} };
+ dict_t *dict = NULL;
+ char *volname = NULL;
+
+ if (!frame || !this || !data) {
+ ret = -1;
+ goto out;
+ }
+ dict = data;
+
+ ret = cli_to_glusterd (&req, frame, gf_cli_defrag_volume_cbk,
+ (xdrproc_t) xdr_gf_cli_req, dict,
+ GLUSTER_CLI_DEFRAG_VOLUME, this, cli_rpc_prog,
+ NULL);
+
+out:
+ gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret);
+
+ GF_FREE (req.dict.dict_val);
+
+ GF_FREE (status_req.dict.dict_val);
+
+ return ret;
+}
+
+int32_t
gf_cli_detach_tier (call_frame_t *frame, xlator_t *this,
void *data)
{
@@ -10726,7 +10759,8 @@ struct rpc_clnt_procedure gluster_cli_actors[GLUSTER_CLI_MAXVALUE] = {
[GLUSTER_CLI_GET_VOL_OPT] = {"GET_VOL_OPT", gf_cli_get_vol_opt},
[GLUSTER_CLI_BITROT] = {"BITROT", gf_cli_bitrot},
[GLUSTER_CLI_ATTACH_TIER] = {"ATTACH_TIER", gf_cli_attach_tier},
- [GLUSTER_CLI_DETACH_TIER] = {"DETACH_TIER", gf_cli_detach_tier}
+ [GLUSTER_CLI_DETACH_TIER] = {"DETACH_TIER", gf_cli_detach_tier},
+ [GLUSTER_CLI_TIER] = {"TIER", gf_cli_tier}
};
struct rpc_clnt_program cli_prog = {
diff --git a/cli/src/cli.h b/cli/src/cli.h
index 47da896..f5441c0 100644
--- a/cli/src/cli.h
+++ b/cli/src/cli.h
@@ -259,6 +259,10 @@ cli_cmd_volume_detach_tier_parse (const char **words, int wordcount,
dict_t **options);
int32_t
+cli_cmd_volume_tier_parse (const char **words, int wordcount,
+ dict_t **options);
+
+int32_t
cli_cmd_volume_remove_brick_parse (const char **words, int wordcount,
dict_t **options, int *question);
diff --git a/libglusterfs/src/gfdb/gfdb_sqlite3.c b/libglusterfs/src/gfdb/gfdb_sqlite3.c
index f5f494f..08aa7d0 100644
--- a/libglusterfs/src/gfdb/gfdb_sqlite3.c
+++ b/libglusterfs/src/gfdb/gfdb_sqlite3.c
@@ -308,7 +308,7 @@ apply_sql_params_db(gf_sql_connection_t *sql_conn, dict_t *param_dict)
GF_SQL_DEFAULT_PAGE_SIZE);
sql_conn->page_size = atoi(temp_str);
/*Apply page_size on the sqlite db*/
- GF_SQLITE3_SET_PRAGMA(sqlite3_config_str, "page_size", "%ld",
+ GF_SQLITE3_SET_PRAGMA(sqlite3_config_str, "page_size", "%zd",
sql_conn->page_size, ret, out);
@@ -322,7 +322,7 @@ apply_sql_params_db(gf_sql_connection_t *sql_conn, dict_t *param_dict)
GF_SQL_DEFAULT_CACHE_SIZE);
sql_conn->cache_size = atoi(temp_str);
/*Apply cache size on the sqlite db*/
- GF_SQLITE3_SET_PRAGMA(sqlite3_config_str, "cache_size", "%ld",
+ GF_SQLITE3_SET_PRAGMA(sqlite3_config_str, "cache_size", "%zd",
sql_conn->cache_size, ret, out);
@@ -354,7 +354,7 @@ apply_sql_params_db(gf_sql_connection_t *sql_conn, dict_t *param_dict)
sql_conn->wal_autocheckpoint = atoi(temp_str);
/*Apply wal auto check point to the sqlite db*/
GF_SQLITE3_SET_PRAGMA(sqlite3_config_str, "wal_autocheckpoint",
- "%ld", sql_conn->wal_autocheckpoint, ret, out);
+ "%zd", sql_conn->wal_autocheckpoint, ret, out);
}
@@ -703,7 +703,7 @@ gf_sqlite3_find_recently_changed_files(void *db_conn,
if (ret != SQLITE_OK) {
gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0,
LG_MSG_BINDING_FAILED, "Failed binding from_time_usec "
- "%ld : %s", from_time_usec,
+ "%"PRIu64" : %s", from_time_usec,
sqlite3_errmsg(sql_conn->sqlite3_db_conn));
ret = -1;
goto out;
@@ -714,7 +714,7 @@ gf_sqlite3_find_recently_changed_files(void *db_conn,
if (ret != SQLITE_OK) {
gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0,
LG_MSG_BINDING_FAILED, "Failed binding from_time_usec "
- "%ld : %s ", from_time_usec,
+ "%"PRIu64" : %s ", from_time_usec,
sqlite3_errmsg(sql_conn->sqlite3_db_conn));
ret = -1;
goto out;
@@ -788,7 +788,7 @@ gf_sqlite3_find_unchanged_for_time (void *db_conn,
if (ret != SQLITE_OK) {
gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0,
LG_MSG_BINDING_FAILED, "Failed binding for_time_usec "
- "%ld : %s", for_time_usec,
+ "%"PRIu64" : %s", for_time_usec,
sqlite3_errmsg(sql_conn->sqlite3_db_conn));
ret = -1;
goto out;
@@ -799,7 +799,7 @@ gf_sqlite3_find_unchanged_for_time (void *db_conn,
if (ret != SQLITE_OK) {
gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0,
LG_MSG_BINDING_FAILED, "Failed binding for_time_usec "
- "%ld : %s", for_time_usec,
+ "%"PRIu64" : %s", for_time_usec,
sqlite3_errmsg(sql_conn->sqlite3_db_conn));
ret = -1;
goto out;
@@ -885,7 +885,7 @@ gf_sqlite3_find_recently_changed_files_freq (void *db_conn,
if (ret != SQLITE_OK) {
gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0,
LG_MSG_BINDING_FAILED, "Failed binding from_time_usec "
- "%ld : %s", from_time_usec,
+ "%"PRIu64" : %s", from_time_usec,
sqlite3_errmsg(sql_conn->sqlite3_db_conn));
ret = -1;
goto out;
@@ -908,7 +908,7 @@ gf_sqlite3_find_recently_changed_files_freq (void *db_conn,
if (ret != SQLITE_OK) {
gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0,
LG_MSG_BINDING_FAILED, "Failed binding from_time_usec "
- "%ld : %s", from_time_usec,
+ "%"PRIu64" : %s", from_time_usec,
sqlite3_errmsg(sql_conn->sqlite3_db_conn));
ret = -1;
goto out;
@@ -1030,7 +1030,7 @@ gf_sqlite3_find_unchanged_for_time_freq (void *db_conn,
if (ret != SQLITE_OK) {
gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0,
LG_MSG_BINDING_FAILED, "Failed binding for_time_usec "
- "%ld : %s", for_time_usec,
+ "%"PRIu64" : %s", for_time_usec,
sqlite3_errmsg(sql_conn->sqlite3_db_conn));
ret = -1;
goto out;
@@ -1052,7 +1052,7 @@ gf_sqlite3_find_unchanged_for_time_freq (void *db_conn,
if (ret != SQLITE_OK) {
gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0,
LG_MSG_BINDING_FAILED, "Failed binding for_time_usec "
- "%ld : %s", for_time_usec,
+ "%"PRIu64" : %s", for_time_usec,
sqlite3_errmsg(sql_conn->sqlite3_db_conn));
ret = -1;
goto out;
@@ -1065,7 +1065,7 @@ gf_sqlite3_find_unchanged_for_time_freq (void *db_conn,
if (ret != SQLITE_OK) {
gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0,
LG_MSG_BINDING_FAILED, "Failed binding for_time_usec "
- "%ld : %s", for_time_usec,
+ "%"PRIu64" : %s", for_time_usec,
sqlite3_errmsg(sql_conn->sqlite3_db_conn));
ret = -1;
goto out;
@@ -1087,7 +1087,7 @@ gf_sqlite3_find_unchanged_for_time_freq (void *db_conn,
if (ret != SQLITE_OK) {
gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0,
LG_MSG_BINDING_FAILED, "Failed binding for_time_usec "
- "%ld : %s", for_time_usec,
+ "%"PRIu64" : %s", for_time_usec,
sqlite3_errmsg(sql_conn->sqlite3_db_conn));
ret = -1;
goto out;
diff --git a/rpc/rpc-lib/src/protocol-common.h b/rpc/rpc-lib/src/protocol-common.h
index 2f7f23f..1203173 100644
--- a/rpc/rpc-lib/src/protocol-common.h
+++ b/rpc/rpc-lib/src/protocol-common.h
@@ -183,6 +183,7 @@ enum gluster_cli_procnum {
GLUSTER_CLI_BITROT,
GLUSTER_CLI_ATTACH_TIER,
GLUSTER_CLI_DETACH_TIER,
+ GLUSTER_CLI_TIER,
GLUSTER_CLI_MAXVALUE,
};
diff --git a/tests/basic/tier/tier.t b/tests/basic/tier/tier.t
index 3b0b0bf..289fc29 100755
--- a/tests/basic/tier/tier.t
+++ b/tests/basic/tier/tier.t
@@ -118,7 +118,7 @@ TEST pidof glusterd
TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0..$LAST_BRICK}
# testing bug 1215122, ie should fail if replica count and bricks are not compatible.
-TEST ! $CLI volume attach-tier $V0 replica 5 $H0:$B0/${V0}$CACHE_BRICK_FIRST $H0:$B0/${V0}$CACHE_BRICK_LAST
+TEST ! $CLI volume tier $V0 attach replica 5 $H0:$B0/${V0}$CACHE_BRICK_FIRST $H0:$B0/${V0}$CACHE_BRICK_LAST
TEST $CLI volume start $V0
@@ -134,16 +134,16 @@ TEST $CLI volume set $V0 features.ctr-enabled on
TEST ! $CLI volume set $V0 cluster.tier-demote-frequency 4
#testing bug #1228112, glusterd crashed when trying to detach-tier commit force on a non-tiered volume.
-TEST ! $CLI volume detach-tier $V0 commit force
+TEST ! $CLI volume tier $V0 detach commit force
-TEST $CLI volume attach-tier $V0 replica 2 $H0:$B0/${V0}$CACHE_BRICK_FIRST $H0:$B0/${V0}$CACHE_BRICK_LAST
+TEST $CLI volume tier $V0 attach replica 2 $H0:$B0/${V0}$CACHE_BRICK_FIRST $H0:$B0/${V0}$CACHE_BRICK_LAST
# stop the volume and restart it. The rebalance daemon should restart.
TEST $CLI volume stop $V0
TEST $CLI volume start $V0
sleep_first_cycle
-$CLI volume rebalance $V0 tier status
+$CLI volume tier $V0 status
#Tier options expect non-negative value
TEST ! $CLI volume set $V0 cluster.tier-promote-frequency -1
@@ -209,9 +209,9 @@ EXPECT "0" file_on_slow_tier d1/data.txt $md5data
EXPECT "0" file_on_slow_tier d1/data2.txt $md5data2
EXPECT "0" file_on_slow_tier d1/data3.txt $md5data3
-TEST $CLI volume detach-tier $V0 start
+TEST $CLI volume tier $V0 detach start
-TEST $CLI volume detach-tier $V0 commit force
+TEST $CLI volume tier $V0 detach commit force
EXPECT "0" confirm_tier_removed ${V0}${CACHE_BRICK_FIRST}