glusterd: glusterd must store all rebalance related information
Change-Id: I8404b864a405411e3af2fbee46ca20330e656045 BUG: 1351021 Signed-off-by: Sakshi Bansal <sabansal@redhat.com> Reviewed-on: http://review.gluster.org/14827 Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
This commit is contained in:
parent
1b420a3f69
commit
0cd287189e
59
tests/bugs/glusterd/bug-1351021-rebalance-info-post-glusterd-restart.t
Executable file
59
tests/bugs/glusterd/bug-1351021-rebalance-info-post-glusterd-restart.t
Executable file
@ -0,0 +1,59 @@
|
||||
#!/bin/bash
|
||||
|
||||
. $(dirname $0)/../../include.rc
|
||||
. $(dirname $0)/../../cluster.rc
|
||||
. $(dirname $0)/../../volume.rc
|
||||
|
||||
cleanup;
|
||||
|
||||
function get_rebalanced_info()
|
||||
{
|
||||
local rebal_info_key=$2
|
||||
$CLI volume rebalance $1 status | awk '{print $'$rebal_info_key'}' |sed -n 3p| sed 's/ *$//g'
|
||||
}
|
||||
|
||||
|
||||
TEST glusterd
|
||||
TEST pidof glusterd
|
||||
|
||||
TEST $CLI volume create $V0 $H0:$B0/${V0}{1..3};
|
||||
TEST $CLI volume start $V0;
|
||||
|
||||
#Mount volume and create data
|
||||
TEST glusterfs -s $H0 --volfile-id $V0 $M0;
|
||||
TEST mkdir $M0/dir{1..10}
|
||||
TEST touch $M0/dir{1..10}/file{1..10}
|
||||
|
||||
# Add-brick and start rebalance
|
||||
TEST $CLI volume add-brick $V0 $H0:$B0/${V0}4
|
||||
TEST $CLI volume rebalance $V0 start
|
||||
EXPECT_WITHIN $REBALANCE_TIMEOUT "completed" rebalance_status_field $V0
|
||||
|
||||
#Rebalance info before glusterd restart
|
||||
OLD_REBAL_FILES=$(get_rebalanced_info $V0 2)
|
||||
OLD_SIZE=$(get_rebalanced_info $V0 3)
|
||||
OLD_SCANNED=$(get_rebalanced_info $V0 4)
|
||||
OLD_FAILURES=$(get_rebalanced_info $V0 5)
|
||||
OLD_SKIPPED=$(get_rebalanced_info $V0 6)
|
||||
|
||||
|
||||
pkill glusterd;
|
||||
pkill glusterfsd;
|
||||
TEST glusterd
|
||||
|
||||
#Rebalance info after glusterd restart
|
||||
NEW_REBAL_FILES=$(get_rebalanced_info $V0 2)
|
||||
NEW_SIZE=$(get_rebalanced_info $V0 3)
|
||||
NEW_SCANNED=$(get_rebalanced_info $V0 4)
|
||||
NEW_FAILURES=$(get_rebalanced_info $V0 5)
|
||||
NEW_SKIPPED=$(get_rebalanced_info $V0 6)
|
||||
|
||||
#Check rebalance info before and after glusterd restart
|
||||
TEST [ $OLD_REBAL_FILES == $NEW_REBAL_FILES ]
|
||||
TEST [ $OLD_SIZE == $NEW_SIZE ]
|
||||
TEST [ $OLD_SCANNED == $NEW_SCANNED ]
|
||||
TEST [ $OLD_FAILURES == $NEW_FAILURES ]
|
||||
TEST [ $OLD_SKIPPED == $NEW_SKIPPED ]
|
||||
|
||||
cleanup;
|
||||
|
@ -1392,6 +1392,41 @@ glusterd_store_node_state_write (int fd, glusterd_volinfo_t *volinfo)
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
snprintf (buf, sizeof (buf), "%"PRIu64, volinfo->rebal.rebalance_files);
|
||||
ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_VOL_DEFRAG_REB_FILES,
|
||||
buf);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
snprintf (buf, sizeof (buf), "%"PRIu64, volinfo->rebal.rebalance_data);
|
||||
ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_VOL_DEFRAG_SIZE, buf);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
snprintf (buf, sizeof (buf), "%"PRIu64, volinfo->rebal.lookedup_files);
|
||||
ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_VOL_DEFRAG_SCANNED,
|
||||
buf);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
snprintf (buf, sizeof (buf), "%"PRIu64, volinfo->rebal.rebalance_failures);
|
||||
ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_VOL_DEFRAG_FAILURES,
|
||||
buf);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
snprintf (buf, sizeof (buf), "%"PRIu64, volinfo->rebal.skipped_files);
|
||||
ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_VOL_DEFRAG_SKIPPED,
|
||||
buf);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
snprintf (buf, sizeof (buf), "%lf", volinfo->rebal.rebalance_time);
|
||||
ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_VOL_DEFRAG_RUN_TIME,
|
||||
buf);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
if (volinfo->rebal.dict) {
|
||||
dict_foreach (volinfo->rebal.dict, _gd_store_rebalance_dict,
|
||||
&fd);
|
||||
@ -2503,8 +2538,26 @@ glusterd_store_retrieve_node_state (glusterd_volinfo_t *volinfo)
|
||||
strlen (GF_REBALANCE_TID_KEY))) {
|
||||
gf_uuid_parse (value, volinfo->rebal.rebalance_id);
|
||||
} else if (!strncmp (key, GLUSTERD_STORE_KEY_DEFRAG_OP,
|
||||
strlen (GLUSTERD_STORE_KEY_DEFRAG_OP))) {
|
||||
strlen (GLUSTERD_STORE_KEY_DEFRAG_OP))) {
|
||||
volinfo->rebal.op = atoi (value);
|
||||
} else if (!strncmp (key, GLUSTERD_STORE_KEY_VOL_DEFRAG_REB_FILES,
|
||||
strlen (GLUSTERD_STORE_KEY_VOL_DEFRAG_REB_FILES))) {
|
||||
volinfo->rebal.rebalance_files = atoi (value);
|
||||
} else if (!strncmp (key, GLUSTERD_STORE_KEY_VOL_DEFRAG_SIZE,
|
||||
strlen (GLUSTERD_STORE_KEY_VOL_DEFRAG_SIZE))) {
|
||||
volinfo->rebal.rebalance_data = atoi (value);
|
||||
} else if (!strncmp (key, GLUSTERD_STORE_KEY_VOL_DEFRAG_SCANNED,
|
||||
strlen (GLUSTERD_STORE_KEY_VOL_DEFRAG_SCANNED))) {
|
||||
volinfo->rebal.lookedup_files = atoi (value);
|
||||
} else if (!strncmp (key, GLUSTERD_STORE_KEY_VOL_DEFRAG_FAILURES,
|
||||
strlen (GLUSTERD_STORE_KEY_VOL_DEFRAG_FAILURES))) {
|
||||
volinfo->rebal.rebalance_failures = atoi (value);
|
||||
} else if (!strncmp (key, GLUSTERD_STORE_KEY_VOL_DEFRAG_SKIPPED,
|
||||
strlen (GLUSTERD_STORE_KEY_VOL_DEFRAG_SKIPPED))) {
|
||||
volinfo->rebal.skipped_files = atoi (value);
|
||||
} else if (!strncmp (key, GLUSTERD_STORE_KEY_VOL_DEFRAG_RUN_TIME,
|
||||
strlen (GLUSTERD_STORE_KEY_VOL_DEFRAG_RUN_TIME))) {
|
||||
volinfo->rebal.rebalance_time = atoi (value);
|
||||
} else {
|
||||
if (!tmp_dict) {
|
||||
tmp_dict = dict_new ();
|
||||
|
@ -103,6 +103,13 @@ typedef enum glusterd_store_ver_ac_{
|
||||
|
||||
#define GLUSTERD_STORE_KEY_VOL_CAPS "caps"
|
||||
|
||||
#define GLUSTERD_STORE_KEY_VOL_DEFRAG_REB_FILES "rebalanced-files"
|
||||
#define GLUSTERD_STORE_KEY_VOL_DEFRAG_SIZE "size"
|
||||
#define GLUSTERD_STORE_KEY_VOL_DEFRAG_SCANNED "scanned"
|
||||
#define GLUSTERD_STORE_KEY_VOL_DEFRAG_FAILURES "failures"
|
||||
#define GLUSTERD_STORE_KEY_VOL_DEFRAG_SKIPPED "skipped"
|
||||
#define GLUSTERD_STORE_KEY_VOL_DEFRAG_RUN_TIME "run-time"
|
||||
|
||||
int32_t
|
||||
glusterd_store_volinfo (glusterd_volinfo_t *volinfo, glusterd_volinfo_ver_ac_t ac);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user