summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt
diff options
context:
space:
mode:
authorvmallika <vmallika@redhat.com>2016-01-20 15:51:41 +0530
committerAtin Mukherjee <amukherj@redhat.com>2016-01-22 03:27:14 -0800
commit90366748a44c853dbba02d6d2a8192643b711017 (patch)
tree41dcb55dedfdeb67e072a7e1ec056c5e9e963b23 /xlators/mgmt
parent424825a649ea0cd9bd4955fbfe9d5ba472e6bc38 (diff)
quota: start aux mount from glusterd with inet address
This is a backport of http://review.gluster.org/#/c/13255 With below patches, quota aux mount now uses unix domain socket to connect to glusterd http://review.gluster.org/#/c/12645/ http://review.gluster.org/#/c/12819/ When USS is enabled, snapd protocol client tries to connect to glusterd with inet and fails, because remote-host option by client process is set to UDS file This patch starts the aux client process from glusterd with inet address > Change-Id: I6967043bfd8824658ea39bfd2842591fcc3280fd > BUG: 1299497 > Signed-off-by: vmallika <vmallika@redhat.com> Change-Id: Ica512aaf5c2b25f86506bd1e0d7810a8ff1f7632 BUG: 1300243 Signed-off-by: vmallika <vmallika@redhat.com> Reviewed-on: http://review.gluster.org/13267 Smoke: Gluster Build System <jenkins@build.gluster.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Diffstat (limited to 'xlators/mgmt')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-quota.c114
1 files changed, 106 insertions, 8 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-quota.c b/xlators/mgmt/glusterd/src/glusterd-quota.c
index fe1b9070017..294ade7fd96 100644
--- a/xlators/mgmt/glusterd/src/glusterd-quota.c
+++ b/xlators/mgmt/glusterd/src/glusterd-quota.c
@@ -1705,6 +1705,94 @@ out:
return ret;
}
+static int
+glusterd_create_quota_auxiliary_mount (xlator_t *this, char *volname)
+{
+ int ret = -1;
+ int retry = 0;
+ char mountdir[PATH_MAX] = {0,};
+ char pidfile_path[PATH_MAX] = {0,};
+ char logfile[PATH_MAX] = {0,};
+ char qpid[16] = {0,};
+ char *volfileserver = NULL;
+ glusterd_conf_t *priv = NULL;
+ struct stat buf = {0,};
+
+ GF_VALIDATE_OR_GOTO ("glusterd", this, out);
+ priv = this->private;
+ GF_VALIDATE_OR_GOTO (this->name, priv, out);
+
+ GLUSTERFS_GET_AUX_MOUNT_PIDFILE (pidfile_path, volname);
+
+ if (gf_is_service_running (pidfile_path, NULL)) {
+ gf_msg_debug (this->name, 0, "Aux mount of volume %s is running"
+ " already", volname);
+ ret = 0;
+ goto out;
+ }
+
+ if (glusterd_is_fuse_available () == _gf_false) {
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_MOUNT_REQ_FAIL, "Fuse unavailable");
+ ret = -1;
+ goto out;
+ }
+
+ GLUSTERD_GET_QUOTA_AUX_MOUNT_PATH (mountdir, volname, "/");
+ ret = sys_mkdir (mountdir, 0777);
+ if (ret && errno != EEXIST) {
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_MOUNT_REQ_FAIL, "Failed to create auxiliary "
+ "mount directory %s", mountdir);
+ goto out;
+ }
+ snprintf (logfile, PATH_MAX-1, "%s/quota-mount-%s.log",
+ DEFAULT_LOG_FILE_DIRECTORY, volname);
+ snprintf(qpid, 15, "%d", GF_CLIENT_PID_QUOTA_MOUNT);
+
+ if (dict_get_str (this->options, "transport.socket.bind-address",
+ &volfileserver) != 0)
+ volfileserver = "localhost";
+
+ synclock_unlock (&priv->big_lock);
+ ret = runcmd (SBIN_DIR"/glusterfs",
+ "--volfile-server", volfileserver,
+ "--volfile-id", volname,
+ "-l", logfile,
+ "-p", pidfile_path,
+ "--client-pid", qpid,
+ mountdir,
+ NULL);
+ if (ret == 0) {
+ /* Block here till mount process is ready to accept FOPs.
+ * Else, if glusterd acquires biglock below before
+ * mount process is ready, then glusterd and mount process
+ * can get into a deadlock situation.
+ */
+ ret = sys_stat (mountdir, &buf);
+ if (ret < 0)
+ ret = -errno;
+ } else {
+ ret = -errno;
+ }
+
+ synclock_lock (&priv->big_lock);
+
+ if (ret) {
+ gf_msg (this->name, GF_LOG_ERROR, -ret,
+ GD_MSG_MOUNT_REQ_FAIL, "Failed to mount glusterfs "
+ "client. Please check the log file %s for more details",
+ logfile);
+ ret = -1;
+ goto out;
+ }
+
+ ret = 0;
+
+out:
+ return ret;
+}
+
int
glusterd_op_stage_quota (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
{
@@ -1792,19 +1880,29 @@ glusterd_op_stage_quota (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
}
switch (type) {
- case GF_QUOTA_OPTION_TYPE_ENABLE:
- case GF_QUOTA_OPTION_TYPE_ENABLE_OBJECTS:
case GF_QUOTA_OPTION_TYPE_LIST:
case GF_QUOTA_OPTION_TYPE_LIST_OBJECTS:
- /* Fuse mount req. only for enable & list-usage options*/
- if (is_origin_glusterd (dict) &&
- !glusterd_is_fuse_available ()) {
- *op_errstr = gf_strdup ("Fuse unavailable");
- ret = -1;
- goto out;
+ case GF_QUOTA_OPTION_TYPE_LIMIT_USAGE:
+ case GF_QUOTA_OPTION_TYPE_LIMIT_OBJECTS:
+ case GF_QUOTA_OPTION_TYPE_REMOVE:
+ case GF_QUOTA_OPTION_TYPE_REMOVE_OBJECTS:
+ /* Quota auxiliary mount is needed by CLI
+ * for list command and need by glusterd for
+ * setting/removing limit
+ */
+ if (is_origin_glusterd (dict)) {
+ ret = glusterd_create_quota_auxiliary_mount (this,
+ volname);
+ if (ret) {
+ *op_errstr = gf_strdup ("Failed to start aux "
+ "mount");
+ goto out;
+ }
}
break;
+ }
+ switch (type) {
case GF_QUOTA_OPTION_TYPE_LIMIT_USAGE:
ret = dict_get_str (dict, "hard-limit", &hard_limit_str);
if (ret) {