glusterd: get-state command should not fail if any brick is gone bad

Problem: get-state command will error out, if any of the underlying
brick(s) of volume(s) in the cluster go bad.

It is expected that get-state command should not error out, but
should generate an output successfully.

Solution: In glusterd_get_state(), a statfs call is made on the
brick path for every bricks of the volumes to calculate the total
and free memory available. If any of statfs call fails on any
brick, we should not error out and should report total memory and free
memory of that brick as 0.

This patch also handles a statfs failure scenario in
glusterd_store_retrieve_bricks().

fixes: bz#1672205

Change-Id: Ia9e8a1d8843b65949d72fd6809bd21d39b31ad83
Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
This commit is contained in:
Sanju Rakonde 2019-02-04 15:07:14 +05:30 committed by Atin Mukherjee
parent a9b51f2d1f
commit 90922d20f5
2 changed files with 7 additions and 5 deletions

View File

@ -5779,12 +5779,13 @@ glusterd_get_state(rpcsvc_request_t *req, dict_t *dict)
if (ret) {
gf_msg(this->name, GF_LOG_ERROR, errno, GD_MSG_FILE_OP_FAILED,
"statfs error: %s ", strerror(errno));
goto out;
memfree = 0;
memtotal = 0;
} else {
memfree = brickstat.f_bfree * brickstat.f_bsize;
memtotal = brickstat.f_blocks * brickstat.f_bsize;
}
memfree = brickstat.f_bfree * brickstat.f_bsize;
memtotal = brickstat.f_blocks * brickstat.f_bsize;
fprintf(fp, "Volume%d.Brick%d.spacefree: %" PRIu64 "Bytes\n",
count_bkp, count, memfree);
fprintf(fp, "Volume%d.Brick%d.spacetotal: %" PRIu64 "Bytes\n",

View File

@ -2878,8 +2878,9 @@ glusterd_store_retrieve_bricks(glusterd_volinfo_t *volinfo)
brickinfo->path);
/* No need for treating it as an error, lets continue
with just a message */
} else {
brickinfo->statfs_fsid = brickstat.f_fsid;
}
brickinfo->statfs_fsid = brickstat.f_fsid;
}
cds_list_add_tail(&brickinfo->brick_list, &volinfo->bricks);