From 52ad549263693685038ad69b36230789daf9690b Mon Sep 17 00:00:00 2001 From: Sunil Kumar Acharya Date: Tue, 16 Jul 2019 02:20:26 -0400 Subject: [PATCH] autobuild v6.0-8 Resolves: bz#1471742 bz#1698435 bz#1704562 bz#1712591 bz#1715447 Resolves: bz#1720488 bz#1721802 bz#1722209 bz#1722512 bz#1724089 Resolves: bz#1726991 bz#1727785 bz#1729108 Signed-off-by: Sunil Kumar Acharya --- ...ht-Fixed-a-memleak-in-dht_rename_cbk.patch | 109 + ...filename-implementation-to-use-ENOAT.patch | 123 + ...ore-replace-inet_addr-with-inet_pton.patch | 53 + ...tils-Fix-py2-py3-util-python-scripts.patch | 448 ++ ...ter-command-path-for-non-root-sessio.patch | 92 + ...ate-pid-of-mux-volumes-from-the-shd-.patch | 914 ++++ ...-enable-notify-contention-by-default.patch | 39 + ...he-correct-brick-status-in-get-state.patch | 113 + ...svc-update-pid-of-mux-volumes-from-t.patch | 893 ++++ ...-Use-top-down-approach-while-cleanin.patch | 180 + ...incorrect-reporting-of-gfid-type-mis.patch | 228 + ...-Use-glusterfs_graph_deactivate-to-f.patch | 78 + ...shd-Change-shd-logfile-to-a-unique-n.patch | 220 + ...svc-Stop-stale-process-using-the-glu.patch | 38 + ...ix-race-between-mux_proc-unlink-and-.patch | 35 + ...ix-race-between-xlator-cleanup-and-o.patch | 227 + ...g-Add-more-logging-in-xlator_is_clea.patch | 47 + ...-Fix-race-with-ec_fini-and-ec_notify.patch | 128 + ...shd-Optimize-the-glustershd-manager-.patch | 54 + ...svc-glusterd_svcs_stop-should-call-i.patch | 82 + ...ts-shd-Add-test-coverage-for-shd-mux.patch | 427 ++ ...d-cleanup-Protect-graph-object-under.patch | 154 + ...eanup-self-heal-daemon-resources-dur.patch | 292 ++ ...erd-Serialize-shd-manager-to-prevent.patch | 151 + ...shd-Keep-a-ref-on-volinfo-until-atta.patch | 53 + ...leanup-self-heal-daemon-resources-du.patch | 144 + ...ix-coverity-issues-introduced-by-shd.patch | 151 + ...t-fini-return-fini-after-rpc-cleanup.patch | 95 + ...Implement-multiplexing-in-self-heal-.patch | 4572 +++++++++++++++++ ...17819-metadata-split-brain-detection.patch | 57 + ...mark-skip_locking-as-true-for-geo-re.patch | 63 + ...k-between-statedump-and-fd_anonymous.patch | 246 + ...-iot_worker-to-release-its-resources.patch | 43 + ...glusterd-with-shd-mux-the-shd-volfil.patch | 104 + glusterfs.spec | 40 +- 35 files changed, 10692 insertions(+), 1 deletion(-) create mode 100644 0222-cluster-dht-Fixed-a-memleak-in-dht_rename_cbk.patch create mode 100644 0223-change-get_real_filename-implementation-to-use-ENOAT.patch create mode 100644 0224-core-replace-inet_addr-with-inet_pton.patch create mode 100644 0225-tests-utils-Fix-py2-py3-util-python-scripts.patch create mode 100644 0226-geo-rep-fix-gluster-command-path-for-non-root-sessio.patch create mode 100644 0227-glusterd-svc-update-pid-of-mux-volumes-from-the-shd-.patch create mode 100644 0228-locks-enable-notify-contention-by-default.patch create mode 100644 0229-glusterd-Show-the-correct-brick-status-in-get-state.patch create mode 100644 0230-Revert-glusterd-svc-update-pid-of-mux-volumes-from-t.patch create mode 100644 0231-Revert-graph-shd-Use-top-down-approach-while-cleanin.patch create mode 100644 0232-cluster-afr-Fix-incorrect-reporting-of-gfid-type-mis.patch create mode 100644 0233-Revert-graph-shd-Use-glusterfs_graph_deactivate-to-f.patch create mode 100644 0234-Revert-glusterd-shd-Change-shd-logfile-to-a-unique-n.patch create mode 100644 0235-Revert-glusterd-svc-Stop-stale-process-using-the-glu.patch create mode 100644 0236-Revert-shd-mux-Fix-race-between-mux_proc-unlink-and-.patch create mode 100644 0237-Revert-ec-fini-Fix-race-between-xlator-cleanup-and-o.patch create mode 100644 0238-Revert-xlator-log-Add-more-logging-in-xlator_is_clea.patch create mode 100644 0239-Revert-ec-fini-Fix-race-with-ec_fini-and-ec_notify.patch create mode 100644 0240-Revert-glusterd-shd-Optimize-the-glustershd-manager-.patch create mode 100644 0241-Revert-glusterd-svc-glusterd_svcs_stop-should-call-i.patch create mode 100644 0242-Revert-tests-shd-Add-test-coverage-for-shd-mux.patch create mode 100644 0243-Revert-glusterfsd-cleanup-Protect-graph-object-under.patch create mode 100644 0244-Revert-ec-shd-Cleanup-self-heal-daemon-resources-dur.patch create mode 100644 0245-Revert-shd-glusterd-Serialize-shd-manager-to-prevent.patch create mode 100644 0246-Revert-glusterd-shd-Keep-a-ref-on-volinfo-until-atta.patch create mode 100644 0247-Revert-afr-shd-Cleanup-self-heal-daemon-resources-du.patch create mode 100644 0248-Revert-shd-mux-Fix-coverity-issues-introduced-by-shd.patch create mode 100644 0249-Revert-client-fini-return-fini-after-rpc-cleanup.patch create mode 100644 0250-Revert-mgmt-shd-Implement-multiplexing-in-self-heal-.patch create mode 100644 0251-tests-Fix-bug-1717819-metadata-split-brain-detection.patch create mode 100644 0252-glusterd-do-not-mark-skip_locking-as-true-for-geo-re.patch create mode 100644 0253-core-fix-deadlock-between-statedump-and-fd_anonymous.patch create mode 100644 0254-Detach-iot_worker-to-release-its-resources.patch create mode 100644 0255-Revert-tier-shd-glusterd-with-shd-mux-the-shd-volfil.patch diff --git a/0222-cluster-dht-Fixed-a-memleak-in-dht_rename_cbk.patch b/0222-cluster-dht-Fixed-a-memleak-in-dht_rename_cbk.patch new file mode 100644 index 0000000..3a492cb --- /dev/null +++ b/0222-cluster-dht-Fixed-a-memleak-in-dht_rename_cbk.patch @@ -0,0 +1,109 @@ +From 5f304e003cc24ff7877ab51bdfded0dbf8ec581b Mon Sep 17 00:00:00 2001 +From: N Balachandran +Date: Fri, 21 Jun 2019 09:04:19 +0530 +Subject: [PATCH 222/255] cluster/dht: Fixed a memleak in dht_rename_cbk + +Fixed a memleak in dht_rename_cbk when creating +a linkto file. + +upstream: https://review.gluster.org/#/c/glusterfs/+/22912/ + +>Change-Id: I705adef3cb79e33806520fc2b15558e90e2c211c +>fixes: bz#1722698 +>Signed-off-by: N Balachandran + +BUG:1722512 +Change-Id: I8450cac82a0e1611e698ffac476ea5516e614236 +Signed-off-by: N Balachandran +Reviewed-on: https://code.engineering.redhat.com/gerrit/175181 +Tested-by: RHGS Build Bot +Reviewed-by: Susant Palai +--- + xlators/cluster/dht/src/dht-rename.c | 44 +++++++++++++++++++++++++++--------- + 1 file changed, 33 insertions(+), 11 deletions(-) + +diff --git a/xlators/cluster/dht/src/dht-rename.c b/xlators/cluster/dht/src/dht-rename.c +index 893b451..5ba2373 100644 +--- a/xlators/cluster/dht/src/dht-rename.c ++++ b/xlators/cluster/dht/src/dht-rename.c +@@ -1009,9 +1009,11 @@ dht_rename_links_create_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + { + xlator_t *prev = NULL; + dht_local_t *local = NULL; ++ call_frame_t *main_frame = NULL; + + prev = cookie; + local = frame->local; ++ main_frame = local->main_frame; + + /* TODO: Handle this case in lookup-optimize */ + if (op_ret == -1) { +@@ -1024,7 +1026,8 @@ dht_rename_links_create_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + dht_linkfile_attr_heal(frame, this); + } + +- dht_rename_unlink(frame, this); ++ dht_rename_unlink(main_frame, this); ++ DHT_STACK_DESTROY(frame); + return 0; + } + +@@ -1040,7 +1043,8 @@ dht_rename_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + xlator_t *src_cached = NULL; + xlator_t *dst_hashed = NULL; + xlator_t *dst_cached = NULL; +- loc_t link_loc = {0}; ++ call_frame_t *link_frame = NULL; ++ dht_local_t *link_local = NULL; + + local = frame->local; + prev = cookie; +@@ -1110,18 +1114,36 @@ dht_rename_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + + /* Create the linkto file for the dst file */ + if ((src_cached == dst_cached) && (dst_hashed != dst_cached)) { +- loc_copy(&link_loc, &local->loc2); +- if (link_loc.inode) +- inode_unref(link_loc.inode); +- link_loc.inode = inode_ref(local->loc.inode); +- gf_uuid_copy(local->gfid, local->loc.inode->gfid); +- gf_uuid_copy(link_loc.gfid, local->loc.inode->gfid); +- +- dht_linkfile_create(frame, dht_rename_links_create_cbk, this, +- src_cached, dst_hashed, &link_loc); ++ link_frame = copy_frame(frame); ++ if (!link_frame) { ++ goto unlink; ++ } ++ ++ /* fop value sent as maxvalue because it is not used ++ * anywhere in this case */ ++ link_local = dht_local_init(link_frame, &local->loc2, NULL, ++ GF_FOP_MAXVALUE); ++ if (!link_local) { ++ goto unlink; ++ } ++ ++ if (link_local->loc.inode) ++ inode_unref(link_local->loc.inode); ++ link_local->loc.inode = inode_ref(local->loc.inode); ++ link_local->main_frame = frame; ++ link_local->stbuf = local->stbuf; ++ gf_uuid_copy(link_local->gfid, local->loc.inode->gfid); ++ ++ dht_linkfile_create(link_frame, dht_rename_links_create_cbk, this, ++ src_cached, dst_hashed, &link_local->loc); + return 0; + } + ++unlink: ++ ++ if (link_frame) { ++ DHT_STACK_DESTROY(link_frame); ++ } + dht_rename_unlink(frame, this); + return 0; + +-- +1.8.3.1 + diff --git a/0223-change-get_real_filename-implementation-to-use-ENOAT.patch b/0223-change-get_real_filename-implementation-to-use-ENOAT.patch new file mode 100644 index 0000000..a533388 --- /dev/null +++ b/0223-change-get_real_filename-implementation-to-use-ENOAT.patch @@ -0,0 +1,123 @@ +From 36b0bd86321436a951f225fcf2e921390ed8dc33 Mon Sep 17 00:00:00 2001 +From: Michael Adam +Date: Thu, 20 Jun 2019 13:09:37 +0200 +Subject: [PATCH 223/255] change get_real_filename implementation to use + ENOATTR instead of ENOENT + +get_real_filename is implemented as a virtual extended attribute to help +Samba implement the case-insensitive but case preserving SMB protocol +more efficiently. It is implemented as a getxattr call on the parent directory +with the virtual key of "get_real_filename:" by looking for a +spelling with different case for the provided file/dir name () +and returning this correct spelling as a result if the entry is found. +Originally (05aaec645a6262d431486eb5ac7cd702646cfcfb), the +implementation used the ENOENT errno to return the authoritative answer +that does not exist in any case folding. + +Now this implementation is actually a violation or misuse of the defined +API for the getxattr call which returns ENOENT for the case that the dir +that the call is made against does not exist and ENOATTR (or the synonym +ENODATA) for the case that the xattr does not exist. + +This was not a problem until the gluster fuse-bridge was changed +to do map ENOENT to ESTALE in 59629f1da9dca670d5dcc6425f7f89b3e96b46bf, +after which we the getxattr call for get_real_filename returned an +ESTALE instead of ENOENT breaking the expectation in Samba. + +It is an independent problem that ESTALE should not leak out to user +space but is intended to trigger retries between fuse and gluster. +But nevertheless, the semantics seem to be incorrect here and should +be changed. + +This patch changes the implementation of the get_real_filename virtual +xattr to correctly return ENOATTR instead of ENOENT if the file/directory +being looked up is not found. + +The Samba glusterfs_fuse vfs module which takes advantage of the +get_real_filename over a fuse mount will receive a corresponding change +to map ENOATTR to ENOENT. Without this change, it will still work +correctly, but the performance optimization for nonexisting files is +lost. On the other hand side, this change removes the distinction +between the old not-implemented case and the implemented case. +So Samba changed to treat ENOATTR like ENOENT will not work correctly +any more against old servers that don't implement get_real_filename. +I.e. existing files will be reported as non-existing + +Backport of https://review.gluster.org/c/glusterfs/+/22925 + +Change-Id: I971b427ab8410636d5d201157d9af70e0d075b67 +fixes: bz#1724089 +Signed-off-by: Michael Adam +Reviewed-on: https://code.engineering.redhat.com/gerrit/175012 +Tested-by: RHGS Build Bot +Reviewed-by: Atin Mukherjee +--- + xlators/cluster/dht/src/dht-common.c | 8 ++++---- + xlators/storage/posix/src/posix-inode-fd-ops.c | 4 ++-- + 2 files changed, 6 insertions(+), 6 deletions(-) + +diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c +index 9a6ea5b..219b072 100644 +--- a/xlators/cluster/dht/src/dht-common.c ++++ b/xlators/cluster/dht/src/dht-common.c +@@ -4618,7 +4618,7 @@ dht_getxattr_get_real_filename_cbk(call_frame_t *frame, void *cookie, + + LOCK(&frame->lock); + { +- if (local->op_errno == ENODATA || local->op_errno == EOPNOTSUPP) { ++ if (local->op_errno == EOPNOTSUPP) { + /* Nothing to do here, we have already found + * a subvol which does not have the get_real_filename + * optimization. If condition is for simple logic. +@@ -4627,7 +4627,7 @@ dht_getxattr_get_real_filename_cbk(call_frame_t *frame, void *cookie, + } + + if (op_ret == -1) { +- if (op_errno == ENODATA || op_errno == EOPNOTSUPP) { ++ if (op_errno == EOPNOTSUPP) { + /* This subvol does not have the optimization. + * Better let the user know we don't support it. + * Remove previous results if any. +@@ -4655,7 +4655,7 @@ dht_getxattr_get_real_filename_cbk(call_frame_t *frame, void *cookie, + goto post_unlock; + } + +- if (op_errno == ENOENT) { ++ if (op_errno == ENOATTR) { + /* Do nothing, our defaults are set to this. + */ + goto unlock; +@@ -4723,7 +4723,7 @@ dht_getxattr_get_real_filename(call_frame_t *frame, xlator_t *this, loc_t *loc, + cnt = local->call_cnt = layout->cnt; + + local->op_ret = -1; +- local->op_errno = ENOENT; ++ local->op_errno = ENOATTR; + + for (i = 0; i < cnt; i++) { + subvol = layout->list[i].xlator; +diff --git a/xlators/storage/posix/src/posix-inode-fd-ops.c b/xlators/storage/posix/src/posix-inode-fd-ops.c +index c949f68..ea3b69c 100644 +--- a/xlators/storage/posix/src/posix-inode-fd-ops.c ++++ b/xlators/storage/posix/src/posix-inode-fd-ops.c +@@ -2954,7 +2954,7 @@ posix_xattr_get_real_filename(call_frame_t *frame, xlator_t *this, loc_t *loc, + (void)sys_closedir(fd); + + if (!found) +- return -ENOENT; ++ return -ENOATTR; + + ret = dict_set_dynstr(dict, (char *)key, found); + if (ret) { +@@ -3422,7 +3422,7 @@ posix_getxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, + if (ret < 0) { + op_ret = -1; + op_errno = -ret; +- if (op_errno == ENOENT) { ++ if (op_errno == ENOATTR) { + gf_msg_debug(this->name, 0, + "Failed to get " + "real filename (%s, %s)", +-- +1.8.3.1 + diff --git a/0224-core-replace-inet_addr-with-inet_pton.patch b/0224-core-replace-inet_addr-with-inet_pton.patch new file mode 100644 index 0000000..f9a3b56 --- /dev/null +++ b/0224-core-replace-inet_addr-with-inet_pton.patch @@ -0,0 +1,53 @@ +From 3528c4fb59ca4d3efda2cf0689b7549e449bb91b Mon Sep 17 00:00:00 2001 +From: Rinku Kothiya +Date: Fri, 14 Jun 2019 07:53:06 +0000 +Subject: [PATCH 224/255] core: replace inet_addr with inet_pton + +Fixes warning raised by RPMDiff on the use of inet_addr, which may +impact Ipv6 support + +> upstream patch : https://review.gluster.org/#/c/glusterfs/+/22866/ + +>fixes: bz#1721385 +>Change-Id: Id2d9afa1747efa64bc79d90dd2566bff54deedeb +>Signed-off-by: Rinku Kothiya + +BUG: 1698435 +Change-Id: Id2d9afa1747efa64bc79d90dd2566bff54deedeb +Signed-off-by: Rinku Kothiya +Reviewed-on: https://code.engineering.redhat.com/gerrit/175318 +Tested-by: RHGS Build Bot +Reviewed-by: Sunil Kumar Heggodu Gopala Acharya +--- + libglusterfs/src/events.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/libglusterfs/src/events.c b/libglusterfs/src/events.c +index 9b3a226..2509767 100644 +--- a/libglusterfs/src/events.c ++++ b/libglusterfs/src/events.c +@@ -41,6 +41,7 @@ _gf_event(eventtypes_t event, const char *fmt, ...) + char *host = NULL; + struct addrinfo hints; + struct addrinfo *result = NULL; ++ xlator_t *this = THIS; + + /* Global context */ + ctx = THIS->ctx; +@@ -82,7 +83,12 @@ _gf_event(eventtypes_t event, const char *fmt, ...) + /* Socket Configurations */ + server.sin_family = AF_INET; + server.sin_port = htons(EVENT_PORT); +- server.sin_addr.s_addr = inet_addr(host); ++ ret = inet_pton(server.sin_family, host, &server.sin_addr); ++ if (ret <= 0) { ++ gf_msg(this->name, GF_LOG_ERROR, EINVAL, LG_MSG_INVALID_ARG, ++ "inet_pton failed with return code %d", ret); ++ goto out; ++ } + memset(&server.sin_zero, '\0', sizeof(server.sin_zero)); + + va_start(arguments, fmt); +-- +1.8.3.1 + diff --git a/0225-tests-utils-Fix-py2-py3-util-python-scripts.patch b/0225-tests-utils-Fix-py2-py3-util-python-scripts.patch new file mode 100644 index 0000000..5ad185d --- /dev/null +++ b/0225-tests-utils-Fix-py2-py3-util-python-scripts.patch @@ -0,0 +1,448 @@ +From 9d10b1fd102dc2d5bfa71891ded52b7a8f5e08d8 Mon Sep 17 00:00:00 2001 +From: Kotresh HR +Date: Thu, 6 Jun 2019 12:54:04 +0530 +Subject: [PATCH 225/255] tests/utils: Fix py2/py3 util python scripts + +Following files are fixed. + +tests/bugs/distribute/overlap.py +tests/utils/changelogparser.py +tests/utils/create-files.py +tests/utils/gfid-access.py +tests/utils/libcxattr.py + +> upstream patch link : https://review.gluster.org/#/c/glusterfs/+/22829/ + +>Change-Id: I3db857cc19e19163d368d913eaec1269fbc37140 +>updates: bz#1193929 +>Signed-off-by: Kotresh HR + +Change-Id: I3db857cc19e19163d368d913eaec1269fbc37140 +BUG: 1704562 +Signed-off-by: Kotresh HR +Reviewed-on: https://code.engineering.redhat.com/gerrit/175483 +Tested-by: RHGS Build Bot +Reviewed-by: Atin Mukherjee +--- + tests/bugs/distribute/overlap.py | 2 +- + tests/bugs/glusterfs/bug-902610.t | 2 +- + tests/utils/changelogparser.py | 5 +- + tests/utils/create-files.py | 9 +- + tests/utils/gfid-access.py | 62 +++++++++---- + tests/utils/libcxattr.py | 22 +++-- + tests/utils/py2py3.py | 186 ++++++++++++++++++++++++++++++++++++++ + 7 files changed, 258 insertions(+), 30 deletions(-) + create mode 100644 tests/utils/py2py3.py + +diff --git a/tests/bugs/distribute/overlap.py b/tests/bugs/distribute/overlap.py +index 0941d37..2813979 100755 +--- a/tests/bugs/distribute/overlap.py ++++ b/tests/bugs/distribute/overlap.py +@@ -17,7 +17,7 @@ def calculate_one (ov, nv): + + def calculate_all (values): + total = 0 +- nv_index = len(values) / 2 ++ nv_index = len(values) // 2 + for old_val in values[:nv_index]: + new_val = values[nv_index] + nv_index += 1 +diff --git a/tests/bugs/glusterfs/bug-902610.t b/tests/bugs/glusterfs/bug-902610.t +index b45e92b..112c947 100755 +--- a/tests/bugs/glusterfs/bug-902610.t ++++ b/tests/bugs/glusterfs/bug-902610.t +@@ -28,7 +28,7 @@ function get_layout() + fi + + # Figure out where the join point is. +- target=$( $PYTHON -c "print '%08x' % (0x$layout1_e + 1)") ++ target=$( $PYTHON -c "print('%08x' % (0x$layout1_e + 1))") + #echo "target for layout2 = $target" > /dev/tty + + # The second layout should cover everything that the first doesn't. +diff --git a/tests/utils/changelogparser.py b/tests/utils/changelogparser.py +index e8e252d..3b8f81d 100644 +--- a/tests/utils/changelogparser.py ++++ b/tests/utils/changelogparser.py +@@ -125,7 +125,10 @@ class Record(object): + return repr(self.__dict__) + + def __str__(self): +- return unicode(self).encode('utf-8') ++ if sys.version_info >= (3,): ++ return self.__unicode__() ++ else: ++ return unicode(self).encode('utf-8') + + + def get_num_tokens(data, tokens, version=Version.V11): +diff --git a/tests/utils/create-files.py b/tests/utils/create-files.py +index b2a1961..04736e9 100755 +--- a/tests/utils/create-files.py ++++ b/tests/utils/create-files.py +@@ -19,6 +19,11 @@ import argparse + datsiz = 0 + timr = 0 + ++def get_ascii_upper_alpha_digits(): ++ if sys.version_info > (3,0): ++ return string.ascii_uppercase+string.digits ++ else: ++ return string.uppercase+string.digits + + def setLogger(filename): + global logger +@@ -111,7 +116,7 @@ def create_tar_file(fil, size, mins, maxs, rand): + + def get_filename(flen): + size = flen +- char = string.uppercase+string.digits ++ char = get_ascii_upper_alpha_digits() + st = ''.join(random.choice(char) for i in range(size)) + ti = str((hex(int(str(time.time()).split('.')[0])))[2:]) + return ti+"%%"+st +@@ -175,7 +180,7 @@ def tar_files(files, file_count, inter, size, mins, maxs, + + + def setxattr_files(files, randname, dir_path): +- char = string.uppercase+string.digits ++ char = get_ascii_upper_alpha_digits() + if not randname: + for k in range(files): + v = ''.join(random.choice(char) for i in range(10)) +diff --git a/tests/utils/gfid-access.py b/tests/utils/gfid-access.py +index 556d2b4..c35c122 100755 +--- a/tests/utils/gfid-access.py ++++ b/tests/utils/gfid-access.py +@@ -33,23 +33,51 @@ def _fmt_mkdir(l): + def _fmt_symlink(l1, l2): + return "!II%dsI%ds%ds" % (37, l1+1, l2+1) + +-def entry_pack_reg(gf, bn, mo, uid, gid): +- blen = len(bn) +- return struct.pack(_fmt_mknod(blen), +- uid, gid, gf, mo, bn, +- stat.S_IMODE(mo), 0, umask()) +- +-def entry_pack_dir(gf, bn, mo, uid, gid): +- blen = len(bn) +- return struct.pack(_fmt_mkdir(blen), +- uid, gid, gf, mo, bn, +- stat.S_IMODE(mo), umask()) +- +-def entry_pack_symlink(gf, bn, lnk, mo, uid, gid): +- blen = len(bn) +- llen = len(lnk) +- return struct.pack(_fmt_symlink(blen, llen), +- uid, gid, gf, mo, bn, lnk) ++ ++if sys.version_info > (3,): ++ def entry_pack_reg(gf, bn, mo, uid, gid): ++ bn_encoded = bn.encode() ++ blen = len(bn_encoded) ++ return struct.pack(_fmt_mknod(blen), ++ uid, gid, gf.encode(), mo, bn_encoded, ++ stat.S_IMODE(mo), 0, umask()) ++ ++ # mkdir ++ def entry_pack_dir(gf, bn, mo, uid, gid): ++ bn_encoded = bn.encode() ++ blen = len(bn_encoded) ++ return struct.pack(_fmt_mkdir(blen), ++ uid, gid, gf.encode(), mo, bn_encoded, ++ stat.S_IMODE(mo), umask()) ++ # symlink ++ def entry_pack_symlink(gf, bn, lnk, st): ++ bn_encoded = bn.encode() ++ blen = len(bn_encoded) ++ lnk_encoded = lnk.encode() ++ llen = len(lnk_encoded) ++ return struct.pack(_fmt_symlink(blen, llen), ++ st['uid'], st['gid'], ++ gf.encode(), st['mode'], bn_encoded, ++ lnk_encoded) ++ ++else: ++ def entry_pack_reg(gf, bn, mo, uid, gid): ++ blen = len(bn) ++ return struct.pack(_fmt_mknod(blen), ++ uid, gid, gf, mo, bn, ++ stat.S_IMODE(mo), 0, umask()) ++ ++ def entry_pack_dir(gf, bn, mo, uid, gid): ++ blen = len(bn) ++ return struct.pack(_fmt_mkdir(blen), ++ uid, gid, gf, mo, bn, ++ stat.S_IMODE(mo), umask()) ++ ++ def entry_pack_symlink(gf, bn, lnk, mo, uid, gid): ++ blen = len(bn) ++ llen = len(lnk) ++ return struct.pack(_fmt_symlink(blen, llen), ++ uid, gid, gf, mo, bn, lnk) + + if __name__ == '__main__': + if len(sys.argv) < 9: +diff --git a/tests/utils/libcxattr.py b/tests/utils/libcxattr.py +index fd0b083..3f3ed1f 100644 +--- a/tests/utils/libcxattr.py ++++ b/tests/utils/libcxattr.py +@@ -10,7 +10,9 @@ + + import os + import sys +-from ctypes import CDLL, c_int, create_string_buffer ++from ctypes import CDLL, c_int ++from py2py3 import bytearray_to_str, gr_create_string_buffer ++from py2py3 import gr_query_xattr, gr_lsetxattr, gr_lremovexattr + + + class Xattr(object): +@@ -47,20 +49,23 @@ class Xattr(object): + @classmethod + def _query_xattr(cls, path, siz, syscall, *a): + if siz: +- buf = create_string_buffer('\0' * siz) ++ buf = gr_create_string_buffer(siz) + else: + buf = None + ret = getattr(cls.libc, syscall)(*((path,) + a + (buf, siz))) + if ret == -1: + cls.raise_oserr() + if siz: +- return buf.raw[:ret] ++ # py2 and py3 compatibility. Convert bytes array ++ # to string ++ result = bytearray_to_str(buf.raw) ++ return result[:ret] + else: + return ret + + @classmethod + def lgetxattr(cls, path, attr, siz=0): +- return cls._query_xattr(path, siz, 'lgetxattr', attr) ++ return gr_query_xattr(cls, path, siz, 'lgetxattr', attr) + + @classmethod + def lgetxattr_buf(cls, path, attr): +@@ -74,20 +79,21 @@ class Xattr(object): + + @classmethod + def llistxattr(cls, path, siz=0): +- ret = cls._query_xattr(path, siz, 'llistxattr') ++ ret = gr_query_xattr(cls, path, siz, 'llistxattr') + if isinstance(ret, str): +- ret = ret.split('\0') ++ ret = ret.strip('\0') ++ ret = ret.split('\0') if ret else [] + return ret + + @classmethod + def lsetxattr(cls, path, attr, val): +- ret = cls.libc.lsetxattr(path, attr, val, len(val), 0) ++ ret = gr_lsetxattr(cls, path, attr, val) + if ret == -1: + cls.raise_oserr() + + @classmethod + def lremovexattr(cls, path, attr): +- ret = cls.libc.lremovexattr(path, attr) ++ ret = gr_lremovexattr(cls, path, attr) + if ret == -1: + cls.raise_oserr() + +diff --git a/tests/utils/py2py3.py b/tests/utils/py2py3.py +new file mode 100644 +index 0000000..63aca10 +--- /dev/null ++++ b/tests/utils/py2py3.py +@@ -0,0 +1,186 @@ ++# ++# Copyright (c) 2018 Red Hat, Inc. ++# This file is part of GlusterFS. ++ ++# This file is licensed to you under your choice of the GNU Lesser ++# General Public License, version 3 or any later version (LGPLv3 or ++# later), or the GNU General Public License, version 2 (GPLv2), in all ++# cases as published by the Free Software Foundation. ++# ++ ++# All python2/python3 compatibility routines ++ ++import sys ++import os ++import stat ++import struct ++from ctypes import create_string_buffer ++ ++def umask(): ++ return os.umask(0) ++ ++if sys.version_info >= (3,): ++ def pipe(): ++ (r, w) = os.pipe() ++ os.set_inheritable(r, True) ++ os.set_inheritable(w, True) ++ return (r, w) ++ ++ # Raw conversion of bytearray to string. Used in the cases where ++ # buffer is created by create_string_buffer which is a 8-bit char ++ # array and passed to syscalls to fetch results. Using encode/decode ++ # doesn't work as it converts to string altering the size. ++ def bytearray_to_str(byte_arr): ++ return ''.join([chr(b) for b in byte_arr]) ++ ++ # Raw conversion of string to bytes. This is required to convert ++ # back the string into bytearray(c char array) to use in struc ++ # pack/unpacking. Again encode/decode can't be used as it ++ # converts it alters size. ++ def str_to_bytearray(string): ++ return bytes([ord(c) for c in string]) ++ ++ def gr_create_string_buffer(size): ++ return create_string_buffer(b'\0', size) ++ ++ def gr_query_xattr(cls, path, size, syscall, attr=None): ++ if attr: ++ return cls._query_xattr(path.encode(), size, syscall, ++ attr.encode()) ++ else: ++ return cls._query_xattr(path.encode(), size, syscall) ++ ++ def gr_lsetxattr(cls, path, attr, val): ++ return cls.libc.lsetxattr(path.encode(), attr.encode(), val, ++ len(val), 0) ++ ++ def gr_lremovexattr(cls, path, attr): ++ return cls.libc.lremovexattr(path.encode(), attr.encode()) ++ ++ def gr_cl_register(cls, brick, path, log_file, log_level, retries): ++ return cls._get_api('gf_changelog_register')(brick.encode(), ++ path.encode(), ++ log_file.encode(), ++ log_level, retries) ++ ++ def gr_cl_done(cls, clfile): ++ return cls._get_api('gf_changelog_done')(clfile.encode()) ++ ++ def gr_cl_history_changelog(cls, changelog_path, start, end, num_parallel, ++ actual_end): ++ return cls._get_api('gf_history_changelog')(changelog_path.encode(), ++ start, end, num_parallel, ++ actual_end) ++ ++ def gr_cl_history_done(cls, clfile): ++ return cls._get_api('gf_history_changelog_done')(clfile.encode()) ++ ++ # regular file ++ ++ def entry_pack_reg(cls, gf, bn, mo, uid, gid): ++ bn_encoded = bn.encode() ++ blen = len(bn_encoded) ++ return struct.pack(cls._fmt_mknod(blen), ++ uid, gid, gf.encode(), mo, bn_encoded, ++ stat.S_IMODE(mo), 0, umask()) ++ ++ def entry_pack_reg_stat(cls, gf, bn, st): ++ bn_encoded = bn.encode() ++ blen = len(bn_encoded) ++ mo = st['mode'] ++ return struct.pack(cls._fmt_mknod(blen), ++ st['uid'], st['gid'], ++ gf.encode(), mo, bn_encoded, ++ stat.S_IMODE(mo), 0, umask()) ++ # mkdir ++ ++ def entry_pack_mkdir(cls, gf, bn, mo, uid, gid): ++ bn_encoded = bn.encode() ++ blen = len(bn_encoded) ++ return struct.pack(cls._fmt_mkdir(blen), ++ uid, gid, gf.encode(), mo, bn_encoded, ++ stat.S_IMODE(mo), umask()) ++ # symlink ++ ++ def entry_pack_symlink(cls, gf, bn, lnk, st): ++ bn_encoded = bn.encode() ++ blen = len(bn_encoded) ++ lnk_encoded = lnk.encode() ++ llen = len(lnk_encoded) ++ return struct.pack(cls._fmt_symlink(blen, llen), ++ st['uid'], st['gid'], ++ gf.encode(), st['mode'], bn_encoded, ++ lnk_encoded) ++else: ++ def pipe(): ++ (r, w) = os.pipe() ++ return (r, w) ++ ++ # Raw conversion of bytearray to string ++ def bytearray_to_str(byte_arr): ++ return byte_arr ++ ++ # Raw conversion of string to bytearray ++ def str_to_bytearray(string): ++ return string ++ ++ def gr_create_string_buffer(size): ++ return create_string_buffer('\0', size) ++ ++ def gr_query_xattr(cls, path, size, syscall, attr=None): ++ if attr: ++ return cls._query_xattr(path, size, syscall, attr) ++ else: ++ return cls._query_xattr(path, size, syscall) ++ ++ def gr_lsetxattr(cls, path, attr, val): ++ return cls.libc.lsetxattr(path, attr, val, len(val), 0) ++ ++ def gr_lremovexattr(cls, path, attr): ++ return cls.libc.lremovexattr(path, attr) ++ ++ def gr_cl_register(cls, brick, path, log_file, log_level, retries): ++ return cls._get_api('gf_changelog_register')(brick, path, log_file, ++ log_level, retries) ++ ++ def gr_cl_done(cls, clfile): ++ return cls._get_api('gf_changelog_done')(clfile) ++ ++ def gr_cl_history_changelog(cls, changelog_path, start, end, num_parallel, ++ actual_end): ++ return cls._get_api('gf_history_changelog')(changelog_path, start, end, ++ num_parallel, actual_end) ++ ++ def gr_cl_history_done(cls, clfile): ++ return cls._get_api('gf_history_changelog_done')(clfile) ++ ++ # regular file ++ ++ def entry_pack_reg(cls, gf, bn, mo, uid, gid): ++ blen = len(bn) ++ return struct.pack(cls._fmt_mknod(blen), ++ uid, gid, gf, mo, bn, ++ stat.S_IMODE(mo), 0, umask()) ++ ++ def entry_pack_reg_stat(cls, gf, bn, st): ++ blen = len(bn) ++ mo = st['mode'] ++ return struct.pack(cls._fmt_mknod(blen), ++ st['uid'], st['gid'], ++ gf, mo, bn, ++ stat.S_IMODE(mo), 0, umask()) ++ # mkdir ++ ++ def entry_pack_mkdir(cls, gf, bn, mo, uid, gid): ++ blen = len(bn) ++ return struct.pack(cls._fmt_mkdir(blen), ++ uid, gid, gf, mo, bn, ++ stat.S_IMODE(mo), umask()) ++ # symlink ++ ++ def entry_pack_symlink(cls, gf, bn, lnk, st): ++ blen = len(bn) ++ llen = len(lnk) ++ return struct.pack(cls._fmt_symlink(blen, llen), ++ st['uid'], st['gid'], ++ gf, st['mode'], bn, lnk) +-- +1.8.3.1 + diff --git a/0226-geo-rep-fix-gluster-command-path-for-non-root-sessio.patch b/0226-geo-rep-fix-gluster-command-path-for-non-root-sessio.patch new file mode 100644 index 0000000..f8f382a --- /dev/null +++ b/0226-geo-rep-fix-gluster-command-path-for-non-root-sessio.patch @@ -0,0 +1,92 @@ +From 1c55f3633f748629cd0484f79b6c49101eb2df82 Mon Sep 17 00:00:00 2001 +From: Sunny Kumar +Date: Mon, 8 Jul 2019 11:47:28 +0530 +Subject: [PATCH 226/255] geo-rep : fix gluster command path for non-root + session + +Problem: +gluster command not found. + +Cause: +In Volinfo class we issue command 'gluster vol info' to get information +about volume like getting brick_root to perform various operation. +When geo-rep session is configured for non-root user Volinfo class +fails to issue gluster command due to unavailability of gluster +binary path for non-root user. + +Solution: +Use config value 'slave-gluster-command-dir'/'gluster-command-dir' to get path +for gluster command based on caller. + +>Backport of: +>Upstream Patch: https://review.gluster.org/#/c/glusterfs/+/22920/. +>fixes: bz#1722740 +>Change-Id: I4ec46373da01f5d00ecd160c4e8c6239da8b3859 +>Signed-off-by: Sunny Kumar + +BUG: 1712591 +Change-Id: Ifea2927253a9521fa459fea6de8a60085c3413f6 +Signed-off-by: Sunny Kumar +Reviewed-on: https://code.engineering.redhat.com/gerrit/175485 +Tested-by: RHGS Build Bot +Reviewed-by: Sunil Kumar Heggodu Gopala Acharya +--- + geo-replication/syncdaemon/monitor.py | 4 ++-- + geo-replication/syncdaemon/syncdutils.py | 12 +++++++++--- + 2 files changed, 11 insertions(+), 5 deletions(-) + +diff --git a/geo-replication/syncdaemon/monitor.py b/geo-replication/syncdaemon/monitor.py +index c45ef24..234f3f1 100644 +--- a/geo-replication/syncdaemon/monitor.py ++++ b/geo-replication/syncdaemon/monitor.py +@@ -369,7 +369,7 @@ def distribute(master, slave): + if rconf.args.use_gconf_volinfo: + mvol = VolinfoFromGconf(master.volume, master=True) + else: +- mvol = Volinfo(master.volume, master.host) ++ mvol = Volinfo(master.volume, master.host, master=True) + logging.debug('master bricks: ' + repr(mvol.bricks)) + prelude = [] + slave_host = None +@@ -385,7 +385,7 @@ def distribute(master, slave): + if rconf.args.use_gconf_volinfo: + svol = VolinfoFromGconf(slave.volume, master=False) + else: +- svol = Volinfo(slave.volume, "localhost", prelude) ++ svol = Volinfo(slave.volume, "localhost", prelude, master=False) + + sbricks = svol.bricks + suuid = svol.uuid +diff --git a/geo-replication/syncdaemon/syncdutils.py b/geo-replication/syncdaemon/syncdutils.py +index 3f41b5f..2ee10ac 100644 +--- a/geo-replication/syncdaemon/syncdutils.py ++++ b/geo-replication/syncdaemon/syncdutils.py +@@ -672,7 +672,7 @@ def get_slv_dir_path(slv_host, slv_volume, gfid): + dir_path = ENOENT + + if not slv_bricks: +- slv_info = Volinfo(slv_volume, slv_host) ++ slv_info = Volinfo(slv_volume, slv_host, master=False) + slv_bricks = slv_info.bricks + # Result of readlink would be of format as below. + # readlink = "../../pgfid[0:2]/pgfid[2:4]/pgfid/basename" +@@ -854,8 +854,14 @@ class Popen(subprocess.Popen): + + class Volinfo(object): + +- def __init__(self, vol, host='localhost', prelude=[]): +- po = Popen(prelude + ['gluster', '--xml', '--remote-host=' + host, ++ def __init__(self, vol, host='localhost', prelude=[], master=True): ++ if master: ++ gluster_cmd_dir = gconf.get("gluster-command-dir") ++ else: ++ gluster_cmd_dir = gconf.get("slave-gluster-command-dir") ++ ++ gluster_cmd = os.path.join(gluster_cmd_dir, 'gluster') ++ po = Popen(prelude + [gluster_cmd, '--xml', '--remote-host=' + host, + 'volume', 'info', vol], + stdout=PIPE, stderr=PIPE, universal_newlines=True) + vix = po.stdout.read() +-- +1.8.3.1 + diff --git a/0227-glusterd-svc-update-pid-of-mux-volumes-from-the-shd-.patch b/0227-glusterd-svc-update-pid-of-mux-volumes-from-the-shd-.patch new file mode 100644 index 0000000..41d482f --- /dev/null +++ b/0227-glusterd-svc-update-pid-of-mux-volumes-from-the-shd-.patch @@ -0,0 +1,914 @@ +From b0815b8a84a07d17a1215c55afc38888ee9fc37c Mon Sep 17 00:00:00 2001 +From: Mohammed Rafi KC +Date: Mon, 24 Jun 2019 12:00:20 +0530 +Subject: [PATCH 227/255] glusterd/svc: update pid of mux volumes from the shd + process + +For a normal volume, we are updating the pid from a the +process while we do a daemonization or at the end of the +init if it is no-daemon mode. Along with updating the pid +we also lock the file, to make sure that the process is +running fine. + +With brick mux, we were updating the pidfile from gluterd +after an attach/detach request. + +There are two problems with this approach. +1) We are not holding a pidlock for any file other than parent + process. +2) There is a chance for possible race conditions with attach/detach. + For example, shd start and a volume stop could race. Let's say + we are starting an shd and it is attached to a volume. + While we trying to link the pid file to the running process, + this would have deleted by the thread that doing a volume stop. + +> upstream patch : https://review.gluster.org/#/c/glusterfs/+/22935/ + +>Change-Id: I29a00352102877ce09ea3f376ca52affceb5cf1a +>Updates: bz#1722541 +>Signed-off-by: Mohammed Rafi KC + +Change-Id: I29a00352102877ce09ea3f376ca52affceb5cf1a +BUG: 1721802 +Signed-off-by: Mohammed Rafi KC +Reviewed-on: https://code.engineering.redhat.com/gerrit/175723 +Tested-by: RHGS Build Bot +Reviewed-by: Atin Mukherjee +--- + glusterfsd/src/gf_attach.c | 2 + + glusterfsd/src/glusterfsd-mgmt.c | 66 +++++++-- + libglusterfs/src/glusterfs/glusterfs.h | 2 +- + libglusterfs/src/glusterfs/libglusterfs-messages.h | 3 +- + libglusterfs/src/graph.c | 154 ++++++++++++++++++++- + rpc/xdr/src/glusterd1-xdr.x | 1 + + xlators/mgmt/glusterd/src/glusterd-handler.c | 2 + + xlators/mgmt/glusterd/src/glusterd-handshake.c | 42 +++++- + xlators/mgmt/glusterd/src/glusterd-op-sm.c | 4 + + .../mgmt/glusterd/src/glusterd-shd-svc-helper.c | 25 ++++ + .../mgmt/glusterd/src/glusterd-shd-svc-helper.h | 3 + + xlators/mgmt/glusterd/src/glusterd-shd-svc.c | 8 +- + xlators/mgmt/glusterd/src/glusterd-svc-helper.c | 57 ++++---- + xlators/mgmt/glusterd/src/glusterd-syncop.c | 2 + + xlators/mgmt/glusterd/src/glusterd-utils.c | 6 +- + 15 files changed, 325 insertions(+), 52 deletions(-) + +diff --git a/glusterfsd/src/gf_attach.c b/glusterfsd/src/gf_attach.c +index 6293b9b..1bff854 100644 +--- a/glusterfsd/src/gf_attach.c ++++ b/glusterfsd/src/gf_attach.c +@@ -65,6 +65,8 @@ send_brick_req(xlator_t *this, struct rpc_clnt *rpc, char *path, int op) + brick_req.name = path; + brick_req.input.input_val = NULL; + brick_req.input.input_len = 0; ++ brick_req.dict.dict_val = NULL; ++ brick_req.dict.dict_len = 0; + + req_size = xdr_sizeof((xdrproc_t)xdr_gd1_mgmt_brick_op_req, req); + iobuf = iobuf_get2(rpc->ctx->iobuf_pool, req_size); +diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c +index 1d2cd1a..f930e0a 100644 +--- a/glusterfsd/src/glusterfsd-mgmt.c ++++ b/glusterfsd/src/glusterfsd-mgmt.c +@@ -50,13 +50,16 @@ int + emancipate(glusterfs_ctx_t *ctx, int ret); + int + glusterfs_process_svc_attach_volfp(glusterfs_ctx_t *ctx, FILE *fp, +- char *volfile_id, char *checksum); ++ char *volfile_id, char *checksum, ++ dict_t *dict); + int + glusterfs_mux_volfile_reconfigure(FILE *newvolfile_fp, glusterfs_ctx_t *ctx, +- gf_volfile_t *volfile_obj, char *checksum); ++ gf_volfile_t *volfile_obj, char *checksum, ++ dict_t *dict); + int + glusterfs_process_svc_attach_volfp(glusterfs_ctx_t *ctx, FILE *fp, +- char *volfile_id, char *checksum); ++ char *volfile_id, char *checksum, ++ dict_t *dict); + int + glusterfs_process_svc_detach(glusterfs_ctx_t *ctx, gf_volfile_t *volfile_obj); + +@@ -75,7 +78,8 @@ mgmt_cbk_spec(struct rpc_clnt *rpc, void *mydata, void *data) + } + + int +-mgmt_process_volfile(const char *volfile, ssize_t size, char *volfile_id) ++mgmt_process_volfile(const char *volfile, ssize_t size, char *volfile_id, ++ dict_t *dict) + { + glusterfs_ctx_t *ctx = NULL; + int ret = 0; +@@ -145,11 +149,11 @@ mgmt_process_volfile(const char *volfile, ssize_t size, char *volfile_id) + * the volfile + */ + ret = glusterfs_process_svc_attach_volfp(ctx, tmpfp, volfile_id, +- sha256_hash); ++ sha256_hash, dict); + goto unlock; + } + ret = glusterfs_mux_volfile_reconfigure(tmpfp, ctx, volfile_obj, +- sha256_hash); ++ sha256_hash, dict); + if (ret < 0) { + gf_msg_debug("glusterfsd-mgmt", EINVAL, "Reconfigure failed !!"); + } +@@ -387,6 +391,8 @@ err: + UNLOCK(&ctx->volfile_lock); + if (xlator_req.input.input_val) + free(xlator_req.input.input_val); ++ if (xlator_req.dict.dict_val) ++ free(xlator_req.dict.dict_val); + free(xlator_req.name); + xlator_req.name = NULL; + return 0; +@@ -561,6 +567,8 @@ out: + + free(xlator_req.name); + free(xlator_req.input.input_val); ++ if (xlator_req.dict.dict_val) ++ free(xlator_req.dict.dict_val); + if (output) + dict_unref(output); + if (dict) +@@ -982,6 +990,8 @@ out: + if (input) + dict_unref(input); + free(xlator_req.input.input_val); /*malloced by xdr*/ ++ if (xlator_req.dict.dict_val) ++ free(xlator_req.dict.dict_val); + if (output) + dict_unref(output); + free(xlator_req.name); +@@ -1062,6 +1072,8 @@ glusterfs_handle_attach(rpcsvc_request_t *req) + out: + UNLOCK(&ctx->volfile_lock); + } ++ if (xlator_req.dict.dict_val) ++ free(xlator_req.dict.dict_val); + free(xlator_req.input.input_val); + free(xlator_req.name); + +@@ -1077,6 +1089,7 @@ glusterfs_handle_svc_attach(rpcsvc_request_t *req) + }; + xlator_t *this = NULL; + glusterfs_ctx_t *ctx = NULL; ++ dict_t *dict = NULL; + + GF_ASSERT(req); + this = THIS; +@@ -1091,20 +1104,41 @@ glusterfs_handle_svc_attach(rpcsvc_request_t *req) + req->rpc_err = GARBAGE_ARGS; + goto out; + } ++ + gf_msg(THIS->name, GF_LOG_INFO, 0, glusterfsd_msg_41, + "received attach " + "request for volfile-id=%s", + xlator_req.name); ++ ++ dict = dict_new(); ++ if (!dict) { ++ ret = -1; ++ errno = ENOMEM; ++ goto out; ++ } ++ ++ ret = dict_unserialize(xlator_req.dict.dict_val, xlator_req.dict.dict_len, ++ &dict); ++ if (ret) { ++ gf_msg(this->name, GF_LOG_WARNING, EINVAL, glusterfsd_msg_42, ++ "failed to unserialize xdata to dictionary"); ++ goto out; ++ } ++ dict->extra_stdfree = xlator_req.dict.dict_val; ++ + ret = 0; + + if (ctx->active) { + ret = mgmt_process_volfile(xlator_req.input.input_val, +- xlator_req.input.input_len, xlator_req.name); ++ xlator_req.input.input_len, xlator_req.name, ++ dict); + } else { + gf_msg(this->name, GF_LOG_WARNING, EINVAL, glusterfsd_msg_42, + "got attach for %s but no active graph", xlator_req.name); + } + out: ++ if (dict) ++ dict_unref(dict); + if (xlator_req.input.input_val) + free(xlator_req.input.input_val); + if (xlator_req.name) +@@ -1241,6 +1275,8 @@ out: + GF_FREE(filepath); + if (xlator_req.input.input_val) + free(xlator_req.input.input_val); ++ if (xlator_req.dict.dict_val) ++ free(xlator_req.dict.dict_val); + + return ret; + } +@@ -1313,6 +1349,8 @@ out: + if (dict) + dict_unref(dict); + free(xlator_req.input.input_val); // malloced by xdr ++ if (xlator_req.dict.dict_val) ++ free(xlator_req.dict.dict_val); + if (output) + dict_unref(output); + free(xlator_req.name); // malloced by xdr +@@ -1461,6 +1499,8 @@ out: + if (output) + dict_unref(output); + free(brick_req.input.input_val); ++ if (brick_req.dict.dict_val) ++ free(brick_req.dict.dict_val); + free(brick_req.name); + GF_FREE(xname); + GF_FREE(msg); +@@ -1654,6 +1694,8 @@ out: + if (dict) + dict_unref(dict); + free(node_req.input.input_val); ++ if (node_req.dict.dict_val) ++ free(node_req.dict.dict_val); + GF_FREE(msg); + GF_FREE(rsp.output.output_val); + GF_FREE(node_name); +@@ -1757,6 +1799,8 @@ glusterfs_handle_nfs_profile(rpcsvc_request_t *req) + + out: + free(nfs_req.input.input_val); ++ if (nfs_req.dict.dict_val) ++ free(nfs_req.dict.dict_val); + if (dict) + dict_unref(dict); + if (output) +@@ -1835,6 +1879,8 @@ out: + if (dict) + dict_unref(dict); + free(xlator_req.input.input_val); // malloced by xdr ++ if (xlator_req.dict.dict_val) ++ free(xlator_req.dict.dict_val); + if (output) + dict_unref(output); + free(xlator_req.name); // malloced by xdr +@@ -1963,7 +2009,8 @@ out: + if (dict) + dict_unref(dict); + free(brick_req.input.input_val); +- ++ if (brick_req.dict.dict_val) ++ free(brick_req.dict.dict_val); + gf_log(THIS->name, GF_LOG_DEBUG, "Returning %d", ret); + return ret; + } +@@ -2213,7 +2260,8 @@ volfile: + size = rsp.op_ret; + volfile_id = frame->local; + if (mgmt_is_multiplexed_daemon(ctx->cmd_args.process_name)) { +- ret = mgmt_process_volfile((const char *)rsp.spec, size, volfile_id); ++ ret = mgmt_process_volfile((const char *)rsp.spec, size, volfile_id, ++ dict); + goto post_graph_mgmt; + } + +diff --git a/libglusterfs/src/glusterfs/glusterfs.h b/libglusterfs/src/glusterfs/glusterfs.h +index 9ec2365..b6327b8 100644 +--- a/libglusterfs/src/glusterfs/glusterfs.h ++++ b/libglusterfs/src/glusterfs/glusterfs.h +@@ -744,7 +744,7 @@ typedef struct { + char vol_id[NAME_MAX + 1]; + struct list_head volfile_list; + glusterfs_graph_t *graph; +- ++ FILE *pidfp; + } gf_volfile_t; + + glusterfs_ctx_t * +diff --git a/libglusterfs/src/glusterfs/libglusterfs-messages.h b/libglusterfs/src/glusterfs/libglusterfs-messages.h +index ea2aa60..7e0eebb 100644 +--- a/libglusterfs/src/glusterfs/libglusterfs-messages.h ++++ b/libglusterfs/src/glusterfs/libglusterfs-messages.h +@@ -111,6 +111,7 @@ GLFS_MSGID( + LG_MSG_PTHREAD_NAMING_FAILED, LG_MSG_SYSCALL_RETURNS_WRONG, + LG_MSG_XXH64_TO_GFID_FAILED, LG_MSG_ASYNC_WARNING, LG_MSG_ASYNC_FAILURE, + LG_MSG_GRAPH_CLEANUP_FAILED, LG_MSG_GRAPH_SETUP_FAILED, +- LG_MSG_GRAPH_DETACH_STARTED, LG_MSG_GRAPH_ATTACH_FAILED); ++ LG_MSG_GRAPH_DETACH_STARTED, LG_MSG_GRAPH_ATTACH_FAILED, ++ LG_MSG_GRAPH_ATTACH_PID_FILE_UPDATED); + + #endif /* !_LG_MESSAGES_H_ */ +diff --git a/libglusterfs/src/graph.c b/libglusterfs/src/graph.c +index 172dc61..05f76bf 100644 +--- a/libglusterfs/src/graph.c ++++ b/libglusterfs/src/graph.c +@@ -1467,6 +1467,21 @@ out: + } + + int ++glusterfs_svc_mux_pidfile_cleanup(gf_volfile_t *volfile_obj) ++{ ++ if (!volfile_obj || !volfile_obj->pidfp) ++ return 0; ++ ++ gf_msg_trace("glusterfsd", 0, "pidfile %s cleanup", volfile_obj->vol_id); ++ ++ lockf(fileno(volfile_obj->pidfp), F_ULOCK, 0); ++ fclose(volfile_obj->pidfp); ++ volfile_obj->pidfp = NULL; ++ ++ return 0; ++} ++ ++int + glusterfs_process_svc_detach(glusterfs_ctx_t *ctx, gf_volfile_t *volfile_obj) + { + xlator_t *last_xl = NULL; +@@ -1502,6 +1517,7 @@ glusterfs_process_svc_detach(glusterfs_ctx_t *ctx, gf_volfile_t *volfile_obj) + + list_del_init(&volfile_obj->volfile_list); + glusterfs_mux_xlator_unlink(parent_graph->top, xl); ++ glusterfs_svc_mux_pidfile_cleanup(volfile_obj); + parent_graph->last_xl = glusterfs_get_last_xlator(parent_graph); + parent_graph->xl_count -= graph->xl_count; + parent_graph->leaf_count -= graph->leaf_count; +@@ -1531,8 +1547,126 @@ out: + } + + int ++glusterfs_svc_mux_pidfile_setup(gf_volfile_t *volfile_obj, const char *pid_file) ++{ ++ int ret = -1; ++ FILE *pidfp = NULL; ++ ++ if (!pid_file || !volfile_obj) ++ goto out; ++ ++ if (volfile_obj->pidfp) { ++ ret = 0; ++ goto out; ++ } ++ pidfp = fopen(pid_file, "a+"); ++ if (!pidfp) { ++ goto out; ++ } ++ volfile_obj->pidfp = pidfp; ++ ++ ret = lockf(fileno(pidfp), F_TLOCK, 0); ++ if (ret) { ++ ret = 0; ++ goto out; ++ } ++out: ++ return ret; ++} ++ ++int ++glusterfs_svc_mux_pidfile_update(gf_volfile_t *volfile_obj, ++ const char *pid_file, pid_t pid) ++{ ++ int ret = 0; ++ FILE *pidfp = NULL; ++ int old_pid; ++ ++ if (!volfile_obj->pidfp) { ++ ret = glusterfs_svc_mux_pidfile_setup(volfile_obj, pid_file); ++ if (ret == -1) ++ goto out; ++ } ++ pidfp = volfile_obj->pidfp; ++ ret = fscanf(pidfp, "%d", &old_pid); ++ if (ret <= 0) { ++ goto update; ++ } ++ if (old_pid == pid) { ++ ret = 0; ++ goto out; ++ } else { ++ gf_msg("mgmt", GF_LOG_INFO, 0, LG_MSG_GRAPH_ATTACH_PID_FILE_UPDATED, ++ "Old pid=%d found in pidfile %s. Cleaning the old pid and " ++ "Updating new pid=%d", ++ old_pid, pid_file, pid); ++ } ++update: ++ ret = sys_ftruncate(fileno(pidfp), 0); ++ if (ret) { ++ gf_msg("glusterfsd", GF_LOG_ERROR, errno, ++ LG_MSG_GRAPH_ATTACH_PID_FILE_UPDATED, ++ "pidfile %s truncation failed", pid_file); ++ goto out; ++ } ++ ++ ret = fprintf(pidfp, "%d\n", pid); ++ if (ret <= 0) { ++ gf_msg("glusterfsd", GF_LOG_ERROR, errno, ++ LG_MSG_GRAPH_ATTACH_PID_FILE_UPDATED, "pidfile %s write failed", ++ pid_file); ++ goto out; ++ } ++ ++ ret = fflush(pidfp); ++ if (ret) { ++ gf_msg("glusterfsd", GF_LOG_ERROR, errno, ++ LG_MSG_GRAPH_ATTACH_PID_FILE_UPDATED, "pidfile %s write failed", ++ pid_file); ++ goto out; ++ } ++out: ++ return ret; ++} ++ ++int ++glusterfs_update_mux_pid(dict_t *dict, gf_volfile_t *volfile_obj) ++{ ++ char *file = NULL; ++ int ret = -1; ++ ++ GF_VALIDATE_OR_GOTO("graph", dict, out); ++ GF_VALIDATE_OR_GOTO("graph", volfile_obj, out); ++ ++ ret = dict_get_str(dict, "pidfile", &file); ++ if (ret < 0) { ++ gf_msg("mgmt", GF_LOG_ERROR, EINVAL, LG_MSG_GRAPH_SETUP_FAILED, ++ "Failed to get pidfile from dict for volfile_id=%s", ++ volfile_obj->vol_id); ++ } ++ ++ ret = glusterfs_svc_mux_pidfile_update(volfile_obj, file, getpid()); ++ if (ret < 0) { ++ ret = -1; ++ gf_msg("mgmt", GF_LOG_ERROR, EINVAL, LG_MSG_GRAPH_SETUP_FAILED, ++ "Failed to update " ++ "the pidfile for volfile_id=%s", ++ volfile_obj->vol_id); ++ ++ goto out; ++ } ++ ++ if (ret == 1) ++ gf_msg("mgmt", GF_LOG_INFO, 0, LG_MSG_GRAPH_ATTACH_PID_FILE_UPDATED, ++ "PID %d updated in pidfile=%s", getpid(), file); ++ ret = 0; ++out: ++ return ret; ++} ++int + glusterfs_process_svc_attach_volfp(glusterfs_ctx_t *ctx, FILE *fp, +- char *volfile_id, char *checksum) ++ char *volfile_id, char *checksum, ++ dict_t *dict) + { + glusterfs_graph_t *graph = NULL; + glusterfs_graph_t *parent_graph = NULL; +@@ -1615,18 +1749,25 @@ glusterfs_process_svc_attach_volfp(glusterfs_ctx_t *ctx, FILE *fp, + ret = -1; + goto out; + } ++ volfile_obj->pidfp = NULL; ++ snprintf(volfile_obj->vol_id, sizeof(volfile_obj->vol_id), "%s", ++ volfile_id); ++ ++ if (strcmp(ctx->cmd_args.process_name, "glustershd") == 0) { ++ ret = glusterfs_update_mux_pid(dict, volfile_obj); ++ if (ret == -1) { ++ goto out; ++ } ++ } + + graph->used = 1; + parent_graph->id++; + list_add(&graph->list, &ctx->graphs); + INIT_LIST_HEAD(&volfile_obj->volfile_list); + volfile_obj->graph = graph; +- snprintf(volfile_obj->vol_id, sizeof(volfile_obj->vol_id), "%s", +- volfile_id); + memcpy(volfile_obj->volfile_checksum, checksum, + sizeof(volfile_obj->volfile_checksum)); + list_add_tail(&volfile_obj->volfile_list, &ctx->volfile_list); +- + gf_log_dump_graph(fp, graph); + graph = NULL; + +@@ -1654,7 +1795,8 @@ out: + + int + glusterfs_mux_volfile_reconfigure(FILE *newvolfile_fp, glusterfs_ctx_t *ctx, +- gf_volfile_t *volfile_obj, char *checksum) ++ gf_volfile_t *volfile_obj, char *checksum, ++ dict_t *dict) + { + glusterfs_graph_t *oldvolfile_graph = NULL; + glusterfs_graph_t *newvolfile_graph = NULL; +@@ -1703,7 +1845,7 @@ glusterfs_mux_volfile_reconfigure(FILE *newvolfile_fp, glusterfs_ctx_t *ctx, + } + volfile_obj = NULL; + ret = glusterfs_process_svc_attach_volfp(ctx, newvolfile_fp, vol_id, +- checksum); ++ checksum, dict); + goto out; + } + +diff --git a/rpc/xdr/src/glusterd1-xdr.x b/rpc/xdr/src/glusterd1-xdr.x +index 9b36d34..02ebec2 100644 +--- a/rpc/xdr/src/glusterd1-xdr.x ++++ b/rpc/xdr/src/glusterd1-xdr.x +@@ -132,6 +132,7 @@ struct gd1_mgmt_brick_op_req { + string name<>; + int op; + opaque input<>; ++ opaque dict<>; + } ; + + struct gd1_mgmt_brick_op_rsp { +diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c +index af8a8a4..cc1f1df 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-handler.c ++++ b/xlators/mgmt/glusterd/src/glusterd-handler.c +@@ -5423,6 +5423,8 @@ glusterd_print_client_details(FILE *fp, dict_t *dict, + + brick_req->op = GLUSTERD_BRICK_STATUS; + brick_req->name = ""; ++ brick_req->dict.dict_val = NULL; ++ brick_req->dict.dict_len = 0; + + ret = dict_set_strn(dict, "brick-name", SLEN("brick-name"), + brickinfo->path); +diff --git a/xlators/mgmt/glusterd/src/glusterd-handshake.c b/xlators/mgmt/glusterd/src/glusterd-handshake.c +index 1ba58c3..86dec82 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-handshake.c ++++ b/xlators/mgmt/glusterd/src/glusterd-handshake.c +@@ -203,7 +203,7 @@ out: + + size_t + build_volfile_path(char *volume_id, char *path, size_t path_len, +- char *trusted_str) ++ char *trusted_str, dict_t *dict) + { + struct stat stbuf = { + 0, +@@ -340,11 +340,19 @@ build_volfile_path(char *volume_id, char *path, size_t path_len, + + ret = glusterd_volinfo_find(volid_ptr, &volinfo); + if (ret == -1) { +- gf_log(this->name, GF_LOG_ERROR, "Couldn't find volinfo"); ++ gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_VOLINFO_GET_FAIL, ++ "Couldn't find volinfo for volid=%s", volid_ptr); + goto out; + } + + glusterd_svc_build_shd_volfile_path(volinfo, path, path_len); ++ ++ ret = glusterd_svc_set_shd_pidfile(volinfo, dict); ++ if (ret == -1) { ++ gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED, ++ "Couldn't set pidfile in dict for volid=%s", volid_ptr); ++ goto out; ++ } + ret = 0; + goto out; + } +@@ -919,6 +927,7 @@ __server_getspec(rpcsvc_request_t *req) + char addrstr[RPCSVC_PEER_STRLEN] = {0}; + peer_info_t *peerinfo = NULL; + xlator_t *this = NULL; ++ dict_t *dict = NULL; + + this = THIS; + GF_ASSERT(this); +@@ -971,6 +980,12 @@ __server_getspec(rpcsvc_request_t *req) + goto fail; + } + ++ dict = dict_new(); ++ if (!dict) { ++ ret = -ENOMEM; ++ goto fail; ++ } ++ + trans = req->trans; + /* addrstr will be empty for cli socket connections */ + ret = rpcsvc_transport_peername(trans, (char *)&addrstr, sizeof(addrstr)); +@@ -989,12 +1004,26 @@ __server_getspec(rpcsvc_request_t *req) + */ + if (strlen(addrstr) == 0 || gf_is_local_addr(addrstr)) { + ret = build_volfile_path(volume, filename, sizeof(filename), +- TRUSTED_PREFIX); ++ TRUSTED_PREFIX, dict); + } else { +- ret = build_volfile_path(volume, filename, sizeof(filename), NULL); ++ ret = build_volfile_path(volume, filename, sizeof(filename), NULL, ++ dict); + } + + if (ret == 0) { ++ if (dict->count > 0) { ++ ret = dict_allocate_and_serialize(dict, &rsp.xdata.xdata_val, ++ &rsp.xdata.xdata_len); ++ if (ret) { ++ gf_msg(this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SERL_LENGTH_GET_FAIL, ++ "Failed to serialize dict " ++ "to request buffer"); ++ goto fail; ++ } ++ dict->extra_free = rsp.xdata.xdata_val; ++ } ++ + /* to allocate the proper buffer to hold the file data */ + ret = sys_stat(filename, &stbuf); + if (ret < 0) { +@@ -1036,7 +1065,6 @@ __server_getspec(rpcsvc_request_t *req) + goto fail; + } + } +- + /* convert to XDR */ + fail: + if (spec_fd >= 0) +@@ -1056,6 +1084,10 @@ fail: + (xdrproc_t)xdr_gf_getspec_rsp); + free(args.key); // malloced by xdr + free(rsp.spec); ++ ++ if (dict) ++ dict_unref(dict); ++ + if (args.xdata.xdata_val) + free(args.xdata.xdata_val); + +diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c +index 9ea695e..454877b 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c ++++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c +@@ -655,6 +655,8 @@ glusterd_brick_op_build_payload(glusterd_op_t op, + break; + } + ++ brick_req->dict.dict_len = 0; ++ brick_req->dict.dict_val = NULL; + ret = dict_allocate_and_serialize(dict, &brick_req->input.input_val, + &brick_req->input.input_len); + if (ret) +@@ -723,6 +725,8 @@ glusterd_node_op_build_payload(glusterd_op_t op, gd1_mgmt_brick_op_req **req, + goto out; + } + ++ brick_req->dict.dict_len = 0; ++ brick_req->dict.dict_val = NULL; + ret = dict_allocate_and_serialize(dict, &brick_req->input.input_val, + &brick_req->input.input_len); + +diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.c b/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.c +index 57ceda9..5661e39 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.c ++++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.c +@@ -126,3 +126,28 @@ glusterd_shd_svcproc_cleanup(glusterd_shdsvc_t *shd) + out: + return; + } ++ ++int ++glusterd_svc_set_shd_pidfile(glusterd_volinfo_t *volinfo, dict_t *dict) ++{ ++ int ret = -1; ++ glusterd_svc_t *svc = NULL; ++ xlator_t *this = NULL; ++ ++ this = THIS; ++ GF_VALIDATE_OR_GOTO("glusterd", this, out); ++ GF_VALIDATE_OR_GOTO(this->name, volinfo, out); ++ GF_VALIDATE_OR_GOTO(this->name, dict, out); ++ ++ svc = &(volinfo->shd.svc); ++ ++ ret = dict_set_dynstr_with_alloc(dict, "pidfile", svc->proc.pidfile); ++ if (ret) { ++ gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED, ++ "Failed to set pidfile %s in dict", svc->proc.pidfile); ++ goto out; ++ } ++ ret = 0; ++out: ++ return ret; ++} +diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.h b/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.h +index 59466ec..1f0984b 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.h ++++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.h +@@ -36,4 +36,7 @@ glusterd_recover_shd_attach_failure(glusterd_volinfo_t *volinfo, + int + glusterd_shdsvc_create_volfile(glusterd_volinfo_t *volinfo); + ++int ++glusterd_svc_set_shd_pidfile(glusterd_volinfo_t *volinfo, dict_t *dict); ++ + #endif +diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c +index 8ad90a9..590169f 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c ++++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c +@@ -258,14 +258,20 @@ glusterd_shdsvc_manager(glusterd_svc_t *svc, void *data, int flags) + gf_boolean_t shd_restart = _gf_false; + + conf = THIS->private; +- volinfo = data; + GF_VALIDATE_OR_GOTO("glusterd", conf, out); + GF_VALIDATE_OR_GOTO("glusterd", svc, out); ++ volinfo = data; + GF_VALIDATE_OR_GOTO("glusterd", volinfo, out); + + if (volinfo) + glusterd_volinfo_ref(volinfo); + ++ if (volinfo->is_snap_volume) { ++ /* healing of a snap volume is not supported yet*/ ++ ret = 0; ++ goto out; ++ } ++ + while (conf->restart_shd) { + synclock_unlock(&conf->big_lock); + sleep(2); +diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c +index 400826f..e106111 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c ++++ b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c +@@ -519,7 +519,7 @@ glusterd_shd_svc_mux_init(glusterd_volinfo_t *volinfo, glusterd_svc_t *svc) + /* Take first entry from the process */ + parent_svc = cds_list_entry(mux_proc->svcs.next, glusterd_svc_t, + mux_svc); +- sys_link(parent_svc->proc.pidfile, svc->proc.pidfile); ++ glusterd_copy_file(parent_svc->proc.pidfile, svc->proc.pidfile); + mux_conn = &parent_svc->conn; + if (volinfo) + volinfo->shd.attached = _gf_true; +@@ -623,12 +623,9 @@ glusterd_svc_attach_cbk(struct rpc_req *req, struct iovec *iov, int count, + glusterd_volinfo_t *volinfo = NULL; + glusterd_shdsvc_t *shd = NULL; + glusterd_svc_t *svc = frame->cookie; +- glusterd_svc_t *parent_svc = NULL; +- glusterd_svc_proc_t *mux_proc = NULL; + glusterd_conf_t *conf = NULL; + int *flag = (int *)frame->local; + xlator_t *this = THIS; +- int pid = -1; + int ret = -1; + gf_getspec_rsp rsp = { + 0, +@@ -679,27 +676,7 @@ glusterd_svc_attach_cbk(struct rpc_req *req, struct iovec *iov, int count, + } + + if (rsp.op_ret == 0) { +- pthread_mutex_lock(&conf->attach_lock); +- { +- if (!strcmp(svc->name, "glustershd")) { +- mux_proc = svc->svc_proc; +- if (mux_proc && +- !gf_is_service_running(svc->proc.pidfile, &pid)) { +- /* +- * When svc's are restarting, there is a chance that the +- * attached svc might not have updated it's pid. Because +- * it was at connection stage. So in that case, we need +- * to retry the pid file copy. +- */ +- parent_svc = cds_list_entry(mux_proc->svcs.next, +- glusterd_svc_t, mux_svc); +- if (parent_svc) +- sys_link(parent_svc->proc.pidfile, svc->proc.pidfile); +- } +- } +- svc->online = _gf_true; +- } +- pthread_mutex_unlock(&conf->attach_lock); ++ svc->online = _gf_true; + gf_msg(this->name, GF_LOG_INFO, 0, GD_MSG_SVC_ATTACH_FAIL, + "svc %s of volume %s attached successfully to pid %d", svc->name, + volinfo->volname, glusterd_proc_get_pid(&svc->proc)); +@@ -726,7 +703,7 @@ out: + + extern size_t + build_volfile_path(char *volume_id, char *path, size_t path_len, +- char *trusted_str); ++ char *trusted_str, dict_t *dict); + + int + __glusterd_send_svc_configure_req(glusterd_svc_t *svc, int flags, +@@ -751,6 +728,7 @@ __glusterd_send_svc_configure_req(glusterd_svc_t *svc, int flags, + ssize_t req_size = 0; + call_frame_t *frame = NULL; + gd1_mgmt_brick_op_req brick_req; ++ dict_t *dict = NULL; + void *req = &brick_req; + void *errlbl = &&err; + struct rpc_clnt_connection *conn; +@@ -776,6 +754,8 @@ __glusterd_send_svc_configure_req(glusterd_svc_t *svc, int flags, + brick_req.name = volfile_id; + brick_req.input.input_val = NULL; + brick_req.input.input_len = 0; ++ brick_req.dict.dict_val = NULL; ++ brick_req.dict.dict_len = 0; + + frame = create_frame(this, this->ctx->pool); + if (!frame) { +@@ -783,7 +763,13 @@ __glusterd_send_svc_configure_req(glusterd_svc_t *svc, int flags, + } + + if (op == GLUSTERD_SVC_ATTACH) { +- (void)build_volfile_path(volfile_id, path, sizeof(path), NULL); ++ dict = dict_new(); ++ if (!dict) { ++ ret = -ENOMEM; ++ goto *errlbl; ++ } ++ ++ (void)build_volfile_path(volfile_id, path, sizeof(path), NULL, dict); + + ret = sys_stat(path, &stbuf); + if (ret < 0) { +@@ -818,6 +804,18 @@ __glusterd_send_svc_configure_req(glusterd_svc_t *svc, int flags, + ret = -EIO; + goto *errlbl; + } ++ if (dict->count > 0) { ++ ret = dict_allocate_and_serialize(dict, &brick_req.dict.dict_val, ++ &brick_req.dict.dict_len); ++ if (ret) { ++ gf_msg(this->name, GF_LOG_ERROR, 0, ++ GD_MSG_DICT_SERL_LENGTH_GET_FAIL, ++ "Failed to serialize dict " ++ "to request buffer"); ++ goto *errlbl; ++ } ++ dict->extra_free = brick_req.dict.dict_val; ++ } + + frame->cookie = svc; + frame->local = GF_CALLOC(1, sizeof(int), gf_gld_mt_int); +@@ -862,6 +860,8 @@ __glusterd_send_svc_configure_req(glusterd_svc_t *svc, int flags, + GF_ATOMIC_INC(conf->blockers); + ret = rpc_clnt_submit(rpc, &gd_brick_prog, op, cbkfn, &iov, 1, NULL, 0, + iobref, frame, NULL, 0, NULL, 0, NULL); ++ if (dict) ++ dict_unref(dict); + GF_FREE(volfile_content); + if (spec_fd >= 0) + sys_close(spec_fd); +@@ -874,6 +874,9 @@ maybe_free_iobuf: + iobuf_unref(iobuf); + } + err: ++ if (dict) ++ dict_unref(dict); ++ + GF_FREE(volfile_content); + if (spec_fd >= 0) + sys_close(spec_fd); +diff --git a/xlators/mgmt/glusterd/src/glusterd-syncop.c b/xlators/mgmt/glusterd/src/glusterd-syncop.c +index 618d8bc..a8098df 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-syncop.c ++++ b/xlators/mgmt/glusterd/src/glusterd-syncop.c +@@ -143,6 +143,8 @@ gd_brick_op_req_free(gd1_mgmt_brick_op_req *req) + if (!req) + return; + ++ if (req->dict.dict_val) ++ GF_FREE(req->dict.dict_val); + GF_FREE(req->input.input_val); + GF_FREE(req); + } +diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c +index 4c487d0..2eb5116 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-utils.c ++++ b/xlators/mgmt/glusterd/src/glusterd-utils.c +@@ -5914,6 +5914,8 @@ send_attach_req(xlator_t *this, struct rpc_clnt *rpc, char *path, + brick_req.name = path; + brick_req.input.input_val = NULL; + brick_req.input.input_len = 0; ++ brick_req.dict.dict_val = NULL; ++ brick_req.dict.dict_len = 0; + + req_size = xdr_sizeof((xdrproc_t)xdr_gd1_mgmt_brick_op_req, req); + iobuf = iobuf_get2(rpc->ctx->iobuf_pool, req_size); +@@ -5977,7 +5979,7 @@ err: + + extern size_t + build_volfile_path(char *volume_id, char *path, size_t path_len, +- char *trusted_str); ++ char *trusted_str, dict_t *dict); + + static int + attach_brick(xlator_t *this, glusterd_brickinfo_t *brickinfo, +@@ -6022,7 +6024,7 @@ attach_brick(xlator_t *this, glusterd_brickinfo_t *brickinfo, + goto out; + } + +- (void)build_volfile_path(full_id, path, sizeof(path), NULL); ++ (void)build_volfile_path(full_id, path, sizeof(path), NULL, NULL); + + for (tries = 15; tries > 0; --tries) { + rpc = rpc_clnt_ref(other_brick->rpc); +-- +1.8.3.1 + diff --git a/0228-locks-enable-notify-contention-by-default.patch b/0228-locks-enable-notify-contention-by-default.patch new file mode 100644 index 0000000..310cd8b --- /dev/null +++ b/0228-locks-enable-notify-contention-by-default.patch @@ -0,0 +1,39 @@ +From 21fe2ef700e76c8b7be40f21d3a4fb6b96eafaf0 Mon Sep 17 00:00:00 2001 +From: Xavi Hernandez +Date: Thu, 6 Jun 2019 08:12:34 +0200 +Subject: [PATCH 228/255] locks: enable notify-contention by default + +This patch enables the lock contention notification by default. + +Upstream patch: +> Change-Id: I10131b026a7cb09fc7c93e1e6c8549988c1d7751 +> Upstream patch link: https://review.gluster.org/c/glusterfs/+/22828 +> BUG: 1717754 +> Signed-off-by: Xavi Hernandez + +Change-Id: I10131b026a7cb09fc7c93e1e6c8549988c1d7751 +Fixes: bz#1720488 +Signed-off-by: Xavi Hernandez +Reviewed-on: https://code.engineering.redhat.com/gerrit/174655 +Tested-by: RHGS Build Bot +Reviewed-by: Sunil Kumar Heggodu Gopala Acharya +--- + xlators/features/locks/src/posix.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/xlators/features/locks/src/posix.c b/xlators/features/locks/src/posix.c +index adb0df5..9db5ac6 100644 +--- a/xlators/features/locks/src/posix.c ++++ b/xlators/features/locks/src/posix.c +@@ -4796,7 +4796,7 @@ struct volume_options options[] = { + "be used in conjunction w/ revocation-clear-all."}, + {.key = {"notify-contention"}, + .type = GF_OPTION_TYPE_BOOL, +- .default_value = "no", ++ .default_value = "yes", + .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC, + .op_version = {GD_OP_VERSION_4_0_0}, + .tags = {"locks", "contention"}, +-- +1.8.3.1 + diff --git a/0229-glusterd-Show-the-correct-brick-status-in-get-state.patch b/0229-glusterd-Show-the-correct-brick-status-in-get-state.patch new file mode 100644 index 0000000..112c02e --- /dev/null +++ b/0229-glusterd-Show-the-correct-brick-status-in-get-state.patch @@ -0,0 +1,113 @@ +From 4fc0a77db5b9760fa5c00d3803c6d11a28a00b74 Mon Sep 17 00:00:00 2001 +From: Mohit Agrawal +Date: Wed, 3 Jul 2019 15:22:38 +0530 +Subject: [PATCH 229/255] glusterd: Show the correct brick status in get-state + +Problem: get-state does not show correct brick status if brick + status is not Started, it always shows started if any value + is set brickinfo->status + +Solution: Check the value of brickinfo->status to show correct status + in get-state + +> Change-Id: I12a79619024c2cf59f338220d144f2f034059b3b +> fixes: bz#1726906 +> (Cherry pick from commit af989db23d1db00e087f2b9d3dfc43b13ef17153) +> (Reviewed on upstream link https://review.gluster.org/#/c/glusterfs/+/22983/) + +BUG: 1726991 +Change-Id: I12a79619024c2cf59f338220d144f2f034059b3b +Signed-off-by: Mohit Agrawal +Reviewed-on: https://code.engineering.redhat.com/gerrit/175355 +Tested-by: Mohit Agrawal +Tested-by: RHGS Build Bot +Reviewed-by: Atin Mukherjee +--- + xlators/mgmt/glusterd/src/glusterd-handler.c | 7 +++++-- + xlators/mgmt/glusterd/src/glusterd-utils.c | 28 ++++++++++++++++++++++++++++ + xlators/mgmt/glusterd/src/glusterd-utils.h | 4 ++++ + 3 files changed, 37 insertions(+), 2 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c +index cc1f1df..94e1be5 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-handler.c ++++ b/xlators/mgmt/glusterd/src/glusterd-handler.c +@@ -5589,7 +5589,9 @@ glusterd_get_state(rpcsvc_request_t *req, dict_t *dict) + char vol_status_str[STATUS_STRLEN] = { + 0, + }; +- ++ char brick_status_str[STATUS_STRLEN] = { ++ 0, ++ }; + this = THIS; + GF_VALIDATE_OR_GOTO(THIS->name, this, out); + +@@ -5852,8 +5854,9 @@ glusterd_get_state(rpcsvc_request_t *req, dict_t *dict) + brickinfo->rdma_port); + fprintf(fp, "Volume%d.Brick%d.port_registered: %d\n", count_bkp, + count, brickinfo->port_registered); ++ glusterd_brick_get_status_str(brickinfo, brick_status_str); + fprintf(fp, "Volume%d.Brick%d.status: %s\n", count_bkp, count, +- brickinfo->status ? "Started" : "Stopped"); ++ brick_status_str); + + /*FIXME: This is a hacky way of figuring out whether a + * brick belongs to the hot or cold tier */ +diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c +index 2eb5116..3bdfd49 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-utils.c ++++ b/xlators/mgmt/glusterd/src/glusterd-utils.c +@@ -13898,6 +13898,34 @@ out: + return ret; + } + ++void ++glusterd_brick_get_status_str(glusterd_brickinfo_t *brickinfo, char *status_str) ++{ ++ GF_VALIDATE_OR_GOTO(THIS->name, brickinfo, out); ++ GF_VALIDATE_OR_GOTO(THIS->name, status_str, out); ++ ++ switch (brickinfo->status) { ++ case GF_BRICK_STOPPED: ++ sprintf(status_str, "%s", "Stopped"); ++ break; ++ case GF_BRICK_STARTED: ++ sprintf(status_str, "%s", "Started"); ++ break; ++ case GF_BRICK_STARTING: ++ sprintf(status_str, "%s", "Starting"); ++ break; ++ case GF_BRICK_STOPPING: ++ sprintf(status_str, "%s", "Stopping"); ++ break; ++ default: ++ sprintf(status_str, "%s", "None"); ++ break; ++ } ++ ++out: ++ return; ++} ++ + int + glusterd_volume_get_transport_type_str(glusterd_volinfo_t *volinfo, + char *transport_type_str) +diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h +index 6ad8062..5c6a453 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-utils.h ++++ b/xlators/mgmt/glusterd/src/glusterd-utils.h +@@ -781,6 +781,10 @@ glusterd_volume_get_type_str(glusterd_volinfo_t *volinfo, char **vol_type_str); + int + glusterd_volume_get_status_str(glusterd_volinfo_t *volinfo, char *status_str); + ++void ++glusterd_brick_get_status_str(glusterd_brickinfo_t *brickinfo, ++ char *status_str); ++ + int + glusterd_volume_get_transport_type_str(glusterd_volinfo_t *volinfo, + char *transport_type_str); +-- +1.8.3.1 + diff --git a/0230-Revert-glusterd-svc-update-pid-of-mux-volumes-from-t.patch b/0230-Revert-glusterd-svc-update-pid-of-mux-volumes-from-t.patch new file mode 100644 index 0000000..a9847ed --- /dev/null +++ b/0230-Revert-glusterd-svc-update-pid-of-mux-volumes-from-t.patch @@ -0,0 +1,893 @@ +From 308fe0d81dbef9f84bb1ad8e7309e3ffc28d6394 Mon Sep 17 00:00:00 2001 +From: Mohammed Rafi KC +Date: Thu, 11 Jul 2019 12:37:29 +0530 +Subject: [PATCH 230/255] Revert "glusterd/svc: update pid of mux volumes from + the shd process" + +This reverts commit b0815b8a84a07d17a1215c55afc38888ee9fc37c. +Label : DOWNSTREAM ONLY + +BUG: 1471742 +Change-Id: Iab11c686565e9a9c852f2b7c2d236fa1a348f96a +Signed-off-by: Mohammed Rafi KC +Reviewed-on: https://code.engineering.redhat.com/gerrit/175940 +Tested-by: RHGS Build Bot +Reviewed-by: Sunil Kumar Heggodu Gopala Acharya +--- + glusterfsd/src/gf_attach.c | 2 - + glusterfsd/src/glusterfsd-mgmt.c | 66 ++------- + libglusterfs/src/glusterfs/glusterfs.h | 2 +- + libglusterfs/src/glusterfs/libglusterfs-messages.h | 3 +- + libglusterfs/src/graph.c | 154 +-------------------- + rpc/xdr/src/glusterd1-xdr.x | 1 - + xlators/mgmt/glusterd/src/glusterd-handler.c | 2 - + xlators/mgmt/glusterd/src/glusterd-handshake.c | 42 +----- + xlators/mgmt/glusterd/src/glusterd-op-sm.c | 4 - + .../mgmt/glusterd/src/glusterd-shd-svc-helper.c | 25 ---- + .../mgmt/glusterd/src/glusterd-shd-svc-helper.h | 3 - + xlators/mgmt/glusterd/src/glusterd-shd-svc.c | 8 +- + xlators/mgmt/glusterd/src/glusterd-svc-helper.c | 57 ++++---- + xlators/mgmt/glusterd/src/glusterd-syncop.c | 2 - + xlators/mgmt/glusterd/src/glusterd-utils.c | 6 +- + 15 files changed, 52 insertions(+), 325 deletions(-) + +diff --git a/glusterfsd/src/gf_attach.c b/glusterfsd/src/gf_attach.c +index 1bff854..6293b9b 100644 +--- a/glusterfsd/src/gf_attach.c ++++ b/glusterfsd/src/gf_attach.c +@@ -65,8 +65,6 @@ send_brick_req(xlator_t *this, struct rpc_clnt *rpc, char *path, int op) + brick_req.name = path; + brick_req.input.input_val = NULL; + brick_req.input.input_len = 0; +- brick_req.dict.dict_val = NULL; +- brick_req.dict.dict_len = 0; + + req_size = xdr_sizeof((xdrproc_t)xdr_gd1_mgmt_brick_op_req, req); + iobuf = iobuf_get2(rpc->ctx->iobuf_pool, req_size); +diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c +index f930e0a..1d2cd1a 100644 +--- a/glusterfsd/src/glusterfsd-mgmt.c ++++ b/glusterfsd/src/glusterfsd-mgmt.c +@@ -50,16 +50,13 @@ int + emancipate(glusterfs_ctx_t *ctx, int ret); + int + glusterfs_process_svc_attach_volfp(glusterfs_ctx_t *ctx, FILE *fp, +- char *volfile_id, char *checksum, +- dict_t *dict); ++ char *volfile_id, char *checksum); + int + glusterfs_mux_volfile_reconfigure(FILE *newvolfile_fp, glusterfs_ctx_t *ctx, +- gf_volfile_t *volfile_obj, char *checksum, +- dict_t *dict); ++ gf_volfile_t *volfile_obj, char *checksum); + int + glusterfs_process_svc_attach_volfp(glusterfs_ctx_t *ctx, FILE *fp, +- char *volfile_id, char *checksum, +- dict_t *dict); ++ char *volfile_id, char *checksum); + int + glusterfs_process_svc_detach(glusterfs_ctx_t *ctx, gf_volfile_t *volfile_obj); + +@@ -78,8 +75,7 @@ mgmt_cbk_spec(struct rpc_clnt *rpc, void *mydata, void *data) + } + + int +-mgmt_process_volfile(const char *volfile, ssize_t size, char *volfile_id, +- dict_t *dict) ++mgmt_process_volfile(const char *volfile, ssize_t size, char *volfile_id) + { + glusterfs_ctx_t *ctx = NULL; + int ret = 0; +@@ -149,11 +145,11 @@ mgmt_process_volfile(const char *volfile, ssize_t size, char *volfile_id, + * the volfile + */ + ret = glusterfs_process_svc_attach_volfp(ctx, tmpfp, volfile_id, +- sha256_hash, dict); ++ sha256_hash); + goto unlock; + } + ret = glusterfs_mux_volfile_reconfigure(tmpfp, ctx, volfile_obj, +- sha256_hash, dict); ++ sha256_hash); + if (ret < 0) { + gf_msg_debug("glusterfsd-mgmt", EINVAL, "Reconfigure failed !!"); + } +@@ -391,8 +387,6 @@ err: + UNLOCK(&ctx->volfile_lock); + if (xlator_req.input.input_val) + free(xlator_req.input.input_val); +- if (xlator_req.dict.dict_val) +- free(xlator_req.dict.dict_val); + free(xlator_req.name); + xlator_req.name = NULL; + return 0; +@@ -567,8 +561,6 @@ out: + + free(xlator_req.name); + free(xlator_req.input.input_val); +- if (xlator_req.dict.dict_val) +- free(xlator_req.dict.dict_val); + if (output) + dict_unref(output); + if (dict) +@@ -990,8 +982,6 @@ out: + if (input) + dict_unref(input); + free(xlator_req.input.input_val); /*malloced by xdr*/ +- if (xlator_req.dict.dict_val) +- free(xlator_req.dict.dict_val); + if (output) + dict_unref(output); + free(xlator_req.name); +@@ -1072,8 +1062,6 @@ glusterfs_handle_attach(rpcsvc_request_t *req) + out: + UNLOCK(&ctx->volfile_lock); + } +- if (xlator_req.dict.dict_val) +- free(xlator_req.dict.dict_val); + free(xlator_req.input.input_val); + free(xlator_req.name); + +@@ -1089,7 +1077,6 @@ glusterfs_handle_svc_attach(rpcsvc_request_t *req) + }; + xlator_t *this = NULL; + glusterfs_ctx_t *ctx = NULL; +- dict_t *dict = NULL; + + GF_ASSERT(req); + this = THIS; +@@ -1104,41 +1091,20 @@ glusterfs_handle_svc_attach(rpcsvc_request_t *req) + req->rpc_err = GARBAGE_ARGS; + goto out; + } +- + gf_msg(THIS->name, GF_LOG_INFO, 0, glusterfsd_msg_41, + "received attach " + "request for volfile-id=%s", + xlator_req.name); +- +- dict = dict_new(); +- if (!dict) { +- ret = -1; +- errno = ENOMEM; +- goto out; +- } +- +- ret = dict_unserialize(xlator_req.dict.dict_val, xlator_req.dict.dict_len, +- &dict); +- if (ret) { +- gf_msg(this->name, GF_LOG_WARNING, EINVAL, glusterfsd_msg_42, +- "failed to unserialize xdata to dictionary"); +- goto out; +- } +- dict->extra_stdfree = xlator_req.dict.dict_val; +- + ret = 0; + + if (ctx->active) { + ret = mgmt_process_volfile(xlator_req.input.input_val, +- xlator_req.input.input_len, xlator_req.name, +- dict); ++ xlator_req.input.input_len, xlator_req.name); + } else { + gf_msg(this->name, GF_LOG_WARNING, EINVAL, glusterfsd_msg_42, + "got attach for %s but no active graph", xlator_req.name); + } + out: +- if (dict) +- dict_unref(dict); + if (xlator_req.input.input_val) + free(xlator_req.input.input_val); + if (xlator_req.name) +@@ -1275,8 +1241,6 @@ out: + GF_FREE(filepath); + if (xlator_req.input.input_val) + free(xlator_req.input.input_val); +- if (xlator_req.dict.dict_val) +- free(xlator_req.dict.dict_val); + + return ret; + } +@@ -1349,8 +1313,6 @@ out: + if (dict) + dict_unref(dict); + free(xlator_req.input.input_val); // malloced by xdr +- if (xlator_req.dict.dict_val) +- free(xlator_req.dict.dict_val); + if (output) + dict_unref(output); + free(xlator_req.name); // malloced by xdr +@@ -1499,8 +1461,6 @@ out: + if (output) + dict_unref(output); + free(brick_req.input.input_val); +- if (brick_req.dict.dict_val) +- free(brick_req.dict.dict_val); + free(brick_req.name); + GF_FREE(xname); + GF_FREE(msg); +@@ -1694,8 +1654,6 @@ out: + if (dict) + dict_unref(dict); + free(node_req.input.input_val); +- if (node_req.dict.dict_val) +- free(node_req.dict.dict_val); + GF_FREE(msg); + GF_FREE(rsp.output.output_val); + GF_FREE(node_name); +@@ -1799,8 +1757,6 @@ glusterfs_handle_nfs_profile(rpcsvc_request_t *req) + + out: + free(nfs_req.input.input_val); +- if (nfs_req.dict.dict_val) +- free(nfs_req.dict.dict_val); + if (dict) + dict_unref(dict); + if (output) +@@ -1879,8 +1835,6 @@ out: + if (dict) + dict_unref(dict); + free(xlator_req.input.input_val); // malloced by xdr +- if (xlator_req.dict.dict_val) +- free(xlator_req.dict.dict_val); + if (output) + dict_unref(output); + free(xlator_req.name); // malloced by xdr +@@ -2009,8 +1963,7 @@ out: + if (dict) + dict_unref(dict); + free(brick_req.input.input_val); +- if (brick_req.dict.dict_val) +- free(brick_req.dict.dict_val); ++ + gf_log(THIS->name, GF_LOG_DEBUG, "Returning %d", ret); + return ret; + } +@@ -2260,8 +2213,7 @@ volfile: + size = rsp.op_ret; + volfile_id = frame->local; + if (mgmt_is_multiplexed_daemon(ctx->cmd_args.process_name)) { +- ret = mgmt_process_volfile((const char *)rsp.spec, size, volfile_id, +- dict); ++ ret = mgmt_process_volfile((const char *)rsp.spec, size, volfile_id); + goto post_graph_mgmt; + } + +diff --git a/libglusterfs/src/glusterfs/glusterfs.h b/libglusterfs/src/glusterfs/glusterfs.h +index b6327b8..9ec2365 100644 +--- a/libglusterfs/src/glusterfs/glusterfs.h ++++ b/libglusterfs/src/glusterfs/glusterfs.h +@@ -744,7 +744,7 @@ typedef struct { + char vol_id[NAME_MAX + 1]; + struct list_head volfile_list; + glusterfs_graph_t *graph; +- FILE *pidfp; ++ + } gf_volfile_t; + + glusterfs_ctx_t * +diff --git a/libglusterfs/src/glusterfs/libglusterfs-messages.h b/libglusterfs/src/glusterfs/libglusterfs-messages.h +index 7e0eebb..ea2aa60 100644 +--- a/libglusterfs/src/glusterfs/libglusterfs-messages.h ++++ b/libglusterfs/src/glusterfs/libglusterfs-messages.h +@@ -111,7 +111,6 @@ GLFS_MSGID( + LG_MSG_PTHREAD_NAMING_FAILED, LG_MSG_SYSCALL_RETURNS_WRONG, + LG_MSG_XXH64_TO_GFID_FAILED, LG_MSG_ASYNC_WARNING, LG_MSG_ASYNC_FAILURE, + LG_MSG_GRAPH_CLEANUP_FAILED, LG_MSG_GRAPH_SETUP_FAILED, +- LG_MSG_GRAPH_DETACH_STARTED, LG_MSG_GRAPH_ATTACH_FAILED, +- LG_MSG_GRAPH_ATTACH_PID_FILE_UPDATED); ++ LG_MSG_GRAPH_DETACH_STARTED, LG_MSG_GRAPH_ATTACH_FAILED); + + #endif /* !_LG_MESSAGES_H_ */ +diff --git a/libglusterfs/src/graph.c b/libglusterfs/src/graph.c +index 05f76bf..172dc61 100644 +--- a/libglusterfs/src/graph.c ++++ b/libglusterfs/src/graph.c +@@ -1467,21 +1467,6 @@ out: + } + + int +-glusterfs_svc_mux_pidfile_cleanup(gf_volfile_t *volfile_obj) +-{ +- if (!volfile_obj || !volfile_obj->pidfp) +- return 0; +- +- gf_msg_trace("glusterfsd", 0, "pidfile %s cleanup", volfile_obj->vol_id); +- +- lockf(fileno(volfile_obj->pidfp), F_ULOCK, 0); +- fclose(volfile_obj->pidfp); +- volfile_obj->pidfp = NULL; +- +- return 0; +-} +- +-int + glusterfs_process_svc_detach(glusterfs_ctx_t *ctx, gf_volfile_t *volfile_obj) + { + xlator_t *last_xl = NULL; +@@ -1517,7 +1502,6 @@ glusterfs_process_svc_detach(glusterfs_ctx_t *ctx, gf_volfile_t *volfile_obj) + + list_del_init(&volfile_obj->volfile_list); + glusterfs_mux_xlator_unlink(parent_graph->top, xl); +- glusterfs_svc_mux_pidfile_cleanup(volfile_obj); + parent_graph->last_xl = glusterfs_get_last_xlator(parent_graph); + parent_graph->xl_count -= graph->xl_count; + parent_graph->leaf_count -= graph->leaf_count; +@@ -1547,126 +1531,8 @@ out: + } + + int +-glusterfs_svc_mux_pidfile_setup(gf_volfile_t *volfile_obj, const char *pid_file) +-{ +- int ret = -1; +- FILE *pidfp = NULL; +- +- if (!pid_file || !volfile_obj) +- goto out; +- +- if (volfile_obj->pidfp) { +- ret = 0; +- goto out; +- } +- pidfp = fopen(pid_file, "a+"); +- if (!pidfp) { +- goto out; +- } +- volfile_obj->pidfp = pidfp; +- +- ret = lockf(fileno(pidfp), F_TLOCK, 0); +- if (ret) { +- ret = 0; +- goto out; +- } +-out: +- return ret; +-} +- +-int +-glusterfs_svc_mux_pidfile_update(gf_volfile_t *volfile_obj, +- const char *pid_file, pid_t pid) +-{ +- int ret = 0; +- FILE *pidfp = NULL; +- int old_pid; +- +- if (!volfile_obj->pidfp) { +- ret = glusterfs_svc_mux_pidfile_setup(volfile_obj, pid_file); +- if (ret == -1) +- goto out; +- } +- pidfp = volfile_obj->pidfp; +- ret = fscanf(pidfp, "%d", &old_pid); +- if (ret <= 0) { +- goto update; +- } +- if (old_pid == pid) { +- ret = 0; +- goto out; +- } else { +- gf_msg("mgmt", GF_LOG_INFO, 0, LG_MSG_GRAPH_ATTACH_PID_FILE_UPDATED, +- "Old pid=%d found in pidfile %s. Cleaning the old pid and " +- "Updating new pid=%d", +- old_pid, pid_file, pid); +- } +-update: +- ret = sys_ftruncate(fileno(pidfp), 0); +- if (ret) { +- gf_msg("glusterfsd", GF_LOG_ERROR, errno, +- LG_MSG_GRAPH_ATTACH_PID_FILE_UPDATED, +- "pidfile %s truncation failed", pid_file); +- goto out; +- } +- +- ret = fprintf(pidfp, "%d\n", pid); +- if (ret <= 0) { +- gf_msg("glusterfsd", GF_LOG_ERROR, errno, +- LG_MSG_GRAPH_ATTACH_PID_FILE_UPDATED, "pidfile %s write failed", +- pid_file); +- goto out; +- } +- +- ret = fflush(pidfp); +- if (ret) { +- gf_msg("glusterfsd", GF_LOG_ERROR, errno, +- LG_MSG_GRAPH_ATTACH_PID_FILE_UPDATED, "pidfile %s write failed", +- pid_file); +- goto out; +- } +-out: +- return ret; +-} +- +-int +-glusterfs_update_mux_pid(dict_t *dict, gf_volfile_t *volfile_obj) +-{ +- char *file = NULL; +- int ret = -1; +- +- GF_VALIDATE_OR_GOTO("graph", dict, out); +- GF_VALIDATE_OR_GOTO("graph", volfile_obj, out); +- +- ret = dict_get_str(dict, "pidfile", &file); +- if (ret < 0) { +- gf_msg("mgmt", GF_LOG_ERROR, EINVAL, LG_MSG_GRAPH_SETUP_FAILED, +- "Failed to get pidfile from dict for volfile_id=%s", +- volfile_obj->vol_id); +- } +- +- ret = glusterfs_svc_mux_pidfile_update(volfile_obj, file, getpid()); +- if (ret < 0) { +- ret = -1; +- gf_msg("mgmt", GF_LOG_ERROR, EINVAL, LG_MSG_GRAPH_SETUP_FAILED, +- "Failed to update " +- "the pidfile for volfile_id=%s", +- volfile_obj->vol_id); +- +- goto out; +- } +- +- if (ret == 1) +- gf_msg("mgmt", GF_LOG_INFO, 0, LG_MSG_GRAPH_ATTACH_PID_FILE_UPDATED, +- "PID %d updated in pidfile=%s", getpid(), file); +- ret = 0; +-out: +- return ret; +-} +-int + glusterfs_process_svc_attach_volfp(glusterfs_ctx_t *ctx, FILE *fp, +- char *volfile_id, char *checksum, +- dict_t *dict) ++ char *volfile_id, char *checksum) + { + glusterfs_graph_t *graph = NULL; + glusterfs_graph_t *parent_graph = NULL; +@@ -1749,25 +1615,18 @@ glusterfs_process_svc_attach_volfp(glusterfs_ctx_t *ctx, FILE *fp, + ret = -1; + goto out; + } +- volfile_obj->pidfp = NULL; +- snprintf(volfile_obj->vol_id, sizeof(volfile_obj->vol_id), "%s", +- volfile_id); +- +- if (strcmp(ctx->cmd_args.process_name, "glustershd") == 0) { +- ret = glusterfs_update_mux_pid(dict, volfile_obj); +- if (ret == -1) { +- goto out; +- } +- } + + graph->used = 1; + parent_graph->id++; + list_add(&graph->list, &ctx->graphs); + INIT_LIST_HEAD(&volfile_obj->volfile_list); + volfile_obj->graph = graph; ++ snprintf(volfile_obj->vol_id, sizeof(volfile_obj->vol_id), "%s", ++ volfile_id); + memcpy(volfile_obj->volfile_checksum, checksum, + sizeof(volfile_obj->volfile_checksum)); + list_add_tail(&volfile_obj->volfile_list, &ctx->volfile_list); ++ + gf_log_dump_graph(fp, graph); + graph = NULL; + +@@ -1795,8 +1654,7 @@ out: + + int + glusterfs_mux_volfile_reconfigure(FILE *newvolfile_fp, glusterfs_ctx_t *ctx, +- gf_volfile_t *volfile_obj, char *checksum, +- dict_t *dict) ++ gf_volfile_t *volfile_obj, char *checksum) + { + glusterfs_graph_t *oldvolfile_graph = NULL; + glusterfs_graph_t *newvolfile_graph = NULL; +@@ -1845,7 +1703,7 @@ glusterfs_mux_volfile_reconfigure(FILE *newvolfile_fp, glusterfs_ctx_t *ctx, + } + volfile_obj = NULL; + ret = glusterfs_process_svc_attach_volfp(ctx, newvolfile_fp, vol_id, +- checksum, dict); ++ checksum); + goto out; + } + +diff --git a/rpc/xdr/src/glusterd1-xdr.x b/rpc/xdr/src/glusterd1-xdr.x +index 02ebec2..9b36d34 100644 +--- a/rpc/xdr/src/glusterd1-xdr.x ++++ b/rpc/xdr/src/glusterd1-xdr.x +@@ -132,7 +132,6 @@ struct gd1_mgmt_brick_op_req { + string name<>; + int op; + opaque input<>; +- opaque dict<>; + } ; + + struct gd1_mgmt_brick_op_rsp { +diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c +index 94e1be5..ac788a0 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-handler.c ++++ b/xlators/mgmt/glusterd/src/glusterd-handler.c +@@ -5423,8 +5423,6 @@ glusterd_print_client_details(FILE *fp, dict_t *dict, + + brick_req->op = GLUSTERD_BRICK_STATUS; + brick_req->name = ""; +- brick_req->dict.dict_val = NULL; +- brick_req->dict.dict_len = 0; + + ret = dict_set_strn(dict, "brick-name", SLEN("brick-name"), + brickinfo->path); +diff --git a/xlators/mgmt/glusterd/src/glusterd-handshake.c b/xlators/mgmt/glusterd/src/glusterd-handshake.c +index 86dec82..1ba58c3 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-handshake.c ++++ b/xlators/mgmt/glusterd/src/glusterd-handshake.c +@@ -203,7 +203,7 @@ out: + + size_t + build_volfile_path(char *volume_id, char *path, size_t path_len, +- char *trusted_str, dict_t *dict) ++ char *trusted_str) + { + struct stat stbuf = { + 0, +@@ -340,19 +340,11 @@ build_volfile_path(char *volume_id, char *path, size_t path_len, + + ret = glusterd_volinfo_find(volid_ptr, &volinfo); + if (ret == -1) { +- gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_VOLINFO_GET_FAIL, +- "Couldn't find volinfo for volid=%s", volid_ptr); ++ gf_log(this->name, GF_LOG_ERROR, "Couldn't find volinfo"); + goto out; + } + + glusterd_svc_build_shd_volfile_path(volinfo, path, path_len); +- +- ret = glusterd_svc_set_shd_pidfile(volinfo, dict); +- if (ret == -1) { +- gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED, +- "Couldn't set pidfile in dict for volid=%s", volid_ptr); +- goto out; +- } + ret = 0; + goto out; + } +@@ -927,7 +919,6 @@ __server_getspec(rpcsvc_request_t *req) + char addrstr[RPCSVC_PEER_STRLEN] = {0}; + peer_info_t *peerinfo = NULL; + xlator_t *this = NULL; +- dict_t *dict = NULL; + + this = THIS; + GF_ASSERT(this); +@@ -980,12 +971,6 @@ __server_getspec(rpcsvc_request_t *req) + goto fail; + } + +- dict = dict_new(); +- if (!dict) { +- ret = -ENOMEM; +- goto fail; +- } +- + trans = req->trans; + /* addrstr will be empty for cli socket connections */ + ret = rpcsvc_transport_peername(trans, (char *)&addrstr, sizeof(addrstr)); +@@ -1004,26 +989,12 @@ __server_getspec(rpcsvc_request_t *req) + */ + if (strlen(addrstr) == 0 || gf_is_local_addr(addrstr)) { + ret = build_volfile_path(volume, filename, sizeof(filename), +- TRUSTED_PREFIX, dict); ++ TRUSTED_PREFIX); + } else { +- ret = build_volfile_path(volume, filename, sizeof(filename), NULL, +- dict); ++ ret = build_volfile_path(volume, filename, sizeof(filename), NULL); + } + + if (ret == 0) { +- if (dict->count > 0) { +- ret = dict_allocate_and_serialize(dict, &rsp.xdata.xdata_val, +- &rsp.xdata.xdata_len); +- if (ret) { +- gf_msg(this->name, GF_LOG_ERROR, 0, +- GD_MSG_DICT_SERL_LENGTH_GET_FAIL, +- "Failed to serialize dict " +- "to request buffer"); +- goto fail; +- } +- dict->extra_free = rsp.xdata.xdata_val; +- } +- + /* to allocate the proper buffer to hold the file data */ + ret = sys_stat(filename, &stbuf); + if (ret < 0) { +@@ -1065,6 +1036,7 @@ __server_getspec(rpcsvc_request_t *req) + goto fail; + } + } ++ + /* convert to XDR */ + fail: + if (spec_fd >= 0) +@@ -1084,10 +1056,6 @@ fail: + (xdrproc_t)xdr_gf_getspec_rsp); + free(args.key); // malloced by xdr + free(rsp.spec); +- +- if (dict) +- dict_unref(dict); +- + if (args.xdata.xdata_val) + free(args.xdata.xdata_val); + +diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c +index 454877b..9ea695e 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c ++++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c +@@ -655,8 +655,6 @@ glusterd_brick_op_build_payload(glusterd_op_t op, + break; + } + +- brick_req->dict.dict_len = 0; +- brick_req->dict.dict_val = NULL; + ret = dict_allocate_and_serialize(dict, &brick_req->input.input_val, + &brick_req->input.input_len); + if (ret) +@@ -725,8 +723,6 @@ glusterd_node_op_build_payload(glusterd_op_t op, gd1_mgmt_brick_op_req **req, + goto out; + } + +- brick_req->dict.dict_len = 0; +- brick_req->dict.dict_val = NULL; + ret = dict_allocate_and_serialize(dict, &brick_req->input.input_val, + &brick_req->input.input_len); + +diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.c b/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.c +index 5661e39..57ceda9 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.c ++++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.c +@@ -126,28 +126,3 @@ glusterd_shd_svcproc_cleanup(glusterd_shdsvc_t *shd) + out: + return; + } +- +-int +-glusterd_svc_set_shd_pidfile(glusterd_volinfo_t *volinfo, dict_t *dict) +-{ +- int ret = -1; +- glusterd_svc_t *svc = NULL; +- xlator_t *this = NULL; +- +- this = THIS; +- GF_VALIDATE_OR_GOTO("glusterd", this, out); +- GF_VALIDATE_OR_GOTO(this->name, volinfo, out); +- GF_VALIDATE_OR_GOTO(this->name, dict, out); +- +- svc = &(volinfo->shd.svc); +- +- ret = dict_set_dynstr_with_alloc(dict, "pidfile", svc->proc.pidfile); +- if (ret) { +- gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED, +- "Failed to set pidfile %s in dict", svc->proc.pidfile); +- goto out; +- } +- ret = 0; +-out: +- return ret; +-} +diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.h b/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.h +index 1f0984b..59466ec 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.h ++++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.h +@@ -36,7 +36,4 @@ glusterd_recover_shd_attach_failure(glusterd_volinfo_t *volinfo, + int + glusterd_shdsvc_create_volfile(glusterd_volinfo_t *volinfo); + +-int +-glusterd_svc_set_shd_pidfile(glusterd_volinfo_t *volinfo, dict_t *dict); +- + #endif +diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c +index 590169f..8ad90a9 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c ++++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c +@@ -258,20 +258,14 @@ glusterd_shdsvc_manager(glusterd_svc_t *svc, void *data, int flags) + gf_boolean_t shd_restart = _gf_false; + + conf = THIS->private; ++ volinfo = data; + GF_VALIDATE_OR_GOTO("glusterd", conf, out); + GF_VALIDATE_OR_GOTO("glusterd", svc, out); +- volinfo = data; + GF_VALIDATE_OR_GOTO("glusterd", volinfo, out); + + if (volinfo) + glusterd_volinfo_ref(volinfo); + +- if (volinfo->is_snap_volume) { +- /* healing of a snap volume is not supported yet*/ +- ret = 0; +- goto out; +- } +- + while (conf->restart_shd) { + synclock_unlock(&conf->big_lock); + sleep(2); +diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c +index e106111..400826f 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c ++++ b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c +@@ -519,7 +519,7 @@ glusterd_shd_svc_mux_init(glusterd_volinfo_t *volinfo, glusterd_svc_t *svc) + /* Take first entry from the process */ + parent_svc = cds_list_entry(mux_proc->svcs.next, glusterd_svc_t, + mux_svc); +- glusterd_copy_file(parent_svc->proc.pidfile, svc->proc.pidfile); ++ sys_link(parent_svc->proc.pidfile, svc->proc.pidfile); + mux_conn = &parent_svc->conn; + if (volinfo) + volinfo->shd.attached = _gf_true; +@@ -623,9 +623,12 @@ glusterd_svc_attach_cbk(struct rpc_req *req, struct iovec *iov, int count, + glusterd_volinfo_t *volinfo = NULL; + glusterd_shdsvc_t *shd = NULL; + glusterd_svc_t *svc = frame->cookie; ++ glusterd_svc_t *parent_svc = NULL; ++ glusterd_svc_proc_t *mux_proc = NULL; + glusterd_conf_t *conf = NULL; + int *flag = (int *)frame->local; + xlator_t *this = THIS; ++ int pid = -1; + int ret = -1; + gf_getspec_rsp rsp = { + 0, +@@ -676,7 +679,27 @@ glusterd_svc_attach_cbk(struct rpc_req *req, struct iovec *iov, int count, + } + + if (rsp.op_ret == 0) { +- svc->online = _gf_true; ++ pthread_mutex_lock(&conf->attach_lock); ++ { ++ if (!strcmp(svc->name, "glustershd")) { ++ mux_proc = svc->svc_proc; ++ if (mux_proc && ++ !gf_is_service_running(svc->proc.pidfile, &pid)) { ++ /* ++ * When svc's are restarting, there is a chance that the ++ * attached svc might not have updated it's pid. Because ++ * it was at connection stage. So in that case, we need ++ * to retry the pid file copy. ++ */ ++ parent_svc = cds_list_entry(mux_proc->svcs.next, ++ glusterd_svc_t, mux_svc); ++ if (parent_svc) ++ sys_link(parent_svc->proc.pidfile, svc->proc.pidfile); ++ } ++ } ++ svc->online = _gf_true; ++ } ++ pthread_mutex_unlock(&conf->attach_lock); + gf_msg(this->name, GF_LOG_INFO, 0, GD_MSG_SVC_ATTACH_FAIL, + "svc %s of volume %s attached successfully to pid %d", svc->name, + volinfo->volname, glusterd_proc_get_pid(&svc->proc)); +@@ -703,7 +726,7 @@ out: + + extern size_t + build_volfile_path(char *volume_id, char *path, size_t path_len, +- char *trusted_str, dict_t *dict); ++ char *trusted_str); + + int + __glusterd_send_svc_configure_req(glusterd_svc_t *svc, int flags, +@@ -728,7 +751,6 @@ __glusterd_send_svc_configure_req(glusterd_svc_t *svc, int flags, + ssize_t req_size = 0; + call_frame_t *frame = NULL; + gd1_mgmt_brick_op_req brick_req; +- dict_t *dict = NULL; + void *req = &brick_req; + void *errlbl = &&err; + struct rpc_clnt_connection *conn; +@@ -754,8 +776,6 @@ __glusterd_send_svc_configure_req(glusterd_svc_t *svc, int flags, + brick_req.name = volfile_id; + brick_req.input.input_val = NULL; + brick_req.input.input_len = 0; +- brick_req.dict.dict_val = NULL; +- brick_req.dict.dict_len = 0; + + frame = create_frame(this, this->ctx->pool); + if (!frame) { +@@ -763,13 +783,7 @@ __glusterd_send_svc_configure_req(glusterd_svc_t *svc, int flags, + } + + if (op == GLUSTERD_SVC_ATTACH) { +- dict = dict_new(); +- if (!dict) { +- ret = -ENOMEM; +- goto *errlbl; +- } +- +- (void)build_volfile_path(volfile_id, path, sizeof(path), NULL, dict); ++ (void)build_volfile_path(volfile_id, path, sizeof(path), NULL); + + ret = sys_stat(path, &stbuf); + if (ret < 0) { +@@ -804,18 +818,6 @@ __glusterd_send_svc_configure_req(glusterd_svc_t *svc, int flags, + ret = -EIO; + goto *errlbl; + } +- if (dict->count > 0) { +- ret = dict_allocate_and_serialize(dict, &brick_req.dict.dict_val, +- &brick_req.dict.dict_len); +- if (ret) { +- gf_msg(this->name, GF_LOG_ERROR, 0, +- GD_MSG_DICT_SERL_LENGTH_GET_FAIL, +- "Failed to serialize dict " +- "to request buffer"); +- goto *errlbl; +- } +- dict->extra_free = brick_req.dict.dict_val; +- } + + frame->cookie = svc; + frame->local = GF_CALLOC(1, sizeof(int), gf_gld_mt_int); +@@ -860,8 +862,6 @@ __glusterd_send_svc_configure_req(glusterd_svc_t *svc, int flags, + GF_ATOMIC_INC(conf->blockers); + ret = rpc_clnt_submit(rpc, &gd_brick_prog, op, cbkfn, &iov, 1, NULL, 0, + iobref, frame, NULL, 0, NULL, 0, NULL); +- if (dict) +- dict_unref(dict); + GF_FREE(volfile_content); + if (spec_fd >= 0) + sys_close(spec_fd); +@@ -874,9 +874,6 @@ maybe_free_iobuf: + iobuf_unref(iobuf); + } + err: +- if (dict) +- dict_unref(dict); +- + GF_FREE(volfile_content); + if (spec_fd >= 0) + sys_close(spec_fd); +diff --git a/xlators/mgmt/glusterd/src/glusterd-syncop.c b/xlators/mgmt/glusterd/src/glusterd-syncop.c +index a8098df..618d8bc 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-syncop.c ++++ b/xlators/mgmt/glusterd/src/glusterd-syncop.c +@@ -143,8 +143,6 @@ gd_brick_op_req_free(gd1_mgmt_brick_op_req *req) + if (!req) + return; + +- if (req->dict.dict_val) +- GF_FREE(req->dict.dict_val); + GF_FREE(req->input.input_val); + GF_FREE(req); + } +diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c +index 3bdfd49..4525ec7 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-utils.c ++++ b/xlators/mgmt/glusterd/src/glusterd-utils.c +@@ -5914,8 +5914,6 @@ send_attach_req(xlator_t *this, struct rpc_clnt *rpc, char *path, + brick_req.name = path; + brick_req.input.input_val = NULL; + brick_req.input.input_len = 0; +- brick_req.dict.dict_val = NULL; +- brick_req.dict.dict_len = 0; + + req_size = xdr_sizeof((xdrproc_t)xdr_gd1_mgmt_brick_op_req, req); + iobuf = iobuf_get2(rpc->ctx->iobuf_pool, req_size); +@@ -5979,7 +5977,7 @@ err: + + extern size_t + build_volfile_path(char *volume_id, char *path, size_t path_len, +- char *trusted_str, dict_t *dict); ++ char *trusted_str); + + static int + attach_brick(xlator_t *this, glusterd_brickinfo_t *brickinfo, +@@ -6024,7 +6022,7 @@ attach_brick(xlator_t *this, glusterd_brickinfo_t *brickinfo, + goto out; + } + +- (void)build_volfile_path(full_id, path, sizeof(path), NULL, NULL); ++ (void)build_volfile_path(full_id, path, sizeof(path), NULL); + + for (tries = 15; tries > 0; --tries) { + rpc = rpc_clnt_ref(other_brick->rpc); +-- +1.8.3.1 + diff --git a/0231-Revert-graph-shd-Use-top-down-approach-while-cleanin.patch b/0231-Revert-graph-shd-Use-top-down-approach-while-cleanin.patch new file mode 100644 index 0000000..3b794c9 --- /dev/null +++ b/0231-Revert-graph-shd-Use-top-down-approach-while-cleanin.patch @@ -0,0 +1,180 @@ +From 21f376939f03f91214218c485e7d3a2848dae4b2 Mon Sep 17 00:00:00 2001 +From: Mohammed Rafi KC +Date: Thu, 11 Jul 2019 12:43:44 +0530 +Subject: [PATCH 231/255] Revert "graph/shd: Use top down approach while + cleaning xlator" + +This reverts commit b963fa8bb71963127147d33bf609f439dd5bd107. + +Label : DOWNSTREAM ONLY + +BUG: 1471742 +Change-Id: Ifb8056395c5988cf7c484891bea052f5415bf9da +Signed-off-by: Mohammed Rafi KC +Reviewed-on: https://code.engineering.redhat.com/gerrit/175941 +Tested-by: RHGS Build Bot +Reviewed-by: Sunil Kumar Heggodu Gopala Acharya +--- + libglusterfs/src/graph.c | 10 +--------- + xlators/features/bit-rot/src/stub/bit-rot-stub.c | 1 - + xlators/features/changelog/src/changelog.c | 1 - + xlators/features/cloudsync/src/cloudsync.c | 4 +--- + xlators/features/index/src/index.c | 1 - + xlators/features/quiesce/src/quiesce.c | 1 - + xlators/features/read-only/src/worm.c | 1 - + xlators/features/sdfs/src/sdfs.c | 1 - + xlators/features/selinux/src/selinux.c | 2 -- + xlators/features/trash/src/trash.c | 1 - + 10 files changed, 2 insertions(+), 21 deletions(-) + +diff --git a/libglusterfs/src/graph.c b/libglusterfs/src/graph.c +index 172dc61..5b95fd6 100644 +--- a/libglusterfs/src/graph.c ++++ b/libglusterfs/src/graph.c +@@ -1193,14 +1193,6 @@ glusterfs_graph_fini(glusterfs_graph_t *graph) + if (trav->init_succeeded) { + trav->cleanup_starting = 1; + trav->fini(trav); +- if (trav->local_pool) { +- mem_pool_destroy(trav->local_pool); +- trav->local_pool = NULL; +- } +- if (trav->itable) { +- inode_table_destroy(trav->itable); +- trav->itable = NULL; +- } + trav->init_succeeded = 0; + } + trav = trav->next; +@@ -1402,7 +1394,7 @@ glusterfs_graph_cleanup(void *arg) + + pthread_mutex_lock(&ctx->cleanup_lock); + { +- glusterfs_graph_fini(graph); ++ glusterfs_graph_deactivate(graph); + glusterfs_graph_destroy(graph); + } + pthread_mutex_unlock(&ctx->cleanup_lock); +diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub.c b/xlators/features/bit-rot/src/stub/bit-rot-stub.c +index 03446be..3f48a4b 100644 +--- a/xlators/features/bit-rot/src/stub/bit-rot-stub.c ++++ b/xlators/features/bit-rot/src/stub/bit-rot-stub.c +@@ -185,7 +185,6 @@ cleanup_lock: + pthread_mutex_destroy(&priv->lock); + free_mempool: + mem_pool_destroy(priv->local_pool); +- priv->local_pool = NULL; + free_priv: + GF_FREE(priv); + this->private = NULL; +diff --git a/xlators/features/changelog/src/changelog.c b/xlators/features/changelog/src/changelog.c +index 2862d1e..d9025f3 100644 +--- a/xlators/features/changelog/src/changelog.c ++++ b/xlators/features/changelog/src/changelog.c +@@ -2790,7 +2790,6 @@ cleanup_options: + changelog_freeup_options(this, priv); + cleanup_mempool: + mem_pool_destroy(this->local_pool); +- this->local_pool = NULL; + cleanup_priv: + GF_FREE(priv); + error_return: +diff --git a/xlators/features/cloudsync/src/cloudsync.c b/xlators/features/cloudsync/src/cloudsync.c +index 0ad987e..26e512c 100644 +--- a/xlators/features/cloudsync/src/cloudsync.c ++++ b/xlators/features/cloudsync/src/cloudsync.c +@@ -200,10 +200,8 @@ cs_init(xlator_t *this) + + out: + if (ret == -1) { +- if (this->local_pool) { ++ if (this->local_pool) + mem_pool_destroy(this->local_pool); +- this->local_pool = NULL; +- } + + cs_cleanup_private(priv); + +diff --git a/xlators/features/index/src/index.c b/xlators/features/index/src/index.c +index 4ece7ff..2f2a6d0 100644 +--- a/xlators/features/index/src/index.c ++++ b/xlators/features/index/src/index.c +@@ -2478,7 +2478,6 @@ out: + GF_FREE(priv); + this->private = NULL; + mem_pool_destroy(this->local_pool); +- this->local_pool = NULL; + } + + if (attr_inited) +diff --git a/xlators/features/quiesce/src/quiesce.c b/xlators/features/quiesce/src/quiesce.c +index 06f58c9..bfd1116 100644 +--- a/xlators/features/quiesce/src/quiesce.c ++++ b/xlators/features/quiesce/src/quiesce.c +@@ -2536,7 +2536,6 @@ fini(xlator_t *this) + this->private = NULL; + + mem_pool_destroy(priv->local_pool); +- priv->local_pool = NULL; + LOCK_DESTROY(&priv->lock); + GF_FREE(priv); + out: +diff --git a/xlators/features/read-only/src/worm.c b/xlators/features/read-only/src/worm.c +index 7d13180..24196f8 100644 +--- a/xlators/features/read-only/src/worm.c ++++ b/xlators/features/read-only/src/worm.c +@@ -569,7 +569,6 @@ fini(xlator_t *this) + mem_put(priv); + this->private = NULL; + mem_pool_destroy(this->local_pool); +- this->local_pool = NULL; + out: + return; + } +diff --git a/xlators/features/sdfs/src/sdfs.c b/xlators/features/sdfs/src/sdfs.c +index 164c632..f0247fd 100644 +--- a/xlators/features/sdfs/src/sdfs.c ++++ b/xlators/features/sdfs/src/sdfs.c +@@ -1429,7 +1429,6 @@ void + fini(xlator_t *this) + { + mem_pool_destroy(this->local_pool); +- this->local_pool = NULL; + return; + } + +diff --git a/xlators/features/selinux/src/selinux.c b/xlators/features/selinux/src/selinux.c +index ce5fc90..58b4c5d 100644 +--- a/xlators/features/selinux/src/selinux.c ++++ b/xlators/features/selinux/src/selinux.c +@@ -256,7 +256,6 @@ out: + GF_FREE(priv); + } + mem_pool_destroy(this->local_pool); +- this->local_pool = NULL; + } + return ret; + } +@@ -285,7 +284,6 @@ fini(xlator_t *this) + GF_FREE(priv); + + mem_pool_destroy(this->local_pool); +- this->local_pool = NULL; + + return; + } +diff --git a/xlators/features/trash/src/trash.c b/xlators/features/trash/src/trash.c +index eb5007b..d668436 100644 +--- a/xlators/features/trash/src/trash.c ++++ b/xlators/features/trash/src/trash.c +@@ -2523,7 +2523,6 @@ out: + GF_FREE(priv); + } + mem_pool_destroy(this->local_pool); +- this->local_pool = NULL; + } + return ret; + } +-- +1.8.3.1 + diff --git a/0232-cluster-afr-Fix-incorrect-reporting-of-gfid-type-mis.patch b/0232-cluster-afr-Fix-incorrect-reporting-of-gfid-type-mis.patch new file mode 100644 index 0000000..b2a8f4c --- /dev/null +++ b/0232-cluster-afr-Fix-incorrect-reporting-of-gfid-type-mis.patch @@ -0,0 +1,228 @@ +From 3ddf12d0710e048878fcf8786d05efe18710c74c Mon Sep 17 00:00:00 2001 +From: karthik-us +Date: Fri, 12 Jul 2019 16:44:20 +0530 +Subject: [PATCH 232/255] cluster/afr: Fix incorrect reporting of gfid & type + mismatch + +Backport of: https://review.gluster.org/#/c/glusterfs/+/22908/ + +Problems: +1. When checking for type and gfid mismatch, if the type or gfid +is unknown because of missing gfid handle and the gfid xattr +it will be reported as type or gfid mismatch and the heal will +not complete. + +2. If the source selected during entry heal has null gfid the same +will be sent to afr_lookup_and_heal_gfid(). In this function when +we try to assign the gfid on the bricks where it does not exist, +we are considering the same gfid and try to assign that on those +bricks. This will fail in posix_gfid_set() since the gfid sent +is null. + +Fix: +If the gfid sent to afr_lookup_and_heal_gfid() is null choose a +valid gfid before proceeding to assign the gfid on the bricks +where it is missing. + +In afr_selfheal_detect_gfid_and_type_mismatch(), do not report +type/gfid mismatch if the type/gfid is unknown or not set. + +Change-Id: Icdb4967c09a48e0a3a64ce4948d5fb0a06d7a7af +fixes: bz#1715447 +Signed-off-by: karthik-us +Reviewed-on: https://code.engineering.redhat.com/gerrit/175966 +Tested-by: RHGS Build Bot +Reviewed-by: Sunil Kumar Heggodu Gopala Acharya +--- + .../bug-1722507-type-mismatch-error-handling.t | 116 +++++++++++++++++++++ + xlators/cluster/afr/src/afr-self-heal-common.c | 12 ++- + xlators/cluster/afr/src/afr-self-heal-entry.c | 13 +++ + 3 files changed, 139 insertions(+), 2 deletions(-) + create mode 100644 tests/bugs/replicate/bug-1722507-type-mismatch-error-handling.t + +diff --git a/tests/bugs/replicate/bug-1722507-type-mismatch-error-handling.t b/tests/bugs/replicate/bug-1722507-type-mismatch-error-handling.t +new file mode 100644 +index 0000000..0aeaaaf +--- /dev/null ++++ b/tests/bugs/replicate/bug-1722507-type-mismatch-error-handling.t +@@ -0,0 +1,116 @@ ++#!/bin/bash ++ ++. $(dirname $0)/../../include.rc ++. $(dirname $0)/../../volume.rc ++. $(dirname $0)/../../afr.rc ++ ++cleanup; ++ ++## Start and create a volume ++TEST glusterd; ++TEST pidof glusterd; ++TEST $CLI volume info; ++ ++TEST $CLI volume create $V0 replica 3 $H0:$B0/${V0}{0,1,2}; ++TEST $CLI volume start $V0; ++TEST $CLI volume set $V0 cluster.heal-timeout 5 ++TEST $CLI volume heal $V0 disable ++EXPECT 'Started' volinfo_field $V0 'Status'; ++TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0 ++ ++TEST mkdir $M0/dir ++ ++########################################################################################## ++# GFID link file and the GFID is missing on one brick and all the bricks are being blamed. ++ ++TEST touch $M0/dir/file ++#TEST kill_brick $V0 $H0 $B0/$V0"1" ++ ++#B0 and B2 must blame B1 ++setfattr -n trusted.afr.$V0-client-0 -v 0x000000000000000000000001 $B0/$V0"2"/dir ++setfattr -n trusted.afr.$V0-client-1 -v 0x000000000000000000000001 $B0/$V0"0"/dir ++setfattr -n trusted.afr.$V0-client-2 -v 0x000000000000000000000001 $B0/$V0"0"/dir ++ ++# Add entry to xattrop dir to trigger index heal. ++xattrop_dir0=$(afr_get_index_path $B0/$V0"0") ++base_entry_b0=`ls $xattrop_dir0` ++gfid_str=$(gf_gfid_xattr_to_str $(gf_get_gfid_xattr $B0/$V0"0"/dir/)) ++ln -s $xattrop_dir0/$base_entry_b0 $xattrop_dir0/$gfid_str ++EXPECT "^1$" get_pending_heal_count $V0 ++ ++# Remove the gfid xattr and the link file on one brick. ++gfid_file=$(gf_get_gfid_xattr $B0/$V0"0"/dir/file) ++gfid_str_file=$(gf_gfid_xattr_to_str $gfid_file) ++TEST setfattr -x trusted.gfid $B0/${V0}0/dir/file ++TEST rm -f $B0/${V0}0/.glusterfs/${gfid_str_file:0:2}/${gfid_str_file:2:2}/$gfid_str_file ++ ++# Launch heal ++TEST $CLI volume heal $V0 enable ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^Y$" glustershd_up_status ++EXPECT_WITHIN $CHILD_UP_TIMEOUT "^1$" afr_child_up_status_in_shd $V0 0 ++EXPECT_WITHIN $CHILD_UP_TIMEOUT "^1$" afr_child_up_status_in_shd $V0 1 ++EXPECT_WITHIN $CHILD_UP_TIMEOUT "^1$" afr_child_up_status_in_shd $V0 2 ++ ++# Wait for 2 second to force posix to consider that this is a valid file but ++# without gfid. ++sleep 2 ++TEST $CLI volume heal $V0 ++ ++# Heal should not fail as the file is missing gfid xattr and the link file, ++# which is not actually the gfid or type mismatch. ++EXPECT_WITHIN $HEAL_TIMEOUT "^0$" get_pending_heal_count $V0 ++ ++EXPECT "$gfid_file" gf_get_gfid_xattr $B0/${V0}0/dir/file ++TEST stat $B0/${V0}0/.glusterfs/${gfid_str_file:0:2}/${gfid_str_file:2:2}/$gfid_str_file ++rm -f $M0/dir/file ++ ++ ++########################################################################################### ++# GFID link file and the GFID is missing on two bricks and all the bricks are being blamed. ++ ++TEST $CLI volume heal $V0 disable ++TEST touch $M0/dir/file ++#TEST kill_brick $V0 $H0 $B0/$V0"1" ++ ++#B0 and B2 must blame B1 ++setfattr -n trusted.afr.$V0-client-0 -v 0x000000000000000000000001 $B0/$V0"2"/dir ++setfattr -n trusted.afr.$V0-client-1 -v 0x000000000000000000000001 $B0/$V0"0"/dir ++setfattr -n trusted.afr.$V0-client-2 -v 0x000000000000000000000001 $B0/$V0"0"/dir ++ ++# Add entry to xattrop dir to trigger index heal. ++xattrop_dir0=$(afr_get_index_path $B0/$V0"0") ++base_entry_b0=`ls $xattrop_dir0` ++gfid_str=$(gf_gfid_xattr_to_str $(gf_get_gfid_xattr $B0/$V0"0"/dir/)) ++ln -s $xattrop_dir0/$base_entry_b0 $xattrop_dir0/$gfid_str ++EXPECT "^1$" get_pending_heal_count $V0 ++ ++# Remove the gfid xattr and the link file on two bricks. ++gfid_file=$(gf_get_gfid_xattr $B0/$V0"0"/dir/file) ++gfid_str_file=$(gf_gfid_xattr_to_str $gfid_file) ++TEST setfattr -x trusted.gfid $B0/${V0}0/dir/file ++TEST rm -f $B0/${V0}0/.glusterfs/${gfid_str_file:0:2}/${gfid_str_file:2:2}/$gfid_str_file ++TEST setfattr -x trusted.gfid $B0/${V0}1/dir/file ++TEST rm -f $B0/${V0}1/.glusterfs/${gfid_str_file:0:2}/${gfid_str_file:2:2}/$gfid_str_file ++ ++# Launch heal ++TEST $CLI volume heal $V0 enable ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^Y$" glustershd_up_status ++EXPECT_WITHIN $CHILD_UP_TIMEOUT "^1$" afr_child_up_status_in_shd $V0 0 ++EXPECT_WITHIN $CHILD_UP_TIMEOUT "^1$" afr_child_up_status_in_shd $V0 1 ++EXPECT_WITHIN $CHILD_UP_TIMEOUT "^1$" afr_child_up_status_in_shd $V0 2 ++ ++# Wait for 2 second to force posix to consider that this is a valid file but ++# without gfid. ++sleep 2 ++TEST $CLI volume heal $V0 ++ ++# Heal should not fail as the file is missing gfid xattr and the link file, ++# which is not actually the gfid or type mismatch. ++EXPECT_WITHIN $HEAL_TIMEOUT "^0$" get_pending_heal_count $V0 ++ ++EXPECT "$gfid_file" gf_get_gfid_xattr $B0/${V0}0/dir/file ++TEST stat $B0/${V0}0/.glusterfs/${gfid_str_file:0:2}/${gfid_str_file:2:2}/$gfid_str_file ++EXPECT "$gfid_file" gf_get_gfid_xattr $B0/${V0}1/dir/file ++TEST stat $B0/${V0}1/.glusterfs/${gfid_str_file:0:2}/${gfid_str_file:2:2}/$gfid_str_file ++ ++cleanup +diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c +index 5157e7d..b38085a 100644 +--- a/xlators/cluster/afr/src/afr-self-heal-common.c ++++ b/xlators/cluster/afr/src/afr-self-heal-common.c +@@ -55,7 +55,8 @@ afr_lookup_and_heal_gfid(xlator_t *this, inode_t *parent, const char *name, + for (i = 0; i < priv->child_count; i++) { + if (source == -1) { + /* case (a) above. */ +- if (replies[i].valid && replies[i].op_ret == 0) { ++ if (replies[i].valid && replies[i].op_ret == 0 && ++ replies[i].poststat.ia_type != IA_INVAL) { + ia_type = replies[i].poststat.ia_type; + break; + } +@@ -63,7 +64,8 @@ afr_lookup_and_heal_gfid(xlator_t *this, inode_t *parent, const char *name, + /* case (b) above. */ + if (i == source) + continue; +- if (sources[i] && replies[i].valid && replies[i].op_ret == 0) { ++ if (sources[i] && replies[i].valid && replies[i].op_ret == 0 && ++ replies[i].poststat.ia_type != IA_INVAL) { + ia_type = replies[i].poststat.ia_type; + break; + } +@@ -77,6 +79,12 @@ heal: + for (i = 0; i < priv->child_count; i++) { + if (!replies[i].valid || replies[i].op_ret != 0) + continue; ++ ++ if (gf_uuid_is_null(gfid) && ++ !gf_uuid_is_null(replies[i].poststat.ia_gfid) && ++ replies[i].poststat.ia_type == ia_type) ++ gfid = replies[i].poststat.ia_gfid; ++ + if (!gf_uuid_is_null(replies[i].poststat.ia_gfid) || + replies[i].poststat.ia_type != ia_type) + continue; +diff --git a/xlators/cluster/afr/src/afr-self-heal-entry.c b/xlators/cluster/afr/src/afr-self-heal-entry.c +index a6890fa..e07b521 100644 +--- a/xlators/cluster/afr/src/afr-self-heal-entry.c ++++ b/xlators/cluster/afr/src/afr-self-heal-entry.c +@@ -246,6 +246,19 @@ afr_selfheal_detect_gfid_and_type_mismatch(xlator_t *this, + if (replies[i].op_ret != 0) + continue; + ++ if (gf_uuid_is_null(replies[i].poststat.ia_gfid)) ++ continue; ++ ++ if (replies[i].poststat.ia_type == IA_INVAL) ++ continue; ++ ++ if (ia_type == IA_INVAL || gf_uuid_is_null(gfid)) { ++ src_idx = i; ++ ia_type = replies[src_idx].poststat.ia_type; ++ gfid = &replies[src_idx].poststat.ia_gfid; ++ continue; ++ } ++ + if (gf_uuid_compare(gfid, replies[i].poststat.ia_gfid) && + (ia_type == replies[i].poststat.ia_type)) { + ret = afr_gfid_split_brain_source(this, replies, inode, pargfid, +-- +1.8.3.1 + diff --git a/0233-Revert-graph-shd-Use-glusterfs_graph_deactivate-to-f.patch b/0233-Revert-graph-shd-Use-glusterfs_graph_deactivate-to-f.patch new file mode 100644 index 0000000..d8e6933 --- /dev/null +++ b/0233-Revert-graph-shd-Use-glusterfs_graph_deactivate-to-f.patch @@ -0,0 +1,78 @@ +From 5c85ce7363b658bc8fa643742626109efe3ade0c Mon Sep 17 00:00:00 2001 +From: Mohammed Rafi KC +Date: Thu, 11 Jul 2019 12:44:04 +0530 +Subject: [PATCH 233/255] Revert "graph/shd: Use glusterfs_graph_deactivate to + free the xl rec" + +This reverts commit 8cc6d8af00303c445b94715c92fe9e3e01edb867. + +BUG: 1471742 +Change-Id: Ib90fe89b85f4143db29702338decec76c83872bc +Signed-off-by: Mohammed Rafi KC +Reviewed-on: https://code.engineering.redhat.com/gerrit/175942 +Tested-by: RHGS Build Bot +Reviewed-by: Sunil Kumar Heggodu Gopala Acharya +--- + libglusterfs/src/graph.c | 2 +- + libglusterfs/src/xlator.c | 9 +-------- + xlators/features/shard/src/shard.c | 3 --- + 3 files changed, 2 insertions(+), 12 deletions(-) + +diff --git a/libglusterfs/src/graph.c b/libglusterfs/src/graph.c +index 5b95fd6..27d9335 100644 +--- a/libglusterfs/src/graph.c ++++ b/libglusterfs/src/graph.c +@@ -1394,7 +1394,7 @@ glusterfs_graph_cleanup(void *arg) + + pthread_mutex_lock(&ctx->cleanup_lock); + { +- glusterfs_graph_deactivate(graph); ++ glusterfs_graph_fini(graph); + glusterfs_graph_destroy(graph); + } + pthread_mutex_unlock(&ctx->cleanup_lock); +diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c +index d9d3441..71e1ed4 100644 +--- a/libglusterfs/src/xlator.c ++++ b/libglusterfs/src/xlator.c +@@ -659,7 +659,6 @@ xlator_fini_rec(xlator_t *xl) + trav = trav->next; + } + +- xl->cleanup_starting = 1; + if (xl->init_succeeded) { + if (xl->fini) { + old_THIS = THIS; +@@ -667,14 +666,8 @@ xlator_fini_rec(xlator_t *xl) + + xl->fini(xl); + +- if (xl->local_pool) { ++ if (xl->local_pool) + mem_pool_destroy(xl->local_pool); +- xl->local_pool = NULL; +- } +- if (xl->itable) { +- inode_table_destroy(xl->itable); +- xl->itable = NULL; +- } + + THIS = old_THIS; + } else { +diff --git a/xlators/features/shard/src/shard.c b/xlators/features/shard/src/shard.c +index 31c7eec..b248767 100644 +--- a/xlators/features/shard/src/shard.c ++++ b/xlators/features/shard/src/shard.c +@@ -6785,9 +6785,6 @@ fini(xlator_t *this) + + GF_VALIDATE_OR_GOTO("shard", this, out); + +- /*Itable was not created by shard, hence setting to NULL.*/ +- this->itable = NULL; +- + mem_pool_destroy(this->local_pool); + this->local_pool = NULL; + +-- +1.8.3.1 + diff --git a/0234-Revert-glusterd-shd-Change-shd-logfile-to-a-unique-n.patch b/0234-Revert-glusterd-shd-Change-shd-logfile-to-a-unique-n.patch new file mode 100644 index 0000000..790d9d1 --- /dev/null +++ b/0234-Revert-glusterd-shd-Change-shd-logfile-to-a-unique-n.patch @@ -0,0 +1,220 @@ +From feeee9a35c1219b2077ea07b6fd80976960bd181 Mon Sep 17 00:00:00 2001 +From: Mohammed Rafi KC +Date: Thu, 11 Jul 2019 12:44:42 +0530 +Subject: [PATCH 234/255] Revert "glusterd/shd: Change shd logfile to a unique + name" + +This reverts commit 541e1400ecaec5fea0f56e8ca18f00c229906d8a. + +BUG: 1471742 +Change-Id: I7e0371d77db6897981f7364c04d4b9b523b865ba +Signed-off-by: Mohammed Rafi KC +Reviewed-on: https://code.engineering.redhat.com/gerrit/175943 +Tested-by: RHGS Build Bot +Reviewed-by: Sunil Kumar Heggodu Gopala Acharya +--- + .../mgmt/glusterd/src/glusterd-shd-svc-helper.c | 12 ++++++++ + .../mgmt/glusterd/src/glusterd-shd-svc-helper.h | 6 ++++ + xlators/mgmt/glusterd/src/glusterd-shd-svc.c | 14 ++++----- + xlators/mgmt/glusterd/src/glusterd-svc-helper.c | 34 +++++----------------- + xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c | 4 +-- + xlators/mgmt/glusterd/src/glusterd-svc-mgmt.h | 4 --- + 6 files changed, 34 insertions(+), 40 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.c b/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.c +index 57ceda9..9196758 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.c ++++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.c +@@ -75,6 +75,18 @@ glusterd_svc_build_shd_volfile_path(glusterd_volinfo_t *volinfo, char *path, + } + + void ++glusterd_svc_build_shd_logdir(char *logdir, char *volname, size_t len) ++{ ++ snprintf(logdir, len, "%s/shd/%s", DEFAULT_LOG_FILE_DIRECTORY, volname); ++} ++ ++void ++glusterd_svc_build_shd_logfile(char *logfile, char *logdir, size_t len) ++{ ++ snprintf(logfile, len, "%s/shd.log", logdir); ++} ++ ++void + glusterd_shd_svcproc_cleanup(glusterd_shdsvc_t *shd) + { + glusterd_svc_proc_t *svc_proc = NULL; +diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.h b/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.h +index 59466ec..c70702c 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.h ++++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.h +@@ -27,6 +27,12 @@ glusterd_svc_build_shd_volfile_path(glusterd_volinfo_t *volinfo, char *path, + int path_len); + + void ++glusterd_svc_build_shd_logdir(char *logdir, char *volname, size_t len); ++ ++void ++glusterd_svc_build_shd_logfile(char *logfile, char *logdir, size_t len); ++ ++void + glusterd_shd_svcproc_cleanup(glusterd_shdsvc_t *shd); + + int +diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c +index 8ad90a9..dbe2560 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c ++++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c +@@ -90,8 +90,8 @@ glusterd_shdsvc_init(void *data, glusterd_conn_t *mux_conn, + GLUSTERD_GET_SHD_RUNDIR(rundir, volinfo, priv); + glusterd_svc_create_rundir(rundir); + +- glusterd_svc_build_logfile_path(shd_svc_name, DEFAULT_LOG_FILE_DIRECTORY, +- logfile, sizeof(logfile)); ++ glusterd_svc_build_shd_logdir(logdir, volinfo->volname, sizeof(logdir)); ++ glusterd_svc_build_shd_logfile(logfile, logdir, sizeof(logfile)); + + /* Initialize the connection mgmt */ + if (mux_conn && mux_svc->rpc) { +@@ -104,7 +104,7 @@ glusterd_shdsvc_init(void *data, glusterd_conn_t *mux_conn, + if (ret < 0) + goto out; + } else { +- ret = mkdir_p(DEFAULT_LOG_FILE_DIRECTORY, 0755, _gf_true); ++ ret = mkdir_p(logdir, 0755, _gf_true); + if ((ret == -1) && (EEXIST != errno)) { + gf_msg(this->name, GF_LOG_ERROR, errno, GD_MSG_CREATE_DIR_FAILED, + "Unable to create logdir %s", logdir); +@@ -460,7 +460,6 @@ glusterd_shdsvc_start(glusterd_svc_t *svc, int flags) + return -1; + + glusterd_volinfo_ref(volinfo); +- + if (!svc->inited) { + ret = glusterd_shd_svc_mux_init(volinfo, svc); + if (ret) +@@ -472,11 +471,12 @@ glusterd_shdsvc_start(glusterd_svc_t *svc, int flags) + /* Unref will happen from glusterd_svc_attach_cbk */ + ret = glusterd_attach_svc(svc, volinfo, flags); + if (ret) { ++ glusterd_volinfo_unref(volinfo); + gf_msg("glusterd", GF_LOG_ERROR, 0, GD_MSG_VOLINFO_GET_FAIL, +- "Failed to attach shd svc(volume=%s) to pid=%d", ++ "Failed to attach shd svc(volume=%s) to pid=%d. Starting" ++ "a new process", + volinfo->volname, glusterd_proc_get_pid(&svc->proc)); +- glusterd_shd_svcproc_cleanup(&volinfo->shd); +- glusterd_volinfo_unref(volinfo); ++ ret = glusterd_recover_shd_attach_failure(volinfo, svc, flags); + } + goto out; + } +diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c +index 400826f..a6e662f 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c ++++ b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c +@@ -469,9 +469,6 @@ glusterd_shd_svc_mux_init(glusterd_volinfo_t *volinfo, glusterd_svc_t *svc) + glusterd_conf_t *conf = NULL; + glusterd_svc_t *parent_svc = NULL; + int pid = -1; +- char pidfile[PATH_MAX] = { +- 0, +- }; + + GF_VALIDATE_OR_GOTO("glusterd", svc, out); + GF_VALIDATE_OR_GOTO("glusterd", volinfo, out); +@@ -481,26 +478,8 @@ glusterd_shd_svc_mux_init(glusterd_volinfo_t *volinfo, glusterd_svc_t *svc) + + pthread_mutex_lock(&conf->attach_lock); + { +- if (svc->inited && !glusterd_proc_is_running(&(svc->proc))) { +- /* This is the case when shd process was abnormally killed */ +- pthread_mutex_unlock(&conf->attach_lock); +- glusterd_shd_svcproc_cleanup(&volinfo->shd); +- pthread_mutex_lock(&conf->attach_lock); +- } +- + if (!svc->inited) { +- glusterd_svc_build_shd_pidfile(volinfo, pidfile, sizeof(pidfile)); +- ret = snprintf(svc->proc.name, sizeof(svc->proc.name), "%s", +- "glustershd"); +- if (ret < 0) +- goto unlock; +- +- ret = snprintf(svc->proc.pidfile, sizeof(svc->proc.pidfile), "%s", +- pidfile); +- if (ret < 0) +- goto unlock; +- +- if (gf_is_service_running(pidfile, &pid)) { ++ if (gf_is_service_running(svc->proc.pidfile, &pid)) { + /* Just connect is required, but we don't know what happens + * during the disconnect. So better to reattach. + */ +@@ -508,10 +487,10 @@ glusterd_shd_svc_mux_init(glusterd_volinfo_t *volinfo, glusterd_svc_t *svc) + } + + if (!mux_proc) { +- if (pid != -1 && sys_access(pidfile, R_OK) == 0) { ++ if (pid != -1 && sys_access(svc->proc.pidfile, R_OK) == 0) { + /* stale pid file, stop and unlink it */ + glusterd_proc_stop(&svc->proc, SIGTERM, PROC_STOP_FORCE); +- glusterd_unlink_file(pidfile); ++ glusterd_unlink_file(svc->proc.pidfile); + } + mux_proc = __gf_find_compatible_svc(GD_NODE_SHD); + } +@@ -705,10 +684,11 @@ glusterd_svc_attach_cbk(struct rpc_req *req, struct iovec *iov, int count, + volinfo->volname, glusterd_proc_get_pid(&svc->proc)); + } else { + gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_SVC_ATTACH_FAIL, +- "svc %s of volume %s failed to attach to pid %d", svc->name, +- volinfo->volname, glusterd_proc_get_pid(&svc->proc)); ++ "svc %s of volume %s failed to " ++ "attach to pid %d. Starting a new process", ++ svc->name, volinfo->volname, glusterd_proc_get_pid(&svc->proc)); + if (!strcmp(svc->name, "glustershd")) { +- glusterd_shd_svcproc_cleanup(&volinfo->shd); ++ glusterd_recover_shd_attach_failure(volinfo, svc, *flag); + } + } + out: +diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c +index fa316a6..f32dafc 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c ++++ b/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c +@@ -33,14 +33,14 @@ glusterd_svc_create_rundir(char *rundir) + return ret; + } + +-void ++static void + glusterd_svc_build_logfile_path(char *server, char *logdir, char *logfile, + size_t len) + { + snprintf(logfile, len, "%s/%s.log", logdir, server); + } + +-void ++static void + glusterd_svc_build_volfileid_path(char *server, char *volfileid, size_t len) + { + snprintf(volfileid, len, "gluster/%s", server); +diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.h b/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.h +index 5a5466a..fbc5225 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.h ++++ b/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.h +@@ -74,10 +74,6 @@ glusterd_svc_build_volfile_path(char *server, char *workdir, char *volfile, + size_t len); + + void +-glusterd_svc_build_logfile_path(char *server, char *logdir, char *logfile, +- size_t len); +- +-void + glusterd_svc_build_svcdir(char *server, char *workdir, char *path, size_t len); + + void +-- +1.8.3.1 + diff --git a/0235-Revert-glusterd-svc-Stop-stale-process-using-the-glu.patch b/0235-Revert-glusterd-svc-Stop-stale-process-using-the-glu.patch new file mode 100644 index 0000000..67348f6 --- /dev/null +++ b/0235-Revert-glusterd-svc-Stop-stale-process-using-the-glu.patch @@ -0,0 +1,38 @@ +From b2040d8404e0ac44742cb903e3c8da2c832b2925 Mon Sep 17 00:00:00 2001 +From: Mohammed Rafi KC +Date: Thu, 11 Jul 2019 12:45:11 +0530 +Subject: [PATCH 235/255] Revert "glusterd/svc: Stop stale process using the + glusterd_proc_stop" + +This reverts commit fe9159ee42f0f67b01e6a495df8105ea0f66738d. + +BUG: 1471742 +Change-Id: Id5ac0d21319724141ad9bcb9b66435803ebe5f47 +Signed-off-by: Mohammed Rafi KC +Reviewed-on: https://code.engineering.redhat.com/gerrit/175944 +Tested-by: RHGS Build Bot +Reviewed-by: Sunil Kumar Heggodu Gopala Acharya +--- + xlators/mgmt/glusterd/src/glusterd-svc-helper.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c +index a6e662f..6a3ca52 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c ++++ b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c +@@ -488,9 +488,9 @@ glusterd_shd_svc_mux_init(glusterd_volinfo_t *volinfo, glusterd_svc_t *svc) + + if (!mux_proc) { + if (pid != -1 && sys_access(svc->proc.pidfile, R_OK) == 0) { +- /* stale pid file, stop and unlink it */ +- glusterd_proc_stop(&svc->proc, SIGTERM, PROC_STOP_FORCE); +- glusterd_unlink_file(svc->proc.pidfile); ++ /* stale pid file, unlink it. */ ++ kill(pid, SIGTERM); ++ sys_unlink(svc->proc.pidfile); + } + mux_proc = __gf_find_compatible_svc(GD_NODE_SHD); + } +-- +1.8.3.1 + diff --git a/0236-Revert-shd-mux-Fix-race-between-mux_proc-unlink-and-.patch b/0236-Revert-shd-mux-Fix-race-between-mux_proc-unlink-and-.patch new file mode 100644 index 0000000..e33c7dd --- /dev/null +++ b/0236-Revert-shd-mux-Fix-race-between-mux_proc-unlink-and-.patch @@ -0,0 +1,35 @@ +From 030b5681d47268c591a72035d5a2419234bd1f5f Mon Sep 17 00:00:00 2001 +From: Mohammed Rafi KC +Date: Thu, 11 Jul 2019 12:44:55 +0530 +Subject: [PATCH 236/255] Revert "shd/mux: Fix race between mux_proc unlink and + stop" + +This reverts commit e386fb4f4baf834e6a8fc25cc2fbbb17eb0a7a56. + +BUG: 1471742 +Change-Id: I6c52835981389fc5bfeb43483feb581ad8507990 +Signed-off-by: Mohammed Rafi KC +Reviewed-on: https://code.engineering.redhat.com/gerrit/175945 +Reviewed-by: Sunil Kumar Heggodu Gopala Acharya +Tested-by: RHGS Build Bot +--- + xlators/mgmt/glusterd/src/glusterd-shd-svc.c | 3 --- + 1 file changed, 3 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c +index dbe2560..d81d760 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c ++++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c +@@ -694,9 +694,6 @@ glusterd_shdsvc_stop(glusterd_svc_t *svc, int sig) + gf_is_service_running(svc->proc.pidfile, &pid); + cds_list_del_init(&svc->mux_svc); + empty = cds_list_empty(&svc_proc->svcs); +- if (empty) { +- cds_list_del_init(&svc_proc->svc_proc_list); +- } + } + pthread_mutex_unlock(&conf->attach_lock); + if (empty) { +-- +1.8.3.1 + diff --git a/0237-Revert-ec-fini-Fix-race-between-xlator-cleanup-and-o.patch b/0237-Revert-ec-fini-Fix-race-between-xlator-cleanup-and-o.patch new file mode 100644 index 0000000..6c88d6a --- /dev/null +++ b/0237-Revert-ec-fini-Fix-race-between-xlator-cleanup-and-o.patch @@ -0,0 +1,227 @@ +From f0c3af09fd919e3646aae2821b0d6bfe4e2fd89c Mon Sep 17 00:00:00 2001 +From: Mohammed Rafi KC +Date: Thu, 11 Jul 2019 12:45:58 +0530 +Subject: [PATCH 237/255] Revert "ec/fini: Fix race between xlator cleanup and + on going async fop" + +This reverts commit 9fd966aa6879ac9867381629f82eca24b950d731. + +BUG: 1471742 +Change-Id: I557ec138174b01d8b8f8d090acd34c179e2c632d +Signed-off-by: Mohammed Rafi KC +Reviewed-on: https://code.engineering.redhat.com/gerrit/175946 +Tested-by: RHGS Build Bot +Reviewed-by: Sunil Kumar Heggodu Gopala Acharya +--- + xlators/cluster/ec/src/ec-common.c | 10 ---------- + xlators/cluster/ec/src/ec-common.h | 2 -- + xlators/cluster/ec/src/ec-data.c | 4 +--- + xlators/cluster/ec/src/ec-heal.c | 17 ++--------------- + xlators/cluster/ec/src/ec-types.h | 1 - + xlators/cluster/ec/src/ec.c | 37 ++++++++++++------------------------- + 6 files changed, 15 insertions(+), 56 deletions(-) + +diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c +index 35c2256..e2e582f 100644 +--- a/xlators/cluster/ec/src/ec-common.c ++++ b/xlators/cluster/ec/src/ec-common.c +@@ -2956,13 +2956,3 @@ ec_manager(ec_fop_data_t *fop, int32_t error) + + __ec_manager(fop, error); + } +- +-gf_boolean_t +-__ec_is_last_fop(ec_t *ec) +-{ +- if ((list_empty(&ec->pending_fops)) && +- (GF_ATOMIC_GET(ec->async_fop_count) == 0)) { +- return _gf_true; +- } +- return _gf_false; +-} +diff --git a/xlators/cluster/ec/src/ec-common.h b/xlators/cluster/ec/src/ec-common.h +index bf6c97d..e948342 100644 +--- a/xlators/cluster/ec/src/ec-common.h ++++ b/xlators/cluster/ec/src/ec-common.h +@@ -204,6 +204,4 @@ void + ec_reset_entry_healing(ec_fop_data_t *fop); + char * + ec_msg_str(ec_fop_data_t *fop); +-gf_boolean_t +-__ec_is_last_fop(ec_t *ec); + #endif /* __EC_COMMON_H__ */ +diff --git a/xlators/cluster/ec/src/ec-data.c b/xlators/cluster/ec/src/ec-data.c +index 8d2d9a1..6ef9340 100644 +--- a/xlators/cluster/ec/src/ec-data.c ++++ b/xlators/cluster/ec/src/ec-data.c +@@ -202,13 +202,11 @@ ec_handle_last_pending_fop_completion(ec_fop_data_t *fop, gf_boolean_t *notify) + { + ec_t *ec = fop->xl->private; + +- *notify = _gf_false; +- + if (!list_empty(&fop->pending_list)) { + LOCK(&ec->lock); + { + list_del_init(&fop->pending_list); +- *notify = __ec_is_last_fop(ec); ++ *notify = list_empty(&ec->pending_fops); + } + UNLOCK(&ec->lock); + } +diff --git a/xlators/cluster/ec/src/ec-heal.c b/xlators/cluster/ec/src/ec-heal.c +index 237fea2..8844c29 100644 +--- a/xlators/cluster/ec/src/ec-heal.c ++++ b/xlators/cluster/ec/src/ec-heal.c +@@ -2814,20 +2814,8 @@ int + ec_replace_heal_done(int ret, call_frame_t *heal, void *opaque) + { + ec_t *ec = opaque; +- gf_boolean_t last_fop = _gf_false; + +- if (GF_ATOMIC_DEC(ec->async_fop_count) == 0) { +- LOCK(&ec->lock); +- { +- last_fop = __ec_is_last_fop(ec); +- } +- UNLOCK(&ec->lock); +- } + gf_msg_debug(ec->xl->name, 0, "getxattr on bricks is done ret %d", ret); +- +- if (last_fop) +- ec_pending_fops_completed(ec); +- + return 0; + } + +@@ -2881,15 +2869,14 @@ ec_launch_replace_heal(ec_t *ec) + { + int ret = -1; + ++ if (!ec) ++ return ret; + ret = synctask_new(ec->xl->ctx->env, ec_replace_brick_heal_wrap, + ec_replace_heal_done, NULL, ec); +- + if (ret < 0) { + gf_msg_debug(ec->xl->name, 0, "Heal failed for replace brick ret = %d", + ret); +- ec_replace_heal_done(-1, NULL, ec); + } +- + return ret; + } + +diff --git a/xlators/cluster/ec/src/ec-types.h b/xlators/cluster/ec/src/ec-types.h +index 4dbf4a3..1c295c0 100644 +--- a/xlators/cluster/ec/src/ec-types.h ++++ b/xlators/cluster/ec/src/ec-types.h +@@ -643,7 +643,6 @@ struct _ec { + uintptr_t xl_notify; /* Bit flag representing + notification for bricks. */ + uintptr_t node_mask; +- gf_atomic_t async_fop_count; /* Number of on going asynchronous fops. */ + xlator_t **xl_list; + gf_lock_t lock; + gf_timer_t *timer; +diff --git a/xlators/cluster/ec/src/ec.c b/xlators/cluster/ec/src/ec.c +index f0d58c0..df5912c 100644 +--- a/xlators/cluster/ec/src/ec.c ++++ b/xlators/cluster/ec/src/ec.c +@@ -355,7 +355,6 @@ ec_notify_cbk(void *data) + ec_t *ec = data; + glusterfs_event_t event = GF_EVENT_MAXVAL; + gf_boolean_t propagate = _gf_false; +- gf_boolean_t launch_heal = _gf_false; + + LOCK(&ec->lock); + { +@@ -385,11 +384,6 @@ ec_notify_cbk(void *data) + * still bricks DOWN, they will be healed when they + * come up. */ + ec_up(ec->xl, ec); +- +- if (ec->shd.iamshd && !ec->shutdown) { +- launch_heal = _gf_true; +- GF_ATOMIC_INC(ec->async_fop_count); +- } + } + + propagate = _gf_true; +@@ -397,12 +391,13 @@ ec_notify_cbk(void *data) + unlock: + UNLOCK(&ec->lock); + +- if (launch_heal) { +- /* We have just brought the volume UP, so we trigger +- * a self-heal check on the root directory. */ +- ec_launch_replace_heal(ec); +- } + if (propagate) { ++ if ((event == GF_EVENT_CHILD_UP) && ec->shd.iamshd) { ++ /* We have just brought the volume UP, so we trigger ++ * a self-heal check on the root directory. */ ++ ec_launch_replace_heal(ec); ++ } ++ + default_notify(ec->xl, event, NULL); + } + } +@@ -430,7 +425,7 @@ ec_disable_delays(ec_t *ec) + { + ec->shutdown = _gf_true; + +- return __ec_is_last_fop(ec); ++ return list_empty(&ec->pending_fops); + } + + void +@@ -608,10 +603,7 @@ ec_notify(xlator_t *this, int32_t event, void *data, void *data2) + if (event == GF_EVENT_CHILD_UP) { + /* We need to trigger a selfheal if a brick changes + * to UP state. */ +- if (ec_set_up_state(ec, mask, mask) && ec->shd.iamshd && +- !ec->shutdown) { +- needs_shd_check = _gf_true; +- } ++ needs_shd_check = ec_set_up_state(ec, mask, mask); + } else if (event == GF_EVENT_CHILD_DOWN) { + ec_set_up_state(ec, mask, 0); + } +@@ -641,21 +633,17 @@ ec_notify(xlator_t *this, int32_t event, void *data, void *data2) + } + } else { + propagate = _gf_false; +- needs_shd_check = _gf_false; +- } +- +- if (needs_shd_check) { +- GF_ATOMIC_INC(ec->async_fop_count); + } + } + unlock: + UNLOCK(&ec->lock); + + done: +- if (needs_shd_check) { +- ec_launch_replace_heal(ec); +- } + if (propagate) { ++ if (needs_shd_check && ec->shd.iamshd) { ++ ec_launch_replace_heal(ec); ++ } ++ + error = default_notify(this, event, data); + } + +@@ -717,7 +705,6 @@ init(xlator_t *this) + ec->xl = this; + LOCK_INIT(&ec->lock); + +- GF_ATOMIC_INIT(ec->async_fop_count, 0); + INIT_LIST_HEAD(&ec->pending_fops); + INIT_LIST_HEAD(&ec->heal_waiting); + INIT_LIST_HEAD(&ec->healing); +-- +1.8.3.1 + diff --git a/0238-Revert-xlator-log-Add-more-logging-in-xlator_is_clea.patch b/0238-Revert-xlator-log-Add-more-logging-in-xlator_is_clea.patch new file mode 100644 index 0000000..0514cd1 --- /dev/null +++ b/0238-Revert-xlator-log-Add-more-logging-in-xlator_is_clea.patch @@ -0,0 +1,47 @@ +From 96072cea4da1c2ba5bd87307f20b3ee2cbe6f63d Mon Sep 17 00:00:00 2001 +From: Mohammed Rafi KC +Date: Thu, 11 Jul 2019 12:46:10 +0530 +Subject: [PATCH 238/255] Revert "xlator/log: Add more logging in + xlator_is_cleanup_starting" + +This reverts commit 9b94397a5a735910fab2a29670146a1feb6d890e. + +BUG: 1471742 +Change-Id: Icc3f0c8741ed780e265202adbb009063f657c7f7 +Signed-off-by: Mohammed Rafi KC +Reviewed-on: https://code.engineering.redhat.com/gerrit/175947 +Tested-by: RHGS Build Bot +Reviewed-by: Sunil Kumar Heggodu Gopala Acharya +--- + libglusterfs/src/xlator.c | 12 +++--------- + 1 file changed, 3 insertions(+), 9 deletions(-) + +diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c +index 71e1ed4..fbfbbe2 100644 +--- a/libglusterfs/src/xlator.c ++++ b/libglusterfs/src/xlator.c +@@ -1494,18 +1494,12 @@ xlator_is_cleanup_starting(xlator_t *this) + glusterfs_graph_t *graph = NULL; + xlator_t *xl = NULL; + +- if (!this) { +- gf_msg("xlator", GF_LOG_WARNING, EINVAL, LG_MSG_INVALID_ARG, +- "xlator object is null, returning false"); ++ if (!this) + goto out; +- } +- + graph = this->graph; +- if (!graph) { +- gf_msg("xlator", GF_LOG_WARNING, EINVAL, LG_MSG_INVALID_ARG, +- "Graph is not set for xlator %s", this->name); ++ ++ if (!graph) + goto out; +- } + + xl = graph->first; + if (xl && xl->cleanup_starting) +-- +1.8.3.1 + diff --git a/0239-Revert-ec-fini-Fix-race-with-ec_fini-and-ec_notify.patch b/0239-Revert-ec-fini-Fix-race-with-ec_fini-and-ec_notify.patch new file mode 100644 index 0000000..f36c997 --- /dev/null +++ b/0239-Revert-ec-fini-Fix-race-with-ec_fini-and-ec_notify.patch @@ -0,0 +1,128 @@ +From ad40c0783e84e5e54a83aeb20a52f720cc881b0c Mon Sep 17 00:00:00 2001 +From: Mohammed Rafi KC +Date: Thu, 11 Jul 2019 12:46:22 +0530 +Subject: [PATCH 239/255] Revert "ec/fini: Fix race with ec_fini and ec_notify" + +This reverts commit 998d9b8b5e271f407e1c654c34f45f0db36abc71. + +BUG: 1471742 +Change-Id: Ifccb8a22d9ef96c22b32dcb4b82bf4d21cf85484 +Signed-off-by: Mohammed Rafi KC +Reviewed-on: https://code.engineering.redhat.com/gerrit/175948 +Tested-by: RHGS Build Bot +Reviewed-by: Sunil Kumar Heggodu Gopala Acharya +--- + libglusterfs/src/glusterfs/xlator.h | 3 --- + libglusterfs/src/libglusterfs.sym | 1 - + libglusterfs/src/xlator.c | 21 --------------------- + xlators/cluster/ec/src/ec-heal.c | 4 ---- + xlators/cluster/ec/src/ec-heald.c | 6 ------ + xlators/cluster/ec/src/ec.c | 3 --- + 6 files changed, 38 deletions(-) + +diff --git a/libglusterfs/src/glusterfs/xlator.h b/libglusterfs/src/glusterfs/xlator.h +index 09e463e..8998976 100644 +--- a/libglusterfs/src/glusterfs/xlator.h ++++ b/libglusterfs/src/glusterfs/xlator.h +@@ -1092,7 +1092,4 @@ gluster_graph_take_reference(xlator_t *tree); + + gf_boolean_t + mgmt_is_multiplexed_daemon(char *name); +- +-gf_boolean_t +-xlator_is_cleanup_starting(xlator_t *this); + #endif /* _XLATOR_H */ +diff --git a/libglusterfs/src/libglusterfs.sym b/libglusterfs/src/libglusterfs.sym +index 86215d2..05f93b4 100644 +--- a/libglusterfs/src/libglusterfs.sym ++++ b/libglusterfs/src/libglusterfs.sym +@@ -1160,4 +1160,3 @@ glusterfs_process_svc_attach_volfp + glusterfs_mux_volfile_reconfigure + glusterfs_process_svc_detach + mgmt_is_multiplexed_daemon +-xlator_is_cleanup_starting +diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c +index fbfbbe2..022c3ed 100644 +--- a/libglusterfs/src/xlator.c ++++ b/libglusterfs/src/xlator.c +@@ -1486,24 +1486,3 @@ mgmt_is_multiplexed_daemon(char *name) + } + return _gf_false; + } +- +-gf_boolean_t +-xlator_is_cleanup_starting(xlator_t *this) +-{ +- gf_boolean_t cleanup = _gf_false; +- glusterfs_graph_t *graph = NULL; +- xlator_t *xl = NULL; +- +- if (!this) +- goto out; +- graph = this->graph; +- +- if (!graph) +- goto out; +- +- xl = graph->first; +- if (xl && xl->cleanup_starting) +- cleanup = _gf_true; +-out: +- return cleanup; +-} +diff --git a/xlators/cluster/ec/src/ec-heal.c b/xlators/cluster/ec/src/ec-heal.c +index 8844c29..2fa1f11 100644 +--- a/xlators/cluster/ec/src/ec-heal.c ++++ b/xlators/cluster/ec/src/ec-heal.c +@@ -2855,10 +2855,6 @@ ec_replace_brick_heal_wrap(void *opaque) + itable = ec->xl->itable; + else + goto out; +- +- if (xlator_is_cleanup_starting(ec->xl)) +- goto out; +- + ret = ec_replace_heal(ec, itable->root); + out: + return ret; +diff --git a/xlators/cluster/ec/src/ec-heald.c b/xlators/cluster/ec/src/ec-heald.c +index 91512d7..edf5e11 100644 +--- a/xlators/cluster/ec/src/ec-heald.c ++++ b/xlators/cluster/ec/src/ec-heald.c +@@ -444,9 +444,6 @@ unlock: + int + ec_shd_full_healer_spawn(xlator_t *this, int subvol) + { +- if (xlator_is_cleanup_starting(this)) +- return -1; +- + return ec_shd_healer_spawn(this, NTH_FULL_HEALER(this, subvol), + ec_shd_full_healer); + } +@@ -454,9 +451,6 @@ ec_shd_full_healer_spawn(xlator_t *this, int subvol) + int + ec_shd_index_healer_spawn(xlator_t *this, int subvol) + { +- if (xlator_is_cleanup_starting(this)) +- return -1; +- + return ec_shd_healer_spawn(this, NTH_INDEX_HEALER(this, subvol), + ec_shd_index_healer); + } +diff --git a/xlators/cluster/ec/src/ec.c b/xlators/cluster/ec/src/ec.c +index df5912c..264582a 100644 +--- a/xlators/cluster/ec/src/ec.c ++++ b/xlators/cluster/ec/src/ec.c +@@ -486,9 +486,6 @@ ec_set_up_state(ec_t *ec, uintptr_t index_mask, uintptr_t new_state) + { + uintptr_t current_state = 0; + +- if (xlator_is_cleanup_starting(ec->xl)) +- return _gf_false; +- + if ((ec->xl_notify & index_mask) == 0) { + ec->xl_notify |= index_mask; + ec->xl_notify_count++; +-- +1.8.3.1 + diff --git a/0240-Revert-glusterd-shd-Optimize-the-glustershd-manager-.patch b/0240-Revert-glusterd-shd-Optimize-the-glustershd-manager-.patch new file mode 100644 index 0000000..54ef75e --- /dev/null +++ b/0240-Revert-glusterd-shd-Optimize-the-glustershd-manager-.patch @@ -0,0 +1,54 @@ +From 9b3adb28207681f49ea97fc2c473634ff0f73db6 Mon Sep 17 00:00:00 2001 +From: Mohammed Rafi KC +Date: Thu, 11 Jul 2019 12:46:35 +0530 +Subject: [PATCH 240/255] Revert "glusterd/shd: Optimize the glustershd manager + to send reconfigure" + +This reverts commit 321080e55f0ae97115a9542ba5de8494e7610860. + +BUG: 1471742 +Change-Id: I5fa84baa3c3e72ca8eb605c7f1fafb53c68859f9 +Signed-off-by: Mohammed Rafi KC +Reviewed-on: https://code.engineering.redhat.com/gerrit/175949 +Tested-by: RHGS Build Bot +Reviewed-by: Sunil Kumar Heggodu Gopala Acharya +--- + libglusterfs/src/graph.c | 1 + + xlators/mgmt/glusterd/src/glusterd-shd-svc.c | 9 ++++----- + 2 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/libglusterfs/src/graph.c b/libglusterfs/src/graph.c +index 27d9335..18fb2d9 100644 +--- a/libglusterfs/src/graph.c ++++ b/libglusterfs/src/graph.c +@@ -1497,6 +1497,7 @@ glusterfs_process_svc_detach(glusterfs_ctx_t *ctx, gf_volfile_t *volfile_obj) + parent_graph->last_xl = glusterfs_get_last_xlator(parent_graph); + parent_graph->xl_count -= graph->xl_count; + parent_graph->leaf_count -= graph->leaf_count; ++ default_notify(xl, GF_EVENT_PARENT_DOWN, xl); + parent_graph->id++; + ret = 0; + } +diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c +index d81d760..981cc87 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c ++++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c +@@ -311,11 +311,10 @@ glusterd_shdsvc_manager(glusterd_svc_t *svc, void *data, int flags) + */ + ret = svc->stop(svc, SIGTERM); + } else if (volinfo) { +- if (volinfo->status != GLUSTERD_STATUS_STARTED) { +- ret = svc->stop(svc, SIGTERM); +- if (ret) +- goto out; +- } ++ ret = svc->stop(svc, SIGTERM); ++ if (ret) ++ goto out; ++ + if (volinfo->status == GLUSTERD_STATUS_STARTED) { + ret = svc->start(svc, flags); + if (ret) +-- +1.8.3.1 + diff --git a/0241-Revert-glusterd-svc-glusterd_svcs_stop-should-call-i.patch b/0241-Revert-glusterd-svc-glusterd_svcs_stop-should-call-i.patch new file mode 100644 index 0000000..965fcfe --- /dev/null +++ b/0241-Revert-glusterd-svc-glusterd_svcs_stop-should-call-i.patch @@ -0,0 +1,82 @@ +From 066189add979d2e4c74463592e5021bd060d5a51 Mon Sep 17 00:00:00 2001 +From: Mohammed Rafi KC +Date: Thu, 11 Jul 2019 12:46:47 +0530 +Subject: [PATCH 241/255] Revert "glusterd/svc: glusterd_svcs_stop should call + individual wrapper function" + +This reverts commit 79fff98f9ca5f815cf0227312b9a997d555dad29. + +BUG: 1471742 +Change-Id: I258040ed9be6bc3b4498c76ed51d59258c55acff +Signed-off-by: Mohammed Rafi KC +Reviewed-on: https://code.engineering.redhat.com/gerrit/175950 +Tested-by: RHGS Build Bot +Reviewed-by: Sunil Kumar Heggodu Gopala Acharya +--- + xlators/mgmt/glusterd/src/glusterd-shd-svc.c | 12 ++---------- + xlators/mgmt/glusterd/src/glusterd-svc-helper.c | 10 +++++----- + 2 files changed, 7 insertions(+), 15 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c +index 981cc87..75f9a07 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c ++++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c +@@ -656,18 +656,10 @@ glusterd_shdsvc_stop(glusterd_svc_t *svc, int sig) + int pid = -1; + + conf = THIS->private; +- GF_VALIDATE_OR_GOTO("glusterd", conf, out); + GF_VALIDATE_OR_GOTO("glusterd", svc, out); + svc_proc = svc->svc_proc; +- if (!svc_proc) { +- /* +- * This can happen when stop was called on a volume that is not shd +- * compatible. +- */ +- gf_msg_debug("glusterd", 0, "svc_proc is null, ie shd already stopped"); +- ret = 0; +- goto out; +- } ++ GF_VALIDATE_OR_GOTO("glusterd", svc_proc, out); ++ GF_VALIDATE_OR_GOTO("glusterd", conf, out); + + /* Get volinfo->shd from svc object */ + shd = cds_list_entry(svc, glusterd_shdsvc_t, svc); +diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c +index 6a3ca52..f7be394 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c ++++ b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c +@@ -86,25 +86,25 @@ glusterd_svcs_stop(glusterd_volinfo_t *volinfo) + priv = this->private; + GF_ASSERT(priv); + +- ret = priv->nfs_svc.stop(&(priv->nfs_svc), SIGKILL); ++ ret = glusterd_svc_stop(&(priv->nfs_svc), SIGKILL); + if (ret) + goto out; + +- ret = priv->quotad_svc.stop(&(priv->quotad_svc), SIGTERM); ++ ret = glusterd_svc_stop(&(priv->quotad_svc), SIGTERM); + if (ret) + goto out; + + if (volinfo) { +- ret = volinfo->shd.svc.stop(&(volinfo->shd.svc), SIGTERM); ++ ret = glusterd_svc_stop(&(volinfo->shd.svc), PROC_START_NO_WAIT); + if (ret) + goto out; + } + +- ret = priv->bitd_svc.stop(&(priv->bitd_svc), SIGTERM); ++ ret = glusterd_svc_stop(&(priv->bitd_svc), SIGTERM); + if (ret) + goto out; + +- ret = priv->scrub_svc.stop(&(priv->scrub_svc), SIGTERM); ++ ret = glusterd_svc_stop(&(priv->scrub_svc), SIGTERM); + out: + return ret; + } +-- +1.8.3.1 + diff --git a/0242-Revert-tests-shd-Add-test-coverage-for-shd-mux.patch b/0242-Revert-tests-shd-Add-test-coverage-for-shd-mux.patch new file mode 100644 index 0000000..2174063 --- /dev/null +++ b/0242-Revert-tests-shd-Add-test-coverage-for-shd-mux.patch @@ -0,0 +1,427 @@ +From 48f7be493588fdf5e99dff0c3b91327e07da05f3 Mon Sep 17 00:00:00 2001 +From: Mohammed Rafi KC +Date: Thu, 11 Jul 2019 12:48:34 +0530 +Subject: [PATCH 242/255] Revert "tests/shd: Add test coverage for shd mux" + +This reverts commit b7f832288d2d2e57231d90765afc049ad7cb2f9d. + +BUG: 1471742 +Change-Id: Ifccac5150f07b98006714e43c77c5a4b1fd38cb8 +Signed-off-by: Mohammed Rafi KC +Reviewed-on: https://code.engineering.redhat.com/gerrit/175951 +Tested-by: RHGS Build Bot +Reviewed-by: Sunil Kumar Heggodu Gopala Acharya +--- + tests/basic/glusterd-restart-shd-mux.t | 96 --------------------- + tests/basic/shd-mux.t | 149 --------------------------------- + tests/basic/volume-scale-shd-mux.t | 112 ------------------------- + tests/volume.rc | 15 ---- + 4 files changed, 372 deletions(-) + delete mode 100644 tests/basic/glusterd-restart-shd-mux.t + delete mode 100644 tests/basic/shd-mux.t + delete mode 100644 tests/basic/volume-scale-shd-mux.t + +diff --git a/tests/basic/glusterd-restart-shd-mux.t b/tests/basic/glusterd-restart-shd-mux.t +deleted file mode 100644 +index a50af9d..0000000 +--- a/tests/basic/glusterd-restart-shd-mux.t ++++ /dev/null +@@ -1,96 +0,0 @@ +-#!/bin/bash +- +-. $(dirname $0)/../include.rc +-. $(dirname $0)/../volume.rc +- +-cleanup; +- +-TESTS_EXPECTED_IN_LOOP=20 +- +-TEST glusterd +-TEST pidof glusterd +-TEST $CLI volume create $V0 replica 3 $H0:$B0/${V0}{0,1,2,3,4,5} +-TEST $CLI volume set $V0 cluster.background-self-heal-count 0 +-TEST $CLI volume set $V0 cluster.eager-lock off +-TEST $CLI volume set $V0 performance.flush-behind off +-TEST $CLI volume start $V0 +- +-for i in $(seq 1 3); do +- TEST $CLI volume create ${V0}_afr$i replica 3 $H0:$B0/${V0}_afr${i}{0,1,2,3,4,5} +- TEST $CLI volume start ${V0}_afr$i +- TEST $CLI volume create ${V0}_ec$i disperse 6 redundancy 2 $H0:$B0/${V0}_ec${i}{0,1,2,3,4,5} +- TEST $CLI volume start ${V0}_ec$i +-done +- +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^1$" shd_count +- +-#Stop the glusterd +-TEST pkill glusterd +-#Only stopping glusterd, so there will be one shd +-EXPECT_WITHIN $PROCESS_DOWN_TIMEOUT "^1$" shd_count +-TEST glusterd +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^1$" shd_count +-#Check the thread count become to number of volumes*number of ec subvolume (3*6=18) +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^18$" number_healer_threads_shd $V0 "__ec_shd_healer_wait" +-#Check the thread count become to number of volumes*number of afr subvolume (4*6=24) +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^24$" number_healer_threads_shd $V0 "__afr_shd_healer_wait" +- +-shd_pid=$(get_shd_mux_pid $V0) +-for i in $(seq 1 3); do +- afr_path="/var/run/gluster/shd/${V0}_afr$i/${V0}_afr$i-shd.pid" +- EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^${shd_pid}$" cat $afr_path +- ec_path="/var/run/gluster/shd/${V0}_ec$i/${V0}_ec${i}-shd.pid" +- EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^${shd_pid}$" cat $ec_path +-done +- +-#Reboot a node scenario +-TEST pkill gluster +-#Only stopped glusterd, so there will be one shd +-EXPECT_WITHIN $PROCESS_DOWN_TIMEOUT "^0$" shd_count +- +-TEST glusterd +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^1$" shd_count +- +-#Check the thread count become to number of volumes*number of ec subvolume (3*6=18) +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^18$" number_healer_threads_shd $V0 "__ec_shd_healer_wait" +-#Check the thread count become to number of volumes*number of afr subvolume (4*6=24) +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^24$" number_healer_threads_shd $V0 "__afr_shd_healer_wait" +- +-shd_pid=$(get_shd_mux_pid $V0) +-for i in $(seq 1 3); do +- afr_path="/var/run/gluster/shd/${V0}_afr$i/${V0}_afr$i-shd.pid" +- EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^${shd_pid}$" cat $afr_path +- ec_path="/var/run/gluster/shd/${V0}_ec$i/${V0}_ec${i}-shd.pid" +- EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^${shd_pid}$" cat $ec_path +-done +- +-for i in $(seq 1 3); do +- TEST $CLI volume stop ${V0}_afr$i +- TEST $CLI volume stop ${V0}_ec$i +-done +- +-EXPECT_WITHIN $PROCESS_DOWN_TIMEOUT "^6$" number_healer_threads_shd $V0 "__afr_shd_healer_wait" +- +-TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0 +- +-TEST kill_brick $V0 $H0 $B0/${V0}0 +-TEST kill_brick $V0 $H0 $B0/${V0}3 +- +-TEST touch $M0/foo{1..100} +- +-EXPECT_WITHIN $HEAL_TIMEOUT "^204$" get_pending_heal_count $V0 +- +-TEST $CLI volume start ${V0} force +- +-EXPECT_WITHIN $HEAL_TIMEOUT "^0$" get_pending_heal_count $V0 +- +-TEST rm -rf $M0/* +-EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0 +- +- +-TEST $CLI volume stop ${V0} +-TEST $CLI volume delete ${V0} +- +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^0$" shd_count +- +-cleanup +diff --git a/tests/basic/shd-mux.t b/tests/basic/shd-mux.t +deleted file mode 100644 +index e42a34a..0000000 +--- a/tests/basic/shd-mux.t ++++ /dev/null +@@ -1,149 +0,0 @@ +-#!/bin/bash +- +-. $(dirname $0)/../include.rc +-. $(dirname $0)/../volume.rc +- +-cleanup; +- +-TESTS_EXPECTED_IN_LOOP=16 +- +-TEST glusterd +-TEST pidof glusterd +-TEST $CLI volume create $V0 replica 3 $H0:$B0/${V0}{0,1,2,3,4,5} +-TEST $CLI volume set $V0 cluster.background-self-heal-count 0 +-TEST $CLI volume set $V0 cluster.eager-lock off +-TEST $CLI volume set $V0 performance.flush-behind off +-TEST $CLI volume start $V0 +-TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0 +- +-shd_pid=$(get_shd_mux_pid $V0) +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^6$" number_healer_threads_shd $V0 "__afr_shd_healer_wait" +- +-#Create a one more volume +-TEST $CLI volume create ${V0}_1 replica 3 $H0:$B0/${V0}_1{0,1,2,3,4,5} +-TEST $CLI volume start ${V0}_1 +- +-#Check whether the shd has multiplexed or not +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^1$" shd_count +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^${shd_pid}$" get_shd_mux_pid ${V0}_1 +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^${shd_pid}$" get_shd_mux_pid ${V0} +- +-TEST $CLI volume set ${V0}_1 cluster.background-self-heal-count 0 +-TEST $CLI volume set ${V0}_1 cluster.eager-lock off +-TEST $CLI volume set ${V0}_1 performance.flush-behind off +-TEST $GFS --volfile-id=/${V0}_1 --volfile-server=$H0 $M1 +- +-TEST kill_brick $V0 $H0 $B0/${V0}0 +-TEST kill_brick $V0 $H0 $B0/${V0}4 +-TEST kill_brick ${V0}_1 $H0 $B0/${V0}_10 +-TEST kill_brick ${V0}_1 $H0 $B0/${V0}_14 +- +-TEST touch $M0/foo{1..100} +-TEST touch $M1/foo{1..100} +- +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^204$" get_pending_heal_count $V0 +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^204$" get_pending_heal_count ${V0}_1 +- +-TEST $CLI volume start ${V0} force +-TEST $CLI volume start ${V0}_1 force +- +-EXPECT_WITHIN $HEAL_TIMEOUT "^0$" get_pending_heal_count $V0 +-EXPECT_WITHIN $HEAL_TIMEOUT "^0$" get_pending_heal_count ${V0}_1 +- +-TEST rm -rf $M0/* +-TEST rm -rf $M1/* +-EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M1 +- +-#Stop the volume +-TEST $CLI volume stop ${V0}_1 +-TEST $CLI volume delete ${V0}_1 +- +-#Check the stop succeeded and detached the volume with out restarting it +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^1$" shd_count +- +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^${shd_pid}$" get_shd_mux_pid $V0 +- +-#Check the thread count become to earlier number after stopping +-EXPECT_WITHIN $PROCESS_DOWN_TIMEOUT "^6$" number_healer_threads_shd $V0 "__afr_shd_healer_wait" +- +- +-#Now create a ec volume and check mux works +-TEST $CLI volume create ${V0}_2 disperse 6 redundancy 2 $H0:$B0/${V0}_2{0,1,2,3,4,5} +-TEST $CLI volume start ${V0}_2 +- +-#Check whether the shd has multiplexed or not +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^1$" shd_count +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^${shd_pid}$" get_shd_mux_pid ${V0}_2 +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^${shd_pid}$" get_shd_mux_pid ${V0} +- +-TEST $CLI volume set ${V0}_2 cluster.background-self-heal-count 0 +-TEST $CLI volume set ${V0}_2 cluster.eager-lock off +-TEST $CLI volume set ${V0}_2 performance.flush-behind off +-TEST $GFS --volfile-id=/${V0}_2 --volfile-server=$H0 $M1 +- +-TEST kill_brick $V0 $H0 $B0/${V0}0 +-TEST kill_brick $V0 $H0 $B0/${V0}4 +-TEST kill_brick ${V0}_2 $H0 $B0/${V0}_20 +-TEST kill_brick ${V0}_2 $H0 $B0/${V0}_22 +- +-TEST touch $M0/foo{1..100} +-TEST touch $M1/foo{1..100} +- +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^204$" get_pending_heal_count $V0 +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^404$" get_pending_heal_count ${V0}_2 +- +-TEST $CLI volume start ${V0} force +-TEST $CLI volume start ${V0}_2 force +- +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^6$" number_healer_threads_shd $V0 "__ec_shd_healer_wait" +- +-EXPECT_WITHIN $HEAL_TIMEOUT "^0$" get_pending_heal_count $V0 +-EXPECT_WITHIN $HEAL_TIMEOUT "^0$" get_pending_heal_count ${V0}_2 +- +-TEST rm -rf $M0/* +-TEST rm -rf $M1/* +- +- +-#Stop the volume +-TEST $CLI volume stop ${V0}_2 +-TEST $CLI volume delete ${V0}_2 +- +-#Check the stop succeeded and detached the volume with out restarting it +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^1$" shd_count +- +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^${shd_pid}$" get_shd_mux_pid $V0 +- +-#Check the thread count become to zero for ec related threads +-EXPECT_WITHIN $PROCESS_DOWN_TIMEOUT "^0$" number_healer_threads_shd $V0 "__ec_shd_healer_wait" +-#Check the thread count become to earlier number after stopping +-EXPECT_WITHIN $PROCESS_DOWN_TIMEOUT "^6$" number_healer_threads_shd $V0 "__afr_shd_healer_wait" +- +-for i in $(seq 1 3); do +- TEST $CLI volume create ${V0}_afr$i replica 3 $H0:$B0/${V0}_afr${i}{0,1,2,3,4,5} +- TEST $CLI volume start ${V0}_afr$i +- TEST $CLI volume create ${V0}_ec$i disperse 6 redundancy 2 $H0:$B0/${V0}_ec${i}{0,1,2,3,4,5} +- TEST $CLI volume start ${V0}_ec$i +-done +- +-#Check the thread count become to number of volumes*number of ec subvolume (3*6=18) +-EXPECT_WITHIN $PROCESS_DOWN_TIMEOUT "^18$" number_healer_threads_shd $V0 "__ec_shd_healer_wait" +-#Check the thread count become to number of volumes*number of afr subvolume (4*6=24) +-EXPECT_WITHIN $PROCESS_DOWN_TIMEOUT "^24$" number_healer_threads_shd $V0 "__afr_shd_healer_wait" +-#Delete the volumes +-for i in $(seq 1 3); do +- TEST $CLI volume stop ${V0}_afr$i +- TEST $CLI volume stop ${V0}_ec$i +- TEST $CLI volume delete ${V0}_afr$i +- TEST $CLI volume delete ${V0}_ec$i +-done +- +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^${shd_pid}$" get_shd_mux_pid $V0 +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^1$" shd_count +- +-EXPECT_WITHIN $PROCESS_DOWN_TIMEOUT "^6$" number_healer_threads_shd $V0 "__afr_shd_healer_wait" +- +-TEST $CLI volume stop ${V0} +-TEST $CLI volume delete ${V0} +-EXPECT_WITHIN $PROCESS_DOWN_TIMEOUT "^0$" shd_count +- +-cleanup +diff --git a/tests/basic/volume-scale-shd-mux.t b/tests/basic/volume-scale-shd-mux.t +deleted file mode 100644 +index dd9cf83..0000000 +--- a/tests/basic/volume-scale-shd-mux.t ++++ /dev/null +@@ -1,112 +0,0 @@ +-#!/bin/bash +- +-. $(dirname $0)/../include.rc +-. $(dirname $0)/../volume.rc +- +-cleanup; +- +-TESTS_EXPECTED_IN_LOOP=6 +- +-TEST glusterd +-TEST pidof glusterd +-TEST $CLI volume create $V0 replica 3 $H0:$B0/${V0}{0,1,2,3,4,5} +-TEST $CLI volume set $V0 cluster.background-self-heal-count 0 +-TEST $CLI volume set $V0 cluster.eager-lock off +-TEST $CLI volume set $V0 performance.flush-behind off +-TEST $CLI volume start $V0 +- +-for i in $(seq 1 2); do +- TEST $CLI volume create ${V0}_afr$i replica 3 $H0:$B0/${V0}_afr${i}{0,1,2,3,4,5} +- TEST $CLI volume start ${V0}_afr$i +- TEST $CLI volume create ${V0}_ec$i disperse 6 redundancy 2 $H0:$B0/${V0}_ec${i}{0,1,2,3,4,5} +- TEST $CLI volume start ${V0}_ec$i +-done +- +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^1$" shd_count +- +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^1$" shd_count +-#Check the thread count become to number of volumes*number of ec subvolume (2*6=12) +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^12$" number_healer_threads_shd $V0 "__ec_shd_healer_wait" +-#Check the thread count become to number of volumes*number of afr subvolume (3*6=18) +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^18$" number_healer_threads_shd $V0 "__afr_shd_healer_wait" +- +-TEST $CLI volume add-brick $V0 replica 3 $H0:$B0/${V0}{6,7,8}; +-#Check the thread count become to number of volumes*number of afr subvolume plus 3 additional threads from newly added bricks (3*6+3=21) +- +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^1$" shd_count +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^21$" number_healer_threads_shd $V0 "__afr_shd_healer_wait" +- +-#Remove the brick and check the detach is successful +-$CLI volume remove-brick $V0 $H0:$B0/${V0}{6,7,8} force +- +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^18$" number_healer_threads_shd $V0 "__afr_shd_healer_wait" +- +-TEST $CLI volume add-brick ${V0}_ec1 $H0:$B0/${V0}_ec1_add{0,1,2,3,4,5}; +-#Check the thread count become to number of volumes*number of ec subvolume plus 2 additional threads from newly added bricks (2*6+6=18) +- +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^1$" shd_count +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^18$" number_healer_threads_shd $V0 "__ec_shd_healer_wait" +- +-#Remove the brick and check the detach is successful +-$CLI volume remove-brick ${V0}_ec1 $H0:$B0/${V0}_ec1_add{0,1,2,3,4,5} force +- +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^12$" number_healer_threads_shd $V0 "__ec_shd_healer_wait" +- +- +-for i in $(seq 1 2); do +- TEST $CLI volume stop ${V0}_afr$i +- TEST $CLI volume stop ${V0}_ec$i +-done +- +-EXPECT_WITHIN $PROCESS_DOWN_TIMEOUT "^6$" number_healer_threads_shd $V0 "__afr_shd_healer_wait" +- +-TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0 +- +-TEST kill_brick $V0 $H0 $B0/${V0}0 +-TEST kill_brick $V0 $H0 $B0/${V0}4 +- +-TEST touch $M0/foo{1..100} +- +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^204$" get_pending_heal_count $V0 +- +-TEST $CLI volume start ${V0} force +- +-EXPECT_WITHIN $HEAL_TIMEOUT "^0$" get_pending_heal_count $V0 +- +-TEST rm -rf $M0/* +-EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0 +-shd_pid=$(get_shd_mux_pid $V0) +-TEST $CLI volume create ${V0}_distribute1 $H0:$B0/${V0}_distribute10 +-TEST $CLI volume start ${V0}_distribute1 +- +-#Creating a non-replicate/non-ec volume should not have any effect in shd +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^6$" number_healer_threads_shd $V0 "__afr_shd_healer_wait" +-EXPECT "^${shd_pid}$" get_shd_mux_pid $V0 +- +-TEST mkdir $B0/add/ +-#Now convert the distributed volume to replicate +-TEST $CLI volume add-brick ${V0}_distribute1 replica 3 $H0:$B0/add/{2..3} +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^9$" number_healer_threads_shd $V0 "__afr_shd_healer_wait" +- +-#scale down the volume +-TEST $CLI volume remove-brick ${V0}_distribute1 replica 1 $H0:$B0/add/{2..3} force +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^6$" number_healer_threads_shd $V0 "__afr_shd_healer_wait" +- +-TEST $CLI volume stop ${V0} +-TEST $CLI volume delete ${V0} +-EXPECT_WITHIN $PROCESS_DOWN_TIMEOUT "^0$" shd_count +- +-TEST rm -rf $B0/add/ +-TEST mkdir $B0/add/ +-#Now convert the distributed volume back to replicate and make sure that a new shd is spawned +-TEST $CLI volume add-brick ${V0}_distribute1 replica 3 $H0:$B0/add/{2..3}; +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^1$" shd_count +-EXPECT_WITHIN $HEAL_TIMEOUT "^3$" number_healer_threads_shd ${V0}_distribute1 "__afr_shd_healer_wait" +- +-#Now convert the replica volume to distribute again and make sure the shd is now stopped +-TEST $CLI volume remove-brick ${V0}_distribute1 replica 1 $H0:$B0/add/{2..3} force +-TEST rm -rf $B0/add/ +- +-EXPECT_WITHIN $PROCESS_DOWN_TIMEOUT "^0$" shd_count +- +-cleanup +diff --git a/tests/volume.rc b/tests/volume.rc +index 6a78c37..022d972 100644 +--- a/tests/volume.rc ++++ b/tests/volume.rc +@@ -913,21 +913,6 @@ function volgen_check_ancestry { + fi + } + +-function get_shd_mux_pid { +- local volume=$1 +- pid=`$CLI volume status $volume shd | awk '/Self-heal/{print $8}'` +- echo $pid +-} +- +-function shd_count { +- ps aux | grep "glustershd" | grep -v grep | wc -l +-} +- +-function number_healer_threads_shd { +- local pid=$(get_shd_mux_pid $1) +- pstack $pid | grep $2 | wc -l +-} +- + function get_mtime { + local time=$(get-mdata-xattr -m $1) + if [ $time == "-1" ]; +-- +1.8.3.1 + diff --git a/0243-Revert-glusterfsd-cleanup-Protect-graph-object-under.patch b/0243-Revert-glusterfsd-cleanup-Protect-graph-object-under.patch new file mode 100644 index 0000000..9e918d7 --- /dev/null +++ b/0243-Revert-glusterfsd-cleanup-Protect-graph-object-under.patch @@ -0,0 +1,154 @@ +From 4d65506ddfa0245dcaa13b14ca13b2ea762df37d Mon Sep 17 00:00:00 2001 +From: Mohammed Rafi KC +Date: Thu, 11 Jul 2019 12:48:51 +0530 +Subject: [PATCH 243/255] Revert "glusterfsd/cleanup: Protect graph object + under a lock" + +This reverts commit 11b64d494c52004002f900888694d20ef8af6df6. + +BUG: 1471742 +Change-Id: I2717207d87ad213722de33c24e451502ed4aff48 +Signed-off-by: Mohammed Rafi KC +Reviewed-on: https://code.engineering.redhat.com/gerrit/175952 +Tested-by: RHGS Build Bot +Reviewed-by: Sunil Kumar Heggodu Gopala Acharya +--- + libglusterfs/src/graph.c | 58 ++++++++++--------------- + libglusterfs/src/statedump.c | 16 ++----- + tests/bugs/glusterd/optimized-basic-testcases.t | 4 +- + 3 files changed, 28 insertions(+), 50 deletions(-) + +diff --git a/libglusterfs/src/graph.c b/libglusterfs/src/graph.c +index 18fb2d9..4c8b02d 100644 +--- a/libglusterfs/src/graph.c ++++ b/libglusterfs/src/graph.c +@@ -1392,12 +1392,8 @@ glusterfs_graph_cleanup(void *arg) + } + pthread_mutex_unlock(&ctx->notify_lock); + +- pthread_mutex_lock(&ctx->cleanup_lock); +- { +- glusterfs_graph_fini(graph); +- glusterfs_graph_destroy(graph); +- } +- pthread_mutex_unlock(&ctx->cleanup_lock); ++ glusterfs_graph_fini(graph); ++ glusterfs_graph_destroy(graph); + out: + return NULL; + } +@@ -1472,37 +1468,31 @@ glusterfs_process_svc_detach(glusterfs_ctx_t *ctx, gf_volfile_t *volfile_obj) + + if (!ctx || !ctx->active || !volfile_obj) + goto out; ++ parent_graph = ctx->active; ++ graph = volfile_obj->graph; ++ if (!graph) ++ goto out; ++ if (graph->first) ++ xl = graph->first; + +- pthread_mutex_lock(&ctx->cleanup_lock); +- { +- parent_graph = ctx->active; +- graph = volfile_obj->graph; +- if (!graph) +- goto unlock; +- if (graph->first) +- xl = graph->first; +- +- last_xl = graph->last_xl; +- if (last_xl) +- last_xl->next = NULL; +- if (!xl || xl->cleanup_starting) +- goto unlock; ++ last_xl = graph->last_xl; ++ if (last_xl) ++ last_xl->next = NULL; ++ if (!xl || xl->cleanup_starting) ++ goto out; + +- xl->cleanup_starting = 1; +- gf_msg("mgmt", GF_LOG_INFO, 0, LG_MSG_GRAPH_DETACH_STARTED, +- "detaching child %s", volfile_obj->vol_id); ++ xl->cleanup_starting = 1; ++ gf_msg("mgmt", GF_LOG_INFO, 0, LG_MSG_GRAPH_DETACH_STARTED, ++ "detaching child %s", volfile_obj->vol_id); + +- list_del_init(&volfile_obj->volfile_list); +- glusterfs_mux_xlator_unlink(parent_graph->top, xl); +- parent_graph->last_xl = glusterfs_get_last_xlator(parent_graph); +- parent_graph->xl_count -= graph->xl_count; +- parent_graph->leaf_count -= graph->leaf_count; +- default_notify(xl, GF_EVENT_PARENT_DOWN, xl); +- parent_graph->id++; +- ret = 0; +- } +-unlock: +- pthread_mutex_unlock(&ctx->cleanup_lock); ++ list_del_init(&volfile_obj->volfile_list); ++ glusterfs_mux_xlator_unlink(parent_graph->top, xl); ++ parent_graph->last_xl = glusterfs_get_last_xlator(parent_graph); ++ parent_graph->xl_count -= graph->xl_count; ++ parent_graph->leaf_count -= graph->leaf_count; ++ default_notify(xl, GF_EVENT_PARENT_DOWN, xl); ++ parent_graph->id++; ++ ret = 0; + out: + if (!ret) { + list_del_init(&volfile_obj->volfile_list); +diff --git a/libglusterfs/src/statedump.c b/libglusterfs/src/statedump.c +index 0d58f8f..0cf80c0 100644 +--- a/libglusterfs/src/statedump.c ++++ b/libglusterfs/src/statedump.c +@@ -805,17 +805,11 @@ gf_proc_dump_info(int signum, glusterfs_ctx_t *ctx) + int brick_count = 0; + int len = 0; + ++ gf_proc_dump_lock(); ++ + if (!ctx) + goto out; + +- /* +- * Multiplexed daemons can change the active graph when attach/detach +- * is called. So this has to be protected with the cleanup lock. +- */ +- if (mgmt_is_multiplexed_daemon(ctx->cmd_args.process_name)) +- pthread_mutex_lock(&ctx->cleanup_lock); +- gf_proc_dump_lock(); +- + if (!mgmt_is_multiplexed_daemon(ctx->cmd_args.process_name) && + (ctx && ctx->active)) { + top = ctx->active->first; +@@ -929,11 +923,7 @@ gf_proc_dump_info(int signum, glusterfs_ctx_t *ctx) + out: + GF_FREE(dump_options.dump_path); + dump_options.dump_path = NULL; +- if (ctx) { +- gf_proc_dump_unlock(); +- if (mgmt_is_multiplexed_daemon(ctx->cmd_args.process_name)) +- pthread_mutex_unlock(&ctx->cleanup_lock); +- } ++ gf_proc_dump_unlock(); + + return; + } +diff --git a/tests/bugs/glusterd/optimized-basic-testcases.t b/tests/bugs/glusterd/optimized-basic-testcases.t +index 110f1b9..d700b5e 100644 +--- a/tests/bugs/glusterd/optimized-basic-testcases.t ++++ b/tests/bugs/glusterd/optimized-basic-testcases.t +@@ -289,9 +289,7 @@ mkdir -p /xyz/var/lib/glusterd/abc + TEST $CLI volume create "test" $H0:/xyz/var/lib/glusterd/abc + EXPECT 'Created' volinfo_field "test" 'Status'; + +-#While taking a statedump, there is a TRY_LOCK on call_frame, which might may cause +-#failure. So Adding a EXPECT_WITHIN +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^1$" generate_statedump_and_check_for_glusterd_info ++EXPECT "1" generate_statedump_and_check_for_glusterd_info + + cleanup_statedump `pidof glusterd` + cleanup +-- +1.8.3.1 + diff --git a/0244-Revert-ec-shd-Cleanup-self-heal-daemon-resources-dur.patch b/0244-Revert-ec-shd-Cleanup-self-heal-daemon-resources-dur.patch new file mode 100644 index 0000000..0888021 --- /dev/null +++ b/0244-Revert-ec-shd-Cleanup-self-heal-daemon-resources-dur.patch @@ -0,0 +1,292 @@ +From f6d967cd70ff41a0f93c54d50128c468e9d5dea9 Mon Sep 17 00:00:00 2001 +From: Mohammed Rafi KC +Date: Thu, 11 Jul 2019 12:49:21 +0530 +Subject: [PATCH 244/255] Revert "ec/shd: Cleanup self heal daemon resources + during ec fini" + +This reverts commit edc238e40060773f5f5fd59fcdad8ae27d65749f. + +BUG: 1471742 +Change-Id: If6cb5941b964f005454a21a67938b354ef1a2037 +Signed-off-by: Mohammed Rafi KC +Reviewed-on: https://code.engineering.redhat.com/gerrit/175953 +Tested-by: RHGS Build Bot +Reviewed-by: Sunil Kumar Heggodu Gopala Acharya +--- + libglusterfs/src/syncop-utils.c | 2 - + xlators/cluster/afr/src/afr-self-heald.c | 5 --- + xlators/cluster/ec/src/ec-heald.c | 77 +++++--------------------------- + xlators/cluster/ec/src/ec-heald.h | 3 -- + xlators/cluster/ec/src/ec-messages.h | 3 +- + xlators/cluster/ec/src/ec.c | 47 ------------------- + 6 files changed, 13 insertions(+), 124 deletions(-) + +diff --git a/libglusterfs/src/syncop-utils.c b/libglusterfs/src/syncop-utils.c +index 4167db4..b842142 100644 +--- a/libglusterfs/src/syncop-utils.c ++++ b/libglusterfs/src/syncop-utils.c +@@ -354,8 +354,6 @@ syncop_mt_dir_scan(call_frame_t *frame, xlator_t *subvol, loc_t *loc, int pid, + + if (frame) { + this = frame->this; +- } else { +- this = THIS; + } + + /*For this functionality to be implemented in general, we need +diff --git a/xlators/cluster/afr/src/afr-self-heald.c b/xlators/cluster/afr/src/afr-self-heald.c +index 522fe5d..8bc4720 100644 +--- a/xlators/cluster/afr/src/afr-self-heald.c ++++ b/xlators/cluster/afr/src/afr-self-heald.c +@@ -524,11 +524,6 @@ afr_shd_full_heal(xlator_t *subvol, gf_dirent_t *entry, loc_t *parent, + afr_private_t *priv = NULL; + + priv = this->private; +- +- if (this->cleanup_starting) { +- return -ENOTCONN; +- } +- + if (!priv->shd.enabled) + return -EBUSY; + +diff --git a/xlators/cluster/ec/src/ec-heald.c b/xlators/cluster/ec/src/ec-heald.c +index edf5e11..cba111a 100644 +--- a/xlators/cluster/ec/src/ec-heald.c ++++ b/xlators/cluster/ec/src/ec-heald.c +@@ -71,11 +71,6 @@ disabled_loop: + break; + } + +- if (ec->shutdown) { +- healer->running = _gf_false; +- return -1; +- } +- + ret = healer->rerun; + healer->rerun = 0; + +@@ -246,11 +241,9 @@ ec_shd_index_sweep(struct subvol_healer *healer) + goto out; + } + +- _mask_cancellation(); + ret = syncop_mt_dir_scan(NULL, subvol, &loc, GF_CLIENT_PID_SELF_HEALD, + healer, ec_shd_index_heal, xdata, + ec->shd.max_threads, ec->shd.wait_qlength); +- _unmask_cancellation(); + out: + if (xdata) + dict_unref(xdata); +@@ -270,11 +263,6 @@ ec_shd_full_heal(xlator_t *subvol, gf_dirent_t *entry, loc_t *parent, + int ret = 0; + + ec = this->private; +- +- if (this->cleanup_starting) { +- return -ENOTCONN; +- } +- + if (ec->xl_up_count <= ec->fragments) { + return -ENOTCONN; + } +@@ -317,15 +305,11 @@ ec_shd_full_sweep(struct subvol_healer *healer, inode_t *inode) + { + ec_t *ec = NULL; + loc_t loc = {0}; +- int ret = -1; + + ec = healer->this->private; + loc.inode = inode; +- _mask_cancellation(); +- ret = syncop_ftw(ec->xl_list[healer->subvol], &loc, +- GF_CLIENT_PID_SELF_HEALD, healer, ec_shd_full_heal); +- _unmask_cancellation(); +- return ret; ++ return syncop_ftw(ec->xl_list[healer->subvol], &loc, ++ GF_CLIENT_PID_SELF_HEALD, healer, ec_shd_full_heal); + } + + void * +@@ -333,16 +317,13 @@ ec_shd_index_healer(void *data) + { + struct subvol_healer *healer = NULL; + xlator_t *this = NULL; +- int run = 0; + + healer = data; + THIS = this = healer->this; + ec_t *ec = this->private; + + for (;;) { +- run = ec_shd_healer_wait(healer); +- if (run == -1) +- break; ++ ec_shd_healer_wait(healer); + + if (ec->xl_up_count > ec->fragments) { + gf_msg_debug(this->name, 0, "starting index sweep on subvol %s", +@@ -371,12 +352,16 @@ ec_shd_full_healer(void *data) + + rootloc.inode = this->itable->root; + for (;;) { +- run = ec_shd_healer_wait(healer); +- if (run < 0) { +- break; +- } else if (run == 0) { +- continue; ++ pthread_mutex_lock(&healer->mutex); ++ { ++ run = __ec_shd_healer_wait(healer); ++ if (!run) ++ healer->running = _gf_false; + } ++ pthread_mutex_unlock(&healer->mutex); ++ ++ if (!run) ++ break; + + if (ec->xl_up_count > ec->fragments) { + gf_msg(this->name, GF_LOG_INFO, 0, EC_MSG_FULL_SWEEP_START, +@@ -577,41 +562,3 @@ out: + dict_del(output, this->name); + return ret; + } +- +-void +-ec_destroy_healer_object(xlator_t *this, struct subvol_healer *healer) +-{ +- if (!healer) +- return; +- +- pthread_cond_destroy(&healer->cond); +- pthread_mutex_destroy(&healer->mutex); +-} +- +-void +-ec_selfheal_daemon_fini(xlator_t *this) +-{ +- struct subvol_healer *healer = NULL; +- ec_self_heald_t *shd = NULL; +- ec_t *priv = NULL; +- int i = 0; +- +- priv = this->private; +- if (!priv) +- return; +- +- shd = &priv->shd; +- if (!shd->iamshd) +- return; +- +- for (i = 0; i < priv->nodes; i++) { +- healer = &shd->index_healers[i]; +- ec_destroy_healer_object(this, healer); +- +- healer = &shd->full_healers[i]; +- ec_destroy_healer_object(this, healer); +- } +- +- GF_FREE(shd->index_healers); +- GF_FREE(shd->full_healers); +-} +diff --git a/xlators/cluster/ec/src/ec-heald.h b/xlators/cluster/ec/src/ec-heald.h +index 8184cf4..2eda2a7 100644 +--- a/xlators/cluster/ec/src/ec-heald.h ++++ b/xlators/cluster/ec/src/ec-heald.h +@@ -24,7 +24,4 @@ ec_selfheal_daemon_init(xlator_t *this); + void + ec_shd_index_healer_wake(ec_t *ec); + +-void +-ec_selfheal_daemon_fini(xlator_t *this); +- + #endif /* __EC_HEALD_H__ */ +diff --git a/xlators/cluster/ec/src/ec-messages.h b/xlators/cluster/ec/src/ec-messages.h +index ce299bb..7c28808 100644 +--- a/xlators/cluster/ec/src/ec-messages.h ++++ b/xlators/cluster/ec/src/ec-messages.h +@@ -55,7 +55,6 @@ GLFS_MSGID(EC, EC_MSG_INVALID_CONFIG, EC_MSG_HEAL_FAIL, + EC_MSG_CONFIG_XATTR_INVALID, EC_MSG_EXTENSION, EC_MSG_EXTENSION_NONE, + EC_MSG_EXTENSION_UNKNOWN, EC_MSG_EXTENSION_UNSUPPORTED, + EC_MSG_EXTENSION_FAILED, EC_MSG_NO_GF, EC_MSG_MATRIX_FAILED, +- EC_MSG_DYN_CREATE_FAILED, EC_MSG_DYN_CODEGEN_FAILED, +- EC_MSG_THREAD_CLEANUP_FAILED); ++ EC_MSG_DYN_CREATE_FAILED, EC_MSG_DYN_CODEGEN_FAILED); + + #endif /* !_EC_MESSAGES_H_ */ +diff --git a/xlators/cluster/ec/src/ec.c b/xlators/cluster/ec/src/ec.c +index 264582a..3c8013e 100644 +--- a/xlators/cluster/ec/src/ec.c ++++ b/xlators/cluster/ec/src/ec.c +@@ -429,51 +429,6 @@ ec_disable_delays(ec_t *ec) + } + + void +-ec_cleanup_healer_object(ec_t *ec) +-{ +- struct subvol_healer *healer = NULL; +- ec_self_heald_t *shd = NULL; +- void *res = NULL; +- int i = 0; +- gf_boolean_t is_join = _gf_false; +- +- shd = &ec->shd; +- if (!shd->iamshd) +- return; +- +- for (i = 0; i < ec->nodes; i++) { +- healer = &shd->index_healers[i]; +- pthread_mutex_lock(&healer->mutex); +- { +- healer->rerun = 1; +- if (healer->running) { +- pthread_cond_signal(&healer->cond); +- is_join = _gf_true; +- } +- } +- pthread_mutex_unlock(&healer->mutex); +- if (is_join) { +- pthread_join(healer->thread, &res); +- is_join = _gf_false; +- } +- +- healer = &shd->full_healers[i]; +- pthread_mutex_lock(&healer->mutex); +- { +- healer->rerun = 1; +- if (healer->running) { +- pthread_cond_signal(&healer->cond); +- is_join = _gf_true; +- } +- } +- pthread_mutex_unlock(&healer->mutex); +- if (is_join) { +- pthread_join(healer->thread, &res); +- is_join = _gf_false; +- } +- } +-} +-void + ec_pending_fops_completed(ec_t *ec) + { + if (ec->shutdown) { +@@ -589,7 +544,6 @@ ec_notify(xlator_t *this, int32_t event, void *data, void *data2) + /* If there aren't pending fops running after we have waken up + * them, we immediately propagate the notification. */ + propagate = ec_disable_delays(ec); +- ec_cleanup_healer_object(ec); + goto unlock; + } + +@@ -805,7 +759,6 @@ failed: + void + fini(xlator_t *this) + { +- ec_selfheal_daemon_fini(this); + __ec_destroy_private(this); + } + +-- +1.8.3.1 + diff --git a/0245-Revert-shd-glusterd-Serialize-shd-manager-to-prevent.patch b/0245-Revert-shd-glusterd-Serialize-shd-manager-to-prevent.patch new file mode 100644 index 0000000..6495e38 --- /dev/null +++ b/0245-Revert-shd-glusterd-Serialize-shd-manager-to-prevent.patch @@ -0,0 +1,151 @@ +From 022701465f3e642cdb7942995647615baa266a35 Mon Sep 17 00:00:00 2001 +From: Mohammed Rafi KC +Date: Thu, 11 Jul 2019 12:49:31 +0530 +Subject: [PATCH 245/255] Revert "shd/glusterd: Serialize shd manager to + prevent race condition" + +This reverts commit 646292b4f73bf1b506d034b85787f794963d7196. + +BUG: 1471742 +Change-Id: Ie21fbe18965d8bdea81f4276b57960a27a4db89d +Signed-off-by: Mohammed Rafi KC +Reviewed-on: https://code.engineering.redhat.com/gerrit/175954 +Tested-by: RHGS Build Bot +Reviewed-by: Sunil Kumar Heggodu Gopala Acharya +--- + .../serialize-shd-manager-glusterd-restart.t | 54 ---------------------- + xlators/mgmt/glusterd/src/glusterd-shd-svc.c | 14 ------ + xlators/mgmt/glusterd/src/glusterd.c | 1 - + xlators/mgmt/glusterd/src/glusterd.h | 3 -- + 4 files changed, 72 deletions(-) + delete mode 100644 tests/bugs/glusterd/serialize-shd-manager-glusterd-restart.t + +diff --git a/tests/bugs/glusterd/serialize-shd-manager-glusterd-restart.t b/tests/bugs/glusterd/serialize-shd-manager-glusterd-restart.t +deleted file mode 100644 +index 3a27c2a..0000000 +--- a/tests/bugs/glusterd/serialize-shd-manager-glusterd-restart.t ++++ /dev/null +@@ -1,54 +0,0 @@ +-#! /bin/bash +- +-. $(dirname $0)/../../include.rc +-. $(dirname $0)/../../cluster.rc +- +-function check_peers { +-count=`$CLI_1 peer status | grep 'Peer in Cluster (Connected)' | wc -l` +-echo $count +-} +- +-function check_shd { +-ps aux | grep $1 | grep glustershd | wc -l +-} +- +-cleanup +- +- +-TEST launch_cluster 6 +- +-TESTS_EXPECTED_IN_LOOP=25 +-for i in $(seq 2 6); do +- hostname="H$i" +- TEST $CLI_1 peer probe ${!hostname} +-done +- +- +-EXPECT_WITHIN $PROBE_TIMEOUT 5 check_peers; +-for i in $(seq 1 5); do +- +- TEST $CLI_1 volume create ${V0}_$i replica 3 $H1:$B1/${V0}_$i $H2:$B2/${V0}_$i $H3:$B3/${V0}_$i $H4:$B4/${V0}_$i $H5:$B5/${V0}_$i $H6:$B6/${V0}_$i +- TEST $CLI_1 volume start ${V0}_$i force +- +-done +- +-#kill a node +-TEST kill_node 3 +- +-TEST $glusterd_3; +-EXPECT_WITHIN $PROBE_TIMEOUT 5 check_peers +- +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT 1 check_shd $H3 +- +-for i in $(seq 1 5); do +- +- TEST $CLI_1 volume stop ${V0}_$i +- TEST $CLI_1 volume delete ${V0}_$i +- +-done +- +-for i in $(seq 1 6); do +- hostname="H$i" +- EXPECT_WITHIN $PROCESS_DOWN_TIMEOUT 0 check_shd ${!hostname} +-done +-cleanup +diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c +index 75f9a07..a9eab42 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c ++++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c +@@ -254,26 +254,14 @@ glusterd_shdsvc_manager(glusterd_svc_t *svc, void *data, int flags) + { + int ret = -1; + glusterd_volinfo_t *volinfo = NULL; +- glusterd_conf_t *conf = NULL; +- gf_boolean_t shd_restart = _gf_false; + +- conf = THIS->private; + volinfo = data; +- GF_VALIDATE_OR_GOTO("glusterd", conf, out); + GF_VALIDATE_OR_GOTO("glusterd", svc, out); + GF_VALIDATE_OR_GOTO("glusterd", volinfo, out); + + if (volinfo) + glusterd_volinfo_ref(volinfo); + +- while (conf->restart_shd) { +- synclock_unlock(&conf->big_lock); +- sleep(2); +- synclock_lock(&conf->big_lock); +- } +- conf->restart_shd = _gf_true; +- shd_restart = _gf_true; +- + ret = glusterd_shdsvc_create_volfile(volinfo); + if (ret) + goto out; +@@ -322,8 +310,6 @@ glusterd_shdsvc_manager(glusterd_svc_t *svc, void *data, int flags) + } + } + out: +- if (shd_restart) +- conf->restart_shd = _gf_false; + if (volinfo) + glusterd_volinfo_unref(volinfo); + if (ret) +diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c +index 6d7dd4a..c0973cb 100644 +--- a/xlators/mgmt/glusterd/src/glusterd.c ++++ b/xlators/mgmt/glusterd/src/glusterd.c +@@ -1819,7 +1819,6 @@ init(xlator_t *this) + conf->rpc = rpc; + conf->uds_rpc = uds_rpc; + conf->gfs_mgmt = &gd_brick_prog; +- conf->restart_shd = _gf_false; + this->private = conf; + /* conf->workdir and conf->rundir are smaller than PATH_MAX; gcc's + * snprintf checking will throw an error here if sprintf is used. +diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h +index 7d07d33..0fbc9dd 100644 +--- a/xlators/mgmt/glusterd/src/glusterd.h ++++ b/xlators/mgmt/glusterd/src/glusterd.h +@@ -222,9 +222,6 @@ typedef struct { + gf_atomic_t blockers; + uint32_t mgmt_v3_lock_timeout; + gf_boolean_t restart_bricks; +- gf_boolean_t restart_shd; /* This flag prevents running two shd manager +- simultaneously +- */ + pthread_mutex_t attach_lock; /* Lock can be per process or a common one */ + pthread_mutex_t volume_lock; /* We release the big_lock from lot of places + which might lead the modification of volinfo +-- +1.8.3.1 + diff --git a/0246-Revert-glusterd-shd-Keep-a-ref-on-volinfo-until-atta.patch b/0246-Revert-glusterd-shd-Keep-a-ref-on-volinfo-until-atta.patch new file mode 100644 index 0000000..bbc780c --- /dev/null +++ b/0246-Revert-glusterd-shd-Keep-a-ref-on-volinfo-until-atta.patch @@ -0,0 +1,53 @@ +From bc5e3967864d6f6ea22deb22ba72aedca8367797 Mon Sep 17 00:00:00 2001 +From: Mohammed Rafi KC +Date: Thu, 11 Jul 2019 12:49:41 +0530 +Subject: [PATCH 246/255] Revert "glusterd/shd: Keep a ref on volinfo until + attach rpc execute cbk" + +This reverts commit c429d3c63601e6ea15af76aa684c30bbeb746467. + +BUG: 1471742 +Change-Id: I614e8bdbcc5111dbf407aba047e7d2284bef8ac8 +Signed-off-by: Mohammed Rafi KC +Reviewed-on: https://code.engineering.redhat.com/gerrit/175955 +Tested-by: RHGS Build Bot +Reviewed-by: Sunil Kumar Heggodu Gopala Acharya +--- + xlators/mgmt/glusterd/src/glusterd-shd-svc.c | 3 --- + xlators/mgmt/glusterd/src/glusterd-svc-helper.c | 4 ---- + 2 files changed, 7 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c +index a9eab42..19eca9f 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c ++++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c +@@ -452,11 +452,8 @@ glusterd_shdsvc_start(glusterd_svc_t *svc, int flags) + } + + if (shd->attached) { +- glusterd_volinfo_ref(volinfo); +- /* Unref will happen from glusterd_svc_attach_cbk */ + ret = glusterd_attach_svc(svc, volinfo, flags); + if (ret) { +- glusterd_volinfo_unref(volinfo); + gf_msg("glusterd", GF_LOG_ERROR, 0, GD_MSG_VOLINFO_GET_FAIL, + "Failed to attach shd svc(volume=%s) to pid=%d. Starting" + "a new process", +diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c +index f7be394..02945b1 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c ++++ b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c +@@ -695,10 +695,6 @@ out: + if (flag) { + GF_FREE(flag); + } +- +- if (volinfo) +- glusterd_volinfo_unref(volinfo); +- + GF_ATOMIC_DEC(conf->blockers); + STACK_DESTROY(frame->root); + return 0; +-- +1.8.3.1 + diff --git a/0247-Revert-afr-shd-Cleanup-self-heal-daemon-resources-du.patch b/0247-Revert-afr-shd-Cleanup-self-heal-daemon-resources-du.patch new file mode 100644 index 0000000..dc17d72 --- /dev/null +++ b/0247-Revert-afr-shd-Cleanup-self-heal-daemon-resources-du.patch @@ -0,0 +1,144 @@ +From 33d59c74169192b4ba89abc915d8d785bc450fbb Mon Sep 17 00:00:00 2001 +From: Mohammed Rafi KC +Date: Thu, 11 Jul 2019 12:49:54 +0530 +Subject: [PATCH 247/255] Revert "afr/shd: Cleanup self heal daemon resources + during afr fini" + +This reverts commit faaaa3452ceec6afcc18cffc9beca3fe19841cce. + +BUG: 1471742 +Change-Id: Id4a22ab45b89872684830f866ec4b589fca50a90 +Signed-off-by: Mohammed Rafi KC +Reviewed-on: https://code.engineering.redhat.com/gerrit/175956 +Tested-by: RHGS Build Bot +Reviewed-by: Sunil Kumar Heggodu Gopala Acharya +--- + libglusterfs/src/syncop-utils.c | 8 ----- + xlators/cluster/afr/src/afr-self-heald.c | 2 -- + xlators/cluster/afr/src/afr.c | 57 -------------------------------- + 3 files changed, 67 deletions(-) + +diff --git a/libglusterfs/src/syncop-utils.c b/libglusterfs/src/syncop-utils.c +index b842142..be03527 100644 +--- a/libglusterfs/src/syncop-utils.c ++++ b/libglusterfs/src/syncop-utils.c +@@ -350,11 +350,6 @@ syncop_mt_dir_scan(call_frame_t *frame, xlator_t *subvol, loc_t *loc, int pid, + gf_boolean_t cond_init = _gf_false; + gf_boolean_t mut_init = _gf_false; + gf_dirent_t entries; +- xlator_t *this = NULL; +- +- if (frame) { +- this = frame->this; +- } + + /*For this functionality to be implemented in general, we need + * synccond_t infra which doesn't block the executing thread. Until then +@@ -402,9 +397,6 @@ syncop_mt_dir_scan(call_frame_t *frame, xlator_t *subvol, loc_t *loc, int pid, + + list_for_each_entry_safe(entry, tmp, &entries.list, list) + { +- if (this && this->cleanup_starting) +- goto out; +- + list_del_init(&entry->list); + if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, "..")) { + gf_dirent_entry_free(entry); +diff --git a/xlators/cluster/afr/src/afr-self-heald.c b/xlators/cluster/afr/src/afr-self-heald.c +index 8bc4720..7eb1207 100644 +--- a/xlators/cluster/afr/src/afr-self-heald.c ++++ b/xlators/cluster/afr/src/afr-self-heald.c +@@ -373,7 +373,6 @@ afr_shd_sweep_prepare(struct subvol_healer *healer) + + time(&event->start_time); + event->end_time = 0; +- _mask_cancellation(); + } + + void +@@ -395,7 +394,6 @@ afr_shd_sweep_done(struct subvol_healer *healer) + + if (eh_save_history(shd->statistics[healer->subvol], history) < 0) + GF_FREE(history); +- _unmask_cancellation(); + } + + int +diff --git a/xlators/cluster/afr/src/afr.c b/xlators/cluster/afr/src/afr.c +index a0a7551..33258a0 100644 +--- a/xlators/cluster/afr/src/afr.c ++++ b/xlators/cluster/afr/src/afr.c +@@ -611,70 +611,13 @@ init(xlator_t *this) + out: + return ret; + } +-void +-afr_destroy_healer_object(xlator_t *this, struct subvol_healer *healer) +-{ +- int ret = -1; +- +- if (!healer) +- return; +- +- if (healer->running) { +- /* +- * If there are any resources to cleanup, We need +- * to do that gracefully using pthread_cleanup_push +- */ +- ret = gf_thread_cleanup_xint(healer->thread); +- if (ret) +- gf_msg(this->name, GF_LOG_WARNING, 0, AFR_MSG_SELF_HEAL_FAILED, +- "Failed to clean up healer threads."); +- healer->thread = 0; +- } +- pthread_cond_destroy(&healer->cond); +- pthread_mutex_destroy(&healer->mutex); +-} +- +-void +-afr_selfheal_daemon_fini(xlator_t *this) +-{ +- struct subvol_healer *healer = NULL; +- afr_self_heald_t *shd = NULL; +- afr_private_t *priv = NULL; +- int i = 0; +- +- priv = this->private; +- if (!priv) +- return; +- +- shd = &priv->shd; +- if (!shd->iamshd) +- return; +- +- for (i = 0; i < priv->child_count; i++) { +- healer = &shd->index_healers[i]; +- afr_destroy_healer_object(this, healer); + +- healer = &shd->full_healers[i]; +- afr_destroy_healer_object(this, healer); +- +- if (shd->statistics[i]) +- eh_destroy(shd->statistics[i]); +- } +- GF_FREE(shd->index_healers); +- GF_FREE(shd->full_healers); +- GF_FREE(shd->statistics); +- if (shd->split_brain) +- eh_destroy(shd->split_brain); +-} + void + fini(xlator_t *this) + { + afr_private_t *priv = NULL; + + priv = this->private; +- +- afr_selfheal_daemon_fini(this); +- + LOCK(&priv->lock); + if (priv->timer != NULL) { + gf_timer_call_cancel(this->ctx, priv->timer); +-- +1.8.3.1 + diff --git a/0248-Revert-shd-mux-Fix-coverity-issues-introduced-by-shd.patch b/0248-Revert-shd-mux-Fix-coverity-issues-introduced-by-shd.patch new file mode 100644 index 0000000..d721a82 --- /dev/null +++ b/0248-Revert-shd-mux-Fix-coverity-issues-introduced-by-shd.patch @@ -0,0 +1,151 @@ +From 469cb9e16d46f075caf609ddcb12a7c02d73ce8b Mon Sep 17 00:00:00 2001 +From: Mohammed Rafi KC +Date: Thu, 11 Jul 2019 12:50:24 +0530 +Subject: [PATCH 248/255] Revert "shd/mux: Fix coverity issues introduced by + shd mux patch" + +This reverts commit 0021a4bbc9af2bfe28d4a79f76c3cd33f23dd118. + +BUG: 1471742 +Change-Id: I0749328412ed3cc7ae5d64baea7a90b63b489a08 +Signed-off-by: Mohammed Rafi KC +Reviewed-on: https://code.engineering.redhat.com/gerrit/175957 +Tested-by: RHGS Build Bot +Reviewed-by: Sunil Kumar Heggodu Gopala Acharya +--- + libglusterfs/src/graph.c | 21 ++++++++------------- + xlators/mgmt/glusterd/src/glusterd-shd-svc.c | 6 ------ + xlators/mgmt/glusterd/src/glusterd-svc-helper.c | 24 +++++++----------------- + 3 files changed, 15 insertions(+), 36 deletions(-) + +diff --git a/libglusterfs/src/graph.c b/libglusterfs/src/graph.c +index 4c8b02d..a492dd8 100644 +--- a/libglusterfs/src/graph.c ++++ b/libglusterfs/src/graph.c +@@ -1470,9 +1470,7 @@ glusterfs_process_svc_detach(glusterfs_ctx_t *ctx, gf_volfile_t *volfile_obj) + goto out; + parent_graph = ctx->active; + graph = volfile_obj->graph; +- if (!graph) +- goto out; +- if (graph->first) ++ if (graph && graph->first) + xl = graph->first; + + last_xl = graph->last_xl; +@@ -1593,10 +1591,12 @@ glusterfs_process_svc_attach_volfp(glusterfs_ctx_t *ctx, FILE *fp, + parent_graph->leaf_count += graph->leaf_count; + parent_graph->id++; + +- volfile_obj = GF_CALLOC(1, sizeof(gf_volfile_t), gf_common_volfile_t); + if (!volfile_obj) { +- ret = -1; +- goto out; ++ volfile_obj = GF_CALLOC(1, sizeof(gf_volfile_t), gf_common_volfile_t); ++ if (!volfile_obj) { ++ ret = -1; ++ goto out; ++ } + } + + graph->used = 1; +@@ -1641,7 +1641,6 @@ glusterfs_mux_volfile_reconfigure(FILE *newvolfile_fp, glusterfs_ctx_t *ctx, + { + glusterfs_graph_t *oldvolfile_graph = NULL; + glusterfs_graph_t *newvolfile_graph = NULL; +- char vol_id[NAME_MAX + 1]; + + int ret = -1; + +@@ -1673,9 +1672,6 @@ glusterfs_mux_volfile_reconfigure(FILE *newvolfile_fp, glusterfs_ctx_t *ctx, + glusterfs_graph_prepare(newvolfile_graph, ctx, newvolfile_graph->first); + + if (!is_graph_topology_equal(oldvolfile_graph, newvolfile_graph)) { +- ret = snprintf(vol_id, sizeof(vol_id), "%s", volfile_obj->vol_id); +- if (ret < 0) +- goto out; + ret = glusterfs_process_svc_detach(ctx, volfile_obj); + if (ret) { + gf_msg("glusterfsd-mgmt", GF_LOG_ERROR, EINVAL, +@@ -1684,9 +1680,8 @@ glusterfs_mux_volfile_reconfigure(FILE *newvolfile_fp, glusterfs_ctx_t *ctx, + "old graph. Aborting the reconfiguration operation"); + goto out; + } +- volfile_obj = NULL; +- ret = glusterfs_process_svc_attach_volfp(ctx, newvolfile_fp, vol_id, +- checksum); ++ ret = glusterfs_process_svc_attach_volfp(ctx, newvolfile_fp, ++ volfile_obj->vol_id, checksum); + goto out; + } + +diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c +index 19eca9f..4789843 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c ++++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c +@@ -101,8 +101,6 @@ glusterd_shdsvc_init(void *data, glusterd_conn_t *mux_conn, + svc->conn.rpc = rpc_clnt_ref(mux_svc->rpc); + ret = snprintf(svc->conn.sockpath, sizeof(svc->conn.sockpath), "%s", + mux_conn->sockpath); +- if (ret < 0) +- goto out; + } else { + ret = mkdir_p(logdir, 0755, _gf_true); + if ((ret == -1) && (EEXIST != errno)) { +@@ -675,10 +673,6 @@ glusterd_shdsvc_stop(glusterd_svc_t *svc, int sig) + glusterd_volinfo_ref(volinfo); + svc_proc->data = volinfo; + ret = glusterd_svc_stop(svc, sig); +- if (ret) { +- glusterd_volinfo_unref(volinfo); +- goto out; +- } + } + if (!empty && pid != -1) { + ret = glusterd_detach_svc(svc, volinfo, sig); +diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c +index 02945b1..e42703c 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c ++++ b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c +@@ -411,14 +411,9 @@ __gf_find_compatible_svc(gd_node_type daemon) + conf = THIS->private; + GF_VALIDATE_OR_GOTO("glusterd", conf, out); + +- switch (daemon) { +- case GD_NODE_SHD: { +- svc_procs = &conf->shd_procs; +- if (!svc_procs) +- goto out; +- } break; +- default: +- /* Add support for other client daemons here */ ++ if (daemon == GD_NODE_SHD) { ++ svc_procs = &conf->shd_procs; ++ if (!svc_procs) + goto out; + } + +@@ -545,16 +540,11 @@ __gf_find_compatible_svc_from_pid(gd_node_type daemon, pid_t pid) + if (!conf) + return NULL; + +- switch (daemon) { +- case GD_NODE_SHD: { +- svc_procs = &conf->shd_procs; +- if (!svc_procs) +- return NULL; +- } break; +- default: +- /* Add support for other client daemons here */ ++ if (daemon == GD_NODE_SHD) { ++ svc_procs = &conf->shd_procs; ++ if (!svc_proc) + return NULL; +- } ++ } /* Can be moved to switch when mux is implemented for other daemon; */ + + cds_list_for_each_entry(svc_proc, svc_procs, svc_proc_list) + { +-- +1.8.3.1 + diff --git a/0249-Revert-client-fini-return-fini-after-rpc-cleanup.patch b/0249-Revert-client-fini-return-fini-after-rpc-cleanup.patch new file mode 100644 index 0000000..5547257 --- /dev/null +++ b/0249-Revert-client-fini-return-fini-after-rpc-cleanup.patch @@ -0,0 +1,95 @@ +From 1864a4f382f3031915e8126440a1561035487e49 Mon Sep 17 00:00:00 2001 +From: Mohammed Rafi KC +Date: Thu, 11 Jul 2019 12:53:20 +0530 +Subject: [PATCH 249/255] Revert "client/fini: return fini after rpc cleanup" + +This reverts commit d79cb2cdff6fe8d962c9ac095a7541ddf500302b. + +BUG: 1471742 +Change-Id: I15e6544d47fb7b6002c3b44de3fe0b2a13c84f51 +Signed-off-by: Mohammed Rafi KC +Reviewed-on: https://code.engineering.redhat.com/gerrit/175958 +Tested-by: RHGS Build Bot +Reviewed-by: Sunil Kumar Heggodu Gopala Acharya +--- + xlators/protocol/client/src/client.c | 25 +++++-------------------- + xlators/protocol/client/src/client.h | 6 ------ + 2 files changed, 5 insertions(+), 26 deletions(-) + +diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c +index 95e4be5..532ef35 100644 +--- a/xlators/protocol/client/src/client.c ++++ b/xlators/protocol/client/src/client.c +@@ -49,12 +49,11 @@ client_fini_complete(xlator_t *this) + if (!conf->destroy) + return 0; + +- pthread_mutex_lock(&conf->lock); +- { +- conf->fini_completed = _gf_true; +- pthread_cond_broadcast(&conf->fini_complete_cond); +- } +- pthread_mutex_unlock(&conf->lock); ++ this->private = NULL; ++ ++ pthread_spin_destroy(&conf->fd_lock); ++ pthread_mutex_destroy(&conf->lock); ++ GF_FREE(conf); + + out: + return 0; +@@ -2730,7 +2729,6 @@ init(xlator_t *this) + goto out; + + pthread_mutex_init(&conf->lock, NULL); +- pthread_cond_init(&conf->fini_complete_cond, NULL); + pthread_spin_init(&conf->fd_lock, 0); + INIT_LIST_HEAD(&conf->saved_fds); + +@@ -2789,7 +2787,6 @@ fini(xlator_t *this) + if (!conf) + return; + +- conf->fini_completed = _gf_false; + conf->destroy = 1; + if (conf->rpc) { + /* cleanup the saved-frames before last unref */ +@@ -2797,18 +2794,6 @@ fini(xlator_t *this) + rpc_clnt_unref(conf->rpc); + } + +- pthread_mutex_lock(&conf->lock); +- { +- while (!conf->fini_completed) +- pthread_cond_wait(&conf->fini_complete_cond, &conf->lock); +- } +- pthread_mutex_unlock(&conf->lock); +- +- pthread_spin_destroy(&conf->fd_lock); +- pthread_mutex_destroy(&conf->lock); +- pthread_cond_destroy(&conf->fini_complete_cond); +- GF_FREE(conf); +- + /* Saved Fds */ + /* TODO: */ + +diff --git a/xlators/protocol/client/src/client.h b/xlators/protocol/client/src/client.h +index 8dcd72f..f12fa61 100644 +--- a/xlators/protocol/client/src/client.h ++++ b/xlators/protocol/client/src/client.h +@@ -235,12 +235,6 @@ typedef struct clnt_conf { + * up, disconnects can be + * logged + */ +- +- gf_boolean_t old_protocol; /* used only for old-protocol testing */ +- pthread_cond_t fini_complete_cond; /* Used to wait till we finsh the fini +- compltely, ie client_fini_complete +- to return*/ +- gf_boolean_t fini_completed; + } clnt_conf_t; + + typedef struct _client_fd_ctx { +-- +1.8.3.1 + diff --git a/0250-Revert-mgmt-shd-Implement-multiplexing-in-self-heal-.patch b/0250-Revert-mgmt-shd-Implement-multiplexing-in-self-heal-.patch new file mode 100644 index 0000000..637a16a --- /dev/null +++ b/0250-Revert-mgmt-shd-Implement-multiplexing-in-self-heal-.patch @@ -0,0 +1,4572 @@ +From ec629963d61c3ec084c95366eec5ee3a976b1213 Mon Sep 17 00:00:00 2001 +From: Mohammed Rafi KC +Date: Thu, 11 Jul 2019 12:57:45 +0530 +Subject: [PATCH 250/255] Revert "mgmt/shd: Implement multiplexing in self heal + daemon" + +This reverts commit 2cede2b87fb3e3e0673be9cf67e7d6eec3f7879c. + +BUG: 1471742 +Change-Id: I3830d9189dfdb567a44935aa97dc963f4594dfdb +fixes: bz#1471742 +Signed-off-by: Mohammed Rafi KC +Reviewed-on: https://code.engineering.redhat.com/gerrit/175959 +Tested-by: RHGS Build Bot +Reviewed-by: Sunil Kumar Heggodu Gopala Acharya +--- + glusterfsd/src/glusterfsd-messages.h | 2 +- + glusterfsd/src/glusterfsd-mgmt.c | 238 +------ + glusterfsd/src/glusterfsd.c | 20 +- + libglusterfs/src/defaults-tmpl.c | 19 +- + libglusterfs/src/glusterfs/glusterfs.h | 7 - + libglusterfs/src/glusterfs/libglusterfs-messages.h | 4 +- + libglusterfs/src/glusterfs/xlator.h | 3 - + libglusterfs/src/graph.c | 451 ------------- + libglusterfs/src/graph.y | 3 - + libglusterfs/src/libglusterfs.sym | 5 - + libglusterfs/src/statedump.c | 3 +- + libglusterfs/src/xlator.c | 16 - + rpc/rpc-lib/src/protocol-common.h | 2 - + tests/basic/glusterd/heald.t | 49 +- + .../reset-brick-and-daemons-follow-quorum.t | 8 +- + tests/volume.rc | 6 +- + xlators/mgmt/glusterd/src/Makefile.am | 6 +- + xlators/mgmt/glusterd/src/glusterd-brick-ops.c | 2 +- + xlators/mgmt/glusterd/src/glusterd-conn-mgmt.c | 42 -- + xlators/mgmt/glusterd/src/glusterd-conn-mgmt.h | 4 +- + xlators/mgmt/glusterd/src/glusterd-gfproxyd-svc.c | 3 +- + xlators/mgmt/glusterd/src/glusterd-handler.c | 11 +- + xlators/mgmt/glusterd/src/glusterd-handshake.c | 21 - + xlators/mgmt/glusterd/src/glusterd-mem-types.h | 1 - + xlators/mgmt/glusterd/src/glusterd-messages.h | 4 +- + xlators/mgmt/glusterd/src/glusterd-op-sm.c | 84 +-- + .../mgmt/glusterd/src/glusterd-shd-svc-helper.c | 140 ---- + .../mgmt/glusterd/src/glusterd-shd-svc-helper.h | 45 -- + xlators/mgmt/glusterd/src/glusterd-shd-svc.c | 540 ++-------------- + xlators/mgmt/glusterd/src/glusterd-shd-svc.h | 17 +- + xlators/mgmt/glusterd/src/glusterd-sm.c | 12 +- + xlators/mgmt/glusterd/src/glusterd-snapd-svc.c | 3 +- + xlators/mgmt/glusterd/src/glusterd-statedump.c | 3 + + xlators/mgmt/glusterd/src/glusterd-svc-helper.c | 715 +-------------------- + xlators/mgmt/glusterd/src/glusterd-svc-helper.h | 40 +- + xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c | 246 ++----- + xlators/mgmt/glusterd/src/glusterd-svc-mgmt.h | 27 - + xlators/mgmt/glusterd/src/glusterd-tier.c | 3 +- + xlators/mgmt/glusterd/src/glusterd-tierd-svc.c | 4 +- + xlators/mgmt/glusterd/src/glusterd-utils.c | 137 +--- + xlators/mgmt/glusterd/src/glusterd-utils.h | 4 - + xlators/mgmt/glusterd/src/glusterd-volgen.c | 60 +- + xlators/mgmt/glusterd/src/glusterd-volgen.h | 11 +- + xlators/mgmt/glusterd/src/glusterd-volume-ops.c | 8 +- + xlators/mgmt/glusterd/src/glusterd.c | 12 +- + xlators/mgmt/glusterd/src/glusterd.h | 30 +- + xlators/protocol/client/src/client.c | 31 +- + 47 files changed, 292 insertions(+), 2810 deletions(-) + delete mode 100644 xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.c + delete mode 100644 xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.h + +diff --git a/glusterfsd/src/glusterfsd-messages.h b/glusterfsd/src/glusterfsd-messages.h +index 280624c..ce6c8ca 100644 +--- a/glusterfsd/src/glusterfsd-messages.h ++++ b/glusterfsd/src/glusterfsd-messages.h +@@ -36,6 +36,6 @@ GLFS_MSGID(GLUSTERFSD, glusterfsd_msg_1, glusterfsd_msg_2, glusterfsd_msg_3, + glusterfsd_msg_31, glusterfsd_msg_32, glusterfsd_msg_33, + glusterfsd_msg_34, glusterfsd_msg_35, glusterfsd_msg_36, + glusterfsd_msg_37, glusterfsd_msg_38, glusterfsd_msg_39, +- glusterfsd_msg_40, glusterfsd_msg_41, glusterfsd_msg_42, glusterfsd_msg_43); ++ glusterfsd_msg_40); + + #endif /* !_GLUSTERFSD_MESSAGES_H_ */ +diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c +index 1d2cd1a..15acc10 100644 +--- a/glusterfsd/src/glusterfsd-mgmt.c ++++ b/glusterfsd/src/glusterfsd-mgmt.c +@@ -48,20 +48,7 @@ int + glusterfs_graph_unknown_options(glusterfs_graph_t *graph); + int + emancipate(glusterfs_ctx_t *ctx, int ret); +-int +-glusterfs_process_svc_attach_volfp(glusterfs_ctx_t *ctx, FILE *fp, +- char *volfile_id, char *checksum); +-int +-glusterfs_mux_volfile_reconfigure(FILE *newvolfile_fp, glusterfs_ctx_t *ctx, +- gf_volfile_t *volfile_obj, char *checksum); +-int +-glusterfs_process_svc_attach_volfp(glusterfs_ctx_t *ctx, FILE *fp, +- char *volfile_id, char *checksum); +-int +-glusterfs_process_svc_detach(glusterfs_ctx_t *ctx, gf_volfile_t *volfile_obj); + +-gf_boolean_t +-mgmt_is_multiplexed_daemon(char *name); + int + mgmt_cbk_spec(struct rpc_clnt *rpc, void *mydata, void *data) + { +@@ -75,96 +62,6 @@ mgmt_cbk_spec(struct rpc_clnt *rpc, void *mydata, void *data) + } + + int +-mgmt_process_volfile(const char *volfile, ssize_t size, char *volfile_id) +-{ +- glusterfs_ctx_t *ctx = NULL; +- int ret = 0; +- FILE *tmpfp = NULL; +- gf_volfile_t *volfile_obj = NULL; +- gf_volfile_t *volfile_tmp = NULL; +- char sha256_hash[SHA256_DIGEST_LENGTH] = { +- 0, +- }; +- int tmp_fd = -1; +- char template[] = "/tmp/glfs.volfile.XXXXXX"; +- +- glusterfs_compute_sha256((const unsigned char *)volfile, size, sha256_hash); +- ctx = THIS->ctx; +- LOCK(&ctx->volfile_lock); +- { +- list_for_each_entry(volfile_obj, &ctx->volfile_list, volfile_list) +- { +- if (!strcmp(volfile_id, volfile_obj->vol_id)) { +- if (!memcmp(sha256_hash, volfile_obj->volfile_checksum, +- sizeof(volfile_obj->volfile_checksum))) { +- UNLOCK(&ctx->volfile_lock); +- gf_msg(THIS->name, GF_LOG_INFO, 0, glusterfsd_msg_40, +- "No change in volfile, continuing"); +- goto out; +- } +- volfile_tmp = volfile_obj; +- break; +- } +- } +- +- /* coverity[secure_temp] mkstemp uses 0600 as the mode */ +- tmp_fd = mkstemp(template); +- if (-1 == tmp_fd) { +- UNLOCK(&ctx->volfile_lock); +- gf_msg(THIS->name, GF_LOG_ERROR, 0, glusterfsd_msg_39, +- "Unable to create temporary file: %s", template); +- ret = -1; +- goto out; +- } +- +- /* Calling unlink so that when the file is closed or program +- * terminates the temporary file is deleted. +- */ +- ret = sys_unlink(template); +- if (ret < 0) { +- gf_msg(THIS->name, GF_LOG_INFO, 0, glusterfsd_msg_39, +- "Unable to delete temporary file: %s", template); +- ret = 0; +- } +- +- tmpfp = fdopen(tmp_fd, "w+b"); +- if (!tmpfp) { +- ret = -1; +- goto unlock; +- } +- +- fwrite(volfile, size, 1, tmpfp); +- fflush(tmpfp); +- if (ferror(tmpfp)) { +- ret = -1; +- goto unlock; +- } +- +- if (!volfile_tmp) { +- /* There is no checksum in the list, which means simple attach +- * the volfile +- */ +- ret = glusterfs_process_svc_attach_volfp(ctx, tmpfp, volfile_id, +- sha256_hash); +- goto unlock; +- } +- ret = glusterfs_mux_volfile_reconfigure(tmpfp, ctx, volfile_obj, +- sha256_hash); +- if (ret < 0) { +- gf_msg_debug("glusterfsd-mgmt", EINVAL, "Reconfigure failed !!"); +- } +- } +-unlock: +- UNLOCK(&ctx->volfile_lock); +-out: +- if (tmpfp) +- fclose(tmpfp); +- else if (tmp_fd != -1) +- sys_close(tmp_fd); +- return ret; +-} +- +-int + mgmt_cbk_event(struct rpc_clnt *rpc, void *mydata, void *data) + { + return 0; +@@ -1069,110 +966,6 @@ glusterfs_handle_attach(rpcsvc_request_t *req) + } + + int +-glusterfs_handle_svc_attach(rpcsvc_request_t *req) +-{ +- int32_t ret = -1; +- gd1_mgmt_brick_op_req xlator_req = { +- 0, +- }; +- xlator_t *this = NULL; +- glusterfs_ctx_t *ctx = NULL; +- +- GF_ASSERT(req); +- this = THIS; +- GF_ASSERT(this); +- +- ctx = this->ctx; +- ret = xdr_to_generic(req->msg[0], &xlator_req, +- (xdrproc_t)xdr_gd1_mgmt_brick_op_req); +- +- if (ret < 0) { +- /*failed to decode msg;*/ +- req->rpc_err = GARBAGE_ARGS; +- goto out; +- } +- gf_msg(THIS->name, GF_LOG_INFO, 0, glusterfsd_msg_41, +- "received attach " +- "request for volfile-id=%s", +- xlator_req.name); +- ret = 0; +- +- if (ctx->active) { +- ret = mgmt_process_volfile(xlator_req.input.input_val, +- xlator_req.input.input_len, xlator_req.name); +- } else { +- gf_msg(this->name, GF_LOG_WARNING, EINVAL, glusterfsd_msg_42, +- "got attach for %s but no active graph", xlator_req.name); +- } +-out: +- if (xlator_req.input.input_val) +- free(xlator_req.input.input_val); +- if (xlator_req.name) +- free(xlator_req.name); +- glusterfs_translator_info_response_send(req, ret, NULL, NULL); +- return 0; +-} +- +-int +-glusterfs_handle_svc_detach(rpcsvc_request_t *req) +-{ +- gd1_mgmt_brick_op_req xlator_req = { +- 0, +- }; +- ssize_t ret; +- glusterfs_ctx_t *ctx = NULL; +- gf_volfile_t *volfile_obj = NULL; +- gf_volfile_t *volfile_tmp = NULL; +- +- ret = xdr_to_generic(req->msg[0], &xlator_req, +- (xdrproc_t)xdr_gd1_mgmt_brick_op_req); +- if (ret < 0) { +- req->rpc_err = GARBAGE_ARGS; +- return -1; +- } +- ctx = glusterfsd_ctx; +- +- LOCK(&ctx->volfile_lock); +- { +- list_for_each_entry(volfile_obj, &ctx->volfile_list, volfile_list) +- { +- if (!strcmp(xlator_req.name, volfile_obj->vol_id)) { +- volfile_tmp = volfile_obj; +- break; +- } +- } +- +- if (!volfile_tmp) { +- UNLOCK(&ctx->volfile_lock); +- gf_msg(THIS->name, GF_LOG_ERROR, 0, glusterfsd_msg_41, +- "can't detach %s - not found", xlator_req.name); +- /* +- * Used to be -ENOENT. However, the caller asked us to +- * make sure it's down and if it's already down that's +- * good enough. +- */ +- ret = 0; +- goto out; +- } +- ret = glusterfs_process_svc_detach(ctx, volfile_tmp); +- if (ret) { +- UNLOCK(&ctx->volfile_lock); +- gf_msg("glusterfsd-mgmt", GF_LOG_ERROR, EINVAL, glusterfsd_msg_41, +- "Could not detach " +- "old graph. Aborting the reconfiguration operation"); +- goto out; +- } +- } +- UNLOCK(&ctx->volfile_lock); +-out: +- glusterfs_terminate_response_send(req, ret); +- free(xlator_req.name); +- xlator_req.name = NULL; +- +- return 0; +-} +- +-int + glusterfs_handle_dump_metrics(rpcsvc_request_t *req) + { + int32_t ret = -1; +@@ -2056,13 +1849,6 @@ rpcsvc_actor_t glusterfs_actors[GLUSTERD_BRICK_MAXVALUE] = { + + [GLUSTERD_DUMP_METRICS] = {"DUMP METRICS", GLUSTERD_DUMP_METRICS, + glusterfs_handle_dump_metrics, NULL, 0, DRC_NA}, +- +- [GLUSTERD_SVC_ATTACH] = {"ATTACH CLIENT", GLUSTERD_SVC_ATTACH, +- glusterfs_handle_svc_attach, NULL, 0, DRC_NA}, +- +- [GLUSTERD_SVC_DETACH] = {"DETACH CLIENT", GLUSTERD_SVC_DETACH, +- glusterfs_handle_svc_detach, NULL, 0, DRC_NA}, +- + }; + + struct rpcsvc_program glusterfs_mop_prog = { +@@ -2210,17 +1996,14 @@ mgmt_getspec_cbk(struct rpc_req *req, struct iovec *iov, int count, + } + + volfile: ++ ret = 0; + size = rsp.op_ret; +- volfile_id = frame->local; +- if (mgmt_is_multiplexed_daemon(ctx->cmd_args.process_name)) { +- ret = mgmt_process_volfile((const char *)rsp.spec, size, volfile_id); +- goto post_graph_mgmt; +- } + +- ret = 0; + glusterfs_compute_sha256((const unsigned char *)rsp.spec, size, + sha256_hash); + ++ volfile_id = frame->local; ++ + LOCK(&ctx->volfile_lock); + { + locked = 1; +@@ -2322,7 +2105,6 @@ volfile: + } + + INIT_LIST_HEAD(&volfile_tmp->volfile_list); +- volfile_tmp->graph = ctx->active; + list_add(&volfile_tmp->volfile_list, &ctx->volfile_list); + snprintf(volfile_tmp->vol_id, sizeof(volfile_tmp->vol_id), "%s", + volfile_id); +@@ -2334,7 +2116,6 @@ volfile: + + locked = 0; + +-post_graph_mgmt: + if (!is_mgmt_rpc_reconnect) { + need_emancipate = 1; + glusterfs_mgmt_pmap_signin(ctx); +@@ -2488,21 +2269,10 @@ glusterfs_volfile_fetch(glusterfs_ctx_t *ctx) + { + xlator_t *server_xl = NULL; + xlator_list_t *trav; +- gf_volfile_t *volfile_obj = NULL; +- int ret = 0; ++ int ret; + + LOCK(&ctx->volfile_lock); + { +- if (ctx->active && +- mgmt_is_multiplexed_daemon(ctx->cmd_args.process_name)) { +- list_for_each_entry(volfile_obj, &ctx->volfile_list, volfile_list) +- { +- ret |= glusterfs_volfile_fetch_one(ctx, volfile_obj->vol_id); +- } +- UNLOCK(&ctx->volfile_lock); +- return ret; +- } +- + if (ctx->active) { + server_xl = ctx->active->first; + if (strcmp(server_xl->type, "protocol/server") != 0) { +diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c +index 2172af4..5b5e996 100644 +--- a/glusterfsd/src/glusterfsd.c ++++ b/glusterfsd/src/glusterfsd.c +@@ -2593,6 +2593,24 @@ out: + #endif + + int ++glusterfs_graph_fini(glusterfs_graph_t *graph) ++{ ++ xlator_t *trav = NULL; ++ ++ trav = graph->first; ++ ++ while (trav) { ++ if (trav->init_succeeded) { ++ trav->fini(trav); ++ trav->init_succeeded = 0; ++ } ++ trav = trav->next; ++ } ++ ++ return 0; ++} ++ ++int + glusterfs_process_volfp(glusterfs_ctx_t *ctx, FILE *fp) + { + glusterfs_graph_t *graph = NULL; +@@ -2791,7 +2809,7 @@ main(int argc, char *argv[]) + + /* set brick_mux mode only for server process */ + if ((ctx->process_mode != GF_SERVER_PROCESS) && cmd->brick_mux) { +- gf_msg("glusterfs", GF_LOG_CRITICAL, 0, glusterfsd_msg_43, ++ gf_msg("glusterfs", GF_LOG_CRITICAL, 0, glusterfsd_msg_40, + "command line argument --brick-mux is valid only for brick " + "process"); + goto out; +diff --git a/libglusterfs/src/defaults-tmpl.c b/libglusterfs/src/defaults-tmpl.c +index 82e7f78..5bf64e8 100644 +--- a/libglusterfs/src/defaults-tmpl.c ++++ b/libglusterfs/src/defaults-tmpl.c +@@ -127,12 +127,6 @@ default_notify(xlator_t *this, int32_t event, void *data, ...) + GF_UNUSED int ret = 0; + xlator_t *victim = data; + +- glusterfs_graph_t *graph = NULL; +- +- GF_VALIDATE_OR_GOTO("notify", this, out); +- graph = this->graph; +- GF_VALIDATE_OR_GOTO(this->name, graph, out); +- + switch (event) { + case GF_EVENT_PARENT_UP: + case GF_EVENT_PARENT_DOWN: { +@@ -165,17 +159,6 @@ default_notify(xlator_t *this, int32_t event, void *data, ...) + xlator_notify(parent->xlator, event, this, NULL); + parent = parent->next; + } +- +- if (event == GF_EVENT_CHILD_DOWN && +- !(this->ctx && this->ctx->master) && (graph->top == this)) { +- /* Make sure this is not a daemon with master xlator */ +- pthread_mutex_lock(&graph->mutex); +- { +- graph->used = 0; +- pthread_cond_broadcast(&graph->child_down_cond); +- } +- pthread_mutex_unlock(&graph->mutex); +- } + } break; + case GF_EVENT_UPCALL: { + xlator_list_t *parent = this->parents; +@@ -222,7 +205,7 @@ default_notify(xlator_t *this, int32_t event, void *data, ...) + * nothing to do with readability. + */ + } +-out: ++ + return 0; + } + +diff --git a/libglusterfs/src/glusterfs/glusterfs.h b/libglusterfs/src/glusterfs/glusterfs.h +index 9ec2365..2cedf1a 100644 +--- a/libglusterfs/src/glusterfs/glusterfs.h ++++ b/libglusterfs/src/glusterfs/glusterfs.h +@@ -597,10 +597,6 @@ struct _glusterfs_graph { + int used; /* Should be set when fuse gets + first CHILD_UP */ + uint32_t volfile_checksum; +- void *last_xl; /* Stores the last xl of the graph, as of now only populated +- in client multiplexed code path */ +- pthread_mutex_t mutex; +- pthread_cond_t child_down_cond; /* for broadcasting CHILD_DOWN */ + }; + typedef struct _glusterfs_graph glusterfs_graph_t; + +@@ -743,7 +739,6 @@ typedef struct { + char volfile_checksum[SHA256_DIGEST_LENGTH]; + char vol_id[NAME_MAX + 1]; + struct list_head volfile_list; +- glusterfs_graph_t *graph; + + } gf_volfile_t; + +@@ -827,6 +822,4 @@ gf_free_mig_locks(lock_migration_info_t *locks); + + int + glusterfs_read_secure_access_file(void); +-int +-glusterfs_graph_fini(glusterfs_graph_t *graph); + #endif /* _GLUSTERFS_H */ +diff --git a/libglusterfs/src/glusterfs/libglusterfs-messages.h b/libglusterfs/src/glusterfs/libglusterfs-messages.h +index ea2aa60..1b72f6d 100644 +--- a/libglusterfs/src/glusterfs/libglusterfs-messages.h ++++ b/libglusterfs/src/glusterfs/libglusterfs-messages.h +@@ -109,8 +109,6 @@ GLFS_MSGID( + LG_MSG_PTHREAD_ATTR_INIT_FAILED, LG_MSG_INVALID_INODE_LIST, + LG_MSG_COMPACT_FAILED, LG_MSG_COMPACT_STATUS, LG_MSG_UTIMENSAT_FAILED, + LG_MSG_PTHREAD_NAMING_FAILED, LG_MSG_SYSCALL_RETURNS_WRONG, +- LG_MSG_XXH64_TO_GFID_FAILED, LG_MSG_ASYNC_WARNING, LG_MSG_ASYNC_FAILURE, +- LG_MSG_GRAPH_CLEANUP_FAILED, LG_MSG_GRAPH_SETUP_FAILED, +- LG_MSG_GRAPH_DETACH_STARTED, LG_MSG_GRAPH_ATTACH_FAILED); ++ LG_MSG_XXH64_TO_GFID_FAILED); + + #endif /* !_LG_MESSAGES_H_ */ +diff --git a/libglusterfs/src/glusterfs/xlator.h b/libglusterfs/src/glusterfs/xlator.h +index 8998976..b78daad 100644 +--- a/libglusterfs/src/glusterfs/xlator.h ++++ b/libglusterfs/src/glusterfs/xlator.h +@@ -1089,7 +1089,4 @@ handle_default_options(xlator_t *xl, dict_t *options); + + void + gluster_graph_take_reference(xlator_t *tree); +- +-gf_boolean_t +-mgmt_is_multiplexed_daemon(char *name); + #endif /* _XLATOR_H */ +diff --git a/libglusterfs/src/graph.c b/libglusterfs/src/graph.c +index a492dd8..bb5e67a 100644 +--- a/libglusterfs/src/graph.c ++++ b/libglusterfs/src/graph.c +@@ -114,53 +114,6 @@ out: + return cert_depth; + } + +-xlator_t * +-glusterfs_get_last_xlator(glusterfs_graph_t *graph) +-{ +- xlator_t *trav = graph->first; +- if (!trav) +- return NULL; +- +- while (trav->next) +- trav = trav->next; +- +- return trav; +-} +- +-xlator_t * +-glusterfs_mux_xlator_unlink(xlator_t *pxl, xlator_t *cxl) +-{ +- xlator_list_t *unlink = NULL; +- xlator_list_t *prev = NULL; +- xlator_list_t **tmp = NULL; +- xlator_t *next_child = NULL; +- xlator_t *xl = NULL; +- +- for (tmp = &pxl->children; *tmp; tmp = &(*tmp)->next) { +- if ((*tmp)->xlator == cxl) { +- unlink = *tmp; +- *tmp = (*tmp)->next; +- if (*tmp) +- next_child = (*tmp)->xlator; +- break; +- } +- prev = *tmp; +- } +- +- if (!prev) +- xl = pxl; +- else if (prev->xlator) +- xl = prev->xlator->graph->last_xl; +- +- if (xl) +- xl->next = next_child; +- if (next_child) +- next_child->prev = xl; +- +- GF_FREE(unlink); +- return next_child; +-} +- + int + glusterfs_xlator_link(xlator_t *pxl, xlator_t *cxl) + { +@@ -1139,8 +1092,6 @@ glusterfs_graph_destroy_residual(glusterfs_graph_t *graph) + ret = xlator_tree_free_memacct(graph->first); + + list_del_init(&graph->list); +- pthread_mutex_destroy(&graph->mutex); +- pthread_cond_destroy(&graph->child_down_cond); + GF_FREE(graph); + + return ret; +@@ -1183,25 +1134,6 @@ out: + } + + int +-glusterfs_graph_fini(glusterfs_graph_t *graph) +-{ +- xlator_t *trav = NULL; +- +- trav = graph->first; +- +- while (trav) { +- if (trav->init_succeeded) { +- trav->cleanup_starting = 1; +- trav->fini(trav); +- trav->init_succeeded = 0; +- } +- trav = trav->next; +- } +- +- return 0; +-} +- +-int + glusterfs_graph_attach(glusterfs_graph_t *orig_graph, char *path, + glusterfs_graph_t **newgraph) + { +@@ -1324,386 +1256,3 @@ glusterfs_graph_attach(glusterfs_graph_t *orig_graph, char *path, + + return 0; + } +-int +-glusterfs_muxsvc_cleanup_parent(glusterfs_ctx_t *ctx, +- glusterfs_graph_t *parent_graph) +-{ +- if (parent_graph) { +- if (parent_graph->first) { +- xlator_destroy(parent_graph->first); +- } +- ctx->active = NULL; +- GF_FREE(parent_graph); +- parent_graph = NULL; +- } +- return 0; +-} +- +-void * +-glusterfs_graph_cleanup(void *arg) +-{ +- glusterfs_graph_t *graph = NULL; +- glusterfs_ctx_t *ctx = THIS->ctx; +- int ret = -1; +- graph = arg; +- +- if (!graph) +- return NULL; +- +- /* To destroy the graph, fitst sent a GF_EVENT_PARENT_DOWN +- * Then wait for GF_EVENT_CHILD_DOWN to get on the top +- * xl. Once we have GF_EVENT_CHILD_DOWN event, then proceed +- * to fini. +- * +- * During fini call, this will take a last unref on rpc and +- * rpc_transport_object. +- */ +- if (graph->first) +- default_notify(graph->first, GF_EVENT_PARENT_DOWN, graph->first); +- +- ret = pthread_mutex_lock(&graph->mutex); +- if (ret != 0) { +- gf_msg("glusterfs", GF_LOG_ERROR, EAGAIN, LG_MSG_GRAPH_CLEANUP_FAILED, +- "Failed to aquire a lock"); +- goto out; +- } +- /* check and wait for CHILD_DOWN for top xlator*/ +- while (graph->used) { +- ret = pthread_cond_wait(&graph->child_down_cond, &graph->mutex); +- if (ret != 0) +- gf_msg("glusterfs", GF_LOG_INFO, 0, LG_MSG_GRAPH_CLEANUP_FAILED, +- "cond wait failed "); +- } +- +- ret = pthread_mutex_unlock(&graph->mutex); +- if (ret != 0) { +- gf_msg("glusterfs", GF_LOG_ERROR, EAGAIN, LG_MSG_GRAPH_CLEANUP_FAILED, +- "Failed to release a lock"); +- } +- +- /* Though we got a child down on top xlator, we have to wait until +- * all the notifier to exit. Because there should not be any threads +- * that access xl variables. +- */ +- pthread_mutex_lock(&ctx->notify_lock); +- { +- while (ctx->notifying) +- pthread_cond_wait(&ctx->notify_cond, &ctx->notify_lock); +- } +- pthread_mutex_unlock(&ctx->notify_lock); +- +- glusterfs_graph_fini(graph); +- glusterfs_graph_destroy(graph); +-out: +- return NULL; +-} +- +-glusterfs_graph_t * +-glusterfs_muxsvc_setup_parent_graph(glusterfs_ctx_t *ctx, char *name, +- char *type) +-{ +- glusterfs_graph_t *parent_graph = NULL; +- xlator_t *ixl = NULL; +- int ret = -1; +- parent_graph = GF_CALLOC(1, sizeof(*parent_graph), +- gf_common_mt_glusterfs_graph_t); +- if (!parent_graph) +- goto out; +- +- INIT_LIST_HEAD(&parent_graph->list); +- +- ctx->active = parent_graph; +- ixl = GF_CALLOC(1, sizeof(*ixl), gf_common_mt_xlator_t); +- if (!ixl) +- goto out; +- +- ixl->ctx = ctx; +- ixl->graph = parent_graph; +- ixl->options = dict_new(); +- if (!ixl->options) +- goto out; +- +- ixl->name = gf_strdup(name); +- if (!ixl->name) +- goto out; +- +- ixl->is_autoloaded = 1; +- +- if (xlator_set_type(ixl, type) == -1) { +- gf_msg("glusterfs", GF_LOG_ERROR, EINVAL, LG_MSG_GRAPH_SETUP_FAILED, +- "%s (%s) set type failed", name, type); +- goto out; +- } +- +- glusterfs_graph_set_first(parent_graph, ixl); +- parent_graph->top = ixl; +- ixl = NULL; +- +- gettimeofday(&parent_graph->dob, NULL); +- fill_uuid(parent_graph->graph_uuid, 128); +- parent_graph->id = ctx->graph_id++; +- ret = 0; +-out: +- if (ixl) +- xlator_destroy(ixl); +- +- if (ret) { +- glusterfs_muxsvc_cleanup_parent(ctx, parent_graph); +- parent_graph = NULL; +- } +- return parent_graph; +-} +- +-int +-glusterfs_process_svc_detach(glusterfs_ctx_t *ctx, gf_volfile_t *volfile_obj) +-{ +- xlator_t *last_xl = NULL; +- glusterfs_graph_t *graph = NULL; +- glusterfs_graph_t *parent_graph = NULL; +- pthread_t clean_graph = { +- 0, +- }; +- int ret = -1; +- xlator_t *xl = NULL; +- +- if (!ctx || !ctx->active || !volfile_obj) +- goto out; +- parent_graph = ctx->active; +- graph = volfile_obj->graph; +- if (graph && graph->first) +- xl = graph->first; +- +- last_xl = graph->last_xl; +- if (last_xl) +- last_xl->next = NULL; +- if (!xl || xl->cleanup_starting) +- goto out; +- +- xl->cleanup_starting = 1; +- gf_msg("mgmt", GF_LOG_INFO, 0, LG_MSG_GRAPH_DETACH_STARTED, +- "detaching child %s", volfile_obj->vol_id); +- +- list_del_init(&volfile_obj->volfile_list); +- glusterfs_mux_xlator_unlink(parent_graph->top, xl); +- parent_graph->last_xl = glusterfs_get_last_xlator(parent_graph); +- parent_graph->xl_count -= graph->xl_count; +- parent_graph->leaf_count -= graph->leaf_count; +- default_notify(xl, GF_EVENT_PARENT_DOWN, xl); +- parent_graph->id++; +- ret = 0; +-out: +- if (!ret) { +- list_del_init(&volfile_obj->volfile_list); +- if (graph) { +- ret = gf_thread_create_detached( +- &clean_graph, glusterfs_graph_cleanup, graph, "graph_clean"); +- if (ret) { +- gf_msg("glusterfs", GF_LOG_ERROR, EINVAL, +- LG_MSG_GRAPH_CLEANUP_FAILED, +- "%s failed to create clean " +- "up thread", +- volfile_obj->vol_id); +- ret = 0; +- } +- } +- GF_FREE(volfile_obj); +- } +- return ret; +-} +- +-int +-glusterfs_process_svc_attach_volfp(glusterfs_ctx_t *ctx, FILE *fp, +- char *volfile_id, char *checksum) +-{ +- glusterfs_graph_t *graph = NULL; +- glusterfs_graph_t *parent_graph = NULL; +- glusterfs_graph_t *clean_graph = NULL; +- int ret = -1; +- xlator_t *xl = NULL; +- xlator_t *last_xl = NULL; +- gf_volfile_t *volfile_obj = NULL; +- pthread_t thread_id = { +- 0, +- }; +- +- if (!ctx) +- goto out; +- parent_graph = ctx->active; +- graph = glusterfs_graph_construct(fp); +- if (!graph) { +- gf_msg("glusterfsd", GF_LOG_ERROR, EINVAL, LG_MSG_GRAPH_ATTACH_FAILED, +- "failed to construct the graph"); +- goto out; +- } +- graph->last_xl = glusterfs_get_last_xlator(graph); +- +- for (xl = graph->first; xl; xl = xl->next) { +- if (strcmp(xl->type, "mount/fuse") == 0) { +- gf_msg("glusterfsd", GF_LOG_ERROR, EINVAL, +- LG_MSG_GRAPH_ATTACH_FAILED, +- "fuse xlator cannot be specified in volume file"); +- goto out; +- } +- } +- +- graph->leaf_count = glusterfs_count_leaves(glusterfs_root(graph)); +- xl = graph->first; +- /* TODO memory leaks everywhere need to free graph in case of error */ +- if (glusterfs_graph_prepare(graph, ctx, xl->name)) { +- gf_msg("glusterfsd", GF_LOG_WARNING, EINVAL, LG_MSG_GRAPH_ATTACH_FAILED, +- "failed to prepare graph for xlator %s", xl->name); +- ret = -1; +- goto out; +- } else if (glusterfs_graph_init(graph)) { +- gf_msg("glusterfsd", GF_LOG_WARNING, EINVAL, LG_MSG_GRAPH_ATTACH_FAILED, +- "failed to initialize graph for xlator %s", xl->name); +- ret = -1; +- goto out; +- } else if (glusterfs_graph_parent_up(graph)) { +- gf_msg("glusterfsd", GF_LOG_WARNING, EINVAL, LG_MSG_GRAPH_ATTACH_FAILED, +- "failed to link the graphs for xlator %s ", xl->name); +- ret = -1; +- goto out; +- } +- +- if (!parent_graph) { +- parent_graph = glusterfs_muxsvc_setup_parent_graph(ctx, "glustershd", +- "debug/io-stats"); +- if (!parent_graph) +- goto out; +- ((xlator_t *)parent_graph->top)->next = xl; +- clean_graph = parent_graph; +- } else { +- last_xl = parent_graph->last_xl; +- if (last_xl) +- last_xl->next = xl; +- xl->prev = last_xl; +- } +- parent_graph->last_xl = graph->last_xl; +- +- ret = glusterfs_xlator_link(parent_graph->top, xl); +- if (ret) { +- gf_msg("graph", GF_LOG_ERROR, 0, LG_MSG_EVENT_NOTIFY_FAILED, +- "parent up notification failed"); +- goto out; +- } +- parent_graph->xl_count += graph->xl_count; +- parent_graph->leaf_count += graph->leaf_count; +- parent_graph->id++; +- +- if (!volfile_obj) { +- volfile_obj = GF_CALLOC(1, sizeof(gf_volfile_t), gf_common_volfile_t); +- if (!volfile_obj) { +- ret = -1; +- goto out; +- } +- } +- +- graph->used = 1; +- parent_graph->id++; +- list_add(&graph->list, &ctx->graphs); +- INIT_LIST_HEAD(&volfile_obj->volfile_list); +- volfile_obj->graph = graph; +- snprintf(volfile_obj->vol_id, sizeof(volfile_obj->vol_id), "%s", +- volfile_id); +- memcpy(volfile_obj->volfile_checksum, checksum, +- sizeof(volfile_obj->volfile_checksum)); +- list_add_tail(&volfile_obj->volfile_list, &ctx->volfile_list); +- +- gf_log_dump_graph(fp, graph); +- graph = NULL; +- +- ret = 0; +-out: +- if (ret) { +- if (graph) { +- gluster_graph_take_reference(graph->first); +- ret = gf_thread_create_detached(&thread_id, glusterfs_graph_cleanup, +- graph, "graph_clean"); +- if (ret) { +- gf_msg("glusterfs", GF_LOG_ERROR, EINVAL, +- LG_MSG_GRAPH_CLEANUP_FAILED, +- "%s failed to create clean " +- "up thread", +- volfile_id); +- ret = 0; +- } +- } +- if (clean_graph) +- glusterfs_muxsvc_cleanup_parent(ctx, clean_graph); +- } +- return ret; +-} +- +-int +-glusterfs_mux_volfile_reconfigure(FILE *newvolfile_fp, glusterfs_ctx_t *ctx, +- gf_volfile_t *volfile_obj, char *checksum) +-{ +- glusterfs_graph_t *oldvolfile_graph = NULL; +- glusterfs_graph_t *newvolfile_graph = NULL; +- +- int ret = -1; +- +- if (!ctx) { +- gf_msg("glusterfsd-mgmt", GF_LOG_ERROR, 0, LG_MSG_CTX_NULL, +- "ctx is NULL"); +- goto out; +- } +- +- /* Change the message id */ +- if (!volfile_obj) { +- gf_msg("glusterfsd-mgmt", GF_LOG_ERROR, 0, LG_MSG_CTX_NULL, +- "failed to get volfile object"); +- goto out; +- } +- +- oldvolfile_graph = volfile_obj->graph; +- if (!oldvolfile_graph) { +- goto out; +- } +- +- newvolfile_graph = glusterfs_graph_construct(newvolfile_fp); +- +- if (!newvolfile_graph) { +- goto out; +- } +- newvolfile_graph->last_xl = glusterfs_get_last_xlator(newvolfile_graph); +- +- glusterfs_graph_prepare(newvolfile_graph, ctx, newvolfile_graph->first); +- +- if (!is_graph_topology_equal(oldvolfile_graph, newvolfile_graph)) { +- ret = glusterfs_process_svc_detach(ctx, volfile_obj); +- if (ret) { +- gf_msg("glusterfsd-mgmt", GF_LOG_ERROR, EINVAL, +- LG_MSG_GRAPH_CLEANUP_FAILED, +- "Could not detach " +- "old graph. Aborting the reconfiguration operation"); +- goto out; +- } +- ret = glusterfs_process_svc_attach_volfp(ctx, newvolfile_fp, +- volfile_obj->vol_id, checksum); +- goto out; +- } +- +- gf_msg_debug("glusterfsd-mgmt", 0, +- "Only options have changed in the" +- " new graph"); +- +- ret = glusterfs_graph_reconfigure(oldvolfile_graph, newvolfile_graph); +- if (ret) { +- gf_msg_debug("glusterfsd-mgmt", 0, +- "Could not reconfigure " +- "new options in old graph"); +- goto out; +- } +- memcpy(volfile_obj->volfile_checksum, checksum, +- sizeof(volfile_obj->volfile_checksum)); +- +- ret = 0; +-out: +- +- if (newvolfile_graph) +- glusterfs_graph_destroy(newvolfile_graph); +- +- return ret; +-} +diff --git a/libglusterfs/src/graph.y b/libglusterfs/src/graph.y +index c60ff38..5b92985 100644 +--- a/libglusterfs/src/graph.y ++++ b/libglusterfs/src/graph.y +@@ -542,9 +542,6 @@ glusterfs_graph_new () + + INIT_LIST_HEAD (&graph->list); + +- pthread_mutex_init(&graph->mutex, NULL); +- pthread_cond_init(&graph->child_down_cond, NULL); +- + gettimeofday (&graph->dob, NULL); + + return graph; +diff --git a/libglusterfs/src/libglusterfs.sym b/libglusterfs/src/libglusterfs.sym +index 05f93b4..4dca7de 100644 +--- a/libglusterfs/src/libglusterfs.sym ++++ b/libglusterfs/src/libglusterfs.sym +@@ -1155,8 +1155,3 @@ gf_changelog_register_generic + gf_gfid_generate_from_xxh64 + find_xlator_option_in_cmd_args_t + gf_d_type_from_ia_type +-glusterfs_graph_fini +-glusterfs_process_svc_attach_volfp +-glusterfs_mux_volfile_reconfigure +-glusterfs_process_svc_detach +-mgmt_is_multiplexed_daemon +diff --git a/libglusterfs/src/statedump.c b/libglusterfs/src/statedump.c +index 0cf80c0..d18b50f 100644 +--- a/libglusterfs/src/statedump.c ++++ b/libglusterfs/src/statedump.c +@@ -810,8 +810,7 @@ gf_proc_dump_info(int signum, glusterfs_ctx_t *ctx) + if (!ctx) + goto out; + +- if (!mgmt_is_multiplexed_daemon(ctx->cmd_args.process_name) && +- (ctx && ctx->active)) { ++ if (ctx && ctx->active) { + top = ctx->active->first; + for (trav_p = &top->children; *trav_p; trav_p = &(*trav_p)->next) { + brick_count++; +diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c +index 022c3ed..6bd4f09 100644 +--- a/libglusterfs/src/xlator.c ++++ b/libglusterfs/src/xlator.c +@@ -1470,19 +1470,3 @@ gluster_graph_take_reference(xlator_t *tree) + } + return; + } +- +-gf_boolean_t +-mgmt_is_multiplexed_daemon(char *name) +-{ +- const char *mux_daemons[] = {"glustershd", NULL}; +- int i; +- +- if (!name) +- return _gf_false; +- +- for (i = 0; mux_daemons[i]; i++) { +- if (!strcmp(name, mux_daemons[i])) +- return _gf_true; +- } +- return _gf_false; +-} +diff --git a/rpc/rpc-lib/src/protocol-common.h b/rpc/rpc-lib/src/protocol-common.h +index 7275d75..779878f 100644 +--- a/rpc/rpc-lib/src/protocol-common.h ++++ b/rpc/rpc-lib/src/protocol-common.h +@@ -245,8 +245,6 @@ enum glusterd_brick_procnum { + GLUSTERD_NODE_BITROT, + GLUSTERD_BRICK_ATTACH, + GLUSTERD_DUMP_METRICS, +- GLUSTERD_SVC_ATTACH, +- GLUSTERD_SVC_DETACH, + GLUSTERD_BRICK_MAXVALUE, + }; + +diff --git a/tests/basic/glusterd/heald.t b/tests/basic/glusterd/heald.t +index 7dae3c3..ca112ad 100644 +--- a/tests/basic/glusterd/heald.t ++++ b/tests/basic/glusterd/heald.t +@@ -7,16 +7,11 @@ + # Covers enable/disable at the moment. Will be enhanced later to include + # the other commands as well. + +-function is_pid_running { +- local pid=$1 +- num=`ps auxww | grep glustershd | grep $pid | grep -v grep | wc -l` +- echo $num +-} +- + cleanup; + TEST glusterd + TEST pidof glusterd + ++volfile=$(gluster system:: getwd)"/glustershd/glustershd-server.vol" + #Commands should fail when volume doesn't exist + TEST ! $CLI volume heal non-existent-volume enable + TEST ! $CLI volume heal non-existent-volume disable +@@ -25,55 +20,51 @@ TEST ! $CLI volume heal non-existent-volume disable + # volumes + TEST $CLI volume create dist $H0:$B0/dist + TEST $CLI volume start dist +-TEST "[ -z $(get_shd_process_pid dist)]" ++TEST "[ -z $(get_shd_process_pid)]" + TEST ! $CLI volume heal dist enable + TEST ! $CLI volume heal dist disable + + # Commands should work on replicate/disperse volume. + TEST $CLI volume create r2 replica 2 $H0:$B0/r2_0 $H0:$B0/r2_1 +-TEST "[ -z $(get_shd_process_pid r2)]" ++TEST "[ -z $(get_shd_process_pid)]" + TEST $CLI volume start r2 +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "[0-9][0-9]*" get_shd_process_pid r2 ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "[0-9][0-9]*" get_shd_process_pid + TEST $CLI volume heal r2 enable + EXPECT "enable" volume_option r2 "cluster.self-heal-daemon" +-volfiler2=$(gluster system:: getwd)"/vols/r2/r2-shd.vol" +-EXPECT "enable" volgen_volume_option $volfiler2 r2-replicate-0 cluster replicate self-heal-daemon +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "[0-9][0-9]*" get_shd_process_pid r2 +-pid=$( get_shd_process_pid r2 ) ++EXPECT "enable" volgen_volume_option $volfile r2-replicate-0 cluster replicate self-heal-daemon ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "[0-9][0-9]*" get_shd_process_pid + TEST $CLI volume heal r2 disable + EXPECT "disable" volume_option r2 "cluster.self-heal-daemon" +-EXPECT "disable" volgen_volume_option $volfiler2 r2-replicate-0 cluster replicate self-heal-daemon +-EXPECT "1" is_pid_running $pid ++EXPECT "disable" volgen_volume_option $volfile r2-replicate-0 cluster replicate self-heal-daemon ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "[0-9][0-9]*" get_shd_process_pid + + # Commands should work on disperse volume. + TEST $CLI volume create ec2 disperse 3 redundancy 1 $H0:$B0/ec2_0 $H0:$B0/ec2_1 $H0:$B0/ec2_2 + TEST $CLI volume start ec2 +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "[0-9][0-9]*" get_shd_process_pid ec2 ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "[0-9][0-9]*" get_shd_process_pid + TEST $CLI volume heal ec2 enable + EXPECT "enable" volume_option ec2 "cluster.disperse-self-heal-daemon" +-volfileec2=$(gluster system:: getwd)"/vols/ec2/ec2-shd.vol" +-EXPECT "enable" volgen_volume_option $volfileec2 ec2-disperse-0 cluster disperse self-heal-daemon +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "[0-9][0-9]*" get_shd_process_pid ec2 +-pid=$(get_shd_process_pid ec2) ++EXPECT "enable" volgen_volume_option $volfile ec2-disperse-0 cluster disperse self-heal-daemon ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "[0-9][0-9]*" get_shd_process_pid + TEST $CLI volume heal ec2 disable + EXPECT "disable" volume_option ec2 "cluster.disperse-self-heal-daemon" +-EXPECT "disable" volgen_volume_option $volfileec2 ec2-disperse-0 cluster disperse self-heal-daemon +-EXPECT "1" is_pid_running $pid ++EXPECT "disable" volgen_volume_option $volfile ec2-disperse-0 cluster disperse self-heal-daemon ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "[0-9][0-9]*" get_shd_process_pid + + #Check that shd graph is rewritten correctly on volume stop/start +-EXPECT "Y" volgen_volume_exists $volfileec2 ec2-disperse-0 cluster disperse +- +-EXPECT "Y" volgen_volume_exists $volfiler2 r2-replicate-0 cluster replicate ++EXPECT "Y" volgen_volume_exists $volfile ec2-disperse-0 cluster disperse ++EXPECT "Y" volgen_volume_exists $volfile r2-replicate-0 cluster replicate + TEST $CLI volume stop r2 +-EXPECT "Y" volgen_volume_exists $volfileec2 ec2-disperse-0 cluster disperse ++EXPECT "Y" volgen_volume_exists $volfile ec2-disperse-0 cluster disperse ++EXPECT "N" volgen_volume_exists $volfile r2-replicate-0 cluster replicate + TEST $CLI volume stop ec2 + # When both the volumes are stopped glustershd volfile is not modified just the + # process is stopped +-TEST "[ -z $(get_shd_process_pid dist) ]" +-TEST "[ -z $(get_shd_process_pid ec2) ]" ++TEST "[ -z $(get_shd_process_pid) ]" + + TEST $CLI volume start r2 +-EXPECT "Y" volgen_volume_exists $volfiler2 r2-replicate-0 cluster replicate ++EXPECT "N" volgen_volume_exists $volfile ec2-disperse-0 cluster disperse ++EXPECT "Y" volgen_volume_exists $volfile r2-replicate-0 cluster replicate + + TEST $CLI volume set r2 self-heal-daemon on + TEST $CLI volume set r2 cluster.self-heal-daemon off +diff --git a/tests/bugs/glusterd/reset-brick-and-daemons-follow-quorum.t b/tests/bugs/glusterd/reset-brick-and-daemons-follow-quorum.t +index e6e65c4..cdb1a33 100644 +--- a/tests/bugs/glusterd/reset-brick-and-daemons-follow-quorum.t ++++ b/tests/bugs/glusterd/reset-brick-and-daemons-follow-quorum.t +@@ -55,9 +55,9 @@ TEST kill_glusterd 1 + #Bring back 1st glusterd + TEST $glusterd_1 + +-# We need to wait till PROCESS_UP_TIMEOUT and then check shd service started +-#on node 2, because once glusterd regains quorum, it will restart all volume +-#level daemons +-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" shd_up_status_2 ++# We need to wait till PROCESS_UP_TIMEOUT and then check shd service does not ++# come up on node 2 ++sleep $PROCESS_UP_TIMEOUT ++EXPECT "N" shd_up_status_2 + + cleanup; +diff --git a/tests/volume.rc b/tests/volume.rc +index 022d972..76a8fd4 100644 +--- a/tests/volume.rc ++++ b/tests/volume.rc +@@ -237,13 +237,11 @@ function ec_child_up_count_shd { + } + + function get_shd_process_pid { +- local vol=$1 +- ps auxww | grep "process-name\ glustershd" | awk '{print $2}' | head -1 ++ ps auxww | grep glusterfs | grep -E "glustershd/glustershd.pid" | awk '{print $2}' | head -1 + } + + function generate_shd_statedump { +- local vol=$1 +- generate_statedump $(get_shd_process_pid $vol) ++ generate_statedump $(get_shd_process_pid) + } + + function generate_nfs_statedump { +diff --git a/xlators/mgmt/glusterd/src/Makefile.am b/xlators/mgmt/glusterd/src/Makefile.am +index 11ae189..5fe5156 100644 +--- a/xlators/mgmt/glusterd/src/Makefile.am ++++ b/xlators/mgmt/glusterd/src/Makefile.am +@@ -18,12 +18,11 @@ glusterd_la_SOURCES = glusterd.c glusterd-handler.c glusterd-sm.c \ + glusterd-locks.c glusterd-snapshot.c glusterd-mgmt-handler.c \ + glusterd-mgmt.c glusterd-peer-utils.c glusterd-statedump.c \ + glusterd-snapshot-utils.c glusterd-conn-mgmt.c \ +- glusterd-proc-mgmt.c glusterd-svc-mgmt.c \ ++ glusterd-proc-mgmt.c glusterd-svc-mgmt.c glusterd-shd-svc.c \ + glusterd-nfs-svc.c glusterd-quotad-svc.c glusterd-svc-helper.c \ + glusterd-conn-helper.c glusterd-snapd-svc.c glusterd-snapd-svc-helper.c \ + glusterd-bitd-svc.c glusterd-scrub-svc.c glusterd-server-quorum.c \ + glusterd-reset-brick.c glusterd-tierd-svc.c glusterd-tierd-svc-helper.c \ +- glusterd-shd-svc.c glusterd-shd-svc-helper.c \ + glusterd-gfproxyd-svc.c glusterd-gfproxyd-svc-helper.c + + +@@ -39,12 +38,11 @@ noinst_HEADERS = glusterd.h glusterd-utils.h glusterd-op-sm.h \ + glusterd-mgmt.h glusterd-messages.h glusterd-peer-utils.h \ + glusterd-statedump.h glusterd-snapshot-utils.h glusterd-geo-rep.h \ + glusterd-conn-mgmt.h glusterd-conn-helper.h glusterd-proc-mgmt.h \ +- glusterd-svc-mgmt.h glusterd-nfs-svc.h \ ++ glusterd-svc-mgmt.h glusterd-shd-svc.h glusterd-nfs-svc.h \ + glusterd-quotad-svc.h glusterd-svc-helper.h glusterd-snapd-svc.h \ + glusterd-snapd-svc-helper.h glusterd-rcu.h glusterd-bitd-svc.h \ + glusterd-scrub-svc.h glusterd-server-quorum.h glusterd-errno.h \ + glusterd-tierd-svc.h glusterd-tierd-svc-helper.h \ +- glusterd-shd-svc.h glusterd-shd-svc-helper.h \ + glusterd-gfproxyd-svc.h glusterd-gfproxyd-svc-helper.h \ + $(CONTRIBDIR)/userspace-rcu/rculist-extra.h + +diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c +index 042a805..ad9a572 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c ++++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c +@@ -2863,7 +2863,7 @@ glusterd_op_remove_brick(dict_t *dict, char **op_errstr) + } + + if (start_remove && volinfo->status == GLUSTERD_STATUS_STARTED) { +- ret = glusterd_svcs_reconfigure(volinfo); ++ ret = glusterd_svcs_reconfigure(); + if (ret) { + gf_msg(this->name, GF_LOG_WARNING, 0, GD_MSG_NFS_RECONF_FAIL, + "Unable to reconfigure NFS-Server"); +diff --git a/xlators/mgmt/glusterd/src/glusterd-conn-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-conn-mgmt.c +index 16eefa1..c6d7a00 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-conn-mgmt.c ++++ b/xlators/mgmt/glusterd/src/glusterd-conn-mgmt.c +@@ -138,45 +138,3 @@ glusterd_conn_build_socket_filepath(char *rundir, uuid_t uuid, char *socketpath, + glusterd_set_socket_filepath(sockfilepath, socketpath, len); + return 0; + } +- +-int +-__glusterd_muxsvc_conn_common_notify(struct rpc_clnt *rpc, void *mydata, +- rpc_clnt_event_t event, void *data) +-{ +- glusterd_conf_t *conf = THIS->private; +- glusterd_svc_proc_t *mux_proc = mydata; +- int ret = -1; +- +- /* Silently ignoring this error, exactly like the current +- * implementation */ +- if (!mux_proc) +- return 0; +- +- if (event == RPC_CLNT_DESTROY) { +- /*RPC_CLNT_DESTROY will only called after mux_proc detached from the +- * list. So it is safe to call without lock. Processing +- * RPC_CLNT_DESTROY under a lock will lead to deadlock. +- */ +- if (mux_proc->data) { +- glusterd_volinfo_unref(mux_proc->data); +- mux_proc->data = NULL; +- } +- GF_FREE(mux_proc); +- ret = 0; +- } else { +- pthread_mutex_lock(&conf->attach_lock); +- { +- ret = mux_proc->notify(mux_proc, event); +- } +- pthread_mutex_unlock(&conf->attach_lock); +- } +- return ret; +-} +- +-int +-glusterd_muxsvc_conn_common_notify(struct rpc_clnt *rpc, void *mydata, +- rpc_clnt_event_t event, void *data) +-{ +- return glusterd_big_locked_notify(rpc, mydata, event, data, +- __glusterd_muxsvc_conn_common_notify); +-} +diff --git a/xlators/mgmt/glusterd/src/glusterd-conn-mgmt.h b/xlators/mgmt/glusterd/src/glusterd-conn-mgmt.h +index d1c4607..602c0ba 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-conn-mgmt.h ++++ b/xlators/mgmt/glusterd/src/glusterd-conn-mgmt.h +@@ -43,11 +43,9 @@ glusterd_conn_disconnect(glusterd_conn_t *conn); + int + glusterd_conn_common_notify(struct rpc_clnt *rpc, void *mydata, + rpc_clnt_event_t event, void *data); +-int +-glusterd_muxsvc_conn_common_notify(struct rpc_clnt *rpc, void *mydata, +- rpc_clnt_event_t event, void *data); + + int32_t + glusterd_conn_build_socket_filepath(char *rundir, uuid_t uuid, char *socketpath, + int len); ++ + #endif +diff --git a/xlators/mgmt/glusterd/src/glusterd-gfproxyd-svc.c b/xlators/mgmt/glusterd/src/glusterd-gfproxyd-svc.c +index b01fd4d..f9c8617 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-gfproxyd-svc.c ++++ b/xlators/mgmt/glusterd/src/glusterd-gfproxyd-svc.c +@@ -370,7 +370,6 @@ int + glusterd_gfproxydsvc_restart() + { + glusterd_volinfo_t *volinfo = NULL; +- glusterd_volinfo_t *tmp = NULL; + int ret = -1; + xlator_t *this = THIS; + glusterd_conf_t *conf = NULL; +@@ -381,7 +380,7 @@ glusterd_gfproxydsvc_restart() + conf = this->private; + GF_VALIDATE_OR_GOTO(this->name, conf, out); + +- cds_list_for_each_entry_safe(volinfo, tmp, &conf->volumes, vol_list) ++ cds_list_for_each_entry(volinfo, &conf->volumes, vol_list) + { + /* Start per volume gfproxyd svc */ + if (volinfo->status == GLUSTERD_STATUS_STARTED) { +diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c +index ac788a0..cb2666b 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-handler.c ++++ b/xlators/mgmt/glusterd/src/glusterd-handler.c +@@ -5940,11 +5940,6 @@ glusterd_get_state(rpcsvc_request_t *req, dict_t *dict) + + GF_FREE(rebal_data); + +- fprintf(fp, "Volume%d.shd_svc.online_status: %s\n", count, +- volinfo->shd.svc.online ? "Online" : "Offline"); +- fprintf(fp, "Volume%d.shd_svc.inited: %s\n", count, +- volinfo->shd.svc.inited ? "True" : "False"); +- + if (volinfo->type == GF_CLUSTER_TYPE_TIER) { + ret = glusterd_volume_get_hot_tier_type_str(volinfo, + &hot_tier_type_str); +@@ -6014,6 +6009,12 @@ glusterd_get_state(rpcsvc_request_t *req, dict_t *dict) + + fprintf(fp, "\n[Services]\n"); + ++ if (priv->shd_svc.inited) { ++ fprintf(fp, "svc%d.name: %s\n", ++count, priv->shd_svc.name); ++ fprintf(fp, "svc%d.online_status: %s\n\n", count, ++ priv->shd_svc.online ? "Online" : "Offline"); ++ } ++ + if (priv->nfs_svc.inited) { + fprintf(fp, "svc%d.name: %s\n", ++count, priv->nfs_svc.name); + fprintf(fp, "svc%d.online_status: %s\n\n", count, +diff --git a/xlators/mgmt/glusterd/src/glusterd-handshake.c b/xlators/mgmt/glusterd/src/glusterd-handshake.c +index 1ba58c3..5599a63 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-handshake.c ++++ b/xlators/mgmt/glusterd/src/glusterd-handshake.c +@@ -30,7 +30,6 @@ + #include "rpcsvc.h" + #include "rpc-common-xdr.h" + #include "glusterd-gfproxyd-svc-helper.h" +-#include "glusterd-shd-svc-helper.h" + + extern struct rpc_clnt_program gd_peer_prog; + extern struct rpc_clnt_program gd_mgmt_prog; +@@ -329,26 +328,6 @@ build_volfile_path(char *volume_id, char *path, size_t path_len, + goto out; + } + +- volid_ptr = strstr(volume_id, "shd/"); +- 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_svc_build_shd_volfile_path(volinfo, path, path_len); +- ret = 0; +- goto out; +- } +- + volid_ptr = strstr(volume_id, "/snaps/"); + if (volid_ptr) { + ret = get_snap_volname_and_volinfo(volid_ptr, &volname, &volinfo); +diff --git a/xlators/mgmt/glusterd/src/glusterd-mem-types.h b/xlators/mgmt/glusterd/src/glusterd-mem-types.h +index 17052ce..7a784db 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-mem-types.h ++++ b/xlators/mgmt/glusterd/src/glusterd-mem-types.h +@@ -51,7 +51,6 @@ typedef enum gf_gld_mem_types_ { + gf_gld_mt_missed_snapinfo_t, + gf_gld_mt_snap_create_args_t, + gf_gld_mt_glusterd_brick_proc_t, +- gf_gld_mt_glusterd_svc_proc_t, + gf_gld_mt_end, + } gf_gld_mem_types_t; + #endif +diff --git a/xlators/mgmt/glusterd/src/glusterd-messages.h b/xlators/mgmt/glusterd/src/glusterd-messages.h +index 424e15f..c7b3ca8 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-messages.h ++++ b/xlators/mgmt/glusterd/src/glusterd-messages.h +@@ -298,8 +298,6 @@ GLFS_MSGID( + GD_MSG_LOCALTIME_LOGGING_ENABLE, GD_MSG_LOCALTIME_LOGGING_DISABLE, + GD_MSG_PORTS_EXHAUSTED, GD_MSG_CHANGELOG_GET_FAIL, + GD_MSG_MANAGER_FUNCTION_FAILED, GD_MSG_NFS_GANESHA_DISABLED, +- GD_MSG_GANESHA_NOT_RUNNING, GD_MSG_DAEMON_LOG_LEVEL_VOL_OPT_VALIDATE_FAIL, +- GD_MSG_SHD_START_FAIL, GD_MSG_SHD_OBJ_GET_FAIL, GD_MSG_SVC_ATTACH_FAIL, +- GD_MSG_ATTACH_INFO, GD_MSG_DETACH_INFO, GD_MSG_SVC_DETACH_FAIL); ++ GD_MSG_GANESHA_NOT_RUNNING, GD_MSG_DAEMON_LOG_LEVEL_VOL_OPT_VALIDATE_FAIL); + + #endif /* !_GLUSTERD_MESSAGES_H_ */ +diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c +index 9ea695e..0d29de2 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c ++++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c +@@ -44,7 +44,6 @@ + #include "glusterd-snapshot-utils.h" + #include "glusterd-svc-mgmt.h" + #include "glusterd-svc-helper.h" +-#include "glusterd-shd-svc-helper.h" + #include "glusterd-shd-svc.h" + #include "glusterd-nfs-svc.h" + #include "glusterd-quotad-svc.h" +@@ -2225,11 +2224,6 @@ glusterd_options_reset(glusterd_volinfo_t *volinfo, char *key, + if (ret) + goto out; + +- svc = &(volinfo->shd.svc); +- ret = svc->reconfigure(volinfo); +- if (ret) +- goto out; +- + ret = glusterd_create_volfiles_and_notify_services(volinfo); + if (ret) { + gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_VOLFILE_CREATE_FAIL, +@@ -2244,7 +2238,7 @@ glusterd_options_reset(glusterd_volinfo_t *volinfo, char *key, + goto out; + + if (GLUSTERD_STATUS_STARTED == volinfo->status) { +- ret = glusterd_svcs_reconfigure(volinfo); ++ ret = glusterd_svcs_reconfigure(); + if (ret) + goto out; + } +@@ -2700,11 +2694,6 @@ glusterd_op_set_all_volume_options(xlator_t *this, dict_t *dict, + if (ret) + goto out; + +- svc = &(volinfo->shd.svc); +- ret = svc->reconfigure(volinfo); +- if (ret) +- goto out; +- + ret = glusterd_create_volfiles_and_notify_services(volinfo); + if (ret) { + gf_msg(this->name, GF_LOG_ERROR, 0, +@@ -2718,7 +2707,7 @@ glusterd_op_set_all_volume_options(xlator_t *this, dict_t *dict, + } + } + if (svcs_reconfigure) { +- ret = glusterd_svcs_reconfigure(NULL); ++ ret = glusterd_svcs_reconfigure(); + if (ret) { + gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_SVC_RESTART_FAIL, + "Unable to restart " +@@ -3103,11 +3092,6 @@ glusterd_op_set_volume(dict_t *dict, char **errstr) + if (ret) + goto out; + +- svc = &(volinfo->shd.svc); +- ret = svc->reconfigure(volinfo); +- if (ret) +- goto out; +- + ret = glusterd_create_volfiles_and_notify_services(volinfo); + if (ret) { + gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_VOLFILE_CREATE_FAIL, +@@ -3123,7 +3107,7 @@ glusterd_op_set_volume(dict_t *dict, char **errstr) + goto out; + + if (GLUSTERD_STATUS_STARTED == volinfo->status) { +- ret = glusterd_svcs_reconfigure(volinfo); ++ ret = glusterd_svcs_reconfigure(); + if (ret) { + gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_SVC_RESTART_FAIL, + "Unable to restart services"); +@@ -3156,11 +3140,6 @@ glusterd_op_set_volume(dict_t *dict, char **errstr) + if (ret) + goto out; + +- svc = &(volinfo->shd.svc); +- ret = svc->reconfigure(volinfo); +- if (ret) +- goto out; +- + ret = glusterd_create_volfiles_and_notify_services(volinfo); + if (ret) { + gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_VOLFILE_CREATE_FAIL, +@@ -3176,7 +3155,7 @@ glusterd_op_set_volume(dict_t *dict, char **errstr) + goto out; + + if (GLUSTERD_STATUS_STARTED == volinfo->status) { +- ret = glusterd_svcs_reconfigure(volinfo); ++ ret = glusterd_svcs_reconfigure(); + if (ret) { + gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_SVC_RESTART_FAIL, + "Unable to restart services"); +@@ -3383,7 +3362,7 @@ glusterd_op_stats_volume(dict_t *dict, char **op_errstr, dict_t *rsp_dict) + goto out; + + if (GLUSTERD_STATUS_STARTED == volinfo->status) { +- ret = glusterd_svcs_reconfigure(volinfo); ++ ret = glusterd_svcs_reconfigure(); + if (ret) + goto out; + } +@@ -3666,6 +3645,14 @@ glusterd_op_status_volume(dict_t *dict, char **op_errstr, dict_t *rsp_dict) + other_count++; + node_count++; + ++ } else if ((cmd & GF_CLI_STATUS_SHD) != 0) { ++ ret = glusterd_add_node_to_dict(priv->shd_svc.name, rsp_dict, 0, ++ vol_opts); ++ if (ret) ++ goto out; ++ other_count++; ++ node_count++; ++ + } else if ((cmd & GF_CLI_STATUS_QUOTAD) != 0) { + ret = glusterd_add_node_to_dict(priv->quotad_svc.name, rsp_dict, 0, + vol_opts); +@@ -3699,12 +3686,6 @@ glusterd_op_status_volume(dict_t *dict, char **op_errstr, dict_t *rsp_dict) + goto out; + other_count++; + node_count++; +- } else if ((cmd & GF_CLI_STATUS_SHD) != 0) { +- ret = glusterd_add_shd_to_dict(volinfo, rsp_dict, other_index); +- if (ret) +- goto out; +- other_count++; +- node_count++; + } else if ((cmd & GF_CLI_STATUS_BRICK) != 0) { + ret = dict_get_strn(dict, "brick", SLEN("brick"), &brick); + if (ret) +@@ -3767,19 +3748,6 @@ glusterd_op_status_volume(dict_t *dict, char **op_errstr, dict_t *rsp_dict) + node_count++; + } + +- if (glusterd_is_shd_compatible_volume(volinfo)) { +- shd_enabled = gd_is_self_heal_enabled(volinfo, vol_opts); +- if (shd_enabled) { +- ret = glusterd_add_shd_to_dict(volinfo, rsp_dict, +- other_index); +- if (ret) +- goto out; +- other_count++; +- other_index++; +- node_count++; +- } +- } +- + nfs_disabled = dict_get_str_boolean(vol_opts, NFS_DISABLE_MAP_KEY, + _gf_false); + if (!nfs_disabled) { +@@ -3792,6 +3760,18 @@ glusterd_op_status_volume(dict_t *dict, char **op_errstr, dict_t *rsp_dict) + node_count++; + } + ++ if (glusterd_is_shd_compatible_volume(volinfo)) ++ shd_enabled = gd_is_self_heal_enabled(volinfo, vol_opts); ++ if (shd_enabled) { ++ ret = glusterd_add_node_to_dict(priv->shd_svc.name, rsp_dict, ++ other_index, vol_opts); ++ if (ret) ++ goto out; ++ other_count++; ++ node_count++; ++ other_index++; ++ } ++ + if (glusterd_is_volume_quota_enabled(volinfo)) { + ret = glusterd_add_node_to_dict(priv->quotad_svc.name, rsp_dict, + other_index, vol_opts); +@@ -6904,18 +6884,16 @@ glusterd_shd_select_brick_xlator(dict_t *dict, gf_xl_afr_op_t heal_op, + int ret = -1; + glusterd_conf_t *priv = NULL; + xlator_t *this = NULL; +- glusterd_svc_t *svc = NULL; + + this = THIS; + GF_ASSERT(this); + priv = this->private; + GF_ASSERT(priv); +- svc = &(volinfo->shd.svc); + + switch (heal_op) { + case GF_SHD_OP_INDEX_SUMMARY: + case GF_SHD_OP_STATISTICS_HEAL_COUNT: +- if (!svc->online) { ++ if (!priv->shd_svc.online) { + if (!rsp_dict) { + gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_OPCTX_NULL, + "Received " +@@ -6936,7 +6914,7 @@ glusterd_shd_select_brick_xlator(dict_t *dict, gf_xl_afr_op_t heal_op, + break; + + case GF_SHD_OP_STATISTICS_HEAL_COUNT_PER_REPLICA: +- if (!svc->online) { ++ if (!priv->shd_svc.online) { + if (!rsp_dict) { + gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_OPCTX_NULL, + "Received " +@@ -7071,7 +7049,7 @@ glusterd_bricks_select_heal_volume(dict_t *dict, char **op_errstr, + ret = -1; + goto out; + } else { +- pending_node->node = &(volinfo->shd.svc); ++ pending_node->node = &(priv->shd_svc); + pending_node->type = GD_NODE_SHD; + cds_list_add_tail(&pending_node->list, selected); + pending_node = NULL; +@@ -7205,7 +7183,6 @@ glusterd_bricks_select_status_volume(dict_t *dict, char **op_errstr, + glusterd_pending_node_t *pending_node = NULL; + xlator_t *this = NULL; + glusterd_conf_t *priv = NULL; +- glusterd_svc_t *svc = NULL; + + GF_ASSERT(dict); + +@@ -7301,8 +7278,7 @@ glusterd_bricks_select_status_volume(dict_t *dict, char **op_errstr, + + ret = 0; + } else if ((cmd & GF_CLI_STATUS_SHD) != 0) { +- svc = &(volinfo->shd.svc); +- if (!svc->online) { ++ if (!priv->shd_svc.online) { + ret = -1; + gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_SELF_HEALD_DISABLED, + "Self-heal daemon is not running"); +@@ -7314,7 +7290,7 @@ glusterd_bricks_select_status_volume(dict_t *dict, char **op_errstr, + ret = -1; + goto out; + } +- pending_node->node = svc; ++ pending_node->node = &(priv->shd_svc); + pending_node->type = GD_NODE_SHD; + pending_node->index = 0; + cds_list_add_tail(&pending_node->list, selected); +diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.c b/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.c +deleted file mode 100644 +index 9196758..0000000 +--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.c ++++ /dev/null +@@ -1,140 +0,0 @@ +-/* +- Copyright (c) 2016 Red Hat, Inc. +- This file is part of GlusterFS. +- +- This file is licensed to you under your choice of the GNU Lesser +- General Public License, version 3 or any later version (LGPLv3 or +- later), or the GNU General Public License, version 2 (GPLv2), in all +- cases as published by the Free Software Foundation. +-*/ +- +-#include "glusterd.h" +-#include "glusterd-utils.h" +-#include "glusterd-shd-svc-helper.h" +-#include "glusterd-messages.h" +-#include "glusterd-volgen.h" +- +-void +-glusterd_svc_build_shd_socket_filepath(glusterd_volinfo_t *volinfo, char *path, +- int path_len) +-{ +- char sockfilepath[PATH_MAX] = { +- 0, +- }; +- char rundir[PATH_MAX] = { +- 0, +- }; +- int32_t len = 0; +- glusterd_conf_t *priv = THIS->private; +- +- if (!priv) +- return; +- +- GLUSTERD_GET_SHD_RUNDIR(rundir, volinfo, priv); +- len = snprintf(sockfilepath, sizeof(sockfilepath), "%s/run-%s", rundir, +- uuid_utoa(MY_UUID)); +- if ((len < 0) || (len >= sizeof(sockfilepath))) { +- sockfilepath[0] = 0; +- } +- +- glusterd_set_socket_filepath(sockfilepath, path, path_len); +-} +- +-void +-glusterd_svc_build_shd_pidfile(glusterd_volinfo_t *volinfo, char *path, +- int path_len) +-{ +- char rundir[PATH_MAX] = { +- 0, +- }; +- glusterd_conf_t *priv = THIS->private; +- +- if (!priv) +- return; +- +- GLUSTERD_GET_SHD_RUNDIR(rundir, volinfo, priv); +- +- snprintf(path, path_len, "%s/%s-shd.pid", rundir, volinfo->volname); +-} +- +-void +-glusterd_svc_build_shd_volfile_path(glusterd_volinfo_t *volinfo, char *path, +- int path_len) +-{ +- char workdir[PATH_MAX] = { +- 0, +- }; +- glusterd_conf_t *priv = THIS->private; +- +- if (!priv) +- return; +- +- GLUSTERD_GET_VOLUME_DIR(workdir, volinfo, priv); +- +- snprintf(path, path_len, "%s/%s-shd.vol", workdir, volinfo->volname); +-} +- +-void +-glusterd_svc_build_shd_logdir(char *logdir, char *volname, size_t len) +-{ +- snprintf(logdir, len, "%s/shd/%s", DEFAULT_LOG_FILE_DIRECTORY, volname); +-} +- +-void +-glusterd_svc_build_shd_logfile(char *logfile, char *logdir, size_t len) +-{ +- snprintf(logfile, len, "%s/shd.log", logdir); +-} +- +-void +-glusterd_shd_svcproc_cleanup(glusterd_shdsvc_t *shd) +-{ +- glusterd_svc_proc_t *svc_proc = NULL; +- glusterd_svc_t *svc = NULL; +- glusterd_conf_t *conf = NULL; +- gf_boolean_t need_unref = _gf_false; +- rpc_clnt_t *rpc = NULL; +- +- conf = THIS->private; +- if (!conf) +- return; +- +- GF_VALIDATE_OR_GOTO(THIS->name, conf, out); +- GF_VALIDATE_OR_GOTO(THIS->name, shd, out); +- +- svc = &shd->svc; +- shd->attached = _gf_false; +- +- if (svc->conn.rpc) { +- rpc_clnt_unref(svc->conn.rpc); +- svc->conn.rpc = NULL; +- } +- +- pthread_mutex_lock(&conf->attach_lock); +- { +- svc_proc = svc->svc_proc; +- svc->svc_proc = NULL; +- svc->inited = _gf_false; +- cds_list_del_init(&svc->mux_svc); +- glusterd_unlink_file(svc->proc.pidfile); +- +- if (svc_proc && cds_list_empty(&svc_proc->svcs)) { +- cds_list_del_init(&svc_proc->svc_proc_list); +- /* We cannot free svc_proc list from here. Because +- * if there are pending events on the rpc, it will +- * try to access the corresponding svc_proc, so unrefing +- * rpc request and then cleaning up the memory is carried +- * from the notify function upon RPC_CLNT_DESTROY destroy. +- */ +- need_unref = _gf_true; +- rpc = svc_proc->rpc; +- svc_proc->rpc = NULL; +- } +- } +- pthread_mutex_unlock(&conf->attach_lock); +- /*rpc unref has to be performed outside the lock*/ +- if (need_unref && rpc) +- rpc_clnt_unref(rpc); +-out: +- return; +-} +diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.h b/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.h +deleted file mode 100644 +index c70702c..0000000 +--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.h ++++ /dev/null +@@ -1,45 +0,0 @@ +-/* +- Copyright (c) 2016 Red Hat, Inc. +- This file is part of GlusterFS. +- +- This file is licensed to you under your choice of the GNU Lesser +- General Public License, version 3 or any later version (LGPLv3 or +- later), or the GNU General Public License, version 2 (GPLv2), in all +- cases as published by the Free Software Foundation. +-*/ +- +-#ifndef _GLUSTERD_SHD_SVC_HELPER_H_ +-#define _GLUSTERD_SHD_SVC_HELPER_H_ +- +-#include "glusterd.h" +-#include "glusterd-svc-mgmt.h" +- +-void +-glusterd_svc_build_shd_socket_filepath(glusterd_volinfo_t *volinfo, char *path, +- int path_len); +- +-void +-glusterd_svc_build_shd_pidfile(glusterd_volinfo_t *volinfo, char *path, +- int path_len); +- +-void +-glusterd_svc_build_shd_volfile_path(glusterd_volinfo_t *volinfo, char *path, +- int path_len); +- +-void +-glusterd_svc_build_shd_logdir(char *logdir, char *volname, size_t len); +- +-void +-glusterd_svc_build_shd_logfile(char *logfile, char *logdir, size_t len); +- +-void +-glusterd_shd_svcproc_cleanup(glusterd_shdsvc_t *shd); +- +-int +-glusterd_recover_shd_attach_failure(glusterd_volinfo_t *volinfo, +- glusterd_svc_t *svc, int flags); +- +-int +-glusterd_shdsvc_create_volfile(glusterd_volinfo_t *volinfo); +- +-#endif +diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c +index 4789843..f5379b0 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c ++++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c +@@ -13,10 +13,9 @@ + #include "glusterd.h" + #include "glusterd-utils.h" + #include "glusterd-volgen.h" ++#include "glusterd-svc-mgmt.h" + #include "glusterd-shd-svc.h" +-#include "glusterd-shd-svc-helper.h" + #include "glusterd-svc-helper.h" +-#include "glusterd-store.h" + + #define GD_SHD_PROCESS_NAME "--process-name" + char *shd_svc_name = "glustershd"; +@@ -24,145 +23,27 @@ char *shd_svc_name = "glustershd"; + void + glusterd_shdsvc_build(glusterd_svc_t *svc) + { +- int ret = -1; +- ret = snprintf(svc->name, sizeof(svc->name), "%s", shd_svc_name); +- if (ret < 0) +- return; +- +- CDS_INIT_LIST_HEAD(&svc->mux_svc); + svc->manager = glusterd_shdsvc_manager; + svc->start = glusterd_shdsvc_start; +- svc->stop = glusterd_shdsvc_stop; +- svc->reconfigure = glusterd_shdsvc_reconfigure; ++ svc->stop = glusterd_svc_stop; + } + + int +-glusterd_shdsvc_init(void *data, glusterd_conn_t *mux_conn, +- glusterd_svc_proc_t *mux_svc) ++glusterd_shdsvc_init(glusterd_svc_t *svc) + { +- int ret = -1; +- char rundir[PATH_MAX] = { +- 0, +- }; +- char sockpath[PATH_MAX] = { +- 0, +- }; +- char pidfile[PATH_MAX] = { +- 0, +- }; +- char volfile[PATH_MAX] = { +- 0, +- }; +- char logdir[PATH_MAX] = { +- 0, +- }; +- char logfile[PATH_MAX] = { +- 0, +- }; +- char volfileid[256] = {0}; +- glusterd_svc_t *svc = NULL; +- glusterd_volinfo_t *volinfo = NULL; +- glusterd_conf_t *priv = NULL; +- glusterd_muxsvc_conn_notify_t notify = NULL; +- xlator_t *this = NULL; +- char *volfileserver = NULL; +- int32_t len = 0; +- +- this = THIS; +- GF_VALIDATE_OR_GOTO(THIS->name, this, out); +- +- priv = this->private; +- GF_VALIDATE_OR_GOTO(this->name, priv, out); +- +- volinfo = data; +- GF_VALIDATE_OR_GOTO(this->name, data, out); +- GF_VALIDATE_OR_GOTO(this->name, mux_svc, out); +- +- svc = &(volinfo->shd.svc); +- +- ret = snprintf(svc->name, sizeof(svc->name), "%s", shd_svc_name); +- if (ret < 0) +- goto out; +- +- notify = glusterd_muxsvc_common_rpc_notify; +- glusterd_store_perform_node_state_store(volinfo); +- +- GLUSTERD_GET_SHD_RUNDIR(rundir, volinfo, priv); +- glusterd_svc_create_rundir(rundir); +- +- glusterd_svc_build_shd_logdir(logdir, volinfo->volname, sizeof(logdir)); +- glusterd_svc_build_shd_logfile(logfile, logdir, sizeof(logfile)); +- +- /* Initialize the connection mgmt */ +- if (mux_conn && mux_svc->rpc) { +- /* multiplexed svc */ +- svc->conn.frame_timeout = mux_conn->frame_timeout; +- /* This will be unrefed from glusterd_shd_svcproc_cleanup*/ +- svc->conn.rpc = rpc_clnt_ref(mux_svc->rpc); +- ret = snprintf(svc->conn.sockpath, sizeof(svc->conn.sockpath), "%s", +- mux_conn->sockpath); +- } else { +- ret = mkdir_p(logdir, 0755, _gf_true); +- if ((ret == -1) && (EEXIST != errno)) { +- gf_msg(this->name, GF_LOG_ERROR, errno, GD_MSG_CREATE_DIR_FAILED, +- "Unable to create logdir %s", logdir); +- goto out; +- } +- +- glusterd_svc_build_shd_socket_filepath(volinfo, sockpath, +- sizeof(sockpath)); +- ret = glusterd_muxsvc_conn_init(&(svc->conn), mux_svc, sockpath, 600, +- notify); +- if (ret) +- goto out; +- /* This will be unrefed when the last svcs is detached from the list */ +- if (!mux_svc->rpc) +- mux_svc->rpc = rpc_clnt_ref(svc->conn.rpc); +- } +- +- /* Initialize the process mgmt */ +- glusterd_svc_build_shd_pidfile(volinfo, pidfile, sizeof(pidfile)); +- glusterd_svc_build_shd_volfile_path(volinfo, volfile, PATH_MAX); +- len = snprintf(volfileid, sizeof(volfileid), "shd/%s", volinfo->volname); +- if ((len < 0) || (len >= sizeof(volfileid))) { +- ret = -1; +- goto out; +- } +- +- if (dict_get_strn(this->options, "transport.socket.bind-address", +- SLEN("transport.socket.bind-address"), +- &volfileserver) != 0) { +- volfileserver = "localhost"; +- } +- ret = glusterd_proc_init(&(svc->proc), shd_svc_name, pidfile, logdir, +- logfile, volfile, volfileid, volfileserver); +- if (ret) +- goto out; +- +-out: +- gf_msg_debug(this ? this->name : "glusterd", 0, "Returning %d", ret); +- return ret; ++ return glusterd_svc_init(svc, shd_svc_name); + } + +-int +-glusterd_shdsvc_create_volfile(glusterd_volinfo_t *volinfo) ++static int ++glusterd_shdsvc_create_volfile() + { + char filepath[PATH_MAX] = { + 0, + }; +- + int ret = -1; ++ glusterd_conf_t *conf = THIS->private; + dict_t *mod_dict = NULL; + +- glusterd_svc_build_shd_volfile_path(volinfo, filepath, PATH_MAX); +- if (!glusterd_is_shd_compatible_volume(volinfo)) { +- /* If volfile exist, delete it. This case happens when we +- * change from replica/ec to distribute. +- */ +- (void)glusterd_unlink_file(filepath); +- ret = 0; +- goto out; +- } + mod_dict = dict_new(); + if (!mod_dict) + goto out; +@@ -183,7 +64,9 @@ glusterd_shdsvc_create_volfile(glusterd_volinfo_t *volinfo) + if (ret) + goto out; + +- ret = glusterd_shdsvc_generate_volfile(volinfo, filepath, mod_dict); ++ glusterd_svc_build_volfile_path(shd_svc_name, conf->workdir, filepath, ++ sizeof(filepath)); ++ ret = glusterd_create_global_volfile(build_shd_graph, filepath, mod_dict); + if (ret) { + gf_msg(THIS->name, GF_LOG_ERROR, 0, GD_MSG_VOLFILE_CREATE_FAIL, + "Failed to create volfile"); +@@ -198,89 +81,26 @@ out: + return ret; + } + +-gf_boolean_t +-glusterd_svcs_shd_compatible_volumes_stopped(glusterd_svc_t *svc) +-{ +- glusterd_svc_proc_t *svc_proc = NULL; +- glusterd_shdsvc_t *shd = NULL; +- glusterd_svc_t *temp_svc = NULL; +- glusterd_volinfo_t *volinfo = NULL; +- gf_boolean_t comp = _gf_false; +- glusterd_conf_t *conf = THIS->private; +- +- GF_VALIDATE_OR_GOTO("glusterd", conf, out); +- GF_VALIDATE_OR_GOTO("glusterd", svc, out); +- pthread_mutex_lock(&conf->attach_lock); +- { +- svc_proc = svc->svc_proc; +- if (!svc_proc) +- goto unlock; +- cds_list_for_each_entry(temp_svc, &svc_proc->svcs, mux_svc) +- { +- /* Get volinfo->shd from svc object */ +- shd = cds_list_entry(svc, glusterd_shdsvc_t, svc); +- if (!shd) { +- gf_msg("glusterd", GF_LOG_ERROR, 0, GD_MSG_SHD_OBJ_GET_FAIL, +- "Failed to get shd object " +- "from shd service"); +- goto unlock; +- } +- +- /* Get volinfo from shd */ +- volinfo = cds_list_entry(shd, glusterd_volinfo_t, shd); +- if (!volinfo) { +- gf_msg("glusterd", GF_LOG_ERROR, 0, GD_MSG_VOLINFO_GET_FAIL, +- "Failed to get volinfo from " +- "from shd"); +- goto unlock; +- } +- if (!glusterd_is_shd_compatible_volume(volinfo)) +- continue; +- if (volinfo->status == GLUSTERD_STATUS_STARTED) +- goto unlock; +- } +- comp = _gf_true; +- } +-unlock: +- pthread_mutex_unlock(&conf->attach_lock); +-out: +- return comp; +-} +- + int + glusterd_shdsvc_manager(glusterd_svc_t *svc, void *data, int flags) + { +- int ret = -1; ++ int ret = 0; + glusterd_volinfo_t *volinfo = NULL; + +- volinfo = data; +- GF_VALIDATE_OR_GOTO("glusterd", svc, out); +- GF_VALIDATE_OR_GOTO("glusterd", volinfo, out); +- +- if (volinfo) +- glusterd_volinfo_ref(volinfo); +- +- ret = glusterd_shdsvc_create_volfile(volinfo); +- if (ret) +- goto out; +- +- if (!glusterd_is_shd_compatible_volume(volinfo)) { +- ret = 0; +- if (svc->inited) { +- /* This means glusterd was running for this volume and now +- * it was converted to a non-shd volume. So just stop the shd +- */ +- ret = svc->stop(svc, SIGTERM); ++ if (!svc->inited) { ++ ret = glusterd_shdsvc_init(svc); ++ if (ret) { ++ gf_msg(THIS->name, GF_LOG_ERROR, 0, GD_MSG_FAILED_INIT_SHDSVC, ++ "Failed to init shd " ++ "service"); ++ goto out; ++ } else { ++ svc->inited = _gf_true; ++ gf_msg_debug(THIS->name, 0, "shd service initialized"); + } +- goto out; + } + +- ret = glusterd_shd_svc_mux_init(volinfo, svc); +- if (ret) { +- gf_msg(THIS->name, GF_LOG_ERROR, 0, GD_MSG_FAILED_INIT_SHDSVC, +- "Failed to init shd service"); +- goto out; +- } ++ volinfo = data; + + /* If all the volumes are stopped or all shd compatible volumes + * are stopped then stop the service if: +@@ -290,26 +110,31 @@ glusterd_shdsvc_manager(glusterd_svc_t *svc, void *data, int flags) + * - volinfo is NULL or + * - volinfo is present and volume is shd compatible + */ +- if (glusterd_svcs_shd_compatible_volumes_stopped(svc)) { +- /* TODO +- * Take a lock and detach all svc's to stop the process +- * also reset the init flag +- */ +- ret = svc->stop(svc, SIGTERM); +- } else if (volinfo) { +- ret = svc->stop(svc, SIGTERM); +- if (ret) +- goto out; ++ if (glusterd_are_all_volumes_stopped() || ++ glusterd_all_shd_compatible_volumes_stopped()) { ++ if (!(volinfo && !glusterd_is_shd_compatible_volume(volinfo))) { ++ ret = svc->stop(svc, SIGTERM); ++ } ++ } else { ++ if (!(volinfo && !glusterd_is_shd_compatible_volume(volinfo))) { ++ ret = glusterd_shdsvc_create_volfile(); ++ if (ret) ++ goto out; ++ ++ ret = svc->stop(svc, SIGTERM); ++ if (ret) ++ goto out; + +- if (volinfo->status == GLUSTERD_STATUS_STARTED) { + ret = svc->start(svc, flags); + if (ret) + goto out; ++ ++ ret = glusterd_conn_connect(&(svc->conn)); ++ if (ret) ++ goto out; + } + } + out: +- if (volinfo) +- glusterd_volinfo_unref(volinfo); + if (ret) + gf_event(EVENT_SVC_MANAGER_FAILED, "svc_name=%s", svc->name); + gf_msg_debug(THIS->name, 0, "Returning %d", ret); +@@ -318,7 +143,7 @@ out: + } + + int +-glusterd_new_shd_svc_start(glusterd_svc_t *svc, int flags) ++glusterd_shdsvc_start(glusterd_svc_t *svc, int flags) + { + int ret = -1; + char glusterd_uuid_option[PATH_MAX] = {0}; +@@ -363,136 +188,31 @@ glusterd_new_shd_svc_start(glusterd_svc_t *svc, int flags) + goto out; + + ret = glusterd_svc_start(svc, flags, cmdline); +- if (ret) +- goto out; + +- ret = glusterd_conn_connect(&(svc->conn)); + out: + if (cmdline) + dict_unref(cmdline); +- return ret; +-} + +-int +-glusterd_recover_shd_attach_failure(glusterd_volinfo_t *volinfo, +- glusterd_svc_t *svc, int flags) +-{ +- int ret = -1; +- glusterd_svc_proc_t *mux_proc = NULL; +- glusterd_conf_t *conf = NULL; +- +- conf = THIS->private; +- +- if (!conf || !volinfo || !svc) +- return -1; +- glusterd_shd_svcproc_cleanup(&volinfo->shd); +- mux_proc = glusterd_svcprocess_new(); +- if (!mux_proc) { +- return -1; +- } +- ret = glusterd_shdsvc_init(volinfo, NULL, mux_proc); +- if (ret) +- return -1; +- pthread_mutex_lock(&conf->attach_lock); +- { +- cds_list_add_tail(&mux_proc->svc_proc_list, &conf->shd_procs); +- svc->svc_proc = mux_proc; +- cds_list_del_init(&svc->mux_svc); +- cds_list_add_tail(&svc->mux_svc, &mux_proc->svcs); +- } +- pthread_mutex_unlock(&conf->attach_lock); +- +- ret = glusterd_new_shd_svc_start(svc, flags); +- if (!ret) { +- volinfo->shd.attached = _gf_true; +- } +- return ret; +-} +- +-int +-glusterd_shdsvc_start(glusterd_svc_t *svc, int flags) +-{ +- int ret = -1; +- glusterd_shdsvc_t *shd = NULL; +- glusterd_volinfo_t *volinfo = NULL; +- glusterd_conf_t *conf = NULL; +- +- GF_VALIDATE_OR_GOTO("glusterd", svc, out); +- conf = THIS->private; +- GF_VALIDATE_OR_GOTO("glusterd", conf, out); +- +- /* Get volinfo->shd from svc object */ +- shd = cds_list_entry(svc, glusterd_shdsvc_t, svc); +- if (!shd) { +- gf_msg("glusterd", GF_LOG_ERROR, 0, GD_MSG_SHD_OBJ_GET_FAIL, +- "Failed to get shd object " +- "from shd service"); +- return -1; +- } +- +- /* Get volinfo from shd */ +- volinfo = cds_list_entry(shd, glusterd_volinfo_t, shd); +- if (!volinfo) { +- gf_msg("glusterd", GF_LOG_ERROR, 0, GD_MSG_VOLINFO_GET_FAIL, +- "Failed to get volinfo from " +- "from shd"); +- return -1; +- } +- +- if (volinfo->status != GLUSTERD_STATUS_STARTED) +- return -1; +- +- glusterd_volinfo_ref(volinfo); +- if (!svc->inited) { +- ret = glusterd_shd_svc_mux_init(volinfo, svc); +- if (ret) +- goto out; +- } +- +- if (shd->attached) { +- ret = glusterd_attach_svc(svc, volinfo, flags); +- if (ret) { +- gf_msg("glusterd", GF_LOG_ERROR, 0, GD_MSG_VOLINFO_GET_FAIL, +- "Failed to attach shd svc(volume=%s) to pid=%d. Starting" +- "a new process", +- volinfo->volname, glusterd_proc_get_pid(&svc->proc)); +- ret = glusterd_recover_shd_attach_failure(volinfo, svc, flags); +- } +- goto out; +- } +- ret = glusterd_new_shd_svc_start(svc, flags); +- if (!ret) { +- shd->attached = _gf_true; +- } +-out: +- if (volinfo) +- glusterd_volinfo_unref(volinfo); + gf_msg_debug(THIS->name, 0, "Returning %d", ret); + + return ret; + } + + int +-glusterd_shdsvc_reconfigure(glusterd_volinfo_t *volinfo) ++glusterd_shdsvc_reconfigure() + { + int ret = -1; + xlator_t *this = NULL; ++ glusterd_conf_t *priv = NULL; + gf_boolean_t identical = _gf_false; +- dict_t *mod_dict = NULL; +- glusterd_svc_t *svc = NULL; + + this = THIS; + GF_VALIDATE_OR_GOTO("glusterd", this, out); + +- if (!volinfo) { +- /* reconfigure will be called separately*/ +- ret = 0; +- goto out; +- } ++ priv = this->private; ++ GF_VALIDATE_OR_GOTO(this->name, priv, out); + +- glusterd_volinfo_ref(volinfo); +- svc = &(volinfo->shd.svc); +- if (glusterd_svcs_shd_compatible_volumes_stopped(svc)) ++ if (glusterd_all_shd_compatible_volumes_stopped()) + goto manager; + + /* +@@ -500,42 +220,8 @@ glusterd_shdsvc_reconfigure(glusterd_volinfo_t *volinfo) + * and cksum i.e. "character-by-character". If YES, then + * NOTHING has been changed, just return. + */ +- +- if (!glusterd_is_shd_compatible_volume(volinfo)) { +- if (svc->inited) +- goto manager; +- +- /* Nothing to do if not shd compatible */ +- ret = 0; +- goto out; +- } +- mod_dict = dict_new(); +- if (!mod_dict) +- goto out; +- +- ret = dict_set_uint32(mod_dict, "cluster.background-self-heal-count", 0); +- if (ret) +- goto out; +- +- ret = dict_set_str(mod_dict, "cluster.data-self-heal", "on"); +- if (ret) +- goto out; +- +- ret = dict_set_str(mod_dict, "cluster.metadata-self-heal", "on"); +- if (ret) +- goto out; +- +- ret = dict_set_int32(mod_dict, "graph-check", 1); +- if (ret) +- goto out; +- +- ret = dict_set_str(mod_dict, "cluster.entry-self-heal", "on"); +- if (ret) +- goto out; +- +- ret = glusterd_volume_svc_check_volfile_identical( +- "glustershd", mod_dict, volinfo, glusterd_shdsvc_generate_volfile, +- &identical); ++ ret = glusterd_svc_check_volfile_identical(priv->shd_svc.name, ++ build_shd_graph, &identical); + if (ret) + goto out; + +@@ -550,9 +236,8 @@ glusterd_shdsvc_reconfigure(glusterd_volinfo_t *volinfo) + * changed, then inform the xlator to reconfigure the options. + */ + identical = _gf_false; /* RESET the FLAG */ +- ret = glusterd_volume_svc_check_topology_identical( +- "glustershd", mod_dict, volinfo, glusterd_shdsvc_generate_volfile, +- &identical); ++ ret = glusterd_svc_check_topology_identical(priv->shd_svc.name, ++ build_shd_graph, &identical); + if (ret) + goto out; + +@@ -560,7 +245,7 @@ glusterd_shdsvc_reconfigure(glusterd_volinfo_t *volinfo) + * options to shd volfile, so that shd will be reconfigured. + */ + if (identical) { +- ret = glusterd_shdsvc_create_volfile(volinfo); ++ ret = glusterd_shdsvc_create_volfile(); + if (ret == 0) { /* Only if above PASSES */ + ret = glusterd_fetchspec_notify(THIS); + } +@@ -568,129 +253,12 @@ glusterd_shdsvc_reconfigure(glusterd_volinfo_t *volinfo) + } + manager: + /* +- * shd volfile's topology has been changed. volfile needs +- * to be RECONFIGURED to ACT on the changed volfile. ++ * shd volfile's topology has been changed. shd server needs ++ * to be RESTARTED to ACT on the changed volfile. + */ +- ret = svc->manager(svc, volinfo, PROC_START_NO_WAIT); ++ ret = priv->shd_svc.manager(&(priv->shd_svc), NULL, PROC_START_NO_WAIT); + + out: +- if (volinfo) +- glusterd_volinfo_unref(volinfo); +- if (mod_dict) +- dict_unref(mod_dict); + gf_msg_debug(this ? this->name : "glusterd", 0, "Returning %d", ret); + return ret; + } +- +-int +-glusterd_shdsvc_restart() +-{ +- glusterd_volinfo_t *volinfo = NULL; +- glusterd_volinfo_t *tmp = NULL; +- int ret = -1; +- xlator_t *this = THIS; +- glusterd_conf_t *conf = NULL; +- glusterd_svc_t *svc = NULL; +- +- GF_VALIDATE_OR_GOTO("glusterd", this, out); +- +- conf = this->private; +- GF_VALIDATE_OR_GOTO(this->name, conf, out); +- +- pthread_mutex_lock(&conf->volume_lock); +- cds_list_for_each_entry_safe(volinfo, tmp, &conf->volumes, vol_list) +- { +- glusterd_volinfo_ref(volinfo); +- pthread_mutex_unlock(&conf->volume_lock); +- /* Start per volume shd svc */ +- if (volinfo->status == GLUSTERD_STATUS_STARTED) { +- svc = &(volinfo->shd.svc); +- ret = svc->manager(svc, volinfo, PROC_START_NO_WAIT); +- if (ret) { +- gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_SHD_START_FAIL, +- "Couldn't start shd for " +- "vol: %s on restart", +- volinfo->volname); +- gf_event(EVENT_SVC_MANAGER_FAILED, "volume=%s;svc_name=%s", +- volinfo->volname, svc->name); +- glusterd_volinfo_unref(volinfo); +- goto out; +- } +- } +- glusterd_volinfo_unref(volinfo); +- pthread_mutex_lock(&conf->volume_lock); +- } +- pthread_mutex_unlock(&conf->volume_lock); +-out: +- return ret; +-} +- +-int +-glusterd_shdsvc_stop(glusterd_svc_t *svc, int sig) +-{ +- int ret = -1; +- glusterd_svc_proc_t *svc_proc = NULL; +- glusterd_shdsvc_t *shd = NULL; +- glusterd_volinfo_t *volinfo = NULL; +- gf_boolean_t empty = _gf_false; +- glusterd_conf_t *conf = NULL; +- int pid = -1; +- +- conf = THIS->private; +- GF_VALIDATE_OR_GOTO("glusterd", svc, out); +- svc_proc = svc->svc_proc; +- GF_VALIDATE_OR_GOTO("glusterd", svc_proc, out); +- GF_VALIDATE_OR_GOTO("glusterd", conf, out); +- +- /* Get volinfo->shd from svc object */ +- shd = cds_list_entry(svc, glusterd_shdsvc_t, svc); +- if (!shd) { +- gf_msg("glusterd", GF_LOG_ERROR, 0, GD_MSG_SHD_OBJ_GET_FAIL, +- "Failed to get shd object " +- "from shd service"); +- return -1; +- } +- +- /* Get volinfo from shd */ +- volinfo = cds_list_entry(shd, glusterd_volinfo_t, shd); +- if (!volinfo) { +- gf_msg("glusterd", GF_LOG_ERROR, 0, GD_MSG_VOLINFO_GET_FAIL, +- "Failed to get volinfo from " +- "from shd"); +- return -1; +- } +- +- glusterd_volinfo_ref(volinfo); +- pthread_mutex_lock(&conf->attach_lock); +- { +- gf_is_service_running(svc->proc.pidfile, &pid); +- cds_list_del_init(&svc->mux_svc); +- empty = cds_list_empty(&svc_proc->svcs); +- } +- pthread_mutex_unlock(&conf->attach_lock); +- if (empty) { +- /* Unref will happen when destroying the connection */ +- glusterd_volinfo_ref(volinfo); +- svc_proc->data = volinfo; +- ret = glusterd_svc_stop(svc, sig); +- } +- if (!empty && pid != -1) { +- ret = glusterd_detach_svc(svc, volinfo, sig); +- if (ret) +- gf_msg(THIS->name, GF_LOG_ERROR, 0, GD_MSG_SVC_STOP_FAIL, +- "shd service is failed to detach volume %s from pid %d", +- volinfo->volname, glusterd_proc_get_pid(&svc->proc)); +- else +- gf_msg(THIS->name, GF_LOG_INFO, 0, GD_MSG_SVC_STOP_SUCCESS, +- "Shd service is detached for volume %s from pid %d", +- volinfo->volname, glusterd_proc_get_pid(&svc->proc)); +- } +- svc->online = _gf_false; +- (void)glusterd_unlink_file((char *)svc->proc.pidfile); +- glusterd_shd_svcproc_cleanup(shd); +- ret = 0; +- glusterd_volinfo_unref(volinfo); +-out: +- gf_msg_debug(THIS->name, 0, "Returning %d", ret); +- return ret; +-} +diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc.h b/xlators/mgmt/glusterd/src/glusterd-shd-svc.h +index 55b409f..775a9d4 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc.h ++++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc.h +@@ -12,20 +12,12 @@ + #define _GLUSTERD_SHD_SVC_H_ + + #include "glusterd-svc-mgmt.h" +-#include "glusterd.h" +- +-typedef struct glusterd_shdsvc_ glusterd_shdsvc_t; +-struct glusterd_shdsvc_ { +- glusterd_svc_t svc; +- gf_boolean_t attached; +-}; + + void + glusterd_shdsvc_build(glusterd_svc_t *svc); + + int +-glusterd_shdsvc_init(void *data, glusterd_conn_t *mux_conn, +- glusterd_svc_proc_t *svc_proc); ++glusterd_shdsvc_init(glusterd_svc_t *svc); + + int + glusterd_shdsvc_manager(glusterd_svc_t *svc, void *data, int flags); +@@ -35,11 +27,4 @@ glusterd_shdsvc_start(glusterd_svc_t *svc, int flags); + + int + glusterd_shdsvc_reconfigure(); +- +-int +-glusterd_shdsvc_restart(); +- +-int +-glusterd_shdsvc_stop(glusterd_svc_t *svc, int sig); +- + #endif +diff --git a/xlators/mgmt/glusterd/src/glusterd-sm.c b/xlators/mgmt/glusterd/src/glusterd-sm.c +index 943b1c6..54a7bd1 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-sm.c ++++ b/xlators/mgmt/glusterd/src/glusterd-sm.c +@@ -748,16 +748,6 @@ glusterd_peer_detach_cleanup(glusterd_conf_t *priv) + } + } + +- if (glusterd_is_shd_compatible_volume(volinfo)) { +- svc = &(volinfo->shd.svc); +- ret = svc->stop(svc, SIGTERM); +- if (ret) { +- gf_msg(THIS->name, GF_LOG_ERROR, 0, GD_MSG_SVC_STOP_FAIL, +- "Failed " +- "to stop shd daemon service"); +- } +- } +- + if (glusterd_is_gfproxyd_enabled(volinfo)) { + svc = &(volinfo->gfproxyd.svc); + ret = svc->stop(svc, SIGTERM); +@@ -785,7 +775,7 @@ glusterd_peer_detach_cleanup(glusterd_conf_t *priv) + } + + /*Reconfigure all daemon services upon peer detach*/ +- ret = glusterd_svcs_reconfigure(NULL); ++ ret = glusterd_svcs_reconfigure(); + if (ret) { + gf_msg(THIS->name, GF_LOG_ERROR, 0, GD_MSG_SVC_STOP_FAIL, + "Failed to reconfigure all daemon services."); +diff --git a/xlators/mgmt/glusterd/src/glusterd-snapd-svc.c b/xlators/mgmt/glusterd/src/glusterd-snapd-svc.c +index 1da4076..56bab07 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-snapd-svc.c ++++ b/xlators/mgmt/glusterd/src/glusterd-snapd-svc.c +@@ -366,7 +366,6 @@ int + glusterd_snapdsvc_restart() + { + glusterd_volinfo_t *volinfo = NULL; +- glusterd_volinfo_t *tmp = NULL; + int ret = 0; + xlator_t *this = THIS; + glusterd_conf_t *conf = NULL; +@@ -377,7 +376,7 @@ glusterd_snapdsvc_restart() + conf = this->private; + GF_ASSERT(conf); + +- cds_list_for_each_entry_safe(volinfo, tmp, &conf->volumes, vol_list) ++ cds_list_for_each_entry(volinfo, &conf->volumes, vol_list) + { + /* Start per volume snapd svc */ + if (volinfo->status == GLUSTERD_STATUS_STARTED) { +diff --git a/xlators/mgmt/glusterd/src/glusterd-statedump.c b/xlators/mgmt/glusterd/src/glusterd-statedump.c +index 69d4cf4..f5ecde7 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-statedump.c ++++ b/xlators/mgmt/glusterd/src/glusterd-statedump.c +@@ -202,6 +202,9 @@ glusterd_dump_priv(xlator_t *this) + gf_proc_dump_build_key(key, "glusterd", "ping-timeout"); + gf_proc_dump_write(key, "%d", priv->ping_timeout); + ++ gf_proc_dump_build_key(key, "glusterd", "shd.online"); ++ gf_proc_dump_write(key, "%d", priv->shd_svc.online); ++ + gf_proc_dump_build_key(key, "glusterd", "nfs.online"); + gf_proc_dump_write(key, "%d", priv->nfs_svc.online); + +diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c +index e42703c..ca19a75 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c ++++ b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c +@@ -7,7 +7,6 @@ + later), or the GNU General Public License, version 2 (GPLv2), in all + cases as published by the Free Software Foundation. + */ +-#include + + #include + #include +@@ -21,14 +20,12 @@ + #include "glusterd-bitd-svc.h" + #include "glusterd-tierd-svc.h" + #include "glusterd-tierd-svc-helper.h" +-#include "glusterd-shd-svc-helper.h" + #include "glusterd-scrub-svc.h" + #include "glusterd-svc-helper.h" + #include +-#include "glusterd-snapshot-utils.h" + + int +-glusterd_svcs_reconfigure(glusterd_volinfo_t *volinfo) ++glusterd_svcs_reconfigure() + { + int ret = 0; + xlator_t *this = THIS; +@@ -46,11 +43,9 @@ glusterd_svcs_reconfigure(glusterd_volinfo_t *volinfo) + goto out; + + svc_name = "self-heald"; +- if (volinfo) { +- ret = glusterd_shdsvc_reconfigure(volinfo); +- if (ret) +- goto out; +- } ++ ret = glusterd_shdsvc_reconfigure(); ++ if (ret) ++ goto out; + + if (conf->op_version == GD_OP_VERSION_MIN) + goto out; +@@ -74,7 +69,7 @@ out: + } + + int +-glusterd_svcs_stop(glusterd_volinfo_t *volinfo) ++glusterd_svcs_stop() + { + int ret = 0; + xlator_t *this = NULL; +@@ -90,15 +85,13 @@ glusterd_svcs_stop(glusterd_volinfo_t *volinfo) + if (ret) + goto out; + +- ret = glusterd_svc_stop(&(priv->quotad_svc), SIGTERM); ++ ret = glusterd_svc_stop(&(priv->shd_svc), SIGTERM); + if (ret) + goto out; + +- if (volinfo) { +- ret = glusterd_svc_stop(&(volinfo->shd.svc), PROC_START_NO_WAIT); +- if (ret) +- goto out; +- } ++ ret = glusterd_svc_stop(&(priv->quotad_svc), SIGTERM); ++ if (ret) ++ goto out; + + ret = glusterd_svc_stop(&(priv->bitd_svc), SIGTERM); + if (ret) +@@ -128,6 +121,12 @@ glusterd_svcs_manager(glusterd_volinfo_t *volinfo) + if (ret) + goto out; + ++ ret = conf->shd_svc.manager(&(conf->shd_svc), volinfo, PROC_START_NO_WAIT); ++ if (ret == -EINVAL) ++ ret = 0; ++ if (ret) ++ goto out; ++ + if (conf->op_version == GD_OP_VERSION_MIN) + goto out; + +@@ -144,15 +143,6 @@ glusterd_svcs_manager(glusterd_volinfo_t *volinfo) + if (ret) + goto out; + +- if (volinfo) { +- ret = volinfo->shd.svc.manager(&(volinfo->shd.svc), volinfo, +- PROC_START_NO_WAIT); +- if (ret == -EINVAL) +- ret = 0; +- if (ret) +- goto out; +- } +- + ret = conf->scrub_svc.manager(&(conf->scrub_svc), NULL, PROC_START_NO_WAIT); + if (ret == -EINVAL) + ret = 0; +@@ -279,678 +269,3 @@ out: + GF_FREE(tmpvol); + return ret; + } +- +-int +-glusterd_volume_svc_check_volfile_identical( +- char *svc_name, dict_t *mode_dict, glusterd_volinfo_t *volinfo, +- glusterd_vol_graph_builder_t builder, gf_boolean_t *identical) +-{ +- char orgvol[PATH_MAX] = { +- 0, +- }; +- char *tmpvol = NULL; +- xlator_t *this = NULL; +- int ret = -1; +- int need_unlink = 0; +- int tmp_fd = -1; +- +- this = THIS; +- +- GF_VALIDATE_OR_GOTO(this->name, this, out); +- GF_VALIDATE_OR_GOTO(this->name, identical, out); +- +- /* This builds volfile for volume level dameons */ +- glusterd_volume_svc_build_volfile_path(svc_name, volinfo, orgvol, +- sizeof(orgvol)); +- +- ret = gf_asprintf(&tmpvol, "/tmp/g%s-XXXXXX", svc_name); +- if (ret < 0) { +- goto out; +- } +- +- /* coverity[secure_temp] mkstemp uses 0600 as the mode and is safe */ +- tmp_fd = mkstemp(tmpvol); +- if (tmp_fd < 0) { +- gf_msg(this->name, GF_LOG_WARNING, errno, GD_MSG_FILE_OP_FAILED, +- "Unable to create temp file" +- " %s:(%s)", +- tmpvol, strerror(errno)); +- ret = -1; +- goto out; +- } +- +- need_unlink = 1; +- +- ret = builder(volinfo, tmpvol, mode_dict); +- if (ret) +- goto out; +- +- ret = glusterd_check_files_identical(orgvol, tmpvol, identical); +-out: +- if (need_unlink) +- sys_unlink(tmpvol); +- +- if (tmpvol != NULL) +- GF_FREE(tmpvol); +- +- if (tmp_fd >= 0) +- sys_close(tmp_fd); +- +- return ret; +-} +- +-int +-glusterd_volume_svc_check_topology_identical( +- char *svc_name, dict_t *mode_dict, glusterd_volinfo_t *volinfo, +- glusterd_vol_graph_builder_t builder, gf_boolean_t *identical) +-{ +- char orgvol[PATH_MAX] = { +- 0, +- }; +- char *tmpvol = NULL; +- glusterd_conf_t *conf = NULL; +- xlator_t *this = THIS; +- int ret = -1; +- int tmpclean = 0; +- int tmpfd = -1; +- +- if ((!identical) || (!this) || (!this->private)) +- goto out; +- +- conf = this->private; +- GF_VALIDATE_OR_GOTO(this->name, conf, out); +- +- /* This builds volfile for volume level dameons */ +- glusterd_volume_svc_build_volfile_path(svc_name, volinfo, orgvol, +- sizeof(orgvol)); +- /* Create the temporary volfile */ +- ret = gf_asprintf(&tmpvol, "/tmp/g%s-XXXXXX", svc_name); +- if (ret < 0) { +- goto out; +- } +- +- /* coverity[secure_temp] mkstemp uses 0600 as the mode and is safe */ +- tmpfd = mkstemp(tmpvol); +- if (tmpfd < 0) { +- gf_msg(this->name, GF_LOG_WARNING, errno, GD_MSG_FILE_OP_FAILED, +- "Unable to create temp file" +- " %s:(%s)", +- tmpvol, strerror(errno)); +- ret = -1; +- goto out; +- } +- +- tmpclean = 1; /* SET the flag to unlink() tmpfile */ +- +- ret = builder(volinfo, tmpvol, mode_dict); +- if (ret) +- goto out; +- +- /* Compare the topology of volfiles */ +- ret = glusterd_check_topology_identical(orgvol, tmpvol, identical); +-out: +- if (tmpfd >= 0) +- sys_close(tmpfd); +- if (tmpclean) +- sys_unlink(tmpvol); +- if (tmpvol != NULL) +- GF_FREE(tmpvol); +- return ret; +-} +- +-void * +-__gf_find_compatible_svc(gd_node_type daemon) +-{ +- glusterd_svc_proc_t *svc_proc = NULL; +- glusterd_svc_proc_t *return_proc = NULL; +- glusterd_svc_t *parent_svc = NULL; +- struct cds_list_head *svc_procs = NULL; +- glusterd_conf_t *conf = NULL; +- int pid = -1; +- +- conf = THIS->private; +- GF_VALIDATE_OR_GOTO("glusterd", conf, out); +- +- if (daemon == GD_NODE_SHD) { +- svc_procs = &conf->shd_procs; +- if (!svc_procs) +- goto out; +- } +- +- cds_list_for_each_entry(svc_proc, svc_procs, svc_proc_list) +- { +- parent_svc = cds_list_entry(svc_proc->svcs.next, glusterd_svc_t, +- mux_svc); +- if (!return_proc) +- return_proc = svc_proc; +- +- /* If there is an already running shd daemons, select it. Otehrwise +- * select the first one. +- */ +- if (parent_svc && gf_is_service_running(parent_svc->proc.pidfile, &pid)) +- return (void *)svc_proc; +- /* +- * Logic to select one process goes here. Currently there is only one +- * shd_proc. So selecting the first one; +- */ +- } +-out: +- return return_proc; +-} +- +-glusterd_svc_proc_t * +-glusterd_svcprocess_new() +-{ +- glusterd_svc_proc_t *new_svcprocess = NULL; +- +- new_svcprocess = GF_CALLOC(1, sizeof(*new_svcprocess), +- gf_gld_mt_glusterd_svc_proc_t); +- +- if (!new_svcprocess) +- return NULL; +- +- CDS_INIT_LIST_HEAD(&new_svcprocess->svc_proc_list); +- CDS_INIT_LIST_HEAD(&new_svcprocess->svcs); +- new_svcprocess->notify = glusterd_muxsvc_common_rpc_notify; +- return new_svcprocess; +-} +- +-int +-glusterd_shd_svc_mux_init(glusterd_volinfo_t *volinfo, glusterd_svc_t *svc) +-{ +- int ret = -1; +- glusterd_svc_proc_t *mux_proc = NULL; +- glusterd_conn_t *mux_conn = NULL; +- glusterd_conf_t *conf = NULL; +- glusterd_svc_t *parent_svc = NULL; +- int pid = -1; +- +- GF_VALIDATE_OR_GOTO("glusterd", svc, out); +- GF_VALIDATE_OR_GOTO("glusterd", volinfo, out); +- conf = THIS->private; +- GF_VALIDATE_OR_GOTO("glusterd", conf, out); +- GF_VALIDATE_OR_GOTO("glusterd", svc, out); +- +- pthread_mutex_lock(&conf->attach_lock); +- { +- if (!svc->inited) { +- if (gf_is_service_running(svc->proc.pidfile, &pid)) { +- /* Just connect is required, but we don't know what happens +- * during the disconnect. So better to reattach. +- */ +- mux_proc = __gf_find_compatible_svc_from_pid(GD_NODE_SHD, pid); +- } +- +- if (!mux_proc) { +- if (pid != -1 && sys_access(svc->proc.pidfile, R_OK) == 0) { +- /* stale pid file, unlink it. */ +- kill(pid, SIGTERM); +- sys_unlink(svc->proc.pidfile); +- } +- mux_proc = __gf_find_compatible_svc(GD_NODE_SHD); +- } +- if (mux_proc) { +- /* Take first entry from the process */ +- parent_svc = cds_list_entry(mux_proc->svcs.next, glusterd_svc_t, +- mux_svc); +- sys_link(parent_svc->proc.pidfile, svc->proc.pidfile); +- mux_conn = &parent_svc->conn; +- if (volinfo) +- volinfo->shd.attached = _gf_true; +- } else { +- mux_proc = glusterd_svcprocess_new(); +- if (!mux_proc) { +- ret = -1; +- goto unlock; +- } +- cds_list_add_tail(&mux_proc->svc_proc_list, &conf->shd_procs); +- } +- svc->svc_proc = mux_proc; +- cds_list_del_init(&svc->mux_svc); +- cds_list_add_tail(&svc->mux_svc, &mux_proc->svcs); +- ret = glusterd_shdsvc_init(volinfo, mux_conn, mux_proc); +- if (ret) { +- pthread_mutex_unlock(&conf->attach_lock); +- gf_msg(THIS->name, GF_LOG_ERROR, 0, GD_MSG_FAILED_INIT_SHDSVC, +- "Failed to init shd " +- "service"); +- goto out; +- } +- gf_msg_debug(THIS->name, 0, "shd service initialized"); +- svc->inited = _gf_true; +- } +- ret = 0; +- } +-unlock: +- pthread_mutex_unlock(&conf->attach_lock); +-out: +- return ret; +-} +- +-void * +-__gf_find_compatible_svc_from_pid(gd_node_type daemon, pid_t pid) +-{ +- glusterd_svc_proc_t *svc_proc = NULL; +- struct cds_list_head *svc_procs = NULL; +- glusterd_svc_t *svc = NULL; +- pid_t mux_pid = -1; +- glusterd_conf_t *conf = NULL; +- +- conf = THIS->private; +- if (!conf) +- return NULL; +- +- if (daemon == GD_NODE_SHD) { +- svc_procs = &conf->shd_procs; +- if (!svc_proc) +- return NULL; +- } /* Can be moved to switch when mux is implemented for other daemon; */ +- +- cds_list_for_each_entry(svc_proc, svc_procs, svc_proc_list) +- { +- cds_list_for_each_entry(svc, &svc_proc->svcs, mux_svc) +- { +- if (gf_is_service_running(svc->proc.pidfile, &mux_pid)) { +- if (mux_pid == pid) { +- /*TODO +- * inefficient loop, but at the moment, there is only +- * one shd. +- */ +- return svc_proc; +- } +- } +- } +- } +- return NULL; +-} +- +-static int32_t +-my_callback(struct rpc_req *req, struct iovec *iov, int count, void *v_frame) +-{ +- call_frame_t *frame = v_frame; +- xlator_t *this = NULL; +- glusterd_conf_t *conf = NULL; +- +- GF_VALIDATE_OR_GOTO("glusterd", frame, out); +- this = frame->this; +- GF_VALIDATE_OR_GOTO("glusterd", this, out); +- conf = this->private; +- GF_VALIDATE_OR_GOTO(this->name, conf, out); +- +- GF_ATOMIC_DEC(conf->blockers); +- +- STACK_DESTROY(frame->root); +-out: +- return 0; +-} +- +-static int32_t +-glusterd_svc_attach_cbk(struct rpc_req *req, struct iovec *iov, int count, +- void *v_frame) +-{ +- call_frame_t *frame = v_frame; +- glusterd_volinfo_t *volinfo = NULL; +- glusterd_shdsvc_t *shd = NULL; +- glusterd_svc_t *svc = frame->cookie; +- glusterd_svc_t *parent_svc = NULL; +- glusterd_svc_proc_t *mux_proc = NULL; +- glusterd_conf_t *conf = NULL; +- int *flag = (int *)frame->local; +- xlator_t *this = THIS; +- int pid = -1; +- int ret = -1; +- gf_getspec_rsp rsp = { +- 0, +- }; +- +- GF_VALIDATE_OR_GOTO("glusterd", this, out); +- conf = this->private; +- GF_VALIDATE_OR_GOTO("glusterd", conf, out); +- GF_VALIDATE_OR_GOTO("glusterd", frame, out); +- GF_VALIDATE_OR_GOTO("glusterd", svc, out); +- +- frame->local = NULL; +- frame->cookie = NULL; +- +- if (!strcmp(svc->name, "glustershd")) { +- /* Get volinfo->shd from svc object */ +- shd = cds_list_entry(svc, glusterd_shdsvc_t, svc); +- if (!shd) { +- gf_msg("glusterd", GF_LOG_ERROR, 0, GD_MSG_SHD_OBJ_GET_FAIL, +- "Failed to get shd object " +- "from shd service"); +- goto out; +- } +- +- /* Get volinfo from shd */ +- volinfo = cds_list_entry(shd, glusterd_volinfo_t, shd); +- if (!volinfo) { +- gf_msg("glusterd", GF_LOG_ERROR, 0, GD_MSG_VOLINFO_GET_FAIL, +- "Failed to get volinfo from " +- "from shd"); +- goto out; +- } +- } +- +- if (!iov) { +- gf_msg(frame->this->name, GF_LOG_ERROR, 0, GD_MSG_REQ_DECODE_FAIL, +- "iov is NULL"); +- ret = -1; +- goto out; +- } +- +- ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gf_getspec_rsp); +- if (ret < 0) { +- gf_msg(frame->this->name, GF_LOG_ERROR, 0, GD_MSG_REQ_DECODE_FAIL, +- "XDR decoding error"); +- ret = -1; +- goto out; +- } +- +- if (rsp.op_ret == 0) { +- pthread_mutex_lock(&conf->attach_lock); +- { +- if (!strcmp(svc->name, "glustershd")) { +- mux_proc = svc->svc_proc; +- if (mux_proc && +- !gf_is_service_running(svc->proc.pidfile, &pid)) { +- /* +- * When svc's are restarting, there is a chance that the +- * attached svc might not have updated it's pid. Because +- * it was at connection stage. So in that case, we need +- * to retry the pid file copy. +- */ +- parent_svc = cds_list_entry(mux_proc->svcs.next, +- glusterd_svc_t, mux_svc); +- if (parent_svc) +- sys_link(parent_svc->proc.pidfile, svc->proc.pidfile); +- } +- } +- svc->online = _gf_true; +- } +- pthread_mutex_unlock(&conf->attach_lock); +- gf_msg(this->name, GF_LOG_INFO, 0, GD_MSG_SVC_ATTACH_FAIL, +- "svc %s of volume %s attached successfully to pid %d", svc->name, +- volinfo->volname, glusterd_proc_get_pid(&svc->proc)); +- } else { +- gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_SVC_ATTACH_FAIL, +- "svc %s of volume %s failed to " +- "attach to pid %d. Starting a new process", +- svc->name, volinfo->volname, glusterd_proc_get_pid(&svc->proc)); +- if (!strcmp(svc->name, "glustershd")) { +- glusterd_recover_shd_attach_failure(volinfo, svc, *flag); +- } +- } +-out: +- if (flag) { +- GF_FREE(flag); +- } +- GF_ATOMIC_DEC(conf->blockers); +- STACK_DESTROY(frame->root); +- return 0; +-} +- +-extern size_t +-build_volfile_path(char *volume_id, char *path, size_t path_len, +- char *trusted_str); +- +-int +-__glusterd_send_svc_configure_req(glusterd_svc_t *svc, int flags, +- struct rpc_clnt *rpc, char *volfile_id, +- int op) +-{ +- int ret = -1; +- struct iobuf *iobuf = NULL; +- struct iobref *iobref = NULL; +- struct iovec iov = { +- 0, +- }; +- char path[PATH_MAX] = { +- '\0', +- }; +- struct stat stbuf = { +- 0, +- }; +- int32_t spec_fd = -1; +- size_t file_len = -1; +- char *volfile_content = NULL; +- ssize_t req_size = 0; +- call_frame_t *frame = NULL; +- gd1_mgmt_brick_op_req brick_req; +- void *req = &brick_req; +- void *errlbl = &&err; +- struct rpc_clnt_connection *conn; +- xlator_t *this = THIS; +- glusterd_conf_t *conf = THIS->private; +- extern struct rpc_clnt_program gd_brick_prog; +- fop_cbk_fn_t cbkfn = my_callback; +- +- if (!rpc) { +- gf_msg("glusterd", GF_LOG_ERROR, 0, GD_MSG_PARAM_NULL, +- "called with null rpc"); +- return -1; +- } +- +- conn = &rpc->conn; +- if (!conn->connected || conn->disconnected) { +- gf_msg(this->name, GF_LOG_INFO, 0, GD_MSG_CONNECT_RETURNED, +- "not connected yet"); +- return -1; +- } +- +- brick_req.op = op; +- brick_req.name = volfile_id; +- brick_req.input.input_val = NULL; +- brick_req.input.input_len = 0; +- +- frame = create_frame(this, this->ctx->pool); +- if (!frame) { +- goto *errlbl; +- } +- +- if (op == GLUSTERD_SVC_ATTACH) { +- (void)build_volfile_path(volfile_id, path, sizeof(path), NULL); +- +- ret = sys_stat(path, &stbuf); +- if (ret < 0) { +- gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_SVC_ATTACH_FAIL, +- "Unable to stat %s (%s)", path, strerror(errno)); +- ret = -EINVAL; +- goto *errlbl; +- } +- +- file_len = stbuf.st_size; +- volfile_content = GF_MALLOC(file_len + 1, gf_common_mt_char); +- if (!volfile_content) { +- ret = -ENOMEM; +- goto *errlbl; +- } +- spec_fd = open(path, O_RDONLY); +- if (spec_fd < 0) { +- gf_msg(THIS->name, GF_LOG_WARNING, 0, GD_MSG_SVC_ATTACH_FAIL, +- "failed to read volfile %s", path); +- ret = -EIO; +- goto *errlbl; +- } +- ret = sys_read(spec_fd, volfile_content, file_len); +- if (ret == file_len) { +- brick_req.input.input_val = volfile_content; +- brick_req.input.input_len = file_len; +- } else { +- gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_SVC_ATTACH_FAIL, +- "read failed on path %s. File size=%" GF_PRI_SIZET +- "read size=%d", +- path, file_len, ret); +- ret = -EIO; +- goto *errlbl; +- } +- +- frame->cookie = svc; +- frame->local = GF_CALLOC(1, sizeof(int), gf_gld_mt_int); +- *((int *)frame->local) = flags; +- cbkfn = glusterd_svc_attach_cbk; +- } +- +- req_size = xdr_sizeof((xdrproc_t)xdr_gd1_mgmt_brick_op_req, req); +- iobuf = iobuf_get2(rpc->ctx->iobuf_pool, req_size); +- if (!iobuf) { +- goto *errlbl; +- } +- errlbl = &&maybe_free_iobuf; +- +- iov.iov_base = iobuf->ptr; +- iov.iov_len = iobuf_pagesize(iobuf); +- +- iobref = iobref_new(); +- if (!iobref) { +- goto *errlbl; +- } +- errlbl = &&free_iobref; +- +- iobref_add(iobref, iobuf); +- /* +- * Drop our reference to the iobuf. The iobref should already have +- * one after iobref_add, so when we unref that we'll free the iobuf as +- * well. This allows us to pass just the iobref as frame->local. +- */ +- iobuf_unref(iobuf); +- /* Set the pointer to null so we don't free it on a later error. */ +- iobuf = NULL; +- +- /* Create the xdr payload */ +- ret = xdr_serialize_generic(iov, req, (xdrproc_t)xdr_gd1_mgmt_brick_op_req); +- if (ret == -1) { +- goto *errlbl; +- } +- iov.iov_len = ret; +- +- /* Send the msg */ +- GF_ATOMIC_INC(conf->blockers); +- ret = rpc_clnt_submit(rpc, &gd_brick_prog, op, cbkfn, &iov, 1, NULL, 0, +- iobref, frame, NULL, 0, NULL, 0, NULL); +- GF_FREE(volfile_content); +- if (spec_fd >= 0) +- sys_close(spec_fd); +- return ret; +- +-free_iobref: +- iobref_unref(iobref); +-maybe_free_iobuf: +- if (iobuf) { +- iobuf_unref(iobuf); +- } +-err: +- GF_FREE(volfile_content); +- if (spec_fd >= 0) +- sys_close(spec_fd); +- if (frame) +- STACK_DESTROY(frame->root); +- return -1; +-} +- +-int +-glusterd_attach_svc(glusterd_svc_t *svc, glusterd_volinfo_t *volinfo, int flags) +-{ +- glusterd_conf_t *conf = THIS->private; +- int ret = -1; +- int tries; +- rpc_clnt_t *rpc = NULL; +- +- GF_VALIDATE_OR_GOTO("glusterd", conf, out); +- GF_VALIDATE_OR_GOTO("glusterd", svc, out); +- GF_VALIDATE_OR_GOTO("glusterd", volinfo, out); +- +- gf_msg("glusterd", GF_LOG_INFO, 0, GD_MSG_ATTACH_INFO, +- "adding svc %s (volume=%s) to existing " +- "process with pid %d", +- svc->name, volinfo->volname, glusterd_proc_get_pid(&svc->proc)); +- +- rpc = rpc_clnt_ref(svc->conn.rpc); +- for (tries = 15; tries > 0; --tries) { +- if (rpc) { +- pthread_mutex_lock(&conf->attach_lock); +- { +- ret = __glusterd_send_svc_configure_req( +- svc, flags, rpc, svc->proc.volfileid, GLUSTERD_SVC_ATTACH); +- } +- pthread_mutex_unlock(&conf->attach_lock); +- if (!ret) { +- volinfo->shd.attached = _gf_true; +- goto out; +- } +- } +- /* +- * It might not actually be safe to manipulate the lock +- * like this, but if we don't then the connection can +- * never actually complete and retries are useless. +- * Unfortunately, all of the alternatives (e.g. doing +- * all of this in a separate thread) are much more +- * complicated and risky. +- * TBD: see if there's a better way +- */ +- synclock_unlock(&conf->big_lock); +- sleep(1); +- synclock_lock(&conf->big_lock); +- } +- ret = -1; +- gf_msg("glusterd", GF_LOG_WARNING, 0, GD_MSG_SVC_ATTACH_FAIL, +- "attach failed for %s(volume=%s)", svc->name, volinfo->volname); +-out: +- if (rpc) +- rpc_clnt_unref(rpc); +- return ret; +-} +- +-int +-glusterd_detach_svc(glusterd_svc_t *svc, glusterd_volinfo_t *volinfo, int sig) +-{ +- glusterd_conf_t *conf = THIS->private; +- int ret = -1; +- int tries; +- rpc_clnt_t *rpc = NULL; +- +- GF_VALIDATE_OR_GOTO(THIS->name, conf, out); +- GF_VALIDATE_OR_GOTO(THIS->name, svc, out); +- GF_VALIDATE_OR_GOTO(THIS->name, volinfo, out); +- +- gf_msg(THIS->name, GF_LOG_INFO, 0, GD_MSG_DETACH_INFO, +- "removing svc %s (volume=%s) from existing " +- "process with pid %d", +- svc->name, volinfo->volname, glusterd_proc_get_pid(&svc->proc)); +- +- rpc = rpc_clnt_ref(svc->conn.rpc); +- for (tries = 15; tries > 0; --tries) { +- if (rpc) { +- /*For detach there is no flags, and we are not using sig.*/ +- pthread_mutex_lock(&conf->attach_lock); +- { +- ret = __glusterd_send_svc_configure_req(svc, 0, svc->conn.rpc, +- svc->proc.volfileid, +- GLUSTERD_SVC_DETACH); +- } +- pthread_mutex_unlock(&conf->attach_lock); +- if (!ret) { +- goto out; +- } +- } +- /* +- * It might not actually be safe to manipulate the lock +- * like this, but if we don't then the connection can +- * never actually complete and retries are useless. +- * Unfortunately, all of the alternatives (e.g. doing +- * all of this in a separate thread) are much more +- * complicated and risky. +- * TBD: see if there's a better way +- */ +- synclock_unlock(&conf->big_lock); +- sleep(1); +- synclock_lock(&conf->big_lock); +- } +- ret = -1; +- gf_msg("glusterd", GF_LOG_WARNING, 0, GD_MSG_SVC_DETACH_FAIL, +- "detach failed for %s(volume=%s)", svc->name, volinfo->volname); +-out: +- if (rpc) +- rpc_clnt_unref(rpc); +- return ret; +-} +diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-helper.h b/xlators/mgmt/glusterd/src/glusterd-svc-helper.h +index 5def246..cc98e78 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-svc-helper.h ++++ b/xlators/mgmt/glusterd/src/glusterd-svc-helper.h +@@ -16,10 +16,10 @@ + #include "glusterd-volgen.h" + + int +-glusterd_svcs_reconfigure(glusterd_volinfo_t *volinfo); ++glusterd_svcs_reconfigure(); + + int +-glusterd_svcs_stop(glusterd_volinfo_t *vol); ++glusterd_svcs_stop(); + + int + glusterd_svcs_manager(glusterd_volinfo_t *volinfo); +@@ -41,41 +41,5 @@ int + glusterd_svc_check_tier_topology_identical(char *svc_name, + glusterd_volinfo_t *volinfo, + gf_boolean_t *identical); +-int +-glusterd_volume_svc_check_volfile_identical(char *svc_name, dict_t *mode_dict, +- glusterd_volinfo_t *volinfo, +- glusterd_vol_graph_builder_t, +- gf_boolean_t *identical); +-int +-glusterd_volume_svc_check_topology_identical(char *svc_name, dict_t *mode_dict, +- glusterd_volinfo_t *volinfo, +- glusterd_vol_graph_builder_t, +- gf_boolean_t *identical); +-void +-glusterd_volume_svc_build_volfile_path(char *server, glusterd_volinfo_t *vol, +- char *volfile, size_t len); +-void * +-__gf_find_compatible_svc(gd_node_type daemon); +- +-glusterd_svc_proc_t * +-glusterd_svcprocess_new(); +- +-int +-glusterd_shd_svc_mux_init(glusterd_volinfo_t *volinfo, glusterd_svc_t *svc); +- +-void * +-__gf_find_compatible_svc_from_pid(gd_node_type daemon, pid_t pid); +- +-int +-glusterd_attach_svc(glusterd_svc_t *svc, glusterd_volinfo_t *volinfo, +- int flags); +- +-int +-glusterd_detach_svc(glusterd_svc_t *svc, glusterd_volinfo_t *volinfo, int sig); +- +-int +-__glusterd_send_svc_configure_req(glusterd_svc_t *svc, int flag, +- struct rpc_clnt *rpc, char *volfile_id, +- int op); + + #endif +diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c +index f32dafc..4cd4cea 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c ++++ b/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c +@@ -18,7 +18,6 @@ + #include "glusterd-conn-mgmt.h" + #include "glusterd-messages.h" + #include +-#include "glusterd-shd-svc-helper.h" + + int + glusterd_svc_create_rundir(char *rundir) +@@ -168,75 +167,68 @@ glusterd_svc_start(glusterd_svc_t *svc, int flags, dict_t *cmdline) + GF_ASSERT(this); + + priv = this->private; +- GF_VALIDATE_OR_GOTO("glusterd", priv, out); +- GF_VALIDATE_OR_GOTO("glusterd", svc, out); +- +- pthread_mutex_lock(&priv->attach_lock); +- { +- if (glusterd_proc_is_running(&(svc->proc))) { +- ret = 0; +- goto unlock; +- } ++ GF_ASSERT(priv); + +- ret = sys_access(svc->proc.volfile, F_OK); +- if (ret) { +- gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_VOLFILE_NOT_FOUND, +- "Volfile %s is not present", svc->proc.volfile); +- goto unlock; +- } ++ if (glusterd_proc_is_running(&(svc->proc))) { ++ ret = 0; ++ goto out; ++ } + +- runinit(&runner); ++ ret = sys_access(svc->proc.volfile, F_OK); ++ if (ret) { ++ gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_VOLFILE_NOT_FOUND, ++ "Volfile %s is not present", svc->proc.volfile); ++ goto out; ++ } + +- if (this->ctx->cmd_args.valgrind) { +- len = snprintf(valgrind_logfile, PATH_MAX, "%s/valgrind-%s.log", +- svc->proc.logfile, svc->name); +- if ((len < 0) || (len >= PATH_MAX)) { +- ret = -1; +- goto unlock; +- } ++ runinit(&runner); + +- runner_add_args(&runner, "valgrind", "--leak-check=full", +- "--trace-children=yes", "--track-origins=yes", +- NULL); +- runner_argprintf(&runner, "--log-file=%s", valgrind_logfile); ++ if (this->ctx->cmd_args.valgrind) { ++ len = snprintf(valgrind_logfile, PATH_MAX, "%s/valgrind-%s.log", ++ svc->proc.logfile, svc->name); ++ if ((len < 0) || (len >= PATH_MAX)) { ++ ret = -1; ++ goto out; + } + +- runner_add_args(&runner, SBIN_DIR "/glusterfs", "-s", +- svc->proc.volfileserver, "--volfile-id", +- svc->proc.volfileid, "-p", svc->proc.pidfile, "-l", +- svc->proc.logfile, "-S", svc->conn.sockpath, NULL); ++ runner_add_args(&runner, "valgrind", "--leak-check=full", ++ "--trace-children=yes", "--track-origins=yes", NULL); ++ runner_argprintf(&runner, "--log-file=%s", valgrind_logfile); ++ } + +- if (dict_get_strn(priv->opts, GLUSTERD_LOCALTIME_LOGGING_KEY, +- SLEN(GLUSTERD_LOCALTIME_LOGGING_KEY), +- &localtime_logging) == 0) { +- if (strcmp(localtime_logging, "enable") == 0) +- runner_add_arg(&runner, "--localtime-logging"); +- } +- if (dict_get_strn(priv->opts, GLUSTERD_DAEMON_LOG_LEVEL_KEY, +- SLEN(GLUSTERD_DAEMON_LOG_LEVEL_KEY), +- &log_level) == 0) { +- snprintf(daemon_log_level, 30, "--log-level=%s", log_level); +- runner_add_arg(&runner, daemon_log_level); +- } ++ runner_add_args(&runner, SBIN_DIR "/glusterfs", "-s", ++ svc->proc.volfileserver, "--volfile-id", ++ svc->proc.volfileid, "-p", svc->proc.pidfile, "-l", ++ svc->proc.logfile, "-S", svc->conn.sockpath, NULL); ++ ++ if (dict_get_strn(priv->opts, GLUSTERD_LOCALTIME_LOGGING_KEY, ++ SLEN(GLUSTERD_LOCALTIME_LOGGING_KEY), ++ &localtime_logging) == 0) { ++ if (strcmp(localtime_logging, "enable") == 0) ++ runner_add_arg(&runner, "--localtime-logging"); ++ } ++ if (dict_get_strn(priv->opts, GLUSTERD_DAEMON_LOG_LEVEL_KEY, ++ SLEN(GLUSTERD_DAEMON_LOG_LEVEL_KEY), &log_level) == 0) { ++ snprintf(daemon_log_level, 30, "--log-level=%s", log_level); ++ runner_add_arg(&runner, daemon_log_level); ++ } + +- if (cmdline) +- dict_foreach(cmdline, svc_add_args, (void *)&runner); ++ if (cmdline) ++ dict_foreach(cmdline, svc_add_args, (void *)&runner); + +- gf_msg(this->name, GF_LOG_INFO, 0, GD_MSG_SVC_START_SUCCESS, +- "Starting %s service", svc->name); ++ gf_msg(this->name, GF_LOG_INFO, 0, GD_MSG_SVC_START_SUCCESS, ++ "Starting %s service", svc->name); + +- if (flags == PROC_START_NO_WAIT) { +- ret = runner_run_nowait(&runner); +- } else { +- synclock_unlock(&priv->big_lock); +- { +- ret = runner_run(&runner); +- } +- synclock_lock(&priv->big_lock); ++ if (flags == PROC_START_NO_WAIT) { ++ ret = runner_run_nowait(&runner); ++ } else { ++ synclock_unlock(&priv->big_lock); ++ { ++ ret = runner_run(&runner); + } ++ synclock_lock(&priv->big_lock); + } +-unlock: +- pthread_mutex_unlock(&priv->attach_lock); ++ + out: + gf_msg_debug(this->name, 0, "Returning %d", ret); + +@@ -289,8 +281,7 @@ glusterd_svc_build_volfile_path(char *server, char *workdir, char *volfile, + + glusterd_svc_build_svcdir(server, workdir, dir, sizeof(dir)); + +- if (!strcmp(server, "quotad")) +- /*quotad has different volfile name*/ ++ if (!strcmp(server, "quotad")) /*quotad has different volfile name*/ + snprintf(volfile, len, "%s/%s.vol", dir, server); + else + snprintf(volfile, len, "%s/%s-server.vol", dir, server); +@@ -375,138 +366,3 @@ glusterd_svc_common_rpc_notify(glusterd_conn_t *conn, rpc_clnt_event_t event) + + return ret; + } +- +-void +-glusterd_volume_svc_build_volfile_path(char *server, glusterd_volinfo_t *vol, +- char *volfile, size_t len) +-{ +- GF_ASSERT(len == PATH_MAX); +- +- if (!strcmp(server, "glustershd")) { +- glusterd_svc_build_shd_volfile_path(vol, volfile, len); +- } +-} +- +-int +-glusterd_muxsvc_common_rpc_notify(glusterd_svc_proc_t *mux_proc, +- rpc_clnt_event_t event) +-{ +- int ret = 0; +- glusterd_svc_t *svc = NULL; +- glusterd_svc_t *tmp = NULL; +- xlator_t *this = NULL; +- gf_boolean_t need_logging = _gf_false; +- +- this = THIS; +- GF_ASSERT(this); +- +- if (!mux_proc) { +- gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_SVC_GET_FAIL, +- "Failed to get the svc proc data"); +- return -1; +- } +- +- /* Currently this function was used for shd svc, if this function is +- * using for another svc, change ths glustershd reference. We can get +- * the svc name from any of the attached svc's +- */ +- switch (event) { +- case RPC_CLNT_CONNECT: +- gf_msg_debug(this->name, 0, +- "glustershd has connected with glusterd."); +- gf_event(EVENT_SVC_CONNECTED, "svc_name=glustershd"); +- cds_list_for_each_entry_safe(svc, tmp, &mux_proc->svcs, mux_svc) +- { +- if (svc->online) +- continue; +- svc->online = _gf_true; +- } +- break; +- +- case RPC_CLNT_DISCONNECT: +- cds_list_for_each_entry_safe(svc, tmp, &mux_proc->svcs, mux_svc) +- { +- if (svc->online) { +- if (!need_logging) +- need_logging = _gf_true; +- svc->online = _gf_false; +- } +- } +- if (need_logging) { +- gf_msg(this->name, GF_LOG_INFO, 0, GD_MSG_NODE_DISCONNECTED, +- "glustershd has disconnected from glusterd."); +- gf_event(EVENT_SVC_DISCONNECTED, "svc_name=glustershd"); +- } +- break; +- +- default: +- gf_msg_trace(this->name, 0, "got some other RPC event %d", event); +- break; +- } +- +- return ret; +-} +- +-int +-glusterd_muxsvc_conn_init(glusterd_conn_t *conn, glusterd_svc_proc_t *mux_proc, +- char *sockpath, int frame_timeout, +- glusterd_muxsvc_conn_notify_t notify) +-{ +- int ret = -1; +- dict_t *options = NULL; +- struct rpc_clnt *rpc = NULL; +- xlator_t *this = THIS; +- glusterd_svc_t *svc = NULL; +- +- options = dict_new(); +- if (!this || !options) +- goto out; +- +- svc = cds_list_entry(conn, glusterd_svc_t, conn); +- if (!svc) { +- gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_SVC_GET_FAIL, +- "Failed to get the service"); +- goto out; +- } +- +- ret = rpc_transport_unix_options_build(options, sockpath, frame_timeout); +- if (ret) +- goto out; +- +- ret = dict_set_int32n(options, "transport.socket.ignore-enoent", +- SLEN("transport.socket.ignore-enoent"), 1); +- if (ret) +- goto out; +- +- /* @options is free'd by rpc_transport when destroyed */ +- rpc = rpc_clnt_new(options, this, (char *)svc->name, 16); +- if (!rpc) { +- ret = -1; +- goto out; +- } +- +- ret = rpc_clnt_register_notify(rpc, glusterd_muxsvc_conn_common_notify, +- mux_proc); +- if (ret) +- goto out; +- +- ret = snprintf(conn->sockpath, sizeof(conn->sockpath), "%s", sockpath); +- if (ret < 0) +- goto out; +- else +- ret = 0; +- +- conn->frame_timeout = frame_timeout; +- conn->rpc = rpc; +- mux_proc->notify = notify; +-out: +- if (options) +- dict_unref(options); +- if (ret) { +- if (rpc) { +- rpc_clnt_unref(rpc); +- rpc = NULL; +- } +- } +- return ret; +-} +diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.h b/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.h +index fbc5225..c850bfd 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.h ++++ b/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.h +@@ -13,12 +13,9 @@ + + #include "glusterd-proc-mgmt.h" + #include "glusterd-conn-mgmt.h" +-#include "glusterd-rcu.h" + + struct glusterd_svc_; +- + typedef struct glusterd_svc_ glusterd_svc_t; +-typedef struct glusterd_svc_proc_ glusterd_svc_proc_t; + + typedef void (*glusterd_svc_build_t)(glusterd_svc_t *svc); + +@@ -28,17 +25,6 @@ typedef int (*glusterd_svc_start_t)(glusterd_svc_t *svc, int flags); + typedef int (*glusterd_svc_stop_t)(glusterd_svc_t *svc, int sig); + typedef int (*glusterd_svc_reconfigure_t)(void *data); + +-typedef int (*glusterd_muxsvc_conn_notify_t)(glusterd_svc_proc_t *mux_proc, +- rpc_clnt_event_t event); +- +-struct glusterd_svc_proc_ { +- struct cds_list_head svc_proc_list; +- struct cds_list_head svcs; +- glusterd_muxsvc_conn_notify_t notify; +- rpc_clnt_t *rpc; +- void *data; +-}; +- + struct glusterd_svc_ { + char name[NAME_MAX]; + glusterd_conn_t conn; +@@ -49,8 +35,6 @@ struct glusterd_svc_ { + gf_boolean_t online; + gf_boolean_t inited; + glusterd_svc_reconfigure_t reconfigure; +- glusterd_svc_proc_t *svc_proc; +- struct cds_list_head mux_svc; + }; + + int +@@ -85,15 +69,4 @@ glusterd_svc_reconfigure(int (*create_volfile)()); + int + glusterd_svc_common_rpc_notify(glusterd_conn_t *conn, rpc_clnt_event_t event); + +-int +-glusterd_muxsvc_common_rpc_notify(glusterd_svc_proc_t *conn, +- rpc_clnt_event_t event); +- +-int +-glusterd_proc_get_pid(glusterd_proc_t *proc); +- +-int +-glusterd_muxsvc_conn_init(glusterd_conn_t *conn, glusterd_svc_proc_t *mux_proc, +- char *sockpath, int frame_timeout, +- glusterd_muxsvc_conn_notify_t notify); + #endif +diff --git a/xlators/mgmt/glusterd/src/glusterd-tier.c b/xlators/mgmt/glusterd/src/glusterd-tier.c +index 23a9592..4dc0d44 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-tier.c ++++ b/xlators/mgmt/glusterd/src/glusterd-tier.c +@@ -27,7 +27,6 @@ + #include "glusterd-messages.h" + #include "glusterd-mgmt.h" + #include "glusterd-syncop.h" +-#include "glusterd-shd-svc-helper.h" + + #include + #include +@@ -616,7 +615,7 @@ glusterd_op_remove_tier_brick(dict_t *dict, char **op_errstr, dict_t *rsp_dict) + + if (cmd == GF_DEFRAG_CMD_DETACH_START && + volinfo->status == GLUSTERD_STATUS_STARTED) { +- ret = glusterd_svcs_reconfigure(volinfo); ++ ret = glusterd_svcs_reconfigure(); + if (ret) { + gf_msg(this->name, GF_LOG_WARNING, 0, GD_MSG_NFS_RECONF_FAIL, + "Unable to reconfigure NFS-Server"); +diff --git a/xlators/mgmt/glusterd/src/glusterd-tierd-svc.c b/xlators/mgmt/glusterd/src/glusterd-tierd-svc.c +index ab463f1..04ceec5 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-tierd-svc.c ++++ b/xlators/mgmt/glusterd/src/glusterd-tierd-svc.c +@@ -83,6 +83,7 @@ glusterd_tierdsvc_init(void *data) + goto out; + + notify = glusterd_svc_common_rpc_notify; ++ glusterd_store_perform_node_state_store(volinfo); + + volinfo->type = GF_CLUSTER_TYPE_TIER; + +@@ -394,7 +395,6 @@ int + glusterd_tierdsvc_restart() + { + glusterd_volinfo_t *volinfo = NULL; +- glusterd_volinfo_t *tmp = NULL; + int ret = 0; + xlator_t *this = THIS; + glusterd_conf_t *conf = NULL; +@@ -405,7 +405,7 @@ glusterd_tierdsvc_restart() + conf = this->private; + GF_VALIDATE_OR_GOTO(this->name, conf, out); + +- cds_list_for_each_entry_safe(volinfo, tmp, &conf->volumes, vol_list) ++ cds_list_for_each_entry(volinfo, &conf->volumes, vol_list) + { + /* Start per volume tierd svc */ + if (volinfo->status == GLUSTERD_STATUS_STARTED && +diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c +index 4525ec7..2aa975b 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-utils.c ++++ b/xlators/mgmt/glusterd/src/glusterd-utils.c +@@ -61,7 +61,6 @@ + #include "glusterd-server-quorum.h" + #include + #include +-#include "glusterd-shd-svc-helper.h" + + #include "xdr-generic.h" + #include +@@ -625,17 +624,13 @@ glusterd_volinfo_t * + glusterd_volinfo_unref(glusterd_volinfo_t *volinfo) + { + int refcnt = -1; +- glusterd_conf_t *conf = THIS->private; + +- pthread_mutex_lock(&conf->volume_lock); ++ pthread_mutex_lock(&volinfo->reflock); + { +- pthread_mutex_lock(&volinfo->reflock); +- { +- refcnt = --volinfo->refcnt; +- } +- pthread_mutex_unlock(&volinfo->reflock); ++ refcnt = --volinfo->refcnt; + } +- pthread_mutex_unlock(&conf->volume_lock); ++ pthread_mutex_unlock(&volinfo->reflock); ++ + if (!refcnt) { + glusterd_volinfo_delete(volinfo); + return NULL; +@@ -707,7 +702,6 @@ glusterd_volinfo_new(glusterd_volinfo_t **volinfo) + glusterd_snapdsvc_build(&new_volinfo->snapd.svc); + glusterd_tierdsvc_build(&new_volinfo->tierd.svc); + glusterd_gfproxydsvc_build(&new_volinfo->gfproxyd.svc); +- glusterd_shdsvc_build(&new_volinfo->shd.svc); + + pthread_mutex_init(&new_volinfo->reflock, NULL); + *volinfo = glusterd_volinfo_ref(new_volinfo); +@@ -1073,11 +1067,11 @@ glusterd_volinfo_delete(glusterd_volinfo_t *volinfo) + gf_store_handle_destroy(volinfo->snapd.handle); + + glusterd_auth_cleanup(volinfo); +- glusterd_shd_svcproc_cleanup(&volinfo->shd); + + pthread_mutex_destroy(&volinfo->reflock); + GF_FREE(volinfo); + ret = 0; ++ + out: + gf_msg_debug(THIS->name, 0, "Returning %d", ret); + return ret; +@@ -3929,7 +3923,6 @@ glusterd_spawn_daemons(void *opaque) + ret = glusterd_snapdsvc_restart(); + ret = glusterd_tierdsvc_restart(); + ret = glusterd_gfproxydsvc_restart(); +- ret = glusterd_shdsvc_restart(); + return ret; + } + +@@ -4880,9 +4873,6 @@ glusterd_delete_stale_volume(glusterd_volinfo_t *stale_volinfo, + svc = &(stale_volinfo->snapd.svc); + (void)svc->manager(svc, stale_volinfo, PROC_START_NO_WAIT); + } +- svc = &(stale_volinfo->shd.svc); +- (void)svc->manager(svc, stale_volinfo, PROC_START_NO_WAIT); +- + (void)glusterd_volinfo_remove(stale_volinfo); + + return 0; +@@ -4997,15 +4987,6 @@ glusterd_import_friend_volume(dict_t *peer_data, int count) + glusterd_volinfo_unref(old_volinfo); + } + +- ret = glusterd_store_volinfo(new_volinfo, GLUSTERD_VOLINFO_VER_AC_NONE); +- if (ret) { +- gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_VOLINFO_STORE_FAIL, +- "Failed to store " +- "volinfo for volume %s", +- new_volinfo->volname); +- goto out; +- } +- + if (glusterd_is_volume_started(new_volinfo)) { + (void)glusterd_start_bricks(new_volinfo); + if (glusterd_is_snapd_enabled(new_volinfo)) { +@@ -5014,10 +4995,15 @@ glusterd_import_friend_volume(dict_t *peer_data, int count) + gf_event(EVENT_SVC_MANAGER_FAILED, "svc_name=%s", svc->name); + } + } +- svc = &(new_volinfo->shd.svc); +- if (svc->manager(svc, new_volinfo, PROC_START_NO_WAIT)) { +- gf_event(EVENT_SVC_MANAGER_FAILED, "svc_name=%s", svc->name); +- } ++ } ++ ++ ret = glusterd_store_volinfo(new_volinfo, GLUSTERD_VOLINFO_VER_AC_NONE); ++ if (ret) { ++ gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_VOLINFO_STORE_FAIL, ++ "Failed to store " ++ "volinfo for volume %s", ++ new_volinfo->volname); ++ goto out; + } + + ret = glusterd_create_volfiles_and_notify_services(new_volinfo); +@@ -5521,7 +5507,9 @@ glusterd_add_node_to_dict(char *server, dict_t *dict, int count, + glusterd_svc_build_pidfile_path(server, priv->rundir, pidfile, + sizeof(pidfile)); + +- if (strcmp(server, priv->nfs_svc.name) == 0) ++ if (strcmp(server, priv->shd_svc.name) == 0) ++ svc = &(priv->shd_svc); ++ else if (strcmp(server, priv->nfs_svc.name) == 0) + svc = &(priv->nfs_svc); + else if (strcmp(server, priv->quotad_svc.name) == 0) + svc = &(priv->quotad_svc); +@@ -5552,6 +5540,9 @@ glusterd_add_node_to_dict(char *server, dict_t *dict, int count, + if (!strcmp(server, priv->nfs_svc.name)) + ret = dict_set_nstrn(dict, key, keylen, "NFS Server", + SLEN("NFS Server")); ++ else if (!strcmp(server, priv->shd_svc.name)) ++ ret = dict_set_nstrn(dict, key, keylen, "Self-heal Daemon", ++ SLEN("Self-heal Daemon")); + else if (!strcmp(server, priv->quotad_svc.name)) + ret = dict_set_nstrn(dict, key, keylen, "Quota Daemon", + SLEN("Quota Daemon")); +@@ -9115,21 +9106,6 @@ glusterd_friend_remove_cleanup_vols(uuid_t uuid) + "to stop snapd daemon service"); + } + } +- +- if (glusterd_is_shd_compatible_volume(volinfo)) { +- /* +- * Sending stop request for all volumes. So it is fine +- * to send stop for mux shd +- */ +- svc = &(volinfo->shd.svc); +- ret = svc->stop(svc, SIGTERM); +- if (ret) { +- gf_msg(THIS->name, GF_LOG_ERROR, 0, GD_MSG_SVC_STOP_FAIL, +- "Failed " +- "to stop shd daemon service"); +- } +- } +- + if (volinfo->type == GF_CLUSTER_TYPE_TIER) { + svc = &(volinfo->tierd.svc); + ret = svc->stop(svc, SIGTERM); +@@ -9155,7 +9131,7 @@ glusterd_friend_remove_cleanup_vols(uuid_t uuid) + } + + /* Reconfigure all daemon services upon peer detach */ +- ret = glusterd_svcs_reconfigure(NULL); ++ ret = glusterd_svcs_reconfigure(); + if (ret) { + gf_msg(THIS->name, GF_LOG_ERROR, 0, GD_MSG_SVC_STOP_FAIL, + "Failed to reconfigure all daemon services."); +@@ -14746,74 +14722,3 @@ glusterd_is_profile_on(glusterd_volinfo_t *volinfo) + return _gf_true; + return _gf_false; + } +- +-int32_t +-glusterd_add_shd_to_dict(glusterd_volinfo_t *volinfo, dict_t *dict, +- int32_t count) +-{ +- int ret = -1; +- int32_t pid = -1; +- int32_t brick_online = -1; +- char key[64] = {0}; +- int keylen; +- char *pidfile = NULL; +- xlator_t *this = NULL; +- char *uuid_str = NULL; +- +- this = THIS; +- GF_VALIDATE_OR_GOTO(THIS->name, this, out); +- +- GF_VALIDATE_OR_GOTO(this->name, volinfo, out); +- GF_VALIDATE_OR_GOTO(this->name, dict, out); +- +- keylen = snprintf(key, sizeof(key), "brick%d.hostname", count); +- ret = dict_set_nstrn(dict, key, keylen, "Self-heal Daemon", +- SLEN("Self-heal Daemon")); +- if (ret) +- goto out; +- +- keylen = snprintf(key, sizeof(key), "brick%d.path", count); +- uuid_str = gf_strdup(uuid_utoa(MY_UUID)); +- if (!uuid_str) { +- ret = -1; +- goto out; +- } +- ret = dict_set_dynstrn(dict, key, keylen, uuid_str); +- if (ret) +- goto out; +- uuid_str = NULL; +- +- /* shd doesn't have a port. but the cli needs a port key with +- * a zero value to parse. +- * */ +- +- keylen = snprintf(key, sizeof(key), "brick%d.port", count); +- ret = dict_set_int32n(dict, key, keylen, 0); +- if (ret) +- goto out; +- +- pidfile = volinfo->shd.svc.proc.pidfile; +- +- brick_online = gf_is_service_running(pidfile, &pid); +- +- /* If shd is not running, then don't print the pid */ +- if (!brick_online) +- pid = -1; +- keylen = snprintf(key, sizeof(key), "brick%d.pid", count); +- ret = dict_set_int32n(dict, key, keylen, pid); +- if (ret) +- goto out; +- +- keylen = snprintf(key, sizeof(key), "brick%d.status", count); +- ret = dict_set_int32n(dict, key, keylen, brick_online); +- +-out: +- if (uuid_str) +- GF_FREE(uuid_str); +- if (ret) +- gf_msg(this ? this->name : "glusterd", GF_LOG_ERROR, 0, +- GD_MSG_DICT_SET_FAILED, +- "Returning %d. adding values to dict failed", ret); +- +- return ret; +-} +diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h +index 5c6a453..ead16b2 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-utils.h ++++ b/xlators/mgmt/glusterd/src/glusterd-utils.h +@@ -881,8 +881,4 @@ glusterd_is_profile_on(glusterd_volinfo_t *volinfo); + + char * + search_brick_path_from_proc(pid_t brick_pid, char *brickpath); +- +-int32_t +-glusterd_add_shd_to_dict(glusterd_volinfo_t *volinfo, dict_t *dict, +- int32_t count); + #endif +diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c +index 8b58d40..5e0214e 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c ++++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c +@@ -36,7 +36,6 @@ + #include "glusterd-svc-mgmt.h" + #include "glusterd-svc-helper.h" + #include "glusterd-snapd-svc-helper.h" +-#include "glusterd-shd-svc-helper.h" + #include "glusterd-gfproxyd-svc-helper.h" + + struct gd_validate_reconf_opts { +@@ -4865,7 +4864,7 @@ volgen_get_shd_key(int type) + static int + volgen_set_shd_key_enable(dict_t *set_dict, const int type) + { +- int ret = 0; ++ int ret = -1; + + switch (type) { + case GF_CLUSTER_TYPE_REPLICATE: +@@ -5156,15 +5155,24 @@ out: + static int + build_shd_volume_graph(xlator_t *this, volgen_graph_t *graph, + glusterd_volinfo_t *volinfo, dict_t *mod_dict, +- dict_t *set_dict, gf_boolean_t graph_check) ++ dict_t *set_dict, gf_boolean_t graph_check, ++ gf_boolean_t *valid_config) + { + volgen_graph_t cgraph = {0}; + int ret = 0; + int clusters = -1; + ++ if (!graph_check && (volinfo->status != GLUSTERD_STATUS_STARTED)) ++ goto out; ++ + if (!glusterd_is_shd_compatible_volume(volinfo)) + goto out; + ++ /* Shd graph is valid only when there is at least one ++ * replica/disperse volume is present ++ */ ++ *valid_config = _gf_true; ++ + ret = prepare_shd_volume_options(volinfo, mod_dict, set_dict); + if (ret) + goto out; +@@ -5194,16 +5202,19 @@ out: + } + + int +-build_shd_graph(glusterd_volinfo_t *volinfo, volgen_graph_t *graph, +- dict_t *mod_dict) ++build_shd_graph(volgen_graph_t *graph, dict_t *mod_dict) + { ++ glusterd_volinfo_t *voliter = NULL; + xlator_t *this = NULL; ++ glusterd_conf_t *priv = NULL; + dict_t *set_dict = NULL; + int ret = 0; ++ gf_boolean_t valid_config = _gf_false; + xlator_t *iostxl = NULL; + gf_boolean_t graph_check = _gf_false; + + this = THIS; ++ priv = this->private; + + set_dict = dict_new(); + if (!set_dict) { +@@ -5213,18 +5224,26 @@ build_shd_graph(glusterd_volinfo_t *volinfo, volgen_graph_t *graph, + + if (mod_dict) + graph_check = dict_get_str_boolean(mod_dict, "graph-check", 0); +- iostxl = volgen_graph_add_as(graph, "debug/io-stats", volinfo->volname); ++ iostxl = volgen_graph_add_as(graph, "debug/io-stats", "glustershd"); + if (!iostxl) { + ret = -1; + goto out; + } + +- ret = build_shd_volume_graph(this, graph, volinfo, mod_dict, set_dict, +- graph_check); ++ cds_list_for_each_entry(voliter, &priv->volumes, vol_list) ++ { ++ ret = build_shd_volume_graph(this, graph, voliter, mod_dict, set_dict, ++ graph_check, &valid_config); ++ ret = dict_reset(set_dict); ++ if (ret) ++ goto out; ++ } + + out: + if (set_dict) + dict_unref(set_dict); ++ if (!valid_config) ++ ret = -EINVAL; + return ret; + } + +@@ -6541,10 +6560,6 @@ glusterd_create_volfiles(glusterd_volinfo_t *volinfo) + if (ret) + gf_log(this->name, GF_LOG_ERROR, "Could not generate gfproxy volfiles"); + +- ret = glusterd_shdsvc_create_volfile(volinfo); +- if (ret) +- gf_log(this->name, GF_LOG_ERROR, "Could not generate shd volfiles"); +- + dict_del_sizen(volinfo->dict, "skip-CLIOT"); + + out: +@@ -6625,7 +6640,7 @@ validate_shdopts(glusterd_volinfo_t *volinfo, dict_t *val_dict, + ret = dict_set_int32_sizen(val_dict, "graph-check", 1); + if (ret) + goto out; +- ret = build_shd_graph(volinfo, &graph, val_dict); ++ ret = build_shd_graph(&graph, val_dict); + if (!ret) + ret = graph_reconf_validateopt(&graph.graph, op_errstr); + +@@ -7002,22 +7017,3 @@ gd_is_boolean_option(char *key) + + return _gf_false; + } +- +-int +-glusterd_shdsvc_generate_volfile(glusterd_volinfo_t *volinfo, char *filename, +- dict_t *mode_dict) +-{ +- int ret = -1; +- volgen_graph_t graph = { +- 0, +- }; +- +- graph.type = GF_SHD; +- ret = build_shd_graph(volinfo, &graph, mode_dict); +- if (!ret) +- ret = volgen_write_volfile(&graph, filename); +- +- volgen_graph_free(&graph); +- +- return ret; +-} +diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.h b/xlators/mgmt/glusterd/src/glusterd-volgen.h +index 897d8fa..f9fc068 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volgen.h ++++ b/xlators/mgmt/glusterd/src/glusterd-volgen.h +@@ -66,7 +66,6 @@ typedef enum { + GF_REBALANCED = 1, + GF_QUOTAD, + GF_SNAPD, +- GF_SHD, + } glusterd_graph_type_t; + + struct volgen_graph { +@@ -78,8 +77,6 @@ typedef struct volgen_graph volgen_graph_t; + + typedef int (*glusterd_graph_builder_t)(volgen_graph_t *graph, + dict_t *mod_dict); +-typedef int (*glusterd_vol_graph_builder_t)(glusterd_volinfo_t *, +- char *filename, dict_t *mod_dict); + + #define COMPLETE_OPTION(key, completion, ret) \ + do { \ +@@ -204,8 +201,7 @@ void + glusterd_get_shd_filepath(char *filename); + + int +-build_shd_graph(glusterd_volinfo_t *volinfo, volgen_graph_t *graph, +- dict_t *mod_dict); ++build_shd_graph(volgen_graph_t *graph, dict_t *mod_dict); + + int + build_nfs_graph(volgen_graph_t *graph, dict_t *mod_dict); +@@ -317,9 +313,4 @@ glusterd_generate_gfproxyd_volfile(glusterd_volinfo_t *volinfo); + + int + glusterd_build_gfproxyd_volfile(glusterd_volinfo_t *volinfo, char *filename); +- +-int +-glusterd_shdsvc_generate_volfile(glusterd_volinfo_t *volinfo, char *filename, +- dict_t *mode_dict); +- + #endif +diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c +index 4c3ad50..1ea8ba6 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c ++++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c +@@ -1940,7 +1940,7 @@ static int + glusterd_handle_heal_cmd(xlator_t *this, glusterd_volinfo_t *volinfo, + dict_t *dict, char **op_errstr) + { +- glusterd_svc_t *svc = NULL; ++ glusterd_conf_t *priv = NULL; + gf_xl_afr_op_t heal_op = GF_SHD_OP_INVALID; + int ret = 0; + char msg[2408] = { +@@ -1950,6 +1950,7 @@ glusterd_handle_heal_cmd(xlator_t *this, glusterd_volinfo_t *volinfo, + "Self-heal daemon is not running. " + "Check self-heal daemon log file."; + ++ priv = this->private; + ret = dict_get_int32n(dict, "heal-op", SLEN("heal-op"), + (int32_t *)&heal_op); + if (ret) { +@@ -1958,7 +1959,6 @@ glusterd_handle_heal_cmd(xlator_t *this, glusterd_volinfo_t *volinfo, + goto out; + } + +- svc = &(volinfo->shd.svc); + switch (heal_op) { + case GF_SHD_OP_INVALID: + case GF_SHD_OP_HEAL_ENABLE: /* This op should be handled in volume-set*/ +@@ -1988,7 +1988,7 @@ glusterd_handle_heal_cmd(xlator_t *this, glusterd_volinfo_t *volinfo, + goto out; + } + +- if (!svc->online) { ++ if (!priv->shd_svc.online) { + ret = -1; + *op_errstr = gf_strdup(offline_msg); + goto out; +@@ -2009,7 +2009,7 @@ glusterd_handle_heal_cmd(xlator_t *this, glusterd_volinfo_t *volinfo, + goto out; + } + +- if (!svc->online) { ++ if (!priv->shd_svc.online) { + ret = -1; + *op_errstr = gf_strdup(offline_msg); + goto out; +diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c +index c0973cb..d360312 100644 +--- a/xlators/mgmt/glusterd/src/glusterd.c ++++ b/xlators/mgmt/glusterd/src/glusterd.c +@@ -1537,6 +1537,14 @@ init(xlator_t *this) + exit(1); + } + ++ ret = glusterd_init_var_run_dirs(this, rundir, GLUSTERD_GLUSTERSHD_RUN_DIR); ++ if (ret) { ++ gf_msg(this->name, GF_LOG_CRITICAL, 0, GD_MSG_CREATE_DIR_FAILED, ++ "Unable to create " ++ "glustershd running directory"); ++ exit(1); ++ } ++ + ret = glusterd_init_var_run_dirs(this, rundir, GLUSTERD_NFS_RUN_DIR); + if (ret) { + gf_msg(this->name, GF_LOG_CRITICAL, 0, GD_MSG_CREATE_DIR_FAILED, +@@ -1811,9 +1819,6 @@ init(xlator_t *this) + CDS_INIT_LIST_HEAD(&conf->snapshots); + CDS_INIT_LIST_HEAD(&conf->missed_snaps_list); + CDS_INIT_LIST_HEAD(&conf->brick_procs); +- CDS_INIT_LIST_HEAD(&conf->shd_procs); +- pthread_mutex_init(&conf->attach_lock, NULL); +- pthread_mutex_init(&conf->volume_lock, NULL); + + pthread_mutex_init(&conf->mutex, NULL); + conf->rpc = rpc; +@@ -1894,6 +1899,7 @@ init(xlator_t *this) + glusterd_mgmt_v3_lock_timer_init(); + glusterd_txn_opinfo_dict_init(); + ++ glusterd_shdsvc_build(&conf->shd_svc); + glusterd_nfssvc_build(&conf->nfs_svc); + glusterd_quotadsvc_build(&conf->quotad_svc); + glusterd_bitdsvc_build(&conf->bitd_svc); +diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h +index 0fbc9dd..2be005c 100644 +--- a/xlators/mgmt/glusterd/src/glusterd.h ++++ b/xlators/mgmt/glusterd/src/glusterd.h +@@ -28,7 +28,6 @@ + #include "glusterd-sm.h" + #include "glusterd-snapd-svc.h" + #include "glusterd-tierd-svc.h" +-#include "glusterd-shd-svc.h" + #include "glusterd-bitd-svc.h" + #include "glusterd1-xdr.h" + #include "protocol-common.h" +@@ -173,6 +172,7 @@ typedef struct { + char workdir[VALID_GLUSTERD_PATHMAX]; + char rundir[VALID_GLUSTERD_PATHMAX]; + rpcsvc_t *rpc; ++ glusterd_svc_t shd_svc; + glusterd_svc_t nfs_svc; + glusterd_svc_t bitd_svc; + glusterd_svc_t scrub_svc; +@@ -181,7 +181,6 @@ typedef struct { + struct cds_list_head volumes; + struct cds_list_head snapshots; /*List of snap volumes */ + struct cds_list_head brick_procs; /* List of brick processes */ +- struct cds_list_head shd_procs; /* List of shd processes */ + pthread_mutex_t xprt_lock; + struct list_head xprt_list; + pthread_mutex_t import_volumes; +@@ -222,11 +221,6 @@ typedef struct { + gf_atomic_t blockers; + uint32_t mgmt_v3_lock_timeout; + gf_boolean_t restart_bricks; +- pthread_mutex_t attach_lock; /* Lock can be per process or a common one */ +- pthread_mutex_t volume_lock; /* We release the big_lock from lot of places +- which might lead the modification of volinfo +- list. +- */ + gf_atomic_t thread_count; + } glusterd_conf_t; + +@@ -519,7 +513,6 @@ struct glusterd_volinfo_ { + + glusterd_snapdsvc_t snapd; + glusterd_tierdsvc_t tierd; +- glusterd_shdsvc_t shd; + glusterd_gfproxydsvc_t gfproxyd; + int32_t quota_xattr_version; + gf_boolean_t stage_deleted; /* volume has passed staging +@@ -646,6 +639,7 @@ typedef enum { + #define GLUSTERD_DEFAULT_SNAPS_BRICK_DIR "/gluster/snaps" + #define GLUSTERD_BITD_RUN_DIR "/bitd" + #define GLUSTERD_SCRUB_RUN_DIR "/scrub" ++#define GLUSTERD_GLUSTERSHD_RUN_DIR "/glustershd" + #define GLUSTERD_NFS_RUN_DIR "/nfs" + #define GLUSTERD_QUOTAD_RUN_DIR "/quotad" + #define GLUSTER_SHARED_STORAGE_BRICK_DIR GLUSTERD_DEFAULT_WORKDIR "/ss_brick" +@@ -701,26 +695,6 @@ typedef ssize_t (*gd_serialize_t)(struct iovec outmsg, void *args); + } \ + } while (0) + +-#define GLUSTERD_GET_SHD_RUNDIR(path, volinfo, priv) \ +- do { \ +- int32_t _shd_dir_len; \ +- _shd_dir_len = snprintf(path, PATH_MAX, "%s/shd/%s", priv->rundir, \ +- volinfo->volname); \ +- if ((_shd_dir_len < 0) || (_shd_dir_len >= PATH_MAX)) { \ +- path[0] = 0; \ +- } \ +- } while (0) +- +-#define GLUSTERD_GET_SHD_PID_FILE(path, volinfo, priv) \ +- do { \ +- int32_t _shd_pid_len; \ +- _shd_pid_len = snprintf(path, PATH_MAX, "%s/shd/%s-shd.pid", \ +- priv->rundir, volinfo->volname); \ +- if ((_shd_pid_len < 0) || (_shd_pid_len >= PATH_MAX)) { \ +- path[0] = 0; \ +- } \ +- } while (0) +- + #define GLUSTERD_GET_VOLUME_PID_DIR(path, volinfo, priv) \ + do { \ + int32_t _vol_pid_len; \ +diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c +index 532ef35..e156d4d 100644 +--- a/xlators/protocol/client/src/client.c ++++ b/xlators/protocol/client/src/client.c +@@ -46,6 +46,7 @@ client_fini_complete(xlator_t *this) + GF_VALIDATE_OR_GOTO(this->name, this->private, out); + + clnt_conf_t *conf = this->private; ++ + if (!conf->destroy) + return 0; + +@@ -68,11 +69,6 @@ client_notify_dispatch_uniq(xlator_t *this, int32_t event, void *data, ...) + return 0; + + return client_notify_dispatch(this, event, data); +- +- /* Please avoid any code that access xlator object here +- * Because for a child down event, once we do the signal +- * we will start cleanup. +- */ + } + + int +@@ -109,11 +105,6 @@ client_notify_dispatch(xlator_t *this, int32_t event, void *data, ...) + } + pthread_mutex_unlock(&ctx->notify_lock); + +- /* Please avoid any code that access xlator object here +- * Because for a child down event, once we do the signal +- * we will start cleanup. +- */ +- + return ret; + } + +@@ -2287,7 +2278,6 @@ client_rpc_notify(struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, + { + xlator_t *this = NULL; + clnt_conf_t *conf = NULL; +- gf_boolean_t is_parent_down = _gf_false; + int ret = 0; + + this = mydata; +@@ -2351,19 +2341,6 @@ client_rpc_notify(struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, + if (conf->portmap_err_logged) + conf->disconnect_err_logged = 1; + } +- /* +- * Once we complete the child down notification, +- * There is a chance that the graph might get freed, +- * So it is not safe to access any xlator contens +- * So here we are checking whether the parent is down +- * or not. +- */ +- pthread_mutex_lock(&conf->lock); +- { +- is_parent_down = conf->parent_down; +- } +- pthread_mutex_unlock(&conf->lock); +- + /* If the CHILD_DOWN event goes to parent xlator + multiple times, the logic of parent xlator notify + may get screwed up.. (eg. CHILD_MODIFIED event in +@@ -2371,12 +2348,6 @@ client_rpc_notify(struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, + to parent are genuine */ + ret = client_notify_dispatch_uniq(this, GF_EVENT_CHILD_DOWN, + NULL); +- if (is_parent_down) { +- /* If parent is down, then there should not be any +- * operation after a child down. +- */ +- goto out; +- } + if (ret) + gf_msg(this->name, GF_LOG_INFO, 0, + PC_MSG_CHILD_DOWN_NOTIFY_FAILED, +-- +1.8.3.1 + diff --git a/0251-tests-Fix-bug-1717819-metadata-split-brain-detection.patch b/0251-tests-Fix-bug-1717819-metadata-split-brain-detection.patch new file mode 100644 index 0000000..028f92c --- /dev/null +++ b/0251-tests-Fix-bug-1717819-metadata-split-brain-detection.patch @@ -0,0 +1,57 @@ +From 7a04fb9999f5d25c17f5593eed5e98d0f5a1932d Mon Sep 17 00:00:00 2001 +From: karthik-us +Date: Mon, 15 Jul 2019 14:30:52 +0530 +Subject: [PATCH 251/255] tests: Fix + bug-1717819-metadata-split-brain-detection.t failure + + + +Problem: +tests/bugs/replicate/bug-1717819-metadata-split-brain-detection.t fails +intermittently in test cases #49 & #50, which compare the values of the +user set xattr values after enabling the heal. We are not waiting for +the heal to complete before comparing those values, which might lead +those tests to fail. + +Fix: +Wait till the HEAL-TIMEOUT before comparing the xattr values. +Also cheking for the shd to come up and the bricks to connect to the shd +process in another case. + +Change-Id: I0021c2d5d251111c695e2bf18c63e8189e456114 +fixes: bz#1704562 +Signed-off-by: karthik-us +Reviewed-on: https://code.engineering.redhat.com/gerrit/176071 +Reviewed-by: Atin Mukherjee +Tested-by: RHGS Build Bot +--- + tests/bugs/replicate/bug-1717819-metadata-split-brain-detection.t | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/tests/bugs/replicate/bug-1717819-metadata-split-brain-detection.t b/tests/bugs/replicate/bug-1717819-metadata-split-brain-detection.t +index 94b8bf3..76d1f21 100644 +--- a/tests/bugs/replicate/bug-1717819-metadata-split-brain-detection.t ++++ b/tests/bugs/replicate/bug-1717819-metadata-split-brain-detection.t +@@ -76,6 +76,10 @@ EXPECT_WITHIN $HEAL_TIMEOUT "^1$" get_pending_heal_count $V0 + + # Launch heal + TEST $CLI volume heal $V0 enable ++EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^Y$" glustershd_up_status ++EXPECT_WITHIN $CHILD_UP_TIMEOUT "^1$" afr_child_up_status_in_shd $V0 0 ++EXPECT_WITHIN $CHILD_UP_TIMEOUT "^1$" afr_child_up_status_in_shd $V0 1 ++EXPECT_WITHIN $CHILD_UP_TIMEOUT "^1$" afr_child_up_status_in_shd $V0 2 + TEST $CLI volume heal $V0 + EXPECT_WITHIN $HEAL_TIMEOUT "^0$" get_pending_heal_count $V0 + +@@ -117,6 +121,8 @@ EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^Y$" glustershd_up_status + EXPECT_WITHIN $CHILD_UP_TIMEOUT "^1$" afr_child_up_status_in_shd $V0 0 + EXPECT_WITHIN $CHILD_UP_TIMEOUT "^1$" afr_child_up_status_in_shd $V0 1 + EXPECT_WITHIN $CHILD_UP_TIMEOUT "^1$" afr_child_up_status_in_shd $V0 2 ++TEST $CLI volume heal $V0 ++EXPECT_WITHIN $HEAL_TIMEOUT "^0$" get_pending_heal_count $V0 + + B0_XATTR=$(getfattr -n 'user.metadata' --absolute-names --only-values $B0/${V0}0/dir/file) + B1_XATTR=$(getfattr -n 'user.metadata' --absolute-names --only-values $B0/${V0}1/dir/file) +-- +1.8.3.1 + diff --git a/0252-glusterd-do-not-mark-skip_locking-as-true-for-geo-re.patch b/0252-glusterd-do-not-mark-skip_locking-as-true-for-geo-re.patch new file mode 100644 index 0000000..b722dff --- /dev/null +++ b/0252-glusterd-do-not-mark-skip_locking-as-true-for-geo-re.patch @@ -0,0 +1,63 @@ +From 5a35a996257d6aaa7fa55ff1e1aac407dd4824fe Mon Sep 17 00:00:00 2001 +From: Sanju Rakonde +Date: Fri, 12 Jul 2019 16:28:04 +0530 +Subject: [PATCH 252/255] glusterd: do not mark skip_locking as true for + geo-rep operations + +We need to send the commit req to peers in case of geo-rep +operations even though it is a no volname operation. In commit +phase peers try to set the txn_opinfo which will fail because +it is a no volname operation where we don't require a commit +phase. We mark skip_locking as true for no volname operations, +but we have to give an exception to geo-rep operations, so that +they can set txn_opinfo in commit phase. + +Please refer to detailed RCA at the bug: 1729463 + +> upstream patch : https://review.gluster.org/#/c/glusterfs/+/23034/ + +>fixes: bz#1729463 +>Change-Id: I9f2478b12a281f6e052035c0563c40543493a3fc +>Signed-off-by: Sanju Rakonde + +Change-Id: I9f2478b12a281f6e052035c0563c40543493a3fc +BUG: 1727785 +Signed-off-by: Sanju Rakonde +Reviewed-on: https://code.engineering.redhat.com/gerrit/176032 +Tested-by: RHGS Build Bot +Reviewed-by: Shwetha Acharya +Reviewed-by: Sunil Kumar Heggodu Gopala Acharya +--- + xlators/mgmt/glusterd/src/glusterd-handler.c | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c +index cb2666b..2e73c98 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-handler.c ++++ b/xlators/mgmt/glusterd/src/glusterd-handler.c +@@ -1078,7 +1078,11 @@ __glusterd_handle_stage_op(rpcsvc_request_t *req) + + /* In cases where there is no volname, the receivers won't have a + * transaction opinfo created, as for those operations, the locking +- * phase where the transaction opinfos are created, won't be called. */ ++ * phase where the transaction opinfos are created, won't be called. ++ * skip_locking will be true for all such transaction and we clear ++ * the txn_opinfo after the staging phase, except for geo-replication ++ * operations where we need to access txn_opinfo in the later phases also. ++ */ + ret = glusterd_get_txn_opinfo(txn_id, &txn_op_info); + if (ret) { + gf_msg_debug(this->name, 0, "No transaction's opinfo set"); +@@ -1087,7 +1091,8 @@ __glusterd_handle_stage_op(rpcsvc_request_t *req) + glusterd_txn_opinfo_init(&txn_op_info, &state, &op_req.op, + req_ctx->dict, req); + +- txn_op_info.skip_locking = _gf_true; ++ if (req_ctx->op != GD_OP_GSYNC_SET) ++ txn_op_info.skip_locking = _gf_true; + ret = glusterd_set_txn_opinfo(txn_id, &txn_op_info); + if (ret) { + gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_TRANS_OPINFO_SET_FAIL, +-- +1.8.3.1 + diff --git a/0253-core-fix-deadlock-between-statedump-and-fd_anonymous.patch b/0253-core-fix-deadlock-between-statedump-and-fd_anonymous.patch new file mode 100644 index 0000000..d313482 --- /dev/null +++ b/0253-core-fix-deadlock-between-statedump-and-fd_anonymous.patch @@ -0,0 +1,246 @@ +From ea7f11b989896d76b8d091d26bc0241bce9413f8 Mon Sep 17 00:00:00 2001 +From: Xavi Hernandez +Date: Thu, 4 Jul 2019 13:21:33 +0200 +Subject: [PATCH 253/255] core: fix deadlock between statedump and + fd_anonymous() + +There exists a deadlock between statedump generation and fd_anonymous() +function because they are acquiring inode table lock and inode lock in +reverse order. + +This patch modifies fd_anonymous() so that it takes inode lock only when +it's really necessary, avoiding the deadlock. + +Upstream patch: +> Change-Id: I24355447f0ea1b39e2546782ad07f0512cc381e7 +> Upstream patch link: https://review.gluster.org/c/glusterfs/+/22995 +> BUG: 1727068 +> Signed-off-by: Xavi Hernandez + +Change-Id: I24355447f0ea1b39e2546782ad07f0512cc381e7 +Fixes: bz#1722209 +Signed-off-by: Xavi Hernandez +Reviewed-on: https://code.engineering.redhat.com/gerrit/176096 +Tested-by: RHGS Build Bot +Reviewed-by: Sunil Kumar Heggodu Gopala Acharya +--- + libglusterfs/src/fd.c | 137 ++++++++++++++++++++++---------------------------- + 1 file changed, 61 insertions(+), 76 deletions(-) + +diff --git a/libglusterfs/src/fd.c b/libglusterfs/src/fd.c +index b8aac72..314546a 100644 +--- a/libglusterfs/src/fd.c ++++ b/libglusterfs/src/fd.c +@@ -532,7 +532,7 @@ fd_unref(fd_t *fd) + return; + } + +-fd_t * ++static fd_t * + __fd_bind(fd_t *fd) + { + list_del_init(&fd->inode_list); +@@ -562,9 +562,9 @@ fd_bind(fd_t *fd) + } + + static fd_t * +-__fd_create(inode_t *inode, uint64_t pid) ++fd_allocate(inode_t *inode, uint64_t pid) + { +- fd_t *fd = NULL; ++ fd_t *fd; + + if (inode == NULL) { + gf_msg_callingfn("fd", GF_LOG_ERROR, EINVAL, LG_MSG_INVALID_ARG, +@@ -573,64 +573,67 @@ __fd_create(inode_t *inode, uint64_t pid) + } + + fd = mem_get0(inode->table->fd_mem_pool); +- if (!fd) +- goto out; ++ if (fd == NULL) { ++ return NULL; ++ } + + fd->xl_count = inode->table->xl->graph->xl_count + 1; + + fd->_ctx = GF_CALLOC(1, (sizeof(struct _fd_ctx) * fd->xl_count), + gf_common_mt_fd_ctx); +- if (!fd->_ctx) +- goto free_fd; ++ if (fd->_ctx == NULL) { ++ goto failed; ++ } + + fd->lk_ctx = fd_lk_ctx_create(); +- if (!fd->lk_ctx) +- goto free_fd_ctx; +- +- fd->inode = inode_ref(inode); +- fd->pid = pid; +- INIT_LIST_HEAD(&fd->inode_list); +- +- LOCK_INIT(&fd->lock); +-out: +- return fd; ++ if (fd->lk_ctx != NULL) { ++ /* We need to take a reference from the inode, but we cannot do it ++ * here because this function can be called with the inode lock taken ++ * and inode_ref() takes the inode's table lock. This is the reverse ++ * of the logical lock acquisition order and can cause a deadlock. So ++ * we simply assign the inode here and we delefate the inode reference ++ * responsibility to the caller (when this function succeeds and the ++ * inode lock is released). This is safe because the caller must hold ++ * a reference of the inode to use it, so it's guaranteed that the ++ * number of references won't reach 0 before the caller finishes. ++ * ++ * TODO: minimize use of locks in favor of atomic operations to avoid ++ * these dependencies. */ ++ fd->inode = inode; ++ fd->pid = pid; ++ INIT_LIST_HEAD(&fd->inode_list); ++ LOCK_INIT(&fd->lock); ++ GF_ATOMIC_INIT(fd->refcount, 1); ++ return fd; ++ } + +-free_fd_ctx: + GF_FREE(fd->_ctx); +-free_fd: ++ ++failed: + mem_put(fd); + + return NULL; + } + + fd_t * +-fd_create(inode_t *inode, pid_t pid) ++fd_create_uint64(inode_t *inode, uint64_t pid) + { +- fd_t *fd = NULL; +- +- fd = __fd_create(inode, (uint64_t)pid); +- if (!fd) +- goto out; ++ fd_t *fd; + +- fd = fd_ref(fd); ++ fd = fd_allocate(inode, pid); ++ if (fd != NULL) { ++ /* fd_allocate() doesn't get a reference from the inode. We need to ++ * take it here in case of success. */ ++ inode_ref(inode); ++ } + +-out: + return fd; + } + + fd_t * +-fd_create_uint64(inode_t *inode, uint64_t pid) ++fd_create(inode_t *inode, pid_t pid) + { +- fd_t *fd = NULL; +- +- fd = __fd_create(inode, pid); +- if (!fd) +- goto out; +- +- fd = fd_ref(fd); +- +-out: +- return fd; ++ return fd_create_uint64(inode, (uint64_t)pid); + } + + static fd_t * +@@ -719,10 +722,13 @@ __fd_lookup_anonymous(inode_t *inode, int32_t flags) + return fd; + } + +-static fd_t * +-__fd_anonymous(inode_t *inode, int32_t flags) ++fd_t * ++fd_anonymous_with_flags(inode_t *inode, int32_t flags) + { + fd_t *fd = NULL; ++ bool ref = false; ++ ++ LOCK(&inode->lock); + + fd = __fd_lookup_anonymous(inode, flags); + +@@ -730,54 +736,33 @@ __fd_anonymous(inode_t *inode, int32_t flags) + __fd_lookup_anonymous(), so no need of one more fd_ref(). + if (!fd); then both create and bind won't bump up the ref + count, so we have to call fd_ref() after bind. */ +- if (!fd) { +- fd = __fd_create(inode, 0); +- +- if (!fd) +- return NULL; +- +- fd->anonymous = _gf_true; +- fd->flags = GF_ANON_FD_FLAGS | flags; ++ if (fd == NULL) { ++ fd = fd_allocate(inode, 0); ++ if (fd != NULL) { ++ fd->anonymous = _gf_true; ++ fd->flags = GF_ANON_FD_FLAGS | (flags & O_DIRECT); + +- __fd_bind(fd); ++ __fd_bind(fd); + +- __fd_ref(fd); ++ ref = true; ++ } + } + +- return fd; +-} +- +-fd_t * +-fd_anonymous(inode_t *inode) +-{ +- fd_t *fd = NULL; ++ UNLOCK(&inode->lock); + +- LOCK(&inode->lock); +- { +- fd = __fd_anonymous(inode, GF_ANON_FD_FLAGS); ++ if (ref) { ++ /* fd_allocate() doesn't get a reference from the inode. We need to ++ * take it here in case of success. */ ++ inode_ref(inode); + } +- UNLOCK(&inode->lock); + + return fd; + } + + fd_t * +-fd_anonymous_with_flags(inode_t *inode, int32_t flags) ++fd_anonymous(inode_t *inode) + { +- fd_t *fd = NULL; +- +- if (flags & O_DIRECT) +- flags = GF_ANON_FD_FLAGS | O_DIRECT; +- else +- flags = GF_ANON_FD_FLAGS; +- +- LOCK(&inode->lock); +- { +- fd = __fd_anonymous(inode, flags); +- } +- UNLOCK(&inode->lock); +- +- return fd; ++ return fd_anonymous_with_flags(inode, 0); + } + + fd_t * +-- +1.8.3.1 + diff --git a/0254-Detach-iot_worker-to-release-its-resources.patch b/0254-Detach-iot_worker-to-release-its-resources.patch new file mode 100644 index 0000000..6019436 --- /dev/null +++ b/0254-Detach-iot_worker-to-release-its-resources.patch @@ -0,0 +1,43 @@ +From 2bbb097d087bb5ef142775500708f11ccd31bac0 Mon Sep 17 00:00:00 2001 +From: Liguang Li +Date: Fri, 21 Jun 2019 12:18:58 +0800 +Subject: [PATCH 254/255] Detach iot_worker to release its resources + +When iot_worker terminates, its resources have not been reaped, which +will consumes lots of memory. + +Detach iot_worker to automically release its resources back to the +system. + +> upstream patch : https://review.gluster.org/#/c/glusterfs/+/22918/ + +>fixes: bz#1729107 +>Change-Id: I71fabb2940e76ad54dc56b4c41aeeead2644b8bb +>Signed-off-by: Liguang Li + +BUG:1729108 +Change-Id: I71fabb2940e76ad54dc56b4c41aeeead2644b8bb +Signed-off-by: Liguang Li +Reviewed-on: https://code.engineering.redhat.com/gerrit/176106 +Tested-by: RHGS Build Bot +Reviewed-by: Ravishankar Narayanankutty +Reviewed-by: Atin Mukherjee +--- + xlators/performance/io-threads/src/io-threads.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/xlators/performance/io-threads/src/io-threads.c b/xlators/performance/io-threads/src/io-threads.c +index 060d923..1d96691 100644 +--- a/xlators/performance/io-threads/src/io-threads.c ++++ b/xlators/performance/io-threads/src/io-threads.c +@@ -835,6 +835,7 @@ __iot_workers_scale(iot_conf_t *conf) + ret = gf_thread_create(&thread, &conf->w_attr, iot_worker, conf, + "iotwr%03hx", conf->curr_count & 0x3ff); + if (ret == 0) { ++ pthread_detach(thread); + conf->curr_count++; + gf_msg_debug(conf->this->name, 0, + "scaled threads to %d (queue_size=%d/%d)", +-- +1.8.3.1 + diff --git a/0255-Revert-tier-shd-glusterd-with-shd-mux-the-shd-volfil.patch b/0255-Revert-tier-shd-glusterd-with-shd-mux-the-shd-volfil.patch new file mode 100644 index 0000000..89a8aaf --- /dev/null +++ b/0255-Revert-tier-shd-glusterd-with-shd-mux-the-shd-volfil.patch @@ -0,0 +1,104 @@ +From 684a4949552164d3469329b3f959de4369d54faa Mon Sep 17 00:00:00 2001 +From: Atin Mukherjee +Date: Sun, 14 Jul 2019 08:06:11 +0530 +Subject: [PATCH 255/255] Revert "tier/shd/glusterd: with shd mux, the shd + volfile path have to be updated for tier-heald.t" + +This reverts commit 6e7d333625ecd9f7402c2e839338350fa86eaf45. + +Updates: bz#1471742 +Change-Id: I6c27634999f72b5bbb35d5d13cdebda7af072b01 +Reviewed-on: https://code.engineering.redhat.com/gerrit/176017 +Tested-by: RHGS Build Bot +Reviewed-by: Sunil Kumar Heggodu Gopala Acharya +--- + tests/basic/tier/tier-heald.t | 35 +++++++++++++++-------------------- + 1 file changed, 15 insertions(+), 20 deletions(-) + +diff --git a/tests/basic/tier/tier-heald.t b/tests/basic/tier/tier-heald.t +index 0ec9e43..a8e634f 100644 +--- a/tests/basic/tier/tier-heald.t ++++ b/tests/basic/tier/tier-heald.t +@@ -11,7 +11,7 @@ cleanup; + TEST glusterd + TEST pidof glusterd + +-r2_volfile=$(gluster system:: getwd)"/vols/r2/r2-shd.vol" ++volfile=$(gluster system:: getwd)"/glustershd/glustershd-server.vol" + + # Commands should fail when both tiers are not of distribute type. + # Glustershd shouldn't be running as long as there are no replicate/disperse +@@ -34,56 +34,51 @@ TEST $CLI volume tier r2 attach $H0:$B0/r2_hot + EXPECT_WITHIN $PROCESS_UP_TIMEOUT "[0-9][0-9]*" get_shd_process_pid + TEST $CLI volume heal r2 enable + EXPECT "enable" volume_option r2 "cluster.self-heal-daemon" +-EXPECT "enable" volgen_volume_option $r2_volfile r2-replicate-0 cluster replicate self-heal-daemon ++EXPECT "enable" volgen_volume_option $volfile r2-replicate-0 cluster replicate self-heal-daemon + EXPECT_WITHIN $PROCESS_UP_TIMEOUT "[0-9][0-9]*" get_shd_process_pid + TEST $CLI volume heal r2 disable + EXPECT "disable" volume_option r2 "cluster.self-heal-daemon" +-EXPECT "disable" volgen_volume_option $r2_volfile r2-replicate-0 cluster replicate self-heal-daemon ++EXPECT "disable" volgen_volume_option $volfile r2-replicate-0 cluster replicate self-heal-daemon + EXPECT_WITHIN $PROCESS_UP_TIMEOUT "[0-9][0-9]*" get_shd_process_pid + # Commands should work on disperse volume. + TEST $CLI volume create ec2 disperse 3 redundancy 1 $H0:$B0/ec2_0 $H0:$B0/ec2_1 $H0:$B0/ec2_2 + TEST $CLI volume start ec2 + +-ec2_volfile=$(gluster system:: getwd)"/vols/ec2/ec2-shd.vol" +- + TEST $CLI volume tier ec2 attach replica 2 $H0:$B0/ec2_hot{1..4} + EXPECT_WITHIN $PROCESS_UP_TIMEOUT "[0-9][0-9]*" get_shd_process_pid + TEST $CLI volume heal ec2 enable + EXPECT "enable" volume_option ec2 "cluster.disperse-self-heal-daemon" +-EXPECT "enable" volgen_volume_option $ec2_volfile ec2-disperse-0 cluster disperse self-heal-daemon ++EXPECT "enable" volgen_volume_option $volfile ec2-disperse-0 cluster disperse self-heal-daemon + EXPECT_WITHIN $PROCESS_UP_TIMEOUT "[0-9][0-9]*" get_shd_process_pid + TEST $CLI volume heal ec2 disable + EXPECT "disable" volume_option ec2 "cluster.disperse-self-heal-daemon" +-EXPECT "disable" volgen_volume_option $ec2_volfile ec2-disperse-0 cluster disperse self-heal-daemon ++EXPECT "disable" volgen_volume_option $volfile ec2-disperse-0 cluster disperse self-heal-daemon + EXPECT_WITHIN $PROCESS_UP_TIMEOUT "[0-9][0-9]*" get_shd_process_pid + + #Check that shd graph is rewritten correctly on volume stop/start +-EXPECT "Y" volgen_volume_exists $ec2_volfile ec2-disperse-0 cluster disperse +-EXPECT "Y" volgen_volume_exists $r2_volfile r2-replicate-0 cluster replicate ++EXPECT "Y" volgen_volume_exists $volfile ec2-disperse-0 cluster disperse ++EXPECT "Y" volgen_volume_exists $volfile r2-replicate-0 cluster replicate + TEST $CLI volume stop r2 +-EXPECT "Y" volgen_volume_exists $ec2_volfile ec2-disperse-0 cluster disperse +- +-# Has been commented as the validations after stop using volfile dont hold true. +-#EXPECT "N" volgen_volume_exists $r2_volfile r2-replicate-0 cluster replicate ++EXPECT "Y" volgen_volume_exists $volfile ec2-disperse-0 cluster disperse ++EXPECT "N" volgen_volume_exists $volfile r2-replicate-0 cluster replicate + TEST $CLI volume stop ec2 + # When both the volumes are stopped glustershd volfile is not modified just the + # process is stopped + TEST "[ -z $(get_shd_process_pid) ]" + + TEST $CLI volume start r2 +-# Has been commented as the validations after stop using volfile dont hold true. +-#EXPECT "N" volgen_volume_exists $ec2_volfile ec2-disperse-0 cluster disperse +-EXPECT "Y" volgen_volume_exists $r2_volfile r2-replicate-0 cluster replicate ++EXPECT "N" volgen_volume_exists $volfile ec2-disperse-0 cluster disperse ++EXPECT "Y" volgen_volume_exists $volfile r2-replicate-0 cluster replicate + + TEST $CLI volume start ec2 + +-EXPECT "Y" volgen_volume_exists $ec2_volfile ec2-disperse-0 cluster disperse +-EXPECT "Y" volgen_volume_exists $ec2_volfile ec2-replicate-0 cluster replicate ++EXPECT "Y" volgen_volume_exists $volfile ec2-disperse-0 cluster disperse ++EXPECT "Y" volgen_volume_exists $volfile ec2-replicate-0 cluster replicate + + TEST $CLI volume tier ec2 detach force + +-EXPECT "Y" volgen_volume_exists $ec2_volfile ec2-disperse-0 cluster disperse +-EXPECT "N" volgen_volume_exists $ec2_volfile ec2-replicate-0 cluster replicate ++EXPECT "Y" volgen_volume_exists $volfile ec2-disperse-0 cluster disperse ++EXPECT "N" volgen_volume_exists $volfile ec2-replicate-0 cluster replicate + + TEST $CLI volume set r2 self-heal-daemon on + TEST $CLI volume set r2 cluster.self-heal-daemon off +-- +1.8.3.1 + diff --git a/glusterfs.spec b/glusterfs.spec index bd8a608..9b3cab2 100644 --- a/glusterfs.spec +++ b/glusterfs.spec @@ -231,7 +231,7 @@ Release: 0.1%{?prereltag:.%{prereltag}}%{?dist} %else Name: glusterfs Version: 6.0 -Release: 7%{?dist} +Release: 8%{?dist} ExcludeArch: i686 %endif License: GPLv2 or LGPLv3+ @@ -530,6 +530,40 @@ Patch0218: 0218-graph-shd-Use-glusterfs_graph_deactivate-to-free-the.patch Patch0219: 0219-posix-add-posix_set_ctime-in-posix_ftruncate.patch Patch0220: 0220-graph-shd-Use-top-down-approach-while-cleaning-xlato.patch Patch0221: 0221-protocol-client-propagte-GF_EVENT_CHILD_PING-only-fo.patch +Patch0222: 0222-cluster-dht-Fixed-a-memleak-in-dht_rename_cbk.patch +Patch0223: 0223-change-get_real_filename-implementation-to-use-ENOAT.patch +Patch0224: 0224-core-replace-inet_addr-with-inet_pton.patch +Patch0225: 0225-tests-utils-Fix-py2-py3-util-python-scripts.patch +Patch0226: 0226-geo-rep-fix-gluster-command-path-for-non-root-sessio.patch +Patch0227: 0227-glusterd-svc-update-pid-of-mux-volumes-from-the-shd-.patch +Patch0228: 0228-locks-enable-notify-contention-by-default.patch +Patch0229: 0229-glusterd-Show-the-correct-brick-status-in-get-state.patch +Patch0230: 0230-Revert-glusterd-svc-update-pid-of-mux-volumes-from-t.patch +Patch0231: 0231-Revert-graph-shd-Use-top-down-approach-while-cleanin.patch +Patch0232: 0232-cluster-afr-Fix-incorrect-reporting-of-gfid-type-mis.patch +Patch0233: 0233-Revert-graph-shd-Use-glusterfs_graph_deactivate-to-f.patch +Patch0234: 0234-Revert-glusterd-shd-Change-shd-logfile-to-a-unique-n.patch +Patch0235: 0235-Revert-glusterd-svc-Stop-stale-process-using-the-glu.patch +Patch0236: 0236-Revert-shd-mux-Fix-race-between-mux_proc-unlink-and-.patch +Patch0237: 0237-Revert-ec-fini-Fix-race-between-xlator-cleanup-and-o.patch +Patch0238: 0238-Revert-xlator-log-Add-more-logging-in-xlator_is_clea.patch +Patch0239: 0239-Revert-ec-fini-Fix-race-with-ec_fini-and-ec_notify.patch +Patch0240: 0240-Revert-glusterd-shd-Optimize-the-glustershd-manager-.patch +Patch0241: 0241-Revert-glusterd-svc-glusterd_svcs_stop-should-call-i.patch +Patch0242: 0242-Revert-tests-shd-Add-test-coverage-for-shd-mux.patch +Patch0243: 0243-Revert-glusterfsd-cleanup-Protect-graph-object-under.patch +Patch0244: 0244-Revert-ec-shd-Cleanup-self-heal-daemon-resources-dur.patch +Patch0245: 0245-Revert-shd-glusterd-Serialize-shd-manager-to-prevent.patch +Patch0246: 0246-Revert-glusterd-shd-Keep-a-ref-on-volinfo-until-atta.patch +Patch0247: 0247-Revert-afr-shd-Cleanup-self-heal-daemon-resources-du.patch +Patch0248: 0248-Revert-shd-mux-Fix-coverity-issues-introduced-by-shd.patch +Patch0249: 0249-Revert-client-fini-return-fini-after-rpc-cleanup.patch +Patch0250: 0250-Revert-mgmt-shd-Implement-multiplexing-in-self-heal-.patch +Patch0251: 0251-tests-Fix-bug-1717819-metadata-split-brain-detection.patch +Patch0252: 0252-glusterd-do-not-mark-skip_locking-as-true-for-geo-re.patch +Patch0253: 0253-core-fix-deadlock-between-statedump-and-fd_anonymous.patch +Patch0254: 0254-Detach-iot_worker-to-release-its-resources.patch +Patch0255: 0255-Revert-tier-shd-glusterd-with-shd-mux-the-shd-volfil.patch %description GlusterFS is a distributed file-system capable of scaling to several @@ -2238,6 +2272,10 @@ fi %endif %changelog +* Tue Jul 16 2019 Sunil Kumar Acharya - 6.0-8 +- fixes bugs bz#1698435 bz#1712591 bz#1715447 bz#1720488 bz#1722209 + bz#1722512 bz#1724089 bz#1726991 bz#1727785 bz#1729108 + * Fri Jun 28 2019 Sunil Kumar Acharya - 6.0-7 - fixes bugs bz#1573077 bz#1600918 bz#1703423 bz#1704207 bz#1708064 bz#1709301 bz#1713664 bz#1716760 bz#1717784 bz#1720163 bz#1720192