diff options
author | Ravishankar N <ravishankar@redhat.com> | 2017-06-15 15:36:07 +0530 |
---|---|---|
committer | Pranith Kumar Karampuri <pkarampu@redhat.com> | 2017-06-19 05:16:53 +0000 |
commit | b58a15948fb3fc37b6c0b70171482f50ed957f42 (patch) | |
tree | b046fe37593ebeea35d5a71daf41e4210bd21843 /xlators/mgmt/glusterd/src/glusterd-utils.c | |
parent | 26ca39ccf0caf0d55c88b05396883dd10ab66dc4 (diff) |
index: Do not proceed with init if brick is not mounted
..or else when a volume start force is given, we end up creating
/brick-path/.glusterfs/indices folder and various subdirs under it and
eventually starting the brick process.
As a part of this patch, glusterd_get_index_basepath() is added in
glusterd, who will then use it to create the basepath during
volume-create, add-brick, replace-brick and reset-brick. It also uses this
function to set the 'index-base' xlator option for the index translator.
Change-Id: Id018cf3cb6f1e2e35b5c4cf438d1e939025cb0fc
BUG: 1457202
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
Reviewed-on: https://review.gluster.org/17426
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>
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-utils.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 44c382ca643..af14187cafe 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -1339,6 +1339,7 @@ glusterd_validate_and_create_brickpath (glusterd_brickinfo_t *brickinfo, struct stat root_st = {0,}; char msg[2048] = {0,}; gf_boolean_t is_created = _gf_false; + char index_basepath[PATH_MAX] = {0}; ret = sys_mkdir (brickinfo->path, 0777); if (ret) { @@ -1353,6 +1354,18 @@ glusterd_validate_and_create_brickpath (glusterd_brickinfo_t *brickinfo, is_created = _gf_true; } + glusterd_get_index_basepath (brickinfo, index_basepath, + sizeof(index_basepath)); + + ret = mkdir_p (index_basepath, 0600, _gf_true); + if (ret && (errno != EEXIST)) { + snprintf (msg, sizeof (msg), "Failed to create index " + "basepath (%s) for brick %s:%s. Reason : %s ", + index_basepath, brickinfo->hostname, + brickinfo->path, strerror (errno)); + goto out; + } + ret = sys_lstat (brickinfo->path, &brick_st); if (ret) { snprintf (msg, sizeof (msg), "lstat failed on %s. Reason : %s", @@ -1432,8 +1445,9 @@ glusterd_validate_and_create_brickpath (glusterd_brickinfo_t *brickinfo, ret = 0; out: - if (ret && is_created) - sys_rmdir (brickinfo->path); + if (ret && is_created) { + recursive_rmdir (brickinfo->path); + } if (ret && !*op_errstr && msg[0] != '\0') *op_errstr = gf_strdup (msg); |