diff options
author | Pranith K <pranithk@gluster.com> | 2010-09-29 03:59:19 +0000 |
---|---|---|
committer | Vijay Bellur <vijay@dev.gluster.com> | 2010-09-29 06:17:52 -0700 |
commit | 6689104ce7eed29c7878c124fa13caecaa1245ef (patch) | |
tree | 0ff8df60e5cd5609feda520351209b1f5d4cb71b /xlators/mgmt/glusterd/src/glusterd-utils.c | |
parent | 95dd4ae4dc2a8a3b3673e60c1fa6cbdbb9409d2c (diff) |
mgmt/glusterd: volume start force
Signed-off-by: Pranith Kumar K <pranithk@gluster.com>
Signed-off-by: Vijay Bellur <vijay@dev.gluster.com>
BUG: 1736 (implement volume start force)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1736
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-utils.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 174 |
1 files changed, 139 insertions, 35 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index d1d45a75c9c..66e11fa7b30 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -816,8 +816,7 @@ out: int32_t glusterd_volume_start_glusterfs (glusterd_volinfo_t *volinfo, - glusterd_brickinfo_t *brickinfo, - int32_t count) + glusterd_brickinfo_t *brickinfo) { int32_t ret = -1; xlator_t *this = NULL; @@ -886,8 +885,7 @@ out: int32_t glusterd_volume_stop_glusterfs (glusterd_volinfo_t *volinfo, - glusterd_brickinfo_t *brickinfo, - int32_t count) + glusterd_brickinfo_t *brickinfo) { xlator_t *this = NULL; glusterd_conf_t *priv = NULL; @@ -1739,14 +1737,91 @@ out: } int -glusterd_restart_bricks (glusterd_conf_t *conf, xlator_t *this) +glusterd_brick_start (glusterd_volinfo_t *volinfo, + glusterd_brickinfo_t *brickinfo) +{ + int ret = -1; + xlator_t *this = NULL; + glusterd_conf_t *conf = NULL; + char path[PATH_MAX] = {0,}; + char pidfile[PATH_MAX] = {0,}; + struct stat stbuf = {0,}; + + if ((!brickinfo) || (!volinfo)) + goto out; + + this = THIS; + GF_ASSERT (this); + conf = this->private; + GF_ASSERT (conf); + + if (uuid_is_null (brickinfo->uuid)) { + ret = glusterd_resolve_brick (brickinfo); + if (ret) { + gf_log ("glusterd", GF_LOG_ERROR, + "cannot resolve brick: %s:%s", + brickinfo->hostname, brickinfo->path); + goto out; + } + } + + if (uuid_compare (brickinfo->uuid, conf->uuid)) { + ret = 0; + goto out; + } + + if (!glusterd_is_brick_started (brickinfo)) { + gf_log ("", GF_LOG_DEBUG, "brick: %s:%s, of volume: %s already" + " started", brickinfo->hostname, brickinfo->path, + volinfo->volname); + ret = 0; + goto out; + } + + GLUSTERD_GET_VOLUME_DIR (path, volinfo, conf); + GLUSTERD_GET_BRICK_PIDFILE (pidfile, path, brickinfo->hostname, + brickinfo->path); + ret = stat (pidfile, &stbuf); + if (ret && errno == ENOENT) { + gf_log ("", GF_LOG_NORMAL, "About to start glusterfs" + " for brick %s:%s", brickinfo->hostname, + brickinfo->path); + ret = glusterd_volume_start_glusterfs (volinfo, brickinfo); + if (ret) { + gf_log ("", GF_LOG_ERROR, "Unable to start " + "glusterfs, ret: %d", ret); + goto out; + } + } else if (!ret) { + ret = pmap_registry_search (this, brickinfo->path, + GF_PMAP_PORT_BRICKSERVER); + if (ret) { + ret = 0; + goto out; + } + ret = unlink (pidfile); + gf_log ("", GF_LOG_NORMAL, "About to start glusterfs" + " for brick %s:%s", brickinfo->hostname, + brickinfo->path); + ret = glusterd_volume_start_glusterfs (volinfo, brickinfo); + if (ret) { + gf_log ("", GF_LOG_ERROR, "Unable to start " + "glusterfs, ret: %d", ret); + goto out; + } + } + +out: + gf_log ("", GF_LOG_DEBUG, "returning %d ", ret); + return ret; +} + +int +glusterd_restart_bricks (glusterd_conf_t *conf) { glusterd_volinfo_t *volinfo = NULL; glusterd_brickinfo_t *brickinfo = NULL; - char pidfile[PATH_MAX] = {0,}; - char path[PATH_MAX] = {0,}; int ret = -1; - struct stat stbuf = {0,}; struct timespec timeout; sigset_t mask; @@ -1762,39 +1837,13 @@ glusterd_restart_bricks (glusterd_conf_t *conf, xlator_t *this) sigtimedwait(&mask, NULL, &timeout); GF_ASSERT (conf); - GF_ASSERT (this); list_for_each_entry (volinfo, &conf->volumes, vol_list) { //If volume status is not started, do not proceed if (volinfo->status == GLUSTERD_STATUS_STARTED) { list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) { - //Only bricks on localhost to started - if (glusterd_is_local_addr (brickinfo->hostname)) - continue; - //if started, implies already registered with pmap - if (!glusterd_is_brick_started(brickinfo)) - continue; - GLUSTERD_GET_VOLUME_DIR (path, volinfo, conf); - GLUSTERD_GET_BRICK_PIDFILE (pidfile, path, - brickinfo->hostname, brickinfo->path); - ret = stat (pidfile, &stbuf); - //pid file not found, proceed to start - if (ret && errno == ENOENT) { - glusterd_volume_start_glusterfs ( - volinfo, brickinfo, 0); - } else if (!ret) { - ret = pmap_registry_search (this, - brickinfo->path, - GF_PMAP_PORT_BRICKSERVER); - if (ret) - continue; - //might be a stale pid file - ret = unlink (pidfile); - //goto out; - glusterd_volume_start_glusterfs ( - volinfo, brickinfo, 0); - } + glusterd_brick_start (volinfo, brickinfo); } glusterd_check_generate_start_nfs (volinfo); } @@ -2007,3 +2056,58 @@ out: gf_log ("", GF_LOG_DEBUG, "returning %d", ret); return ret; } + +int +glusterd_brick_stop (glusterd_volinfo_t *volinfo, + glusterd_brickinfo_t *brickinfo) +{ + int ret = -1; + xlator_t *this = NULL; + glusterd_conf_t *conf = NULL; + + if ((!brickinfo) || (!volinfo)) + goto out; + + this = THIS; + GF_ASSERT (this); + conf = this->private; + GF_ASSERT (conf); + + if (uuid_is_null (brickinfo->uuid)) { + ret = glusterd_resolve_brick (brickinfo); + if (ret) { + gf_log ("glusterd", GF_LOG_ERROR, + "cannot resolve brick: %s:%s", + brickinfo->hostname, brickinfo->path); + goto out; + } + } + + if (uuid_compare (brickinfo->uuid, conf->uuid)) { + ret = 0; + goto out; + } + + if (glusterd_is_brick_started (brickinfo)) { + gf_log ("", GF_LOG_DEBUG, "brick: %s:%s, of volume: %s not" + " started", brickinfo->hostname, brickinfo->path, + volinfo->volname); + ret = 0; + goto out; + } + + gf_log ("", GF_LOG_NORMAL, "About to stop glusterfs" + " for brick %s:%s", brickinfo->hostname, + brickinfo->path); + ret = glusterd_volume_stop_glusterfs (volinfo, brickinfo); + if (ret) { + gf_log ("", GF_LOG_CRITICAL, "Unable to remove" + " brick: %s:%s", brickinfo->hostname, + brickinfo->path); + goto out; + } + +out: + gf_log ("", GF_LOG_DEBUG, "returning %d ", ret); + return ret; +} |