diff options
author | Anoop C S <achiraya@redhat.com> | 2014-11-12 18:02:15 +0530 |
---|---|---|
committer | Raghavendra G <rgowdapp@redhat.com> | 2014-11-18 01:00:44 -0800 |
commit | c566e914a1ae84b18e20c917474be3028cd1b5de (patch) | |
tree | f74b3b1efa0bd75cc5db3b5cce51e28dfd9a4df5 /xlators/mgmt/glusterd/src | |
parent | 85e92d160bd71fdaeb3ae89d3440eec8fd438da9 (diff) |
rdma: Wrong volfile fetch on fuse mounting tcp,rdma volume via rdma
As of now for both tcp only volumes and rdma only volumes, volfile
names are in the format <volname>-fuse.vol. This patch will change
the client volfile namings as shown below.
* TCP mounts always use <volname>-fuse.vol
* RDMA mounts always use <volname>.rdma-fuse.vol
Following the above naming convention, for tcp,rdma volumes both
volfiles will be present under /var/lib/glusterd/vols/<volname>/
such that rdma only volume can be mounted as
mount -t glusterfs -o transport=rdma <server/ip>:/<volname> <mount-point>
OR
mount -t glusterfs <server/ip>:/<volname>.rdma <mount-point>
The above command format can also be used to fuse mount a tcp,rdma
volume via rdma transport.
When we try to fuse mount a tcp,rdma volume with transport-type
as rdma it silently mounts via tcp. This change will also make
sure that it fetches the correct volfile based on the
transport-type specified from client side.
BUG: 1131502
Change-Id: I34da4b01ac813b69494a43188f51145457412923
Signed-off-by: Anoop C S <achiraya@redhat.com>
Reviewed-on: http://review.gluster.org/8498
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Tested-by: Raghavendra G <rgowdapp@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-handshake.c | 122 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 54 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.h | 4 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volgen.c | 30 |
4 files changed, 128 insertions, 82 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handshake.c b/xlators/mgmt/glusterd/src/glusterd-handshake.c index 7971f12bdac..f2f5178a456 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handshake.c +++ b/xlators/mgmt/glusterd/src/glusterd-handshake.c @@ -147,54 +147,73 @@ out: } static size_t -build_volfile_path (const char *volname, char *path, +build_volfile_path (char *volume_id, char *path, size_t path_len, char *trusted_str) { struct stat stbuf = {0,}; int32_t ret = -1; - glusterd_conf_t *priv = NULL; char *vol = NULL; char *dup_volname = NULL; - char *free_ptr = NULL; char *save_ptr = NULL; - char *str_token = NULL; - glusterd_volinfo_t *volinfo = NULL; - char *server = NULL; - const char *volname_ptr = NULL; + char *free_ptr = NULL; + char *volname = NULL; + char *volid_ptr = NULL; char path_prefix [PATH_MAX] = {0,}; xlator_t *this = NULL; - char *volname_tmp = NULL; + glusterd_volinfo_t *volinfo = NULL; + glusterd_conf_t *priv = NULL; this = THIS; GF_ASSERT (this); priv = this->private; GF_ASSERT (priv); - GF_ASSERT (volname); + GF_ASSERT (volume_id); GF_ASSERT (path); - if (strstr (volname, "snapd/")) { - volname_tmp = strchr (volname, '/') + 1; - ret = glusterd_volinfo_find (volname_tmp, &volinfo); + volid_ptr = strstr (volume_id, "snapd/"); + if (volid_ptr) { + volid_ptr = strchr (volid_ptr, '/'); + if (!volid_ptr) { + ret = -1; + goto out; + } + volid_ptr++; + + ret = glusterd_volinfo_find (volid_ptr, &volinfo); if (ret == -1) { gf_log (this->name, GF_LOG_ERROR, "Couldn't find volinfo"); goto out; } glusterd_get_snapd_volfile (volinfo, path, path_len); - ret = 1; + ret = 0; goto out; - } else if (strstr (volname, "gluster/")) { - server = strchr (volname, '/') + 1; - glusterd_get_nodesvc_volfile (server, priv->workdir, + + } + + volid_ptr = strstr (volume_id, "gluster/"); + if (volid_ptr) { + volid_ptr = strchr (volid_ptr, '/'); + if (!volid_ptr) { + ret = -1; + goto out; + } + volid_ptr++; + + glusterd_get_nodesvc_volfile (volid_ptr, priv->workdir, path, path_len); - ret = 1; + ret = 0; goto out; - } else if ((str_token = strstr (volname, "/snaps/"))) { - ret = get_snap_volname_and_volinfo (str_token, &dup_volname, + + } + + volid_ptr = strstr (volume_id, "/snaps/"); + if (volid_ptr) { + ret = get_snap_volname_and_volinfo (volid_ptr, &volname, &volinfo); if (ret) { gf_log (this->name, GF_LOG_ERROR, "Failed to get snap" - " volinfo from path (%s)", volname); + " volinfo from path (%s)", volume_id); ret = -1; goto out; } @@ -202,38 +221,43 @@ build_volfile_path (const char *volname, char *path, snprintf (path_prefix, sizeof (path_prefix), "%s/snaps/%s", priv->workdir, volinfo->snapshot->snapname); - free_ptr = dup_volname; - volname_ptr = dup_volname; + volid_ptr = volname; + /* this is to ensure that volname recvd from + get_snap_volname_and_volinfo is free'd */ + free_ptr = volname; goto gotvolinfo; - } else if (volname[0] != '/') { - /* Normal behavior */ - dup_volname = gf_strdup (volname); - } else { - /* Bringing in NFS like behavior for mount command, */ - /* With this, one can mount a volume with below cmd */ - /* bash# mount -t glusterfs server:/volume /mnt/pnt */ - dup_volname = gf_strdup (&volname[1]); + } - if (!dup_volname) { - gf_log(THIS->name, GF_LOG_ERROR, "strdup failed"); - ret = -1; - goto out; + if (volume_id[0] == '/') { + /* Normal behavior */ + volid_ptr = volume_id; + volid_ptr++; + + } else { + /* Bringing in NFS like behavior for mount command, */ + /* With this, one can mount a volume with below cmd */ + /* bash# mount -t glusterfs server:/volume /mnt/pnt */ + volid_ptr = volume_id; } - free_ptr = dup_volname; - volname_ptr = volname; snprintf (path_prefix, sizeof (path_prefix), "%s/vols", priv->workdir); - ret = glusterd_volinfo_find (dup_volname, &volinfo); + ret = glusterd_volinfo_find (volid_ptr, &volinfo); if (ret) { + dup_volname = gf_strdup (volid_ptr); + if (!dup_volname) { + ret = -1; + goto out; + } /* Split the volume name */ vol = strtok_r (dup_volname, ".", &save_ptr); - if (!vol) + if (!vol) { + ret = -1; goto out; - + } ret = glusterd_volinfo_find (vol, &volinfo); if (ret) goto out; @@ -244,7 +268,7 @@ gotvolinfo: trusted_str = NULL; ret = snprintf (path, path_len, "%s/%s/%s.vol", path_prefix, - volinfo->volname, volname_ptr); + volinfo->volname, volid_ptr); if (ret == -1) goto out; @@ -254,19 +278,14 @@ gotvolinfo: snprintf (path, path_len, "%s/%s/%s%s-fuse.vol", path_prefix, volinfo->volname, (trusted_str ? trusted_str : ""), - dup_volname); - + volid_ptr); ret = stat (path, &stbuf); } - - if ((ret == -1) && (errno == ENOENT)) { - snprintf (path, path_len, "%s/%s/%s-tcp.vol", - path_prefix, volinfo->volname, volname_ptr); - } - - ret = 1; out: - GF_FREE (free_ptr); + if (dup_volname) + GF_FREE (dup_volname); + if (free_ptr) + GF_FREE (free_ptr); return ret; } @@ -705,7 +724,7 @@ __server_getspec (rpcsvc_request_t *req) sizeof (filename), NULL); } - if (ret > 0) { + if (ret == 0) { /* to allocate the proper buffer to hold the file data */ ret = stat (filename, &stbuf); if (ret < 0){ @@ -725,6 +744,7 @@ __server_getspec (rpcsvc_request_t *req) ret = file_len = stbuf.st_size; } else { op_errno = ENOENT; + goto fail; } if (file_len) { diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index ad824be73f3..f5dd952048b 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -9053,47 +9053,65 @@ out: return ret; } -void +int glusterd_get_client_filepath (char *filepath, glusterd_volinfo_t *volinfo, gf_transport_type type) { - char path[PATH_MAX] = {0,}; + int ret = 0; + char path[PATH_MAX] = {0,}; glusterd_conf_t *priv = NULL; priv = THIS->private; GLUSTERD_GET_VOLUME_DIR (path, volinfo, priv); - if ((volinfo->transport_type == GF_TRANSPORT_BOTH_TCP_RDMA) && - (type == GF_TRANSPORT_RDMA)) - snprintf (filepath, PATH_MAX, "%s/%s.rdma-fuse.vol", - path, volinfo->volname); - else - snprintf (filepath, PATH_MAX, "%s/%s-fuse.vol", - path, volinfo->volname); + switch (type) { + case GF_TRANSPORT_TCP: + snprintf (filepath, PATH_MAX, + "%s/%s-fuse.vol", path, volinfo->volname); + break; + + case GF_TRANSPORT_RDMA: + snprintf (filepath, PATH_MAX, + "%s/%s.rdma-fuse.vol", path, volinfo->volname); + break; + default: + ret = -1; + break; + } + + return ret; } -void +int glusterd_get_trusted_client_filepath (char *filepath, glusterd_volinfo_t *volinfo, gf_transport_type type) { - char path[PATH_MAX] = {0,}; + int ret = 0; + char path[PATH_MAX] = {0,}; glusterd_conf_t *priv = NULL; priv = THIS->private; GLUSTERD_GET_VOLUME_DIR (path, volinfo, priv); - if ((volinfo->transport_type == GF_TRANSPORT_BOTH_TCP_RDMA) && - (type == GF_TRANSPORT_RDMA)) - snprintf (filepath, PATH_MAX, - "%s/trusted-%s.rdma-fuse.vol", + switch (type) { + case GF_TRANSPORT_TCP: + snprintf (filepath, PATH_MAX, "%s/trusted-%s-fuse.vol", path, volinfo->volname); - else - snprintf (filepath, PATH_MAX, - "%s/trusted-%s-fuse.vol", + break; + + case GF_TRANSPORT_RDMA: + snprintf (filepath, PATH_MAX, "%s/trusted-%s.rdma-fuse.vol", path, volinfo->volname); + break; + default: + ret = -1; + break; + } + + return ret; } int diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h index a6613d9b325..6cc34b5c2a7 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.h +++ b/xlators/mgmt/glusterd/src/glusterd-utils.h @@ -458,11 +458,11 @@ glusterd_friend_contains_vol_bricks (glusterd_volinfo_t *volinfo, int glusterd_friend_remove_cleanup_vols (uuid_t uuid); -void +int glusterd_get_client_filepath (char *filepath, glusterd_volinfo_t *volinfo, gf_transport_type type); -void +int glusterd_get_trusted_client_filepath (char *filepath, glusterd_volinfo_t *volinfo, gf_transport_type type); diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c index 22af263547b..ea255f93208 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -3836,12 +3836,15 @@ int generate_client_volfiles (glusterd_volinfo_t *volinfo, glusterd_client_type_t client_type) { + int i = 0; + int ret = -1; char filepath[PATH_MAX] = {0,}; - int ret = -1; - char *types[] = {NULL, NULL, NULL}; - int i = 0; - dict_t *dict = NULL; - gf_transport_type type = GF_TRANSPORT_TCP; + char *types[] = {NULL, NULL, NULL}; + dict_t *dict = NULL; + xlator_t *this = NULL; + gf_transport_type type = GF_TRANSPORT_TCP; + + this = THIS; enumerate_transport_reqs (volinfo->transport_type, types); dict = dict_new (); @@ -3859,13 +3862,18 @@ generate_client_volfiles (glusterd_volinfo_t *volinfo, goto out; if (client_type == GF_CLIENT_TRUSTED) { - glusterd_get_trusted_client_filepath (filepath, - volinfo, - type); + ret = glusterd_get_trusted_client_filepath (filepath, + volinfo, + type); } else { - glusterd_get_client_filepath (filepath, - volinfo, - type); + ret = glusterd_get_client_filepath (filepath, + volinfo, + type); + } + if (ret) { + gf_log (this->name, GF_LOG_ERROR, + "Received invalid transport-type"); + goto out; } ret = generate_single_transport_client_volfile (volinfo, |