11
#include <glusterfs/globals.h>
12
#include <glusterfs/run.h>
13
#include "glusterd-utils.h"
14
#include "glusterd-volgen.h"
15
#include "glusterd-scrub-svc.h"
16
#include "glusterd-svc-helper.h"
18
char *scrub_svc_name = "scrub";
21
glusterd_scrubsvc_build(glusterd_svc_t *svc)
23
svc->manager = glusterd_scrubsvc_manager;
24
svc->start = glusterd_genericsvc_start;
25
svc->stop = glusterd_scrubsvc_stop;
29
glusterd_scrubsvc_init(glusterd_svc_t *svc)
31
return glusterd_svc_init(svc, scrub_svc_name);
35
glusterd_scrubsvc_create_volfile(void)
37
char filepath[PATH_MAX] = {
41
glusterd_conf_t *conf = NULL;
42
xlator_t *this = THIS;
47
glusterd_svc_build_volfile_path(scrub_svc_name, conf->workdir, filepath,
50
ret = glusterd_create_global_volfile(build_scrub_graph, filepath, NULL);
52
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_VOLFILE_CREATE_FAIL,
53
"Failed to create volfile");
58
gf_msg_debug(this->name, 0, "Returning %d", ret);
64
glusterd_scrubsvc_manager(glusterd_svc_t *svc, void *data, int flags)
67
xlator_t *this = THIS;
70
ret = glusterd_scrubsvc_init(svc);
72
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_SCRUB_INIT_FAIL,
77
svc->inited = _gf_true;
78
gf_msg_debug(this->name, 0,
84
if (glusterd_should_i_stop_bitd()) {
85
ret = svc->stop(svc, SIGTERM);
87
ret = glusterd_scrubsvc_create_volfile();
91
ret = svc->stop(svc, SIGKILL);
95
ret = svc->start(svc, flags);
99
ret = glusterd_conn_connect(&(svc->conn));
106
gf_event(EVENT_SVC_MANAGER_FAILED, "svc_name=%s", svc->name);
107
gf_msg_debug(this->name, 0, "Returning %d", ret);
113
glusterd_scrubsvc_stop(glusterd_svc_t *svc, int sig)
115
return glusterd_svc_stop(svc, sig);
119
glusterd_scrubsvc_reconfigure(void)
122
xlator_t *this = THIS;
123
glusterd_conf_t *priv = NULL;
124
gf_boolean_t identical = _gf_false;
126
priv = this->private;
127
GF_VALIDATE_OR_GOTO(this->name, priv, out);
129
if (glusterd_should_i_stop_bitd())
137
ret = glusterd_svc_check_volfile_identical(priv->scrub_svc.name,
138
build_scrub_graph, &identical);
152
identical = _gf_false;
153
ret = glusterd_svc_check_topology_identical(priv->scrub_svc.name,
154
build_scrub_graph, &identical);
162
ret = glusterd_scrubsvc_create_volfile();
164
ret = glusterd_fetchspec_notify(THIS);
174
ret = priv->scrub_svc.manager(&(priv->scrub_svc), NULL, PROC_START_NO_WAIT);
177
gf_msg_debug(this->name, 0, "Returning %d", ret);