From cdc96d5d4c6247d9b0ca942eeb37338dacfe93ee Mon Sep 17 00:00:00 2001 From: Atin Mukherjee Date: Tue, 19 Jan 2016 10:45:22 +0530 Subject: glusterd: use string comparison for realpath checks in glusterd_is_brickpath_available Backport of http://review.gluster.org/13258 glusterd_is_brickpath_available () used to call realpath() for checking the whether the new brick path matches with the existing ones. The problem with this is if the underlying file system is bad for any one of the existing bricks then realpath() would fail and we wouldn't allow to create the new brick even if it should be allowed. Fix is to use string comparison with having a new field real_path in brickinfo to store the absolute path Change-Id: I1250ea5345f00fca0f6128056ebd08750d604f0a BUG: 1312878 Signed-off-by: Atin Mukherjee Reviewed-on: http://review.gluster.org/13258 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Jeff Darcy Reviewed-on: http://review.gluster.org/13550 --- xlators/mgmt/glusterd/src/glusterd-store.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'xlators/mgmt/glusterd/src/glusterd-store.c') diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index ca02b10b572..19115ef8943 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -2252,6 +2252,7 @@ glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo) char tmpkey[4096] = {0,}; gf_store_iter_t *tmpiter = NULL; char *tmpvalue = NULL; + char abspath[PATH_MAX] = {0}; struct pmap_registry *pmap = NULL; xlator_t *this = NULL; int brickid = 0; @@ -2405,7 +2406,22 @@ glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo) GLUSTERD_ASSIGN_BRICKID_TO_BRICKINFO (brickinfo, volinfo, brickid++); } - + ret = glusterd_resolve_brick (brickinfo); + if (ret) + goto out; + if (!gf_uuid_compare(brickinfo->uuid, MY_UUID)) { + if (!realpath (brickinfo->path, abspath)) { + gf_msg (this->name, GF_LOG_CRITICAL, errno, + GD_MSG_BRICKINFO_CREATE_FAIL, "realpath" + " () failed for brick %s. The " + "underlying file system may be in bad" + " state", brickinfo->path); + ret = -1; + goto out; + } + strncpy (brickinfo->real_path, abspath, + strlen(abspath)); + } cds_list_add_tail (&brickinfo->brick_list, &volinfo->bricks); brick_count++; } -- cgit