11
#include <glusterfs/globals.h>
12
#include <glusterfs/run.h>
13
#include "glusterd-utils.h"
14
#include "glusterd-volgen.h"
15
#include "glusterd-bitd-svc.h"
16
#include "glusterd-svc-helper.h"
19
glusterd_bitdsvc_build(glusterd_svc_t *svc)
21
svc->manager = glusterd_bitdsvc_manager;
22
svc->start = glusterd_genericsvc_start;
23
svc->stop = glusterd_bitdsvc_stop;
27
glusterd_bitdsvc_init(glusterd_svc_t *svc)
29
return glusterd_svc_init(svc, bitd_svc_name);
33
glusterd_bitdsvc_create_volfile(void)
35
char filepath[PATH_MAX] = {
39
glusterd_conf_t *conf = NULL;
40
xlator_t *this = THIS;
45
glusterd_svc_build_volfile_path(bitd_svc_name, conf->workdir, filepath,
48
ret = glusterd_create_global_volfile(build_bitd_graph, filepath, NULL);
50
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_VOLFILE_CREATE_FAIL,
51
"Failed to create volfile");
54
gf_msg_debug(this->name, 0, "Returning %d", ret);
59
glusterd_bitdsvc_manager(glusterd_svc_t *svc, void *data, int flags)
62
xlator_t *this = THIS;
65
ret = glusterd_bitdsvc_init(svc);
67
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_BITD_INIT_FAIL,
72
svc->inited = _gf_true;
73
gf_msg_debug(this->name, 0,
79
if (glusterd_should_i_stop_bitd()) {
80
ret = svc->stop(svc, SIGTERM);
82
ret = glusterd_bitdsvc_create_volfile();
86
ret = svc->stop(svc, SIGKILL);
90
ret = svc->start(svc, flags);
94
ret = glusterd_conn_connect(&(svc->conn));
101
gf_event(EVENT_SVC_MANAGER_FAILED, "svc_name=%s", svc->name);
103
gf_msg_debug(this->name, 0, "Returning %d", ret);
109
glusterd_bitdsvc_stop(glusterd_svc_t *svc, int sig)
111
return glusterd_svc_stop(svc, sig);
115
glusterd_bitdsvc_reconfigure(void)
118
xlator_t *this = THIS;
119
glusterd_conf_t *priv = NULL;
120
gf_boolean_t identical = _gf_false;
122
priv = this->private;
123
GF_VALIDATE_OR_GOTO(this->name, priv, out);
125
if (glusterd_should_i_stop_bitd())
132
ret = glusterd_svc_check_volfile_identical(priv->bitd_svc.name,
133
build_bitd_graph, &identical);
146
identical = _gf_false;
147
ret = glusterd_svc_check_topology_identical(priv->bitd_svc.name,
148
build_bitd_graph, &identical);
156
ret = glusterd_bitdsvc_create_volfile();
158
ret = glusterd_fetchspec_notify(THIS);
168
ret = priv->bitd_svc.manager(&(priv->bitd_svc), NULL, PROC_START_NO_WAIT);
171
gf_msg_debug(this->name, 0, "Returning %d", ret);