diff options
author | Prashanth Pai <ppai@redhat.com> | 2017-08-09 16:34:39 +0530 |
---|---|---|
committer | Pranith Kumar Karampuri <pkarampu@redhat.com> | 2017-08-23 13:09:47 +0000 |
commit | ee3d9ac7f2db3a4aa9186e08b5a1db62c3270188 (patch) | |
tree | 70fce6f1aabcc57d465c427bd292e9936928a259 /xlators | |
parent | d165ffd7a5e19fa6d0c2f36be9b47280e3df8443 (diff) |
glusterd: do not create .glusterfs/indices
glusterd shouldn't concern itself with creating directories specific to
certain xlators.
The index xlator will now proceed creating './glusterfs/indices' dir
only if the parent '.glusterfs' directory exists, which still fixes the
original problem reported i.e 'volume start force' command shouldn't
create brick path if it doesn't exist (BUG 1457202)
This reverts most of the changes done by the commit
b58a15948fb3fc37b6c0b70171482f50ed957f42
Change-Id: I7fc52ad64dce220e336c218fb4d85933ca2e61c0
Signed-off-by: Prashanth Pai <ppai@redhat.com>
Reviewed-on: https://review.gluster.org/18003
Smoke: Gluster Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Jeff Darcy <jeff@pl.atyp.us>
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/features/index/src/index.c | 13 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 26 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.h | 11 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volgen.c | 4 |
4 files changed, 25 insertions, 29 deletions
diff --git a/xlators/features/index/src/index.c b/xlators/features/index/src/index.c index 8590482a5b3..12f98974fc3 100644 --- a/xlators/features/index/src/index.c +++ b/xlators/features/index/src/index.c @@ -15,6 +15,7 @@ #include "common-utils.h" #include "index-messages.h" #include <ftw.h> +#include <libgen.h> /* for dirname() */ #include <signal.h> #define XATTROP_SUBDIR "xattrop" @@ -2285,6 +2286,8 @@ init (xlator_t *this) char *watchlist = NULL; char *dirtylist = NULL; char *pendinglist = NULL; + char *index_base_parent = NULL; + char *tmp = NULL; if (!this->children || this->children->next) { gf_msg (this->name, GF_LOG_ERROR, EINVAL, @@ -2336,12 +2339,14 @@ init (xlator_t *this) } GF_OPTION_INIT ("index-base", priv->index_basepath, path, out); - if (gf_lstat_dir (priv->index_basepath, NULL) != 0) { + tmp = gf_strdup(priv->index_basepath); + index_base_parent = dirname(tmp); + if (gf_lstat_dir (index_base_parent, NULL) != 0) { ret = -1; gf_msg (this->name, GF_LOG_ERROR, errno, INDEX_MSG_INDEX_DIR_CREATE_FAILED, - "Failed to find index basepath %s.", - priv->index_basepath); + "Failed to find parent dir (%s) of index basepath %s.", + index_base_parent, priv->index_basepath); goto out; } @@ -2414,6 +2419,8 @@ init (xlator_t *this) ret = 0; out: + GF_FREE(tmp); + if (ret) { if (cond_inited) pthread_cond_destroy (&priv->cond); diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index dfdd795f186..fbf192ebdb7 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -1444,7 +1444,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}; + char glusterfs_dir_path[PATH_MAX] = {0}; ret = sys_mkdir (brickinfo->path, 0777); if (ret) { @@ -1459,18 +1459,6 @@ 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", @@ -1547,6 +1535,18 @@ glusterd_validate_and_create_brickpath (glusterd_brickinfo_t *brickinfo, if (ret) goto out; + /* create .glusterfs directory */ + snprintf (glusterfs_dir_path, sizeof (glusterfs_dir_path), "%s/%s", + brickinfo->path, ".glusterfs"); + ret = sys_mkdir (glusterfs_dir_path, 0600); + if (ret && (errno != EEXIST)) { + snprintf (msg, sizeof (msg), "Failed to create .glusterfs " + "directory for brick %s:%s. Reason : %s ", + brickinfo->hostname, brickinfo->path, + strerror (errno)); + goto out; + } + ret = 0; out: diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h index fce56b12e9c..ce3a7787be5 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.h +++ b/xlators/mgmt/glusterd/src/glusterd-utils.h @@ -874,15 +874,4 @@ glusterd_brick_op_prerequisites (dict_t *dict, int glusterd_get_volinfo_from_brick (char *brick, glusterd_volinfo_t **volinfo); -#define INDEX_BASEPATH ".glusterfs/indices" -static inline void -glusterd_get_index_basepath (glusterd_brickinfo_t *brickinfo, char *buffer, - size_t size) -{ - if (!buffer) - return; - snprintf (buffer, size, "%s/%s", brickinfo->path, INDEX_BASEPATH); - -} - #endif diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c index 69629f201aa..b261889407c 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -2012,8 +2012,8 @@ brick_graph_add_index (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, if (!xl) goto out; - glusterd_get_index_basepath (brickinfo, index_basepath, - sizeof(index_basepath)); + snprintf (index_basepath, sizeof (index_basepath), "%s/%s", + brickinfo->path, ".glusterfs/indices"); ret = xlator_set_option (xl, "index-base", index_basepath); if (ret) |