diff options
author | Mohit Agrawal <moagrawal@redhat.com> | 2019-06-24 10:57:49 +0530 |
---|---|---|
committer | Atin Mukherjee <amukherj@redhat.com> | 2019-06-25 11:48:46 +0000 |
commit | 2d7b77eb971700c1073db2b74f5877c1ae8293fc (patch) | |
tree | 99f5a8b96e861233c9b35320d4f1831b7b5a82de | |
parent | 390cd44b7d0f894a05750245a87d74a7f814493d (diff) |
glusterd: Can't run rebalance due to long unix socket
Problem: glusterd populate unix socket file name based
on volname and if volname is lengthy socket
system call's are failed due to breach maximum length
is defined in the kernel.
Solution:Convert unix socket name to hash to resolve the issue
Change-Id: I5072e8184013095587537dbfa4767286307fff65
fixes: bz#1720566
Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
-rw-r--r-- | tests/bugs/glusterd/bug-1720566.t | 50 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-rebalance.c | 60 |
2 files changed, 59 insertions, 51 deletions
diff --git a/tests/bugs/glusterd/bug-1720566.t b/tests/bugs/glusterd/bug-1720566.t new file mode 100644 index 00000000000..99bcf6ff785 --- /dev/null +++ b/tests/bugs/glusterd/bug-1720566.t @@ -0,0 +1,50 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../cluster.rc +. $(dirname $0)/../../volume.rc + + +cleanup; +V0="TestLongVolnamec363b7b536700ff06eedeae0dd9037fec363b7b536700ff06eedeae0dd9037fec363b7b536700ff06eedeae0dd9abcd" +V1="TestLongVolname3102bd28a16c49440bd5210e4ec4d5d93102bd28a16c49440bd5210e4ec4d5d933102bd28a16c49440bd5210e4ebbcd" +TEST launch_cluster 2; +TEST $CLI_1 peer probe $H2; + +EXPECT_WITHIN $PROBE_TIMEOUT 1 peer_count + +$CLI_1 volume create $V0 $H1:$B1/$V0 $H2:$B2/$V0 +EXPECT 'Created' cluster_volinfo_field 1 $V0 'Status'; +$CLI_1 volume create $V1 $H1:$B1/$V1 $H2:$B2/$V1 +EXPECT 'Created' cluster_volinfo_field 1 $V1 'Status'; + +$CLI_1 volume start $V0 +EXPECT 'Started' cluster_volinfo_field 1 $V0 'Status'; + +$CLI_1 volume start $V1 +EXPECT 'Started' cluster_volinfo_field 1 $V1 'Status'; + +#Mount FUSE +TEST glusterfs -s $H1 --volfile-id=$V0 $M0; + + +#Mount FUSE +TEST glusterfs -s $H1 --volfile-id=$V1 $M1; + +TEST mkdir $M0/dir{1..4}; +TEST touch $M0/dir{1..4}/files{1..4}; + +TEST mkdir $M1/dir{1..4}; +TEST touch $M1/dir{1..4}/files{1..4}; + +TEST $CLI_1 volume add-brick $V0 $H1:$B1/${V0}_1 $H2:$B2/${V0}_1 +TEST $CLI_1 volume add-brick $V1 $H1:$B1/${V1}_1 $H2:$B2/${V1}_1 + + +TEST $CLI_1 volume rebalance $V0 start +TEST $CLI_1 volume rebalance $V1 start + +EXPECT_WITHIN $REBALANCE_TIMEOUT "completed" cluster_rebalance_status_field 1 $V0 +EXPECT_WITHIN $REBALANCE_TIMEOUT "completed" cluster_rebalance_status_field 1 $V1 + +cleanup; diff --git a/xlators/mgmt/glusterd/src/glusterd-rebalance.c b/xlators/mgmt/glusterd/src/glusterd-rebalance.c index ca408856c23..5733729630e 100644 --- a/xlators/mgmt/glusterd/src/glusterd-rebalance.c +++ b/xlators/mgmt/glusterd/src/glusterd-rebalance.c @@ -34,28 +34,21 @@ #include "cli1-xdr.h" #include "xdr-generic.h" -#define GLUSTERD_GET_DEFRAG_SOCK_FILE_OLD(path, volinfo, priv) \ - do { \ - char defrag_path[PATH_MAX]; \ - int32_t _sockfile_old_len; \ - GLUSTERD_GET_DEFRAG_DIR(defrag_path, volinfo, priv); \ - _sockfile_old_len = snprintf(path, PATH_MAX, "%s/%s.sock", \ - defrag_path, uuid_utoa(MY_UUID)); \ - if ((_sockfile_old_len < 0) || (_sockfile_old_len >= PATH_MAX)) { \ - path[0] = 0; \ - } \ - } while (0) - #define GLUSTERD_GET_DEFRAG_SOCK_FILE(path, volinfo) \ do { \ int32_t _defrag_sockfile_len; \ + char tmppath[PATH_MAX] = { \ + 0, \ + }; \ _defrag_sockfile_len = snprintf( \ - path, UNIX_PATH_MAX, \ - DEFAULT_VAR_RUN_DIRECTORY "/gluster-%s-%s.sock", "rebalance", \ - uuid_utoa(volinfo->volume_id)); \ + tmppath, PATH_MAX, \ + DEFAULT_VAR_RUN_DIRECTORY "/gluster-%s-%s-%s.sock", "rebalance", \ + volinfo->volname, uuid_utoa(MY_UUID)); \ if ((_defrag_sockfile_len < 0) || \ (_defrag_sockfile_len >= PATH_MAX)) { \ path[0] = 0; \ + } else { \ + glusterd_set_socket_filepath(tmppath, path, sizeof(path)); \ } \ } while (0) @@ -290,17 +283,7 @@ glusterd_handle_defrag_start(glusterd_volinfo_t *volinfo, char *op_errstr, if (dict_get_strn(this->options, "transport.socket.bind-address", SLEN("transport.socket.bind-address"), - &volfileserver) == 0) { - /*In the case of running multiple glusterds on a single machine, - *we should ensure that log file and unix socket file should be - *unique in given cluster */ - - GLUSTERD_GET_DEFRAG_SOCK_FILE_OLD(sockfile, volinfo, priv); - snprintf(logfile, PATH_MAX, "%s/%s-%s-%s.log", - DEFAULT_LOG_FILE_DIRECTORY, volinfo->volname, "rebalance", - uuid_utoa(MY_UUID)); - - } else { + &volfileserver) != 0) { volfileserver = "localhost"; } @@ -396,9 +379,6 @@ glusterd_rebalance_rpc_create(glusterd_volinfo_t *volinfo) glusterd_defrag_info_t *defrag = volinfo->rebal.defrag; glusterd_conf_t *priv = NULL; xlator_t *this = NULL; - struct stat buf = { - 0, - }; this = THIS; GF_ASSERT(this); @@ -414,28 +394,6 @@ glusterd_rebalance_rpc_create(glusterd_volinfo_t *volinfo) goto out; GLUSTERD_GET_DEFRAG_SOCK_FILE(sockfile, volinfo); - /* Check if defrag sockfile exists in the new location - * in /var/run/ , if it does not try the old location - */ - ret = sys_stat(sockfile, &buf); - /* TODO: Remove this once we don't need backward compatibility - * with the older path - */ - if (ret && (errno == ENOENT)) { - gf_msg(this->name, GF_LOG_WARNING, errno, GD_MSG_FILE_OP_FAILED, - "Rebalance sockfile " - "%s does not exist. Trying old path.", - sockfile); - GLUSTERD_GET_DEFRAG_SOCK_FILE_OLD(sockfile, volinfo, priv); - ret = sys_stat(sockfile, &buf); - if (ret && (ENOENT == errno)) { - gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_REBAL_NO_SOCK_FILE, - "Rebalance " - "sockfile %s does not exist", - sockfile); - goto out; - } - } /* Setting frame-timeout to 10mins (600seconds). * Unix domain sockets ensures that the connection is reliable. The |