Skip to content

Commit

Permalink
stripe cleanup: Remove the option from create and add-brick cmds (glu…
Browse files Browse the repository at this point in the history
…ster#1812)

* stripe cleanup: Remove the option from create and add-brick cmds

This patch aims to remove the code for stripe option instead
of keeping a default values of stripe/stripe-count variables and
setting and getting dict options and similar redundant operations.
Also removing tests for stripe volumes that have been already
marked bad.

Updates: gluster#1000
Change-Id: Ic2b3cabd671f0c8dc0521384b164c3078f7ca7c6
Signed-off-by: Sheetal Pamecha <spamecha@redhat.com>

* Fix regression error

tests/000-flaky/basic_changelog_changelog-snapshot.t
was failing due to 0 return value

Change-Id: I8ea0443669c63768760526db5aa1f205978e1dbb
Signed-off-by: Sheetal Pamecha <spamecha@redhat.com>

* add constant stripe_count value for upgrade scenerios

Change-Id: I49f3da4f106c55f9da20d0b0a299275a19daf4ba

* Fix clang-format warning

Change-Id: I83bae85d10c8c5b3c66f56c9f8de1ec81d0bbc95
  • Loading branch information
Sheetalpamecha committed Jan 5, 2021
1 parent 738b23b commit 1d74669
Show file tree
Hide file tree
Showing 16 changed files with 29 additions and 252 deletions.
29 changes: 6 additions & 23 deletions cli/src/cli-cmd-parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,16 +567,15 @@ cli_cmd_volume_create_parse(struct cli_state *state, const char **words,
char *bricks = NULL;
char *ta_brick = NULL;
int32_t brick_count = 0;
static char *opwords[] = {"replica", "stripe", "transport",
"disperse", "redundancy", "disperse-data",
"arbiter", "thin-arbiter", NULL};
static char *opwords[] = {
"replica", "transport", "disperse", "redundancy",
"disperse-data", "arbiter", "thin-arbiter", NULL};

char *w = NULL;
int op_count = 0;
int32_t replica_count = 1;
int32_t arbiter_count = 0;
int32_t thin_arbiter_count = 0;
int32_t stripe_count = 1;
int32_t disperse_count = -1;
int32_t redundancy_count = -1;
int32_t disperse_data_count = -1;
Expand Down Expand Up @@ -619,16 +618,12 @@ cli_cmd_volume_create_parse(struct cli_state *state, const char **words,
break;
} else if ((strcmp(w, "replica")) == 0) {
switch (type) {
case GF_CLUSTER_TYPE_STRIPE_REPLICATE:
case GF_CLUSTER_TYPE_REPLICATE:
cli_err("replica option given twice");
goto out;
case GF_CLUSTER_TYPE_NONE:
type = GF_CLUSTER_TYPE_REPLICATE;
break;
case GF_CLUSTER_TYPE_STRIPE:
cli_err("stripe option not supported");
goto out;
case GF_CLUSTER_TYPE_DISPERSE:
cli_err(
"replicated-dispersed volume is not "
Expand Down Expand Up @@ -726,9 +721,6 @@ cli_cmd_volume_create_parse(struct cli_state *state, const char **words,
if (ret)
goto out;

} else if ((strcmp(w, "stripe")) == 0) {
cli_err("stripe option not supported");
goto out;
} else if ((strcmp(w, "transport")) == 0) {
if (trans_type) {
cli_err(
Expand Down Expand Up @@ -826,15 +818,9 @@ cli_cmd_volume_create_parse(struct cli_state *state, const char **words,
goto out;

sub_count = disperse_count;
} else
sub_count = stripe_count * replica_count;

}
if (brick_count % sub_count) {
if (type == GF_CLUSTER_TYPE_STRIPE)
cli_err(
"number of bricks is not a multiple of "
"stripe count");
else if (type == GF_CLUSTER_TYPE_REPLICATE)
if (type == GF_CLUSTER_TYPE_REPLICATE)
cli_err(
"number of bricks is not a multiple of "
"replica count");
Expand Down Expand Up @@ -1852,7 +1838,7 @@ cli_cmd_volume_add_brick_parse(struct cli_state *state, const char **words,
int ret = -1;
int brick_count = 0, brick_index = 0;
char *bricks = NULL;
static char *opwords_cl[] = {"replica", "stripe", NULL};
static char *opwords_cl[] = {"replica", NULL};
gf1_cluster_type type = GF_CLUSTER_TYPE_NONE;
int count = 1;
int arbiter_count = 0;
Expand Down Expand Up @@ -1946,9 +1932,6 @@ cli_cmd_volume_add_brick_parse(struct cli_state *state, const char **words,
}
}
}
} else if ((strcmp(w, "stripe")) == 0) {
cli_err("stripe option not supported");
goto out;
} else {
GF_ASSERT(!"opword mismatch");
ret = -1;
Expand Down
23 changes: 2 additions & 21 deletions cli/src/cli-cmd-volume.c
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,6 @@ cli_cmd_volume_add_brick_cbk(struct cli_state *state, struct cli_cmd_word *word,
dict_t *options = NULL;
int sent = 0;
int parse_error = 0;
gf_answer_t answer = GF_ANSWER_NO;
cli_local_t *local = NULL;

#if (USE_EVENTS)
Expand All @@ -1047,31 +1046,13 @@ cli_cmd_volume_add_brick_cbk(struct cli_state *state, struct cli_cmd_word *word,
const char *eventstrformat = "volume=%s;bricks=%s";
#endif

const char *question =
"Changing the 'stripe count' of the volume is "
"not a supported feature. In some cases it may result in data "
"loss on the volume. Also there may be issues with regular "
"filesystem operations on the volume after the change. Do you "
"really want to continue with 'stripe' count option ? ";

ret = cli_cmd_volume_add_brick_parse(state, words, wordcount, &options, 0);
if (ret) {
cli_usage_out(word->pattern);
parse_error = 1;
goto out;
}

/* TODO: there are challenges in supporting changing of
stripe-count, until it is properly supported give warning to user */
if (dict_get(options, "stripe-count")) {
answer = cli_cmd_get_confirmation(state, question);

if (GF_ANSWER_NO == answer) {
ret = 0;
goto out;
}
}

#if (USE_EVENTS)
/* Get the list of bricks for the event */

Expand Down Expand Up @@ -3039,7 +3020,7 @@ struct cli_cmd volume_cmds[] = {
{"volume info [all|<VOLNAME>]", cli_cmd_volume_info_cbk,
"list information of all volumes"},

{"volume create <NEW-VOLNAME> [stripe <COUNT>] "
{"volume create <NEW-VOLNAME> "
"[[replica <COUNT> [arbiter <COUNT>]]|[replica 2 thin-arbiter 1]] "
"[disperse [<COUNT>]] [disperse-data <COUNT>] [redundancy <COUNT>] "
"[transport <tcp|rdma|tcp,rdma>] <NEW-BRICK> <TA-BRICK>"
Expand All @@ -3061,7 +3042,7 @@ struct cli_cmd volume_cmds[] = {
cli_cmd_volume_rename_cbk,
"rename volume <VOLNAME> to <NEW-VOLNAME>"},*/

{"volume add-brick <VOLNAME> [<stripe|replica> <COUNT> "
{"volume add-brick <VOLNAME> [<replica> <COUNT> "
"[arbiter <COUNT>]] <NEW-BRICK> ... [force]",
cli_cmd_volume_add_brick_cbk, "add brick to volume <VOLNAME>"},

Expand Down
27 changes: 7 additions & 20 deletions cli/src/cli-rpc-ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -677,9 +677,8 @@ print_brick_details(dict_t *dict, int volcount, int start_index, int end_index,

static void
gf_cli_print_number_of_bricks(int type, int brick_count, int dist_count,
int stripe_count, int replica_count,
int disperse_count, int redundancy_count,
int arbiter_count)
int replica_count, int disperse_count,
int redundancy_count, int arbiter_count)
{
if (type == GF_CLUSTER_TYPE_NONE) {
cli_out("Number of Bricks: %d", brick_count);
Expand All @@ -688,8 +687,7 @@ gf_cli_print_number_of_bricks(int type, int brick_count, int dist_count,
(brick_count / dist_count), disperse_count - redundancy_count,
redundancy_count, brick_count);
} else {
/* For both replicate and stripe, dist_count is
good enough */
/* For replicate, dist_count is good enough */
if (arbiter_count == 0) {
cli_out("Number of Bricks: %d x %d = %d",
(brick_count / dist_count), dist_count, brick_count);
Expand All @@ -713,7 +711,6 @@ gf_cli_get_volume_cbk(struct rpc_req *req, struct iovec *iov, int count,
int32_t type = 0;
int32_t brick_count = 0;
int32_t dist_count = 0;
int32_t stripe_count = 0;
int32_t replica_count = 0;
int32_t disperse_count = 0;
int32_t redundancy_count = 0;
Expand Down Expand Up @@ -861,16 +858,6 @@ gf_cli_get_volume_cbk(struct rpc_req *req, struct iovec *iov, int count,
if (ret)
goto out;

keylen = snprintf(key, sizeof(key), "volume%d.stripe_count", i);
ret = dict_get_int32n(dict, key, keylen, &stripe_count);
if (ret)
goto out;

keylen = snprintf(key, sizeof(key), "volume%d.replica_count", i);
ret = dict_get_int32n(dict, key, keylen, &replica_count);
if (ret)
goto out;

keylen = snprintf(key, sizeof(key), "volume%d.disperse_count", i);
ret = dict_get_int32n(dict, key, keylen, &disperse_count);
if (ret)
Expand Down Expand Up @@ -906,7 +893,7 @@ gf_cli_get_volume_cbk(struct rpc_req *req, struct iovec *iov, int count,
if (ret)
goto out;

// Distributed (stripe/replicate/stripe-replica) setups
// Distributed (replicate) setups
vol_type = get_vol_type(type, dist_count, brick_count);

cli_out("Volume Name: %s", volname);
Expand All @@ -915,9 +902,9 @@ gf_cli_get_volume_cbk(struct rpc_req *req, struct iovec *iov, int count,
cli_out("Status: %s", cli_vol_status_str[status]);
cli_out("Snapshot Count: %d", snap_count);

gf_cli_print_number_of_bricks(
type, brick_count, dist_count, stripe_count, replica_count,
disperse_count, redundancy_count, arbiter_count);
gf_cli_print_number_of_bricks(type, brick_count, dist_count,
replica_count, disperse_count,
redundancy_count, arbiter_count);

cli_out("Transport-type: %s",
((transport == 0) ? "tcp"
Expand Down
11 changes: 1 addition & 10 deletions cli/src/cli-xml-output.c
Original file line number Diff line number Diff line change
Expand Up @@ -2429,7 +2429,6 @@ cli_xml_output_vol_info(cli_local_t *local, dict_t *dict)
int status = 0;
int brick_count = 0;
int dist_count = 0;
int stripe_count = 0;
int replica_count = 0;
int arbiter_count = 0;
int snap_count = 0;
Expand Down Expand Up @@ -2509,14 +2508,6 @@ cli_xml_output_vol_info(cli_local_t *local, dict_t *dict)
(brick_count / dist_count));
XML_RET_CHECK_AND_GOTO(ret, out);

snprintf(key, sizeof(key), "volume%d.stripe_count", i);
ret = dict_get_int32(dict, key, &stripe_count);
if (ret)
goto out;
ret = xmlTextWriterWriteFormatElement(
local->writer, (xmlChar *)"stripeCount", "%d", stripe_count);
XML_RET_CHECK_AND_GOTO(ret, out);

snprintf(key, sizeof(key), "volume%d.replica_count", i);
ret = dict_get_int32(dict, key, &replica_count);
if (ret)
Expand Down Expand Up @@ -2554,7 +2545,7 @@ cli_xml_output_vol_info(cli_local_t *local, dict_t *dict)
ret = dict_get_int32(dict, key, &type);
if (ret)
goto out;
/* For Distributed-(stripe,replicate,stipe-replicate,disperse)
/* For Distributed-(replicate,disperse)
types
*/
type = get_vol_type(type, dist_count, brick_count);
Expand Down
55 changes: 0 additions & 55 deletions tests/bugs/stripe/bug-1002207.t

This file was deleted.

20 changes: 0 additions & 20 deletions tests/bugs/stripe/bug-1111454.t

This file was deleted.

Loading

0 comments on commit 1d74669

Please sign in to comment.