diff options
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-handshake.c | 41 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-pmap.c | 52 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-pmap.h | 1 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 14 |
4 files changed, 95 insertions, 13 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handshake.c b/xlators/mgmt/glusterd/src/glusterd-handshake.c index 9f5e03f5306..43a93731790 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handshake.c +++ b/xlators/mgmt/glusterd/src/glusterd-handshake.c @@ -42,13 +42,44 @@ static size_t build_volfile_path (const char *volname, char *path, size_t path_len) { - int32_t ret = -1; - glusterd_conf_t *priv = NULL; + struct stat stbuf = {0,}; + int32_t ret = -1; + glusterd_conf_t *priv = NULL; + char *vol = NULL; + char *dup_volname = NULL; + char *tmp = NULL; + glusterd_volinfo_t *volinfo = NULL; priv = THIS->private; + dup_volname = gf_strdup (volname); + + ret = glusterd_volinfo_find (dup_volname, &volinfo); + if (ret) { + /* Split the volume name */ + vol = strtok_r (dup_volname, "-", &tmp); + if (!vol) + goto out; + vol = strtok_r (NULL, "-", &tmp); + if (!vol) + goto out; + ret = glusterd_volinfo_find (vol, &volinfo); + if (ret) + goto out; + } + ret = snprintf (path, path_len, "%s/vols/%s/%s.vol", + priv->workdir, volinfo->volname, volname); + if (ret == -1) + goto out; + + ret = stat (path, &stbuf); + if ((ret == -1) && (errno == ENOENT)) + ret = snprintf (path, path_len, "%s/vols/%s/%s-tcp.vol", + priv->workdir, volinfo->volname, volname); - ret = snprintf (path, path_len, "%s/vols/%s/%s-tcp.vol", - priv->workdir, volname, volname); + ret = 1; +out: + if (dup_volname) + GF_FREE (dup_volname); return ret; } @@ -139,6 +170,8 @@ fail: if (cookie) rsp.op_errno = cookie; + if (!rsp.spec) + rsp.spec = ""; glusterd_submit_reply (req, &rsp, NULL, 0, NULL, (gd_serialize_t)xdr_serialize_getspec_rsp); diff --git a/xlators/mgmt/glusterd/src/glusterd-pmap.c b/xlators/mgmt/glusterd/src/glusterd-pmap.c index 3ae51339398..3a45da000c5 100644 --- a/xlators/mgmt/glusterd/src/glusterd-pmap.c +++ b/xlators/mgmt/glusterd/src/glusterd-pmap.c @@ -125,6 +125,25 @@ pmap_registry_search (xlator_t *this, const char *brickname) } +char * +pmap_registry_search_by_port (xlator_t *this, int port) +{ + struct pmap_registry *pmap = NULL; + char *brickname = NULL; + + if (port > 65535) + goto out; + + pmap = pmap_registry_get (this); + + if (pmap->ports[port].used) + brickname = pmap->ports[port].brickname; + +out: + return brickname; +} + + int pmap_registry_alloc (xlator_t *this) { @@ -171,6 +190,26 @@ out: return 0; } +int +pmap_registry_remove (xlator_t *this, int port, const char *brickname) +{ + struct pmap_registry *pmap = NULL; + int p = 0; + + pmap = pmap_registry_get (this); + + if (port > 65535) + goto out; + + p = port; + pmap->ports[p].used = 0; + if (pmap->ports[p].brickname) + free (pmap->ports[p].brickname); + +out: + return 0; +} + typedef ssize_t (*gfs_serialize_t) (struct iovec outmsg, void *data); @@ -200,7 +239,6 @@ gluster_pmap_portbybrick (rpcsvc_request_t *req) char *brick = NULL; int port = 0; - if (xdr_to_glusterfs_req (req, &args, xdr_to_pmap_port_by_brick_req)) { req->rpc_err = GARBAGE_ARGS; goto fail; @@ -229,13 +267,16 @@ gluster_pmap_brickbyport (rpcsvc_request_t *req) pmap_brick_by_port_req args = {0,}; pmap_brick_by_port_rsp rsp = {0,}; - if (xdr_to_glusterfs_req (req, &args, xdr_to_pmap_brick_by_port_req)) { req->rpc_err = GARBAGE_ARGS; goto fail; } - + rsp.brick = pmap_registry_search_by_port (THIS, args.port); + if (!rsp.brick) { + rsp.op_ret = -1; + rsp.brick = ""; + } fail: glusterd_submit_reply (req, &rsp, NULL, 0, NULL, @@ -258,6 +299,7 @@ gluster_pmap_signup (rpcsvc_request_t *req) goto fail; } + rsp.op_ret = pmap_registry_bind (THIS, args.port, args.brick); fail: glusterd_submit_reply (req, &rsp, NULL, 0, NULL, @@ -273,13 +315,14 @@ gluster_pmap_signin (rpcsvc_request_t *req) pmap_signin_req args = {0,}; pmap_signin_rsp rsp = {0,}; - if (xdr_to_glusterfs_req (req, &args, xdr_to_pmap_signin_req)) { req->rpc_err = GARBAGE_ARGS; goto fail; } + rsp.op_ret = pmap_registry_bind (THIS, args.port, args.brick); + fail: glusterd_submit_reply (req, &rsp, NULL, 0, NULL, (gd_serialize_t)xdr_from_pmap_signin_rsp); @@ -302,6 +345,7 @@ gluster_pmap_signout (rpcsvc_request_t *req) goto fail; } + rsp.op_ret = pmap_registry_remove (THIS, args.port, args.brick); fail: glusterd_submit_reply (req, &rsp, NULL, 0, NULL, diff --git a/xlators/mgmt/glusterd/src/glusterd-pmap.h b/xlators/mgmt/glusterd/src/glusterd-pmap.h index dd72012a7dd..4bc4536f84e 100644 --- a/xlators/mgmt/glusterd/src/glusterd-pmap.h +++ b/xlators/mgmt/glusterd/src/glusterd-pmap.h @@ -51,5 +51,6 @@ struct pmap_registry { int pmap_registry_alloc (xlator_t *this); int pmap_registry_bind (xlator_t *this, int port, const char *brickname); +int pmap_registry_remove (xlator_t *this, int port, const char *brickname); #endif diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index beb4185835b..4202f271638 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -763,16 +763,18 @@ glusterd_volume_start_glusterfs (glusterd_volinfo_t *volinfo, port = pmap_registry_alloc (THIS); GLUSTERD_GET_BRICK_PIDFILE (pidfile, path, brickinfo->hostname, count); - snprintf (volfile, PATH_MAX, "%s/%s-%s-%d.vol", path, - brickinfo->hostname, volinfo->volname, count); + snprintf (volfile, PATH_MAX, "%s-%s-%d", brickinfo->hostname, + volinfo->volname, count); snprintf (cmd_str, 8192, - "glusterfs --xlator-option server-*.listen-port=%d -f %s -p %s", - port, volfile, pidfile); + "glusterfs --xlator-option server-*.listen-port=%d " + "-s localhost --volfile-id %s -p %s --brick-name %s " + "--brick-port %d", + port, volfile, pidfile, brickinfo->path, port); ret = system (cmd_str); if (ret == 0) { - pmap_registry_bind (THIS, port, brickinfo->path); + //pmap_registry_bind (THIS, port, brickinfo->path); brickinfo->port = port; } out: @@ -832,6 +834,8 @@ glusterd_volume_stop_glusterfs (glusterd_volinfo_t *volinfo, goto out; } + //pmap_registry_remove (THIS, brickinfo->port, brickinfo->path); + ret = unlink (pidfile); if (ret) { |