diff options
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/features/index/src/index.c | 8 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 18 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.h | 11 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volgen.c | 5 |
4 files changed, 38 insertions, 4 deletions
diff --git a/xlators/features/index/src/index.c b/xlators/features/index/src/index.c index 975d5f998bd..e5e1c986fcc 100644 --- a/xlators/features/index/src/index.c +++ b/xlators/features/index/src/index.c @@ -2323,6 +2323,14 @@ init (xlator_t *this) } GF_OPTION_INIT ("index-base", priv->index_basepath, path, out); + if (gf_lstat_dir (priv->index_basepath, 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); + goto out; + } GF_OPTION_INIT ("xattrop64-watchlist", watchlist, str, out); ret = index_make_xattrop_watchlist (this, priv, watchlist, diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 9664a8ca710..684ae726515 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); diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h index d694a312a41..7a739c85ebd 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.h +++ b/xlators/mgmt/glusterd/src/glusterd-utils.h @@ -861,4 +861,15 @@ 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 02c8ed2ade2..0a0668e9ea6 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -1978,8 +1978,9 @@ brick_graph_add_index (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, if (!xl) goto out; - snprintf (index_basepath, sizeof (index_basepath), "%s/%s", - brickinfo->path, ".glusterfs/indices"); + glusterd_get_index_basepath (brickinfo, index_basepath, + sizeof(index_basepath)); + ret = xlator_set_option (xl, "index-base", index_basepath); if (ret) goto out; |