diff options
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-snapd-svc.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-snapd-svc.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapd-svc.c b/xlators/mgmt/glusterd/src/glusterd-snapd-svc.c index 757c7f6d81c..2ec7200d1da 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapd-svc.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapd-svc.c @@ -36,6 +36,13 @@ glusterd_svc_build_snapd_logfile (char *logfile, char *logdir, size_t len) snprintf (logfile, len, "%s/snapd.log", logdir); } +void +glusterd_snapdsvc_build (glusterd_svc_t *svc) +{ + svc->manager = glusterd_snapdsvc_manager; + svc->start = glusterd_snapdsvc_start; + svc->stop = glusterd_svc_stop; +} int glusterd_snapdsvc_init (void *data) @@ -69,10 +76,6 @@ glusterd_snapdsvc_init (void *data) if (ret < 0) goto out; - svc->manager = glusterd_snapdsvc_manager; - svc->start = glusterd_snapdsvc_start; - svc->stop = glusterd_svc_stop; - notify = glusterd_snapdsvc_rpc_notify; glusterd_svc_build_snapd_rundir (volinfo, rundir, sizeof (rundir)); @@ -123,6 +126,21 @@ glusterd_snapdsvc_manager (glusterd_svc_t *svc, void *data, int flags) volinfo = data; + if (!svc->inited) { + ret = glusterd_snapdsvc_init (volinfo); + if (ret) { + gf_msg (THIS->name, GF_LOG_ERROR, 0, + GD_MSG_SNAPD_INIT_FAIL, "Failed to initialize " + "snapd service for volume %s", + volinfo->volname); + goto out; + } else { + svc->inited = _gf_true; + gf_msg_debug (THIS->name, 0, "snapd service " + "initialized"); + } + } + ret = glusterd_is_snapd_enabled (volinfo); if (ret == -1) { gf_msg (this->name, GF_LOG_ERROR, 0, |