From 2313600f0749094f1246e663a0db15da3c2812db Mon Sep 17 00:00:00 2001 From: Krishnan Parthasarathi Date: Fri, 6 Jan 2012 12:18:35 +0530 Subject: glusterd: Improved err msgs for add_brick Change-Id: I4b97d7e26b8c81ed52657467981be0c4adc291ae BUG: 772145 Signed-off-by: Krishnan Parthasarathi Reviewed-on: http://review.gluster.com/2589 Tested-by: Gluster Build System Reviewed-by: Amar Tumballi --- xlators/mgmt/glusterd/src/glusterd-brick-ops.c | 38 ++++++++++++++++++-------- 1 file changed, 27 insertions(+), 11 deletions(-) (limited to 'xlators/mgmt/glusterd/src/glusterd-brick-ops.c') diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c index 5a4bbab77fb..2f1c37f0e9f 100644 --- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c @@ -107,12 +107,19 @@ gd_addbr_validate_stripe_count (glusterd_volinfo_t *volinfo, int stripe_count, case GF_CLUSTER_TYPE_NONE: if ((volinfo->brick_count * stripe_count) == total_bricks) { /* Change the volume type */ + *type = GF_CLUSTER_TYPE_STRIPE; gf_log (THIS->name, GF_LOG_INFO, "Changing the type of volume %s from " - "None to 'stripe'", volinfo->volname); - *type = GF_CLUSTER_TYPE_STRIPE; + "'distribute' to 'stripe'", volinfo->volname); ret = 0; goto out; + } else { + snprintf (err_str, err_len, "Incorrect number of " + "bricks (%d) supplied for stripe count (%d).", + (total_bricks - volinfo->brick_count), + stripe_count); + gf_log (THIS->name, GF_LOG_ERROR, "%s", err_str); + goto out; } break; case GF_CLUSTER_TYPE_REPLICATE: @@ -131,10 +138,10 @@ gd_addbr_validate_stripe_count (glusterd_volinfo_t *volinfo, int stripe_count, case GF_CLUSTER_TYPE_STRIPE_REPLICATE: if (stripe_count < volinfo->stripe_count) { snprintf (err_str, err_len, - "wrong stripe count (%d) given. " - "already have %d", + "Incorrect stripe count (%d) supplied. " + "Volume already has stripe count (%d)", stripe_count, volinfo->stripe_count); - gf_log ("glusterd", GF_LOG_ERROR, "%s", err_str); + gf_log (THIS->name, GF_LOG_ERROR, "%s", err_str); goto out; } if (stripe_count == volinfo->stripe_count) { @@ -170,7 +177,8 @@ out: static int gd_addbr_validate_replica_count (glusterd_volinfo_t *volinfo, int replica_count, - int total_bricks, int *type, char *err_str, int err_len) + int total_bricks, int *type, char *err_str, + int err_len) { int ret = -1; @@ -179,12 +187,20 @@ gd_addbr_validate_replica_count (glusterd_volinfo_t *volinfo, int replica_count, case GF_CLUSTER_TYPE_NONE: if ((volinfo->brick_count * replica_count) == total_bricks) { /* Change the volume type */ + *type = GF_CLUSTER_TYPE_REPLICATE; gf_log (THIS->name, GF_LOG_INFO, "Changing the type of volume %s from " - "None to 'replica'", volinfo->volname); - *type = GF_CLUSTER_TYPE_REPLICATE; + "'distribute' to 'replica'", volinfo->volname); ret = 0; goto out; + + } else { + snprintf (err_str, err_len, "Incorrect number of " + "bricks (%d) supplied for replica count (%d).", + (total_bricks - volinfo->brick_count), + replica_count); + gf_log (THIS->name, GF_LOG_ERROR, "%s", err_str); + goto out; } break; case GF_CLUSTER_TYPE_STRIPE: @@ -203,10 +219,10 @@ gd_addbr_validate_replica_count (glusterd_volinfo_t *volinfo, int replica_count, case GF_CLUSTER_TYPE_STRIPE_REPLICATE: if (replica_count < volinfo->replica_count) { snprintf (err_str, err_len, - "wrong replica count (%d) given. " - "already have %d", + "Incorrect replica count (%d) supplied. " + "Volume already has (%d)", replica_count, volinfo->replica_count); - gf_log ("glusterd", GF_LOG_ERROR, "%s", err_str); + gf_log (THIS->name, GF_LOG_ERROR, "%s", err_str); goto out; } if (replica_count == volinfo->replica_count) { -- cgit