From d772a79d6fac46426b5eaa6a307bac74f4e8033f Mon Sep 17 00:00:00 2001 From: "Kaleb S. KEITHLEY" Date: Thu, 9 Mar 2017 12:34:41 -0500 Subject: build/packaging: Debian and Ubuntu don't have /usr/libexec GLUSTERFS_LIBEXECDIR is effectively hard-coded to /usr/libexec/glusterfs in configure(.ac) Debian-based distributions don't have a /usr/libexec/ directory This issues is partially mitigated by the use of $libexecdir in some of the Makefile.am files, but even so the incorrectly defined GLUSTERFS_LIBEXECDIR results in various things such as gsyncd, glusterfind, eventsd, etc., trying to invoke other scripts and programs from a location that doesn't exist. And once we correctly define GLUSTERFS_LIBEXECDIR, then we might as well use it appropriatedly. master change https://review.gluster.org/16880 master BZ: 1430841 release-3.10 change https://review.gluster.org/16881 release-3.10 BZ: 1430845 Change-Id: If5219cadc51ae316f7ba2e2831d739235c77902d BUG: 1430845 Signed-off-by: Kaleb S. KEITHLEY Reviewed-on: https://review.gluster.org/16882 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Milind Changire --- cli/src/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cli/src') diff --git a/cli/src/Makefile.am b/cli/src/Makefile.am index 91819d111e3..8e47e209056 100644 --- a/cli/src/Makefile.am +++ b/cli/src/Makefile.am @@ -17,7 +17,7 @@ AM_CPPFLAGS = $(GF_CPPFLAGS) \ -I$(top_srcdir)/rpc/xdr/src\ -DDATADIR=\"$(localstatedir)\" \ -DCONFDIR=\"$(sysconfdir)/glusterfs\" \ - -DGSYNCD_PREFIX=\"$(libexecdir)/glusterfs\"\ + -DGSYNCD_PREFIX=\"$(GLUSTERFS_LIBEXECDIR)\"\ -DSYNCDAEMON_COMPILE=$(SYNCDAEMON_COMPILE) -DSBIN_DIR=\"$(sbindir)\"\ $(XML_CPPFLAGS) -- cgit From 2dcb19813e7dbb2afd2f482ed9a3401371325b1d Mon Sep 17 00:00:00 2001 From: Sanoj Unnikrishnan Date: Wed, 22 Mar 2017 15:02:12 +0530 Subject: Fixes quota aux mount failure The aux mount is created on the first limit/remove_limit/list command and it remains until volume is stopped / deleted / (quota is disabled) , where we do a lazy unmount. If the process is uncleanly terminated, then the mount entry remains and we get (Transport disconnected) error on subsequent attempts to run quota list/limit-usage/remove commands. Second issue, There is also a risk of inadvertent rm -rf on the /var/run/gluster causing data loss for the user. Ideally, /var/run is a temp path for application use and should not cause any data loss to persistent storage. Solution: 1) unmount the aux mount after each use. 2) clean stale mount before mounting, if any. One caveat with doing mount/unmount on each command is that we cannot use same mount point for both list and limit commands. The reason for this is that list command needs mount to be accessible in cli after response from glusterd, So it could be unmounted by a limit command if executed in parallel (had we used same mount point) Hence we use separate mount points for list and limit commands. > Reviewed-on: https://review.gluster.org/16938 > NetBSD-regression: NetBSD Build System > Smoke: Gluster Build System > Reviewed-by: Manikandan Selvaganesh > CentOS-regression: Gluster Build System > Reviewed-by: Raghavendra G > Reviewed-by: Atin Mukherjee > (cherry picked from commit 2ae4b4058691b324535d802f4e6d24cce89a10e5) Change-Id: I4f9e39da2ac2b65941399bffb6440db8a6ba59d0 BUG: 1449782 Signed-off-by: Sanoj Unnikrishnan Reviewed-on: https://review.gluster.org/17242 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Raghavendra G --- cli/src/cli-rpc-ops.c | 29 ++++++++++++++++++++++++++++- cli/src/cli.h | 7 ++++--- 2 files changed, 32 insertions(+), 4 deletions(-) (limited to 'cli/src') diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 602d3ff1611..07a63364ebe 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -3399,6 +3399,26 @@ out: return ret; } +int +gluster_remove_auxiliary_mount (char *volname) +{ + int ret = -1; + char mountdir[PATH_MAX] = {0,}; + xlator_t *this = NULL; + + this = THIS; + GF_ASSERT (this); + + GLUSTERD_GET_QUOTA_LIST_MOUNT_PATH (mountdir, volname, "/"); + ret = gf_umount_lazy (this->name, mountdir, 1); + if (ret) { + gf_log("cli", GF_LOG_ERROR, "umount on %s failed, " + "reason : %s", mountdir, strerror (errno)); + } + + return ret; +} + int gf_cli_print_limit_list_from_dict (cli_local_t *local, char *volname, dict_t *dict, char *default_sl, int count, @@ -3447,7 +3467,7 @@ gf_cli_print_limit_list_from_dict (cli_local_t *local, char *volname, ret = gf_canonicalize_path (path); if (ret) goto out; - GLUSTERD_GET_QUOTA_AUX_MOUNT_PATH (mountdir, volname, path); + GLUSTERD_GET_QUOTA_LIST_MOUNT_PATH (mountdir, volname, path); ret = print_quota_list_from_mountdir (local, mountdir, default_sl, path, type); } @@ -3930,6 +3950,7 @@ gf_cli_quota_cbk (struct rpc_req *req, struct iovec *iov, } xml_output: + if (global_state->mode & GLUSTER_MODE_XML) { ret = cli_xml_output_str ("volQuota", NULL, rsp.op_ret, rsp.op_errno, rsp.op_errstr); @@ -3945,6 +3966,12 @@ xml_output: ret = rsp.op_ret; out: + + if ((type == GF_QUOTA_OPTION_TYPE_LIST) + || (type == GF_QUOTA_OPTION_TYPE_LIST_OBJECTS)) { + gluster_remove_auxiliary_mount (volname); + } + cli_cmd_broadcast_response (ret); if (dict) dict_unref (dict); diff --git a/cli/src/cli.h b/cli/src/cli.h index 8acec640c83..b59e254d44f 100644 --- a/cli/src/cli.h +++ b/cli/src/cli.h @@ -62,9 +62,10 @@ typedef enum { #define GLUSTER_MODE_WIGNORE (1 << 3) -#define GLUSTERD_GET_QUOTA_AUX_MOUNT_PATH(abspath, volname, path) \ - snprintf (abspath, sizeof (abspath)-1, \ - DEFAULT_VAR_RUN_DIRECTORY"/%s%s", volname, path); +#define GLUSTERD_GET_QUOTA_LIST_MOUNT_PATH(abspath, volname, path) do { \ + snprintf (abspath, sizeof (abspath)-1, \ + DEFAULT_VAR_RUN_DIRECTORY"/%s_quota_list%s", volname, path);\ + } while (0) struct cli_state; struct cli_cmd_word; -- cgit From b7b13c8cd295fa2e9fba9cc77211e576469e9581 Mon Sep 17 00:00:00 2001 From: Atin Mukherjee Date: Wed, 5 Jul 2017 14:58:50 +0530 Subject: cli/xml: fix return handling The return code of xmlTextWriter* APIs says it returns either the bytes written (may be 0 because of buffering) or -1 in case of error. Now if the volume of the xml data payload is not huge then most of the time the data to be written gets buffered, however when this grows sometimes this APIs will return the total number of bytes written and then it becomes absolutely mandatory that every such call is followed by XML_RET_CHECK_AND_GOTO otherwise we may end up returning a non zero ret code which would result into the overall xml generation to fail. >Reviewed-on: https://review.gluster.org/17702 >Smoke: Gluster Build System >Reviewed-by: Amar Tumballi >CentOS-regression: Gluster Build System >Reviewed-by: Gaurav Yadav Change-Id: I02ee7076e1d8c26cf654d3dc3e77b1eb17cbdab0 BUG: 1470495 Signed-off-by: Atin Mukherjee Reviewed-on: https://review.gluster.org/17766 Smoke: Gluster Build System CentOS-regression: Gluster Build System Reviewed-by: Samikshan Bairagya Reviewed-by: Niels de Vos --- cli/src/cli-xml-output.c | 91 +++++++++++++++++++++++++++--------------------- 1 file changed, 52 insertions(+), 39 deletions(-) (limited to 'cli/src') diff --git a/cli/src/cli-xml-output.c b/cli/src/cli-xml-output.c index 4eafc0b5e68..0704174c211 100644 --- a/cli/src/cli-xml-output.c +++ b/cli/src/cli-xml-output.c @@ -194,6 +194,8 @@ cli_xml_output_data_pair (dict_t *this, char *key, data_t *value, ret = xmlTextWriterWriteFormatElement (*writer, (xmlChar *)key, "%s", value->data); + XML_RET_CHECK_AND_GOTO (ret, out); +out: return ret; } #endif @@ -324,7 +326,7 @@ cli_xml_output_vol_status_common (xmlTextWriterPtr writer, dict_t *dict, ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"port", "%s", "N/A"); - + XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterStartElement (writer, (xmlChar *)"ports"); if (*online == 1 && (port != 0 || rdma_port != 0)) { @@ -337,7 +339,7 @@ cli_xml_output_vol_status_common (xmlTextWriterPtr writer, dict_t *dict, (xmlChar *)"tcp", "%s", "N/A"); } - + XML_RET_CHECK_AND_GOTO (ret, out); if (rdma_port) { ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"rdma", @@ -347,14 +349,16 @@ cli_xml_output_vol_status_common (xmlTextWriterPtr writer, dict_t *dict, (xmlChar *)"rdma", "%s", "N/A"); } - + XML_RET_CHECK_AND_GOTO (ret, out); } else { ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"tcp", "%s", "N/A"); + XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"rdma", "%s", "N/A"); + XML_RET_CHECK_AND_GOTO (ret, out); } ret = xmlTextWriterEndElement (writer); @@ -392,77 +396,86 @@ cli_xml_output_vol_status_detail (xmlTextWriterPtr writer, dict_t *dict, snprintf (key, sizeof (key), "brick%d.total", brick_index); ret = dict_get_uint64 (dict, key, &size_total); - if (!ret) + if (!ret) { ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"sizeTotal", "%"PRIu64, size_total); - + XML_RET_CHECK_AND_GOTO (ret, out); + } memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.free", brick_index); ret = dict_get_uint64 (dict, key, &size_free); - if (!ret) + if (!ret) { ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"sizeFree", "%"PRIu64, size_free); - + XML_RET_CHECK_AND_GOTO (ret, out); + } memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.device", brick_index); ret = dict_get_str (dict, key, &device); - if (!ret) + if (!ret) { ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"device", "%s", device); - + XML_RET_CHECK_AND_GOTO (ret, out); + } memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.block_size", brick_index); ret = dict_get_uint64 (dict, key, &block_size); - if (!ret) + if (!ret) { ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"blockSize", "%"PRIu64, block_size); - XML_RET_CHECK_AND_GOTO (ret, out); - + XML_RET_CHECK_AND_GOTO (ret, out); + } memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.mnt_options", brick_index); ret = dict_get_str (dict, key, &mnt_options); - if (!ret) + if (!ret) { ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"mntOptions", "%s", mnt_options); - + XML_RET_CHECK_AND_GOTO (ret, out); + } memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.fs_name", brick_index); ret = dict_get_str (dict, key, &fs_name); - if (!ret) + if (!ret) { ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"fsName", "%s", fs_name); - + XML_RET_CHECK_AND_GOTO (ret, out); + } memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.inode_size", brick_index); ret = dict_get_str (dict, key, &inode_size); - if (!ret) + if (!ret) { ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"inodeSize", "%s", fs_name); - + XML_RET_CHECK_AND_GOTO (ret, out); + } memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.total_inodes", brick_index); ret = dict_get_uint64 (dict, key, &inodes_total); - if (!ret) + if (!ret) { ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"inodesTotal", "%"PRIu64, inodes_total); - + XML_RET_CHECK_AND_GOTO (ret, out); + } memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.free_inodes", brick_index); ret = dict_get_uint64 (dict, key, &inodes_free); - if (!ret) + if (!ret) { ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"inodesFree", "%"PRIu64, inodes_free); - else + XML_RET_CHECK_AND_GOTO (ret, out); + } else { ret = 0; + } out: gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret); @@ -1366,6 +1379,7 @@ cli_xml_output_vol_status_callpool (xmlTextWriterPtr writer, dict_t *dict, goto out; ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"count", "%d", call_count); + XML_RET_CHECK_AND_GOTO (ret, out); for (i = 0; i < call_count; i++) { memset (key, 0, sizeof (key)); @@ -1476,7 +1490,7 @@ cli_xml_output_remove_brick_task_params (xmlTextWriterPtr writer, dict_t *dict, /* */ ret = xmlTextWriterEndElement (writer); - + XML_RET_CHECK_AND_GOTO (ret, out); out: gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret); return ret; @@ -1560,7 +1574,7 @@ cli_xml_output_vol_status_tasks (cli_local_t *local, dict_t *dict) { /* */ ret = xmlTextWriterEndElement (local->writer); - + XML_RET_CHECK_AND_GOTO (ret, out); out: gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret); return ret; @@ -1637,8 +1651,8 @@ cli_xml_output_vol_status (cli_local_t *local, dict_t *dict) ret = xmlTextWriterWriteFormatElement (local->writer, (xmlChar *)"nodeCount", "%d", brick_count); - if (ret) - goto out; + + XML_RET_CHECK_AND_GOTO (ret, out); ret = dict_get_uint32 (dict, "cmd", &cmd); if (ret) @@ -2018,6 +2032,7 @@ cli_xml_output_vol_top (dict_t *dict, int op_ret, int op_errno, ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"timeTaken", "%f", time_taken); + XML_RET_CHECK_AND_GOTO (ret, out); } break; @@ -2320,8 +2335,7 @@ cli_xml_output_vol_profile (dict_t *dict, int op_ret, int op_errno, (writer, (xmlChar *)"clearStats", "%s", stats_cleared ? "Cleared stats." : "Failed to clear stats."); - if (ret) - goto out; + XML_RET_CHECK_AND_GOTO (ret, out); } else { snprintf (key, sizeof (key), "%d-cumulative", i); ret = dict_get_int32 (dict, key, &interval); @@ -2832,6 +2846,7 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) ret = xmlTextWriterWriteFormatElement (local->writer, (xmlChar *)"hotBrickType", "%s", cli_vol_type_str[tier_vol_type]); + XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterWriteFormatElement (local->writer, (xmlChar *)"hotreplicaCount", @@ -2852,7 +2867,6 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) (local->writer, (xmlChar *)"numberOfBricks", "%d", value[HOT_BRICK_COUNT]); - XML_RET_CHECK_AND_GOTO (ret, out); } else { ret = xmlTextWriterWriteFormatElement (local->writer, @@ -2863,6 +2877,7 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) hot_dist_count, value[HOT_BRICK_COUNT]); } + XML_RET_CHECK_AND_GOTO (ret, out); while (index <= value[HOT_BRICK_COUNT]) { snprintf (key, 1024, "volume%d.brick%d", i, @@ -2924,6 +2939,7 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) ret = xmlTextWriterWriteFormatElement (local->writer, (xmlChar *)"coldBrickType", "%s", cli_vol_type_str[tier_vol_type]); + XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterWriteFormatElement (local->writer, (xmlChar *)"coldreplicaCount", @@ -2953,8 +2969,6 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) (local->writer, (xmlChar *)"numberOfBricks", "%d", value[COLD_BRICK_COUNT]); - XML_RET_CHECK_AND_GOTO (ret, out); - } else if (value[COLD_TYPE] == GF_CLUSTER_TYPE_DISPERSE) { ret = xmlTextWriterWriteFormatElement @@ -2979,6 +2993,7 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) } start_index = index = value[HOT_BRICK_COUNT] + 1; + XML_RET_CHECK_AND_GOTO (ret, out); while (index <= brick_count) { snprintf (key, 1024, "volume%d.brick%d", i, @@ -3170,7 +3185,7 @@ cli_xml_output_vol_info_end (cli_local_t *local) ret = xmlTextWriterWriteFormatElement (local->writer, (xmlChar *)"count", "%d", local->vol_count); - + XML_RET_CHECK_AND_GOTO (ret, out); /* */ ret = xmlTextWriterEndElement (local->writer); XML_RET_CHECK_AND_GOTO (ret, out); @@ -3196,9 +3211,7 @@ cli_xml_output_vol_quota_limit_list_end (cli_local_t *local) int ret = -1; ret = xmlTextWriterEndElement (local->writer); - if (ret) { - goto out; - } + XML_RET_CHECK_AND_GOTO (ret, out); ret = cli_end_xml_output (local->writer, local->doc); @@ -3266,7 +3279,7 @@ cli_xml_output_peer_hostnames (xmlTextWriterPtr writer, dict_t *dict, /* */ ret = xmlTextWriterEndElement (writer); - + XML_RET_CHECK_AND_GOTO (ret, out); out: gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret); return ret; @@ -3470,6 +3483,7 @@ cli_xml_output_vol_rebalance_status (xmlTextWriterPtr writer, dict_t *dict, ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"nodeName", "%s", node_name); + XML_RET_CHECK_AND_GOTO (ret, out); memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "node-uuid-%d", i); @@ -3554,6 +3568,7 @@ cli_xml_output_vol_rebalance_status (xmlTextWriterPtr writer, dict_t *dict, (xmlChar *)"statusStr", "%s", cli_vol_task_status_str[status_rcd]); + XML_RET_CHECK_AND_GOTO (ret, out); memset (key, 0, 256); snprintf (key, 256, "run-time-%d", i); @@ -5767,7 +5782,6 @@ cli_xml_snapshot_delete (xmlTextWriterPtr writer, xmlDocPtr doc, dict_t *dict, ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "status", "Success"); - XML_RET_CHECK_AND_GOTO (ret, xmlend); } else { ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "status", @@ -5777,9 +5791,8 @@ cli_xml_snapshot_delete (xmlTextWriterPtr writer, xmlDocPtr doc, dict_t *dict, ret = cli_xml_output_common (writer, rsp->op_ret, rsp->op_errno, rsp->op_errstr); - XML_RET_CHECK_AND_GOTO (ret, xmlend); } - + XML_RET_CHECK_AND_GOTO (ret, xmlend); ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "name", "%s", str_value); -- cgit