From a60c39de31e8258cb56d8db6bd8ec2491a942a4e 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 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: 1299710 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 --- xlators/mgmt/glusterd/src/glusterd-snapshot.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'xlators/mgmt/glusterd/src/glusterd-snapshot.c') diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c index 297add57be6..2b106b63d4d 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c @@ -4819,6 +4819,7 @@ glusterd_add_brick_to_snap_volume (dict_t *dict, dict_t *rsp_dict, gf_boolean_t add_missed_snap = _gf_false; int32_t ret = -1; xlator_t *this = NULL; + char abspath[PATH_MAX] = {0}; this = THIS; GF_ASSERT (this); @@ -4956,6 +4957,21 @@ glusterd_add_brick_to_snap_volume (dict_t *dict, dict_t *rsp_dict, strcpy (snap_brickinfo->hostname, original_brickinfo->hostname); strcpy (snap_brickinfo->path, snap_brick_path); + + if (!realpath (snap_brick_path, abspath)) { + /* ENOENT indicates that brick path has not been created which + * is a valid scenario */ + if (errno != ENOENT) { + gf_msg (this->name, GF_LOG_CRITICAL, errno, + GD_MSG_BRICKINFO_CREATE_FAIL, "realpath () " + "failed for brick %s. The underlying filesystem" + " may be in bad state", snap_brick_path); + ret = -1; + goto out; + } + } + strncpy (snap_brickinfo->real_path, abspath, strlen(abspath)); + strcpy (snap_brickinfo->mount_dir, original_brickinfo->mount_dir); gf_uuid_copy (snap_brickinfo->uuid, original_brickinfo->uuid); /* AFR changelog names are based on brick_id and hence the snap -- cgit