summaryrefslogtreecommitdiffstats
path: root/cli/src
diff options
context:
space:
mode:
authorAtin Mukherjee <amukherj@redhat.com>2017-06-04 20:19:19 +0530
committerAtin Mukherjee <amukherj@redhat.com>2017-06-06 11:31:48 +0000
commit4dba0d5f8d9ac13504087f553d7c730060f0f9c7 (patch)
tree3d8e92cd6db648db0f5915f52de18d16d4961bd9 /cli/src
parent7b58ec260152bdcf840ac622dbb883ce8b593f63 (diff)
cli: add 'all' option in gluster v get cli usage
Change-Id: If216b13b7f9072f875eb2c5019d3b50b8bf3313e BUG: 1458582 Signed-off-by: Atin Mukherjee <amukherj@redhat.com> Reviewed-on: https://review.gluster.org/17460 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: Samikshan Bairagya <samikshan@gmail.com>
Diffstat (limited to 'cli/src')
-rw-r--r--cli/src/cli-cmd-volume.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index 41995791cdd..81b273e2777 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -3313,9 +3313,11 @@ struct cli_cmd volume_cmds[] = {
cli_cmd_volume_barrier_cbk,
"Barrier/unbarrier file operations on a volume"
},
- {"volume get <VOLNAME> <key|all>",
+ {"volume get <VOLNAME|all> <key|all>",
cli_cmd_volume_getopt_cbk,
"Get the value of the all options or given option for volume <VOLNAME>"
+ " or all option. gluster volume get all all is to get all global "
+ "options"
},
{"volume bitrot <VOLNAME> {enable|disable} |\n"
"volume bitrot <volname> scrub-throttle {lazy|normal|aggressive} |\n"
ss='graph'>
10 files changed, 295 insertions, 102 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index 797141decd1..891c1a97da5 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -56,7 +56,6 @@
#endif
extern glusterd_op_info_t opinfo;
-extern uuid_t global_txn_id;
int glusterd_big_locked_notify (struct rpc_clnt *rpc, void *mydata,
rpc_clnt_event_t event,
@@ -623,7 +622,6 @@ glusterd_op_txn_begin (rpcsvc_request_t *req, glusterd_op_t op, void *ctx,
gf_log (this->name, GF_LOG_ERROR,
"Failed to generate transaction id");
goto out;
-
}
/* Save the MY_UUID as the originator_uuid. This originator_uuid
@@ -684,7 +682,7 @@ local_locking_done:
/* If no volname is given as a part of the command, locks will
* not be held, hence sending stage event. */
- if (volname)
+ if (volname || (priv->op_version < GD_OP_VERSION_4))
event_type = GD_OP_EVENT_START_LOCK;
else {
txn_op_info.state.state = GD_OP_STATE_LOCK_SENT;
@@ -743,13 +741,18 @@ __glusterd_handle_cluster_lock (rpcsvc_request_t *req)
glusterd_op_t op = GD_OP_EVENT_LOCK;
glusterd_peerinfo_t *peerinfo = NULL;
glusterd_op_info_t txn_op_info = {{0},};
- uuid_t *txn_id = &global_txn_id;
+ glusterd_conf_t *priv = NULL;
+ uuid_t *txn_id = NULL;
xlator_t *this = NULL;
this = THIS;
GF_ASSERT (this);
+ priv = this->private;
+ GF_ASSERT (priv);
GF_ASSERT (req);
+ txn_id = &priv->global_txn_id;
+
ret = xdr_to_generic (req->msg[0], &lock_req,
(xdrproc_t)xdr_gd1_mgmt_cluster_lock_req);
if (ret < 0) {
@@ -1057,14 +1060,19 @@ __glusterd_handle_stage_op (rpcsvc_request_t *req)
gd1_mgmt_stage_op_req op_req = {{0},};
glusterd_peerinfo_t *peerinfo = NULL;
xlator_t *this = NULL;
- uuid_t *txn_id = &global_txn_id;
+ uuid_t *txn_id = NULL;
glusterd_op_info_t txn_op_info = {{0},};
glusterd_op_sm_state_info_t state = {0,};
+ glusterd_conf_t *priv = NULL;
this = THIS;
GF_ASSERT (this);
+ priv = this->private;
+ GF_ASSERT (priv);
GF_ASSERT (req);
+ txn_id = &priv->global_txn_id;
+
ret = xdr_to_generic (req->msg[0], &op_req,
(xdrproc_t)xdr_gd1_mgmt_stage_op_req);
if (ret < 0) {
@@ -1141,12 +1149,17 @@ __glusterd_handle_commit_op (rpcsvc_request_t *req)
gd1_mgmt_commit_op_req op_req = {{0},};
glusterd_peerinfo_t *peerinfo = NULL;
xlator_t *this = NULL;
- uuid_t *txn_id = &global_txn_id;
+ uuid_t *txn_id = NULL;
+ glusterd_conf_t *priv = NULL;
this = THIS;
GF_ASSERT (this);
+ priv = this->private;
+ GF_ASSERT (priv);
GF_ASSERT (req);
+ txn_id = &priv->global_txn_id;
+
ret = xdr_to_generic (req->msg[0], &op_req,
(xdrproc_t)xdr_gd1_mgmt_commit_op_req);
if (ret < 0) {
@@ -2285,12 +2298,17 @@ __glusterd_handle_cluster_unlock (rpcsvc_request_t *req)
glusterd_op_lock_ctx_t *ctx = NULL;
glusterd_peerinfo_t *peerinfo = NULL;
xlator_t *this = NULL;
- uuid_t *txn_id = &global_txn_id;
+ uuid_t *txn_id = NULL;
+ glusterd_conf_t *priv = NULL;
this = THIS;
GF_ASSERT (this);
+ priv = this->private;
+ GF_ASSERT (priv);
GF_ASSERT (req);
+ txn_id = &priv->global_txn_id;
+
ret = xdr_to_generic (req->msg[0], &unlock_req,
(xdrproc_t)xdr_gd1_mgmt_cluster_unlock_req);
if (ret < 0) {
diff --git a/xlators/mgmt/glusterd/src/glusterd-locks.c b/xlators/mgmt/glusterd/src/glusterd-locks.c
index 68c6d74264b..9e8bbc21b81 100644
--- a/xlators/mgmt/glusterd/src/glusterd-locks.c
+++ b/xlators/mgmt/glusterd/src/glusterd-locks.c
@@ -26,17 +26,22 @@
#include <signal.h>
-static dict_t *vol_lock;
-
/* Initialize the global vol-lock list(dict) when
* glusterd is spawned */
int32_t
glusterd_vol_lock_init ()
{
- int32_t ret = -1;
+ int32_t ret = -1;
+ xlator_t *this = NULL;
+ glusterd_conf_t *priv = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
+ priv = this->private;
+ GF_ASSERT (priv);
- vol_lock = dict_new ();
- if (!vol_lock)
+ priv->vol_lock = dict_new ();
+ if (!priv->vol_lock)
goto out;
ret = 0;
@@ -49,16 +54,31 @@ out:
void
glusterd_vol_lock_fini ()
{
- if (vol_lock)
- dict_unref (vol_lock);
+ xlator_t *this = NULL;
+ glusterd_conf_t *priv = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
+ priv = this->private;
+ GF_ASSERT (priv);
+
+ if (priv->vol_lock)
+ dict_unref (priv->vol_lock);
}
int32_t
glusterd_get_vol_lock_owner (char *volname, uuid_t *uuid)
{
- int32_t ret = -1;
- vol_lock_obj *lock_obj = NULL;
- uuid_t no_owner = {0,};
+ int32_t ret = -1;
+ glusterd_vol_lock_obj *lock_obj = NULL;
+ glusterd_conf_t *priv = NULL;
+ uuid_t no_owner = {0,};
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
+ priv = this->private;
+ GF_ASSERT (priv);
if (!volname || !uuid) {
gf_log ("", GF_LOG_ERROR, "volname or uuid is null.");
@@ -66,7 +86,7 @@ glusterd_get_vol_lock_owner (char *volname, uuid_t *uuid)
goto out;
}
- ret = dict_get_bin (vol_lock, volname, (void **) &lock_obj);
+ ret = dict_get_bin (priv->vol_lock, volname, (void **) &lock_obj);
if (!ret)
uuid_copy (*uuid, lock_obj->lock_owner);
else
@@ -81,9 +101,16 @@ out:
int32_t
glusterd_volume_lock (char *volname, uuid_t uuid)
{
- int32_t ret = -1;
- vol_lock_obj *lock_obj = NULL;
- uuid_t owner = {0};
+ int32_t ret = -1;
+ glusterd_vol_lock_obj *lock_obj = NULL;
+ glusterd_conf_t *priv = NULL;
+ uuid_t owner = {0};
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
+ priv = this->private;
+ GF_ASSERT (priv);
if (!volname) {
gf_log ("", GF_LOG_ERROR, "volname is null.");
@@ -93,21 +120,22 @@ glusterd_volume_lock (char *volname, uuid_t uuid)
ret = glusterd_get_vol_lock_owner (volname, &owner);
if (ret) {
- gf_log ("", GF_LOG_DEBUG, "Unable to get volume lock owner");
+ gf_log ("", GF_LOG_WARNING,
+ "Unable to get volume lock owner");
goto out;
}
/* If the lock has already been held for the given volume
* we fail */
if (!uuid_is_null (owner)) {
- gf_log ("", GF_LOG_ERROR, "Unable to acquire lock. "
+ gf_log ("", GF_LOG_WARNING, "Unable to acquire lock. "
"Lock for %s held by %s", volname,
uuid_utoa (owner));
ret = -1;
goto out;
}
- lock_obj = GF_CALLOC (1, sizeof(vol_lock_obj),
+ lock_obj = GF_CALLOC (1, sizeof(glusterd_vol_lock_obj),
gf_common_mt_vol_lock_obj_t);
if (!lock_obj) {
ret = -1;
@@ -116,7 +144,8 @@ glusterd_volume_lock (char *volname, uuid_t uuid)
uuid_copy (lock_obj->lock_owner, uuid);
- ret = dict_set_bin (vol_lock, volname, lock_obj, sizeof(vol_lock_obj));
+ ret = dict_set_bin (priv->vol_lock, volname, lock_obj,
+ sizeof(glusterd_vol_lock_obj));
if (ret) {
gf_log ("", GF_LOG_ERROR, "Unable to set lock owner "
"in volume lock");
@@ -137,8 +166,15 @@ out:
int32_t
glusterd_volume_unlock (char *volname, uuid_t uuid)
{
- int32_t ret = -1;
- uuid_t owner = {0};
+ int32_t ret = -1;
+ glusterd_conf_t *priv = NULL;
+ uuid_t owner = {0};
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
+ priv = this->private;
+ GF_ASSERT (priv);
if (!volname) {
gf_log ("", GF_LOG_ERROR, "volname is null.");
@@ -151,21 +187,21 @@ glusterd_volume_unlock (char *volname, uuid_t uuid)
goto out;
if (uuid_is_null (owner)) {
- gf_log ("", GF_LOG_ERROR, "Lock for %s not held", volname);
+ gf_log ("", GF_LOG_WARNING, "Lock for %s not held", volname);
ret = -1;
goto out;
}
ret = uuid_compare (uuid, owner);
if (ret) {
- gf_log (THIS->name, GF_LOG_ERROR, "Lock owner mismatch. "
+ gf_log (THIS->name, GF_LOG_WARNING, "Lock owner mismatch. "
"Lock for %s held by %s",
volname, uuid_utoa (owner));
goto out;
}
/* Removing the volume lock from the global list */
- dict_del (vol_lock, volname);
+ dict_del (priv->vol_lock, volname);
gf_log ("", GF_LOG_DEBUG, "Lock for %s successfully released",
volname);
diff --git a/xlators/mgmt/glusterd/src/glusterd-locks.h b/xlators/mgmt/glusterd/src/glusterd-locks.h
index 2a8cc20ed25..6e3f56f9cf9 100644
--- a/xlators/mgmt/glusterd/src/glusterd-locks.h
+++ b/xlators/mgmt/glusterd/src/glusterd-locks.h
@@ -15,10 +15,9 @@
#include "config.h"
#endif
-struct volume_lock_object_ {
+typedef struct glusterd_volume_lock_object_ {
uuid_t lock_owner;
-};
-typedef struct volume_lock_object_ vol_lock_obj;
+} glusterd_vol_lock_obj;
int32_t
glusterd_vol_lock_init ();
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 83c91a52d1d..385f14e9e7a 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -68,29 +68,27 @@
static struct list_head gd_op_sm_queue;
pthread_mutex_t gd_op_sm_lock;
glusterd_op_info_t opinfo = {{0},};
-uuid_t global_txn_id = {0}; /* To be used in
- * heterogeneous
- * cluster with no
- * transaction ids */
-
-static dict_t *txn_opinfo;
-
-struct glusterd_txn_opinfo_object_ {
- glusterd_op_info_t opinfo;
-};
-typedef struct glusterd_txn_opinfo_object_ glusterd_txn_opinfo_obj;
int32_t
glusterd_txn_opinfo_dict_init ()
{
- int32_t ret = -1;
+ int32_t ret = -1;
+ xlator_t *this = NULL;
+ glusterd_conf_t *priv = NULL;
- txn_opinfo = dict_new ();
- if (!txn_opinfo) {
+ this = THIS;
+ GF_ASSERT (this);
+ priv = this->private;
+ GF_ASSERT (priv);
+
+ priv->glusterd_txn_opinfo = dict_new ();
+ if (!priv->glusterd_txn_opinfo) {
ret = -1;
goto out;
}
+ memset (priv->global_txn_id, '\0', sizeof(uuid_t));
+
ret = 0;
out:
return ret;
@@ -99,8 +97,16 @@ out:
void
glusterd_txn_opinfo_dict_fini ()
{
- if (txn_opinfo)
- dict_destroy (txn_opinfo);
+ xlator_t *this = NULL;
+ glusterd_conf_t *priv = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
+ priv = this->private;
+ GF_ASSERT (priv);
+
+ if (priv->glusterd_txn_opinfo)
+ dict_unref (priv->glusterd_txn_opinfo);
}
void
@@ -118,7 +124,10 @@ glusterd_txn_opinfo_init (glusterd_op_info_t *opinfo,
if (op)
opinfo->op = *op;
- opinfo->op_ctx = dict_ref(op_ctx);
+ if (op_ctx)
+ opinfo->op_ctx = dict_ref(op_ctx);
+ else
+ opinfo->op_ctx = NULL;
if (req)
opinfo->req = req;
@@ -130,14 +139,23 @@ int32_t
glusterd_generate_txn_id (dict_t *dict, uuid_t **txn_id)
{
int32_t ret = -1;
+ glusterd_conf_t *priv = NULL;
+ xlator_t *this = NULL;
+ this = THIS;
+ GF_ASSERT (this);
+ priv = this->private;
+ GF_ASSERT (priv);
GF_ASSERT (dict);
*txn_id = GF_CALLOC (1, sizeof(uuid_t), gf_common_mt_uuid_t);
if (!*txn_id)
goto out;
- uuid_generate (**txn_id);
+ if (priv->op_version < GD_OP_VERSION_4)
+ uuid_copy (**txn_id, priv->global_txn_id);
+ else
+ uuid_generate (**txn_id);
ret = dict_set_bin (dict, "transaction_id",
*txn_id, sizeof (uuid_t));
@@ -150,8 +168,10 @@ glusterd_generate_txn_id (dict_t *dict, uuid_t **txn_id)
gf_log ("", GF_LOG_DEBUG,
"Transaction_id = %s", uuid_utoa (**txn_id));
out:
- if (ret && *txn_id)
+ if (ret && *txn_id) {
GF_FREE (*txn_id);
+ *txn_id = NULL;
+ }
return ret;
}
@@ -161,6 +181,13 @@ glusterd_get_txn_opinfo (uuid_t *txn_id, glusterd_op_info_t *opinfo)
{
int32_t ret = -1;
glusterd_txn_opinfo_obj *opinfo_obj = NULL;
+ glusterd_conf_t *priv = NULL;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
+ priv = this->private;
+ GF_ASSERT (priv);
if (!txn_id || !opinfo) {
gf_log ("", GF_LOG_ERROR,
@@ -169,16 +196,23 @@ glusterd_get_txn_opinfo (uuid_t *txn_id, glusterd_op_info_t *opinfo)
goto out;
}
- ret = dict_get_bin(txn_opinfo, uuid_utoa (*txn_id),
+ ret = dict_get_bin(priv->glusterd_txn_opinfo,
+ uuid_utoa (*txn_id),
(void **) &opinfo_obj);
if (ret) {
gf_log ("", GF_LOG_ERROR,
- "Unable to get transaction opinfo");
+ "Unable to get transaction opinfo "
+ "for transaction ID : %s",
+ uuid_utoa (*txn_id));
goto out;
}
(*opinfo) = opinfo_obj->opinfo;
+ gf_log ("", GF_LOG_DEBUG,
+ "Successfully got opinfo for transaction ID : %s",
+ uuid_utoa (*txn_id));
+
ret = 0;
out:
gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
@@ -190,6 +224,13 @@ glusterd_set_txn_opinfo (uuid_t *txn_id, glusterd_op_info_t *opinfo)
{
int32_t ret = -1;
glusterd_txn_opinfo_obj *opinfo_obj = NULL;
+ glusterd_conf_t *priv = NULL;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
+ priv = this->private;
+ GF_ASSERT (priv);
if (!txn_id) {
gf_log ("", GF_LOG_ERROR, "Empty transaction id received.");
@@ -197,7 +238,8 @@ glusterd_set_txn_opinfo (uuid_t *txn_id, glusterd_op_info_t *opinfo)
goto out;
}
- ret = dict_get_bin(txn_opinfo, uuid_utoa (*txn_id),
+ ret = dict_get_bin(priv->glusterd_txn_opinfo,
+ uuid_utoa (*txn_id),
(void **) &opinfo_obj);
if (ret) {
opinfo_obj = GF_CALLOC (1, sizeof(glusterd_txn_opinfo_obj),
@@ -207,7 +249,8 @@ glusterd_set_txn_opinfo (uuid_t *txn_id, glusterd_op_info_t *opinfo)
goto out;
}
- ret = dict_set_bin(txn_opinfo, uuid_utoa (*txn_id), opinfo_obj,
+ ret = dict_set_bin(priv->glusterd_txn_opinfo,
+ uuid_utoa (*txn_id), opinfo_obj,
sizeof(glusterd_txn_opinfo_obj));
if (ret) {
gf_log ("", GF_LOG_ERROR,
@@ -219,6 +262,9 @@ glusterd_set_txn_opinfo (uuid_t *txn_id, glusterd_op_info_t *opinfo)
opinfo_obj->opinfo = (*opinfo);
+ gf_log ("", GF_LOG_DEBUG,
+ "Successfully set opinfo for transaction ID : %s",
+ uuid_utoa (*txn_id));
ret = 0;
out:
if (ret)
@@ -234,6 +280,13 @@ glusterd_clear_txn_opinfo (uuid_t *txn_id)
{
int32_t ret = -1;
glusterd_op_info_t txn_op_info = {{0},};
+ glusterd_conf_t *priv = NULL;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
+ priv = this->private;
+ GF_ASSERT (priv);
if (!txn_id) {
gf_log ("", GF_LOG_ERROR, "Empty transaction id received.");
@@ -247,9 +300,14 @@ glusterd_clear_txn_opinfo (uuid_t *txn_id)
goto out;
}
- dict_unref (txn_op_info.op_ctx);
+ if (txn_op_info.op_ctx)
+ dict_unref (txn_op_info.op_ctx);
- dict_del(txn_opinfo, uuid_utoa (*txn_id));
+ dict_del(priv->glusterd_txn_opinfo, uuid_utoa (*txn_id));
+
+ gf_log ("", GF_LOG_DEBUG,
+ "Successfully cleared opinfo for transaction ID : %s",
+ uuid_utoa (*txn_id));
ret = 0;
out:
@@ -4293,7 +4351,7 @@ glusterd_op_ac_stage_op (glusterd_op_sm_event_t *event, void *ctx)
}
ret = dict_set_bin (rsp_dict, "transaction_id",
- txn_id, sizeof(uuid_t *));
+ txn_id, sizeof(uuid_t));
if (ret) {
gf_log (this->name, GF_LOG_ERROR,
"Failed to set transaction id.");
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.h b/xlators/mgmt/glusterd/src/glusterd-op-sm.h
index 53d4e2ff4b1..4a73b08f43a 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.h
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.h
@@ -172,6 +172,10 @@ typedef struct gsync_status_param {
glusterd_volinfo_t *volinfo;
}gsync_status_param_t;
+typedef struct glusterd_txn_opinfo_object_ {
+ glusterd_op_info_t opinfo;
+} glusterd_txn_opinfo_obj;
+
typedef enum cli_cmd_type_ {
PER_REPLICA,
ALL_REPLICA,
diff --git a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
index f26108f89c2..9685cb37461 100644
--- a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
+++ b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
@@ -1895,15 +1895,17 @@ glusterd_do_replace_brick (void *data)
glusterd_brickinfo_t *src_brickinfo = NULL;
glusterd_brickinfo_t *dst_brickinfo = NULL;
glusterd_conf_t *priv = NULL;
- uuid_t *txn_id = &global_txn_id;
+ uuid_t *txn_id = NULL;
int ret = 0;
dict = data;
GF_ASSERT (THIS);
-
priv = THIS->private;
+ GF_ASSERT (priv);
+
+ txn_id = &priv->global_txn_id;
if (priv->timer) {
gf_timer_call_cancel (THIS->ctx, priv->timer);
diff --git a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c
index 9af26cfab07..18f37c190fe 100644
--- a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c
+++ b/