summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorSanoj Unnikrishnan <sunnikri@redhat.com>2017-03-22 15:02:12 +0530
committerjiffin tony Thottan <jthottan@redhat.com>2017-06-19 04:56:43 +0000
commit2dcb19813e7dbb2afd2f482ed9a3401371325b1d (patch)
tree5113a33acd4e603a44ffb1252b86d06871c568b8 /cli
parent5d13784dc6aa406f69061f2608a19ef0c8a80581 (diff)
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 <jenkins@build.gluster.org> > Smoke: Gluster Build System <jenkins@build.gluster.org> > Reviewed-by: Manikandan Selvaganesh <manikandancs333@gmail.com> > CentOS-regression: Gluster Build System <jenkins@build.gluster.org> > Reviewed-by: Raghavendra G <rgowdapp@redhat.com> > Reviewed-by: Atin Mukherjee <amukherj@redhat.com> > (cherry picked from commit 2ae4b4058691b324535d802f4e6d24cce89a10e5) Change-Id: I4f9e39da2ac2b65941399bffb6440db8a6ba59d0 BUG: 1449782 Signed-off-by: Sanoj Unnikrishnan <sunnikri@redhat.com> Reviewed-on: https://review.gluster.org/17242 Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-rpc-ops.c29
-rw-r--r--cli/src/cli.h7
2 files changed, 32 insertions, 4 deletions
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
@@ -3400,6 +3400,26 @@ out:
}
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,
int op_ret, int op_errno, char *op_errstr)
@@ -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;