diff options
author | Amar Tumballi <amar@gluster.com> | 2010-10-04 13:51:29 +0000 |
---|---|---|
committer | Vijay Bellur <vijay@dev.gluster.com> | 2010-10-04 12:52:42 -0700 |
commit | 2136876274690bc7377b97ca0ed812a6befafee2 (patch) | |
tree | a947b90718b854324c7c66f3bd1571037d119b84 /xlators/mgmt/glusterd/src/glusterd-utils.c | |
parent | 0d31e7e4239d4765198ea6f46b98ba680038f7ad (diff) |
glusterd: more sanity checks during restart
* check for validity of pid file before doing pmap search, as in
few cases, pmap_signin() may take more time.
* remove stale code from 'init()'
* update pmap->last_alloc during restore itself to handle glusterd
restarts more agnostics to port collisions
Signed-off-by: Amar Tumballi <amar@gluster.com>
Signed-off-by: Vijay Bellur <vijay@dev.gluster.com>
BUG: 971 (dynamic volume management)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=971
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-utils.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 3649ef8639d..0e24aca77ed 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -915,6 +915,19 @@ glusterd_volume_start_glusterfs (glusterd_volinfo_t *volinfo, GLUSTERD_GET_BRICK_PIDFILE (pidfile, path, brickinfo->hostname, brickinfo->path); + + file = fopen (pidfile, "r+"); + if (file) { + ret = lockf (fileno (file), F_TLOCK, 0); + if (ret && ((EAGAIN == errno) || (EACCES == errno))) { + ret = 0; + gf_log ("", GF_LOG_NORMAL, "brick %s:%s " + "already started", brickinfo->hostname, + brickinfo->path); + goto out; + } + } + ret = pmap_registry_search (this, brickinfo->path, GF_PMAP_PORT_BRICKSERVER); if (ret) { @@ -932,6 +945,9 @@ glusterd_volume_start_glusterfs (glusterd_volinfo_t *volinfo, is_locked = _gf_true; } } + /* This means, pmap has the entry, remove it */ + ret = pmap_registry_remove (this, 0, brickinfo->path, + GF_PMAP_PORT_BRICKSERVER, NULL); } unlink (pidfile); |