gluster volume info: fix the output of 'stripe-replicated' volumes

also fix the glusterd-store to preserve the required information

Signed-off-by: Amar Tumballi <amar@gluster.com>
Signed-off-by: Anand Avati <avati@gluster.com>

BUG: 3040 (need a way to create volumes with 'stripe+replicate' setup..)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=3040
This commit is contained in:
Amar Tumballi 2011-06-16 23:42:53 +00:00 committed by Anand Avati
parent c9854677fc
commit 89452c4db4
4 changed files with 49 additions and 13 deletions

View File

@ -53,8 +53,10 @@ extern int connected;
char *cli_volume_type[] = {"Distribute",
"Stripe",
"Replicate",
"Striped-Replicate (RAID 01)",
"Distributed-Stripe",
"Distributed-Replicate",
"Distributed-Striped-Replicate (RAID 01)",
};
@ -380,6 +382,7 @@ gf_cli3_1_get_volume_cbk (struct rpc_req *req, struct iovec *iov,
int32_t type = 0;
int32_t brick_count = 0;
int32_t sub_count = 0;
int32_t stripe_count = 0;
int32_t vol_type = 0;
char *brick = NULL;
int32_t j = 1;
@ -484,6 +487,11 @@ gf_cli3_1_get_volume_cbk (struct rpc_req *req, struct iovec *iov,
if (ret)
goto out;
snprintf (key, 256, "volume%d.stripe_count", i);
ret = dict_get_int32 (dict, key, &stripe_count);
if (ret)
goto out;
snprintf (key, 256, "volume%d.transport", i);
ret = dict_get_int32 (dict, key, &transport);
if (ret)
@ -491,23 +499,32 @@ gf_cli3_1_get_volume_cbk (struct rpc_req *req, struct iovec *iov,
vol_type = type;
// Stripe
if ((type == 1) && (sub_count < brick_count))
vol_type = 3;
// Replicate
if ((type == 2) && (sub_count < brick_count))
vol_type = 4;
// Distributed (stripe/replicate/raid01) setups
if ((type > 1) && ( sub_count < brick_count))
vol_type = type + 3;
cli_out ("Volume Name: %s", volname);
cli_out ("Type: %s", cli_volume_type[vol_type]);
cli_out ("Status: %s", cli_volume_status[status]);
if ((sub_count > 1) && (brick_count > sub_count))
cli_out ("Number of Bricks: %d x %d = %d",
brick_count / sub_count, sub_count,
brick_count);
else
cli_out ("Number of Bricks: %d", brick_count);
if ((sub_count > 1) && (brick_count > sub_count)) {
if (!stripe_count)
cli_out ("Number of Bricks: %d x %d = %d",
brick_count / sub_count, sub_count,
brick_count);
else
cli_out ("Number of Bricks: %d x %d x %d = %d",
brick_count / sub_count, stripe_count,
sub_count / stripe_count, brick_count);
} else {
if (!stripe_count)
cli_out ("Number of Bricks: %d",
brick_count);
else
cli_out ("Number of Bricks: %d x %d = %d",
stripe_count,
(brick_count / stripe_count),
brick_count);
}
cli_out ("Transport-type: %s",
((transport == 0)?"tcp":

View File

@ -319,6 +319,11 @@ glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo,
if (ret)
goto out;
snprintf (key, 256, "volume%d.stripe_count", count);
ret = dict_set_int32 (volumes, key, volinfo->stripe_count);
if (ret)
goto out;
snprintf (key, 256, "volume%d.transport", count);
ret = dict_set_int32 (volumes, key, volinfo->transport_type);
if (ret)

View File

@ -591,6 +591,12 @@ glusterd_volume_exclude_options_write (int fd, glusterd_volinfo_t *volinfo)
if (ret)
goto out;
snprintf (buf, sizeof (buf), "%d", volinfo->stripe_count);
ret = glusterd_store_save_value (fd, GLUSTERD_STORE_KEY_VOL_STRIPE_CNT,
buf);
if (ret)
goto out;
snprintf (buf, sizeof (buf), "%d", volinfo->version);
ret = glusterd_store_save_value (fd, GLUSTERD_STORE_KEY_VOL_VERSION,
buf);
@ -1555,6 +1561,9 @@ glusterd_store_retrieve_volume (char *volname)
} else if (!strncmp (key, GLUSTERD_STORE_KEY_VOL_SUB_COUNT,
strlen (GLUSTERD_STORE_KEY_VOL_SUB_COUNT))) {
volinfo->sub_count = atoi (value);
} else if (!strncmp (key, GLUSTERD_STORE_KEY_VOL_STRIPE_CNT,
strlen (GLUSTERD_STORE_KEY_VOL_STRIPE_CNT))) {
volinfo->stripe_count = atoi (value);
} else if (!strncmp (key, GLUSTERD_STORE_KEY_VOL_TRANSPORT,
strlen (GLUSTERD_STORE_KEY_VOL_TRANSPORT))) {
volinfo->transport_type = atoi (value);
@ -1613,6 +1622,10 @@ glusterd_store_retrieve_volume (char *volname)
if (op_errno != GD_STORE_EOF)
goto out;
if (volinfo->stripe_count)
volinfo->replica_count = (volinfo->sub_count /
volinfo->stripe_count);
ret = glusterd_store_iter_destroy (iter);
if (ret)

View File

@ -50,6 +50,7 @@ typedef enum glusterd_store_ver_ac_{
#define GLUSTERD_STORE_KEY_VOL_STATUS "status"
#define GLUSTERD_STORE_KEY_VOL_PORT "port"
#define GLUSTERD_STORE_KEY_VOL_SUB_COUNT "sub_count"
#define GLUSTERD_STORE_KEY_VOL_STRIPE_CNT "stripe_count"
#define GLUSTERD_STORE_KEY_VOL_BRICK "brick"
#define GLUSTERD_STORE_KEY_VOL_VERSION "version"
#define GLUSTERD_STORE_KEY_VOL_TRANSPORT "transport-type"