diff options
-rw-r--r-- | tests/basic/ec/statedump.t | 26 | ||||
-rw-r--r-- | tests/volume.rc | 24 | ||||
-rw-r--r-- | xlators/cluster/ec/src/ec.c | 30 |
3 files changed, 80 insertions, 0 deletions
diff --git a/tests/basic/ec/statedump.t b/tests/basic/ec/statedump.t new file mode 100644 index 00000000000..6881c7f8c27 --- /dev/null +++ b/tests/basic/ec/statedump.t @@ -0,0 +1,26 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc + +cleanup + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume create $V0 redundancy 1 $H0:$B0/${V0}{0..2} +TEST $CLI volume start $V0 +TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0 + +EXPECT_WITHIN $CHILD_UP_TIMEOUT "3" ec_child_up_count $V0 0 +EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" ec_child_up_status $V0 0 0 +EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" ec_child_up_status $V0 0 1 +EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" ec_child_up_status $V0 0 2 + +TEST kill_brick $V0 $H0 $B0/${V0}0 + +EXPECT_WITHIN $CHILD_UP_TIMEOUT "2" ec_child_up_count $V0 0 +EXPECT_WITHIN $CHILD_UP_TIMEOUT "0" ec_child_up_status $V0 0 0 +EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" ec_child_up_status $V0 0 1 +EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" ec_child_up_status $V0 0 2 + +cleanup diff --git a/tests/volume.rc b/tests/volume.rc index 009f58b7c60..a216ba5fb7f 100644 --- a/tests/volume.rc +++ b/tests/volume.rc @@ -110,6 +110,30 @@ function afr_child_up_status { _afr_child_up_status $vol $brick_id generate_mount_statedump } +function ec_get_info { + local vol=$1 + local dist_id=$2 + local key=$3 + local fpath=$(generate_mount_statedump $vol) + local value=$(sed -n "/^\[cluster\/disperse\.$vol-disperse-$dist_id\]/,/^\[/{s/^$key=\(.*\)/\1/p;}" $fpath | head -1) + rm -f $fpath + echo "$value" +} + +function ec_child_up_status { + local vol=$1 + local dist_id=$2 + local brick_id=$(($3 + 1)) + local mask=$(ec_get_info $vol $dist_id "childs_up_mask") + echo "${mask: -$brick_id:1}" +} + +function ec_child_up_count { + local vol=$1 + local dist_id=$2 + ec_get_info $vol $dist_id "childs_up" +} + function get_shd_process_pid { local vol=$1 ps auxww | grep glusterfs | grep -E "glustershd/run/glustershd.pid" | awk '{print $2}' | head -1 diff --git a/xlators/cluster/ec/src/ec.c b/xlators/cluster/ec/src/ec.c index 93bee1a4d32..545d109af9f 100644 --- a/xlators/cluster/ec/src/ec.c +++ b/xlators/cluster/ec/src/ec.c @@ -19,8 +19,10 @@ */ #include "defaults.h" +#include "statedump.h" #include "ec-mem-types.h" +#include "ec-helpers.h" #include "ec-common.h" #include "ec-fops.h" #include "ec-method.h" @@ -830,6 +832,30 @@ int32_t ec_gf_releasedir(xlator_t * this, fd_t * fd) return 0; } +int32_t ec_dump_private(xlator_t *this) +{ + ec_t *ec = NULL; + char key_prefix[GF_DUMP_MAX_BUF_LEN]; + char tmp[65]; + + GF_ASSERT(this); + + ec = this->private; + GF_ASSERT(ec); + + snprintf(key_prefix, GF_DUMP_MAX_BUF_LEN, "%s.%s", this->type, this->name); + gf_proc_dump_add_section(key_prefix); + gf_proc_dump_write("nodes", "%u", ec->nodes); + gf_proc_dump_write("redundancy", "%u", ec->redundancy); + gf_proc_dump_write("fragment_size", "%u", ec->fragment_size); + gf_proc_dump_write("stripe_size", "%u", ec->stripe_size); + gf_proc_dump_write("childs_up", "%u", ec->xl_up_count); + gf_proc_dump_write("childs_up_mask", "%s", + ec_bin(tmp, sizeof(tmp), ec->xl_up, ec->nodes)); + + return 0; +} + struct xlator_fops fops = { .lookup = ec_gf_lookup, @@ -884,6 +910,10 @@ struct xlator_cbks cbks = .releasedir = ec_gf_releasedir }; +struct xlator_dumpops dumpops = { + .priv = ec_dump_private +}; + struct volume_options options[] = { { |