summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/mgmt')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c180
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-mem-types.h3
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c336
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.h9
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c23
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c9
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.c9
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.h31
-rw-r--r--xlators/mgmt/glusterd/src/glusterd3_1-mops.c16
9 files changed, 589 insertions, 27 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index 503d390c3..02b5ed576 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -54,7 +54,6 @@
#include "defaults.c"
#include "common-utils.h"
-
static int
glusterd_friend_find_by_hostname (const char *hoststr,
glusterd_peerinfo_t **peerinfo)
@@ -515,7 +514,7 @@ glusterd_handle_cli_probe (rpcsvc_request_t *req)
if (!gf_xdr_to_cli_probe_req (req->msg[0], &cli_req)) {
//failed to decode msg;
- gf_log ("", 1, "error");
+ gf_log ("", GF_LOG_ERROR, "xdr decoding error");
req->rpc_err = GARBAGE_ARGS;
goto out;
}
@@ -1156,6 +1155,7 @@ out:
return ret;
}
+
int
glusterd_handle_cli_stop_volume (rpcsvc_request_t *req)
{
@@ -1562,6 +1562,144 @@ out:
}
int
+glusterd_handle_log_filename (rpcsvc_request_t *req)
+{
+ int32_t ret = -1;
+ gf1_cli_log_filename_req cli_req = {0,};
+ dict_t *dict = NULL;
+
+ GF_ASSERT (req);
+
+ if (!gf_xdr_to_cli_log_filename_req (req->msg[0], &cli_req)) {
+ //failed to decode msg;
+ req->rpc_err = GARBAGE_ARGS;
+ goto out;
+ }
+
+ gf_log ("glusterd", GF_LOG_NORMAL, "Received log filename req "
+ "for volume %s", cli_req.volname);
+
+ dict = dict_new ();
+ if (!dict)
+ goto out;
+
+ ret = dict_set_str (dict, "volname", cli_req.volname);
+ if (ret)
+ goto out;
+ ret = dict_set_str (dict, "brick", cli_req.brick);
+ if (ret)
+ goto out;
+ ret = dict_set_str (dict, "path", cli_req.path);
+ if (ret)
+ goto out;
+
+ ret = glusterd_log_filename (req, dict);
+
+out:
+ return ret;
+}
+
+int
+glusterd_handle_log_locate (rpcsvc_request_t *req)
+{
+ int32_t ret = -1;
+ gf1_cli_log_locate_req cli_req = {0,};
+ gf1_cli_log_locate_rsp rsp = {0,};
+ dict_t *dict = NULL;
+ glusterd_volinfo_t *volinfo = NULL;
+ glusterd_brickinfo_t *brickinfo = NULL;
+ char *tmp_str = NULL;
+
+ GF_ASSERT (req);
+
+ if (!gf_xdr_to_cli_log_locate_req (req->msg[0], &cli_req)) {
+ //failed to decode msg;
+ req->rpc_err = GARBAGE_ARGS;
+ goto out;
+ }
+
+ gf_log ("glusterd", GF_LOG_NORMAL, "Received log locate req "
+ "for volume %s", cli_req.volname);
+
+ dict = dict_new ();
+ if (!dict)
+ goto out;
+
+ if (strchr (cli_req.brick, ':')) {
+ /* TODO: need to get info of only that brick and then
+ tell what is the exact location */
+ gf_log ("", GF_LOG_DEBUG, "brick : %s", cli_req.brick);
+ }
+
+ ret = glusterd_volinfo_find (cli_req.volname, &volinfo);
+ if (ret) {
+ rsp.path = "request sent on non-existent volume";
+ goto out;
+ }
+
+ list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
+ tmp_str = gf_strdup (brickinfo->logfile);
+ rsp.path = dirname (tmp_str);
+ break;
+ }
+
+ ret = 0;
+out:
+ rsp.op_ret = ret;
+ if (!rsp.path)
+ rsp.path = "";
+
+ ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL,
+ gf_xdr_serialize_cli_log_locate_rsp);
+
+ if (tmp_str)
+ GF_FREE (tmp_str);
+
+ return ret;
+}
+
+int
+glusterd_handle_log_rotate (rpcsvc_request_t *req)
+{
+ int32_t ret = -1;
+ gf1_cli_log_rotate_req cli_req = {0,};
+ dict_t *dict = NULL;
+
+ GF_ASSERT (req);
+
+ if (!gf_xdr_to_cli_log_rotate_req (req->msg[0], &cli_req)) {
+ //failed to decode msg;
+ req->rpc_err = GARBAGE_ARGS;
+ goto out;
+ }
+
+ gf_log ("glusterd", GF_LOG_NORMAL, "Received log rotate req "
+ "for volume %s", cli_req.volname);
+
+ dict = dict_new ();
+ if (!dict)
+ goto out;
+
+ ret = dict_set_str (dict, "volname", cli_req.volname);
+ if (ret)
+ goto out;
+
+ ret = dict_set_str (dict, "brick", cli_req.brick);
+ if (ret)
+ goto out;
+
+ ret = dict_set_uint64 (dict, "rotate-key", (uint64_t)time (NULL));
+ if (ret)
+ goto out;
+
+ ret = glusterd_log_rotate (req, dict);
+
+out:
+ return ret;
+}
+
+
+int
glusterd_op_lock_send_resp (rpcsvc_request_t *req, int32_t status)
{
@@ -2437,6 +2575,44 @@ glusterd_remove_brick (rpcsvc_request_t *req, dict_t *dict)
}
int32_t
+glusterd_log_filename (rpcsvc_request_t *req, dict_t *dict)
+{
+ int32_t ret = -1;
+
+ GF_ASSERT (req);
+ GF_ASSERT (dict);
+
+ glusterd_op_set_op (GD_OP_LOG_FILENAME);
+ glusterd_op_set_ctx (GD_OP_LOG_FILENAME, dict);
+ glusterd_op_set_ctx_free (GD_OP_LOG_FILENAME, _gf_true);
+ glusterd_op_set_req (req);
+
+ ret = glusterd_op_txn_begin ();
+
+ return ret;
+}
+
+
+int32_t
+glusterd_log_rotate (rpcsvc_request_t *req, dict_t *dict)
+{
+ int32_t ret = -1;
+
+ GF_ASSERT (req);
+ GF_ASSERT (dict);
+
+ glusterd_op_set_op (GD_OP_LOG_ROTATE);
+ glusterd_op_set_ctx (GD_OP_LOG_ROTATE, dict);
+ glusterd_op_set_ctx_free (GD_OP_LOG_ROTATE, _gf_true);
+ glusterd_op_set_req (req);
+
+ ret = glusterd_op_txn_begin ();
+
+ return ret;
+}
+
+
+int32_t
glusterd_list_friends (rpcsvc_request_t *req, dict_t *dict, int32_t flags)
{
int32_t ret = -1;
diff --git a/xlators/mgmt/glusterd/src/glusterd-mem-types.h b/xlators/mgmt/glusterd/src/glusterd-mem-types.h
index 13da58e67..5db1e0d79 100644
--- a/xlators/mgmt/glusterd/src/glusterd-mem-types.h
+++ b/xlators/mgmt/glusterd/src/glusterd-mem-types.h
@@ -55,6 +55,9 @@ enum gf_gld_mem_types_ {
gf_gld_mt_store_handle_t,
gf_gld_mt_store_iter_t,
gf_gld_mt_defrag_info,
+ gf_gld_mt_log_filename_ctx_t,
+ gf_gld_mt_log_locate_ctx_t,
+ gf_gld_mt_log_rotate_ctx_t,
gf_gld_mt_end
};
#endif
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 8db3e3786..3f819515a 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -250,6 +250,34 @@ glusterd_op_build_payload (glusterd_op_t op, gd1_mgmt_stage_op_req **req)
}
break;
+ case GD_OP_LOG_FILENAME:
+ {
+ dict_t *dict = NULL;
+ dict = glusterd_op_get_ctx (op);
+ GF_ASSERT (dict);
+ ret = dict_allocate_and_serialize (dict,
+ &stage_req->buf.buf_val,
+ (size_t *)&stage_req->buf.buf_len);
+ if (ret) {
+ goto out;
+ }
+ }
+ break;
+
+ case GD_OP_LOG_ROTATE:
+ {
+ dict_t *dict = NULL;
+ dict = glusterd_op_get_ctx (op);
+ GF_ASSERT (dict);
+ ret = dict_allocate_and_serialize (dict,
+ &stage_req->buf.buf_val,
+ (size_t *)&stage_req->buf.buf_len);
+ if (ret) {
+ goto out;
+ }
+ }
+ break;
+
default:
break;
}
@@ -704,6 +732,86 @@ out:
}
static int
+glusterd_op_stage_log_filename (gd1_mgmt_stage_op_req *req)
+{
+ int ret = 0;
+ dict_t *dict = NULL;
+ char *volname = NULL;
+ gf_boolean_t exists = _gf_false;
+
+ GF_ASSERT (req);
+
+ dict = dict_new ();
+ if (!dict)
+ goto out;
+
+ ret = dict_unserialize (req->buf.buf_val, req->buf.buf_len, &dict);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "Unable to unserialize dict");
+ goto out;
+ }
+
+ ret = dict_get_str (dict, "volname", &volname);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "Unable to get volume name");
+ goto out;
+ }
+
+ exists = glusterd_check_volume_exists (volname);
+ if (!exists) {
+ gf_log ("", GF_LOG_ERROR, "Volume with name: %s not exists",
+ volname);
+ ret = -1;
+ goto out;
+ }
+
+out:
+ gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+
+ return ret;
+}
+
+static int
+glusterd_op_stage_log_rotate (gd1_mgmt_stage_op_req *req)
+{
+ int ret = 0;
+ dict_t *dict = NULL;
+ char *volname = NULL;
+ gf_boolean_t exists = _gf_false;
+
+ GF_ASSERT (req);
+
+ dict = dict_new ();
+ if (!dict)
+ goto out;
+
+ ret = dict_unserialize (req->buf.buf_val, req->buf.buf_len, &dict);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "Unable to unserialize dict");
+ goto out;
+ }
+
+ ret = dict_get_str (dict, "volname", &volname);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "Unable to get volume name");
+ goto out;
+ }
+
+ exists = glusterd_check_volume_exists (volname);
+ if (!exists) {
+ gf_log ("", GF_LOG_ERROR, "Volume with name: %s not exists",
+ volname);
+ ret = -1;
+ goto out;
+ }
+
+out:
+ gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+
+ return ret;
+}
+
+static int
glusterd_op_stage_remove_brick (gd1_mgmt_stage_op_req *req)
{
int ret = 0;
@@ -2069,6 +2177,195 @@ out:
}
static int
+glusterd_op_log_filename (gd1_mgmt_stage_op_req *req)
+{
+ int ret = 0;
+ dict_t *dict = NULL;
+ glusterd_conf_t *priv = NULL;
+ glusterd_volinfo_t *volinfo = NULL;
+ glusterd_brickinfo_t *brickinfo = NULL;
+ xlator_t *this = NULL;
+ char *volname = NULL;
+ char *brick = NULL;
+ char *path = NULL;
+ char logfile[PATH_MAX] = {0,};
+ char exp_path[PATH_MAX] = {0,};
+ struct stat stbuf = {0,};
+
+ GF_ASSERT (req);
+
+ this = THIS;
+ GF_ASSERT (this);
+ priv = this->private;
+ GF_ASSERT (priv);
+
+ dict = dict_new ();
+ if (!dict) {
+ gf_log ("", GF_LOG_ERROR, "ENOMEM, !dict");
+ goto out;
+ }
+
+ ret = dict_unserialize (req->buf.buf_val, req->buf.buf_len, &dict);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "Unable to unserialize dict");
+ goto out;
+ }
+
+ ret = dict_get_str (dict, "volname", &volname);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "volname not found");
+ goto out;
+ }
+ ret = dict_get_str (dict, "path", &path);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "path not found");
+ goto out;
+ }
+
+ ret = stat (path, &stbuf);
+ if (!S_ISDIR (stbuf.st_mode)) {
+ ret = -1;
+ gf_log ("", GF_LOG_ERROR, "not a directory");
+ goto out;
+ }
+
+ ret = dict_get_str (dict, "brick", &brick);
+ if (ret)
+ goto out;
+
+ if (!strchr (brick, ':'))
+ brick = NULL;
+
+ ret = glusterd_volinfo_find (volname, &volinfo);
+ if (ret)
+ goto out;
+
+ list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
+ if (brick && strcmp (brickinfo->path, brick))
+ continue;
+
+ GLUSTERD_REMOVE_SLASH_FROM_PATH (brickinfo->path, exp_path);
+
+ snprintf (logfile, PATH_MAX, "%s/%s.log", path, exp_path);
+
+ if (brickinfo->logfile)
+ GF_FREE (brickinfo->logfile);
+ brickinfo->logfile = gf_strdup (logfile);
+ }
+
+ ret = 0;
+
+out:
+ return ret;
+}
+
+static int
+glusterd_op_log_rotate (gd1_mgmt_stage_op_req *req)
+{
+ int ret = 0;
+ dict_t *dict = NULL;
+ glusterd_conf_t *priv = NULL;
+ glusterd_volinfo_t *volinfo = NULL;
+ glusterd_brickinfo_t *brickinfo = NULL;
+ xlator_t *this = NULL;
+ char *volname = NULL;
+ char *brick = NULL;
+ char path[PATH_MAX] = {0,};
+ char logfile[PATH_MAX] = {0,};
+ char pidfile[PATH_MAX] = {0,};
+ FILE *file = NULL;
+ pid_t pid = 0;
+ uint64_t key = 0;
+
+ GF_ASSERT (req);
+
+ this = THIS;
+ GF_ASSERT (this);
+ priv = this->private;
+ GF_ASSERT (priv);
+
+ dict = dict_new ();
+ if (!dict) {
+ gf_log ("", GF_LOG_ERROR, "ENOMEM, !dict");
+ goto out;
+ }
+
+ ret = dict_unserialize (req->buf.buf_val, req->buf.buf_len, &dict);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "Unable to unserialize dict");
+ goto out;
+ }
+
+ ret = dict_get_str (dict, "volname", &volname);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "volname not found");
+ goto out;
+ }
+
+ ret = dict_get_uint64 (dict, "rotate-key", &key);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "rotate key not found");
+ goto out;
+ }
+
+ ret = dict_get_str (dict, "brick", &brick);
+ if (ret)
+ goto out;
+
+ if (!strchr (brick, ':'))
+ brick = NULL;
+
+ ret = glusterd_volinfo_find (volname, &volinfo);
+ if (ret)
+ goto out;
+
+ list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
+ if (brick && strcmp (brickinfo->path, brick))
+ continue;
+
+ GLUSTERD_GET_VOLUME_DIR (path, volinfo, priv);
+ GLUSTERD_GET_BRICK_PIDFILE (pidfile, path, brickinfo->hostname,
+ brickinfo->path);
+
+ file = fopen (pidfile, "r+");
+ if (!file) {
+ gf_log ("", GF_LOG_ERROR, "Unable to open pidfile: %s",
+ pidfile);
+ ret = -1;
+ goto out;
+ }
+
+ ret = fscanf (file, "%d", &pid);
+ if (ret <= 0) {
+ gf_log ("", GF_LOG_ERROR, "Unable to read pidfile: %s",
+ pidfile);
+ ret = -1;
+ goto out;
+ }
+ fclose (file);
+ file = NULL;
+
+ snprintf (logfile, PATH_MAX, "%s.%"PRIu64,
+ brickinfo->logfile, key);
+
+ ret = rename (brickinfo->logfile, logfile);
+ if (ret)
+ gf_log ("", GF_LOG_WARNING, "rename failed");
+
+ ret = kill (pid, SIGHUP);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "Unable to SIGHUP to %d", pid);
+ goto out;
+ }
+ }
+
+ ret = 0;
+
+out:
+ return ret;
+}
+
+static int
glusterd_op_stop_volume (gd1_mgmt_stage_op_req *req)
{
int ret = 0;
@@ -2480,8 +2777,28 @@ glusterd_op_send_cli_response (int32_t op, int32_t op_ret,
sfunc = gf_xdr_serialize_cli_remove_brick_rsp;
break;
}
- }
+ case GD_MGMT_CLI_LOG_FILENAME:
+ {
+ gf1_cli_log_filename_rsp rsp = {0,};
+ rsp.op_ret = op_ret;
+ rsp.op_errno = op_errno;
+ rsp.errstr = "";
+ cli_rsp = &rsp;
+ sfunc = gf_xdr_serialize_cli_log_filename_rsp;
+ break;
+ }
+ case GD_MGMT_CLI_LOG_ROTATE:
+ {
+ gf1_cli_log_rotate_rsp rsp = {0,};
+ rsp.op_ret = op_ret;
+ rsp.op_errno = op_errno;
+ rsp.errstr = "";
+ cli_rsp = &rsp;
+ sfunc = gf_xdr_serialize_cli_log_rotate_rsp;
+ break;
+ }
+ }
ret = glusterd_submit_reply (req, cli_rsp, NULL, 0, NULL,
sfunc);
@@ -2666,11 +2983,18 @@ glusterd_op_stage_validate (gd1_mgmt_stage_op_req *req)
ret = glusterd_op_stage_replace_brick (req);
break;
-
case GD_OP_REMOVE_BRICK:
ret = glusterd_op_stage_remove_brick (req);
break;
+ case GD_OP_LOG_FILENAME:
+ ret = glusterd_op_stage_log_filename (req);
+ break;
+
+ case GD_OP_LOG_ROTATE:
+ ret = glusterd_op_stage_log_rotate (req);
+ break;
+
default:
gf_log ("", GF_LOG_ERROR, "Unknown op %d",
req->op);
@@ -2718,6 +3042,14 @@ glusterd_op_commit_perform (gd1_mgmt_stage_op_req *req)
ret = glusterd_op_remove_brick (req);
break;
+ case GD_OP_LOG_FILENAME:
+ ret = glusterd_op_log_filename (req);
+ break;
+
+ case GD_OP_LOG_ROTATE:
+ ret = glusterd_op_log_rotate (req);
+ break;
+
default:
gf_log ("", GF_LOG_ERROR, "Unknown op %d",
req->op);
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.h b/xlators/mgmt/glusterd/src/glusterd-op-sm.h
index ed824cc6a..00b387217 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.h
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.h
@@ -96,6 +96,9 @@ typedef enum glusterd_op_ {
GD_OP_REMOVE_BRICK,
GD_OP_REPLACE_BRICK,
GD_OP_SYNC_VOLUME,
+ GD_OP_LOG_FILENAME,
+ GD_OP_LOG_LOCATE,
+ GD_OP_LOG_ROTATE,
GD_OP_MAX,
} glusterd_op_t;
@@ -130,6 +133,12 @@ struct glusterd_op_start_volume_ctx_ {
typedef struct glusterd_op_start_volume_ctx_ glusterd_op_start_volume_ctx_t;
typedef struct glusterd_op_start_volume_ctx_ glusterd_op_delete_volume_ctx_t;
+struct glusterd_op_log_filename_ctx_ {
+ char volume_name[GD_VOLUME_NAME_MAX];
+ char brick[GD_VOLUME_NAME_MAX];
+ char path[PATH_MAX];
+};
+typedef struct glusterd_op_log_filename_ctx_ glusterd_op_log_filename_ctx_t;
struct glusterd_op_lock_ctx_ {
uuid_t uuid;
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 024f5e5fa..1866a9904 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -765,8 +765,8 @@ glusterd_volume_start_glusterfs (glusterd_volinfo_t *volinfo,
char cmd_str[8192] = {0,};
char rundir[PATH_MAX] = {0,};
char exp_path[PATH_MAX] = {0,};
+ char logfile[PATH_MAX] = {0,};
int port = 0;
- int i = 0;
GF_ASSERT (volinfo);
GF_ASSERT (brickinfo);
@@ -792,19 +792,23 @@ glusterd_volume_start_glusterfs (glusterd_volinfo_t *volinfo,
GLUSTERD_GET_BRICK_PIDFILE (pidfile, path, brickinfo->hostname,
brickinfo->path);
- for (i = 1; i < strlen (brickinfo->path); i++) {
- exp_path[i-1] = brickinfo->path[i];
- if (exp_path[i-1] == '/')
- exp_path[i-1] = '-';
- }
+
+ GLUSTERD_REMOVE_SLASH_FROM_PATH (brickinfo->path, exp_path);
snprintf (volfile, PATH_MAX, "%s.%s.%s", volinfo->volname,
brickinfo->hostname, exp_path);
+ if (!brickinfo->logfile) {
+ snprintf (logfile, PATH_MAX, "%s/logs/%s.log",
+ priv->workdir, exp_path);
+ brickinfo->logfile = gf_strdup (logfile);
+ }
+
snprintf (cmd_str, 8192,
"%s/sbin/glusterfs --xlator-option %s-server.listen-port=%d "
"-s localhost --volfile-id %s -p %s --brick-name %s "
- "--brick-port %d", GFS_PREFIX, volinfo->volname,
- port, volfile, pidfile, brickinfo->path, port);
+ "--brick-port %d -l %s", GFS_PREFIX, volinfo->volname,
+ port, volfile, pidfile, brickinfo->path, port,
+ brickinfo->logfile);
ret = gf_system (cmd_str);
if (ret == 0) {
@@ -957,6 +961,9 @@ glusterd_is_cli_op_req (int32_t op)
case GD_MGMT_CLI_DEFRAG_VOLUME:
case GD_MGMT_CLI_ADD_BRICK:
case GD_MGMT_CLI_REMOVE_BRICK:
+ case GD_MGMT_CLI_LOG_FILENAME:
+ case GD_MGMT_CLI_LOG_LOCATE:
+ case GD_MGMT_CLI_LOG_ROTATE:
return _gf_true;
break;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index 2f4ab6cd4..3e8e6177d 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -1543,19 +1543,12 @@ get_brick_filename (glusterd_volinfo_t *volinfo,
char *ret = NULL;
char brick[PATH_MAX] = {0,};
char *filename = NULL;
- int i = 0;
filename = GF_CALLOC (1, PATH_MAX, gf_gld_mt_char);
if (!filename)
goto out;
- /* TODO: make this part a macro, so everyone uses same thing */
- for (i = 1; i < strlen (brickinfo->path); i++) {
- brick[i-1] = brickinfo->path[i];
- if (brick[i-1] == '/')
- brick[i-1] = '-';
- }
-
+ GLUSTERD_REMOVE_SLASH_FROM_PATH (brickinfo->path, brick);
VOLGEN_GET_VOLUME_DIR (path, volinfo);
snprintf (filename, PATH_MAX, "%s/%s.%s.%s.vol",
diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c
index a038bc698..7653f6900 100644
--- a/xlators/mgmt/glusterd/src/glusterd.c
+++ b/xlators/mgmt/glusterd/src/glusterd.c
@@ -304,6 +304,15 @@ init (xlator_t *this)
exit (1);
}
+ snprintf (voldir, PATH_MAX, "%s/logs", dirname);
+ ret = mkdir (voldir, 0777);
+ if ((-1 == ret) && (errno != EEXIST)) {
+ gf_log (this->name, GF_LOG_CRITICAL,
+ "Unable to create logs directory %s"
+ " ,errno = %d", voldir, errno);
+ exit (1);
+ }
+
rpc = rpcsvc_init (this->ctx, this->options);
if (rpc == NULL) {
gf_log (this->name, GF_LOG_ERROR,
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
index 50348cf13..d52f71305 100644
--- a/xlators/mgmt/glusterd/src/glusterd.h
+++ b/xlators/mgmt/glusterd/src/glusterd.h
@@ -28,6 +28,7 @@
#include <sys/types.h>
#include <dirent.h>
#include <pthread.h>
+#include <libgen.h>
#include "uuid.h"
@@ -79,6 +80,7 @@ struct glusterd_brickinfo {
struct list_head brick_list;
uuid_t uuid;
int port;
+ char *logfile;
glusterd_store_handle_t *shandle;
};
@@ -181,14 +183,18 @@ typedef ssize_t (*gd_serialize_t) (struct iovec outmsg, void *args);
GLUSTERD_VOLUME_DIR_PREFIX, volinfo->volname, \
GLUSTERD_BRICK_INFO_DIR);
-#define GLUSTERD_GET_BRICK_PIDFILE(pidfile,volpath,hostname,brickpath) { \
+#define GLUSTERD_REMOVE_SLASH_FROM_PATH(path,string) do { \
int i = 0; \
- char exp_path[PATH_MAX] = {0,}; \
- for (i = 0; i < strlen (brickpath); i++) { \
- exp_path[i] = brickpath[i]; \
- if (exp_path[i] == '/') \
- exp_path[i] = '-'; \
+ for (i = 1; i < strlen (path); i++) { \
+ string[i-1] = path[i]; \
+ if (string[i-1] == '/') \
+ string[i-1] = '-'; \
} \
+ } while (0)
+
+#define GLUSTERD_GET_BRICK_PIDFILE(pidfile,volpath,hostname,brickpath) { \
+ char exp_path[PATH_MAX] = {0,}; \
+ GLUSTERD_REMOVE_SLASH_FROM_PATH (brickpath, exp_path); \
snprintf (pidfile, PATH_MAX, "%s/run/%s-%s.pid", \
volpath, hostname, exp_path); \
}
@@ -322,7 +328,6 @@ glusterd_add_brick (rpcsvc_request_t *req, dict_t *dict);
int
glusterd_handle_add_brick (rpcsvc_request_t *req);
-
int32_t
glusterd_replace_brick (rpcsvc_request_t *req, dict_t *dict);
@@ -332,6 +337,18 @@ glusterd_handle_replace_brick (rpcsvc_request_t *req);
int
glusterd_handle_remove_brick (rpcsvc_request_t *req);
+int
+glusterd_handle_log_filename (rpcsvc_request_t *req);
+int
+glusterd_handle_log_locate (rpcsvc_request_t *req);
+int
+glusterd_handle_log_rotate (rpcsvc_request_t *req);
+
+int32_t
+glusterd_log_filename (rpcsvc_request_t *req, dict_t *dict);
+int32_t
+glusterd_log_rotate (rpcsvc_request_t *req, dict_t *dict);
+
int32_t
glusterd_remove_brick (rpcsvc_request_t *req, dict_t *dict);
diff --git a/xlators/mgmt/glusterd/src/glusterd3_1-mops.c b/xlators/mgmt/glusterd/src/glusterd3_1-mops.c
index 5196055b3..3777e6992 100644
--- a/xlators/mgmt/glusterd/src/glusterd3_1-mops.c
+++ b/xlators/mgmt/glusterd/src/glusterd3_1-mops.c
@@ -1193,6 +1193,19 @@ glusterd_handle_rpc_msg (rpcsvc_request_t *req)
case GD_MGMT_CLI_REMOVE_BRICK:
ret = glusterd_handle_remove_brick (req);
break;
+
+ case GD_MGMT_CLI_LOG_FILENAME:
+ ret = glusterd_handle_log_filename (req);
+ break;
+
+ case GD_MGMT_CLI_LOG_LOCATE:
+ ret = glusterd_handle_log_locate (req);
+ break;
+
+ case GD_MGMT_CLI_LOG_ROTATE:
+ ret = glusterd_handle_log_rotate (req);
+ break;
+
default:
GF_ASSERT (0);
}
@@ -1231,6 +1244,9 @@ rpcsvc_actor_t glusterd1_mgmt_actors[] = {
[GD_MGMT_CLI_ADD_BRICK] = { "ADD_BRICK", GD_MGMT_CLI_ADD_BRICK, glusterd_handle_rpc_msg, NULL, NULL},
[GD_MGMT_CLI_REPLACE_BRICK] = { "REPLACE_BRICK", GD_MGMT_CLI_REPLACE_BRICK, glusterd_handle_rpc_msg, NULL, NULL},
[GD_MGMT_CLI_REMOVE_BRICK] = { "REMOVE_BRICK", GD_MGMT_CLI_REMOVE_BRICK, glusterd_handle_rpc_msg, NULL, NULL},
+ [GD_MGMT_CLI_LOG_FILENAME] = { "LOG FILENAME", GD_MGMT_CLI_LOG_FILENAME, glusterd_handle_rpc_msg, NULL, NULL},
+ [GD_MGMT_CLI_LOG_LOCATE] = { "LOG LOCATE", GD_MGMT_CLI_LOG_LOCATE, glusterd_handle_log_locate, NULL, NULL},
+ [GD_MGMT_CLI_LOG_ROTATE] = { "LOG FILENAME", GD_MGMT_CLI_LOG_ROTATE, glusterd_handle_rpc_msg, NULL, NULL},
};
/*rpcsvc_actor_t glusterd1_mgmt_actors[] = {