summaryrefslogtreecommitdiffstats
path: root/cli/src/cli-rpc-ops.c
diff options
context:
space:
mode:
authorKrutika Dhananjay <kdhananj@redhat.com>2013-07-31 13:19:19 +0530
committerKrishnan Parthasarathi <kparthas@redhat.com>2013-08-12 00:48:15 +0530
commitcadba04360c88c87dc6ffdf8e15ec70e81a943c8 (patch)
tree447afeeca763c81bd8b29777157e4fde58ffb80d /cli/src/cli-rpc-ops.c
parent2da625ddd39ea3818da60c625cd578cb65c904aa (diff)
glusterd: club limit-usage and soft-limit into a single command
Change-Id: I5f680675576aeec584b497eb25dd804a9dd6d690 Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com>
Diffstat (limited to 'cli/src/cli-rpc-ops.c')
-rw-r--r--cli/src/cli-rpc-ops.c85
1 files changed, 76 insertions, 9 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index 49949f54..cd1e0047 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -2570,6 +2570,60 @@ out:
return ret;
}
+static int
+gf_cli_create_auxiliary_mount (char *volname)
+{
+ int ret = -1;
+ char mountdir[PATH_MAX] = {0,};
+
+ snprintf (mountdir, sizeof (mountdir)-1, "/tmp/%s", volname);
+ ret = mkdir (mountdir, 0777);
+ if (ret && errno != EEXIST)
+ goto out;
+
+ ret = runcmd (SBIN_DIR"/glusterfs", "-s",
+ "localhost", "--volfile-id", volname, "-l",
+ DEFAULT_LOG_FILE_DIRECTORY"/quota-enable.log",
+ mountdir, "--client-pid", "-42", NULL);
+ if (ret) {
+ gf_log ("cli", GF_LOG_WARNING, "failed to mount glusterfs "
+ "client");
+ ret = -1;
+ goto out;
+ }
+ ret = 0;
+
+out:
+ return ret;
+}
+
+static int
+gf_cli_remove_auxiliary_mount (char *volname)
+{
+ int ret = -1;
+ runner_t runner = {0,};
+ char mountdir [PATH_MAX] = {0,};
+
+ snprintf (mountdir, sizeof (mountdir)-1, "/tmp/%s", volname);
+
+ runinit (&runner);
+ runner_add_args (&runner, "umount",
+
+#if GF_LINUX_HOST_OS
+ "-l",
+#endif
+ mountdir, NULL);
+ ret = runner_run_reuse (&runner);
+ if (ret)
+ gf_log ("cli", GF_LOG_WARNING, "umount on %s failed, "
+ "reason : %s", mountdir, strerror (errno));
+ runner_end (&runner);
+
+ rmdir (mountdir);
+ return ret;
+
+}
+
int
gf_cli_quota_list_run_crawler (char *volname, char *limit_list, dict_t *dict,
int count, char *op_errstr, uint32_t op_version,
@@ -2723,7 +2777,17 @@ gf_cli_quota_cbk (struct rpc_req *req, struct iovec *iov,
gf_log (frame->this->name, GF_LOG_TRACE, "failed to get entry "
"count");
- if (type == GF_QUOTA_OPTION_TYPE_LIST) {
+ if (type == GF_QUOTA_OPTION_TYPE_ENABLE) {
+ ret = gf_cli_create_auxiliary_mount (volname);
+ if (ret)
+ goto out;
+
+ } else if (type == GF_QUOTA_OPTION_TYPE_DISABLE) {
+ ret = gf_cli_remove_auxiliary_mount (volname);
+ if (ret)
+ goto out;
+
+ } else if (type == GF_QUOTA_OPTION_TYPE_LIST) {
if (global_state->mode & GLUSTER_MODE_XML) {
ret = cli_xml_output_vol_quota_limit_list
(volname, limit_list, rsp.op_ret,
@@ -2732,22 +2796,25 @@ gf_cli_quota_cbk (struct rpc_req *req, struct iovec *iov,
gf_log ("cli", GF_LOG_ERROR,
"Error outputting to xml");
goto out;
-
}
- gf_log ("cli", GF_LOG_INFO, "Received resp to quota command");
-
gf_cli_quota_list_run_crawler (volname, limit_list, dict, count,
rsp.op_errstr, op_version,
default_sl, entry_count);
if (rsp.op_errstr)
- snprintf (msg, sizeof (msg), "%s", rsp.op_errstr);
+ snprintf (msg, sizeof (msg)-1, "%s", rsp.op_errstr);
+ }
+
+ gf_log ("cli", GF_LOG_DEBUG, "Received resp to quota command");
+
+ if (rsp.op_errstr) {
+ snprintf (msg, sizeof (msg)-1, "%s", rsp.op_errstr);
} else {
- gf_log ("cli", GF_LOG_INFO, "Received resp to quota command");
- if (rsp.op_errstr)
- snprintf (msg, sizeof (msg), "%s", rsp.op_errstr);
+ if (!rsp.op_ret)
+ snprintf (msg, sizeof (msg)-1, "Quota command "
+ "successful");
else
- snprintf (msg, sizeof (msg), "successful");
+ snprintf (msg, sizeof (msg)-1, "Quota command failed");
}
xml_output: