diff options
author | Krutika Dhananjay <kdhananj@redhat.com> | 2013-07-17 18:29:43 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2013-08-08 11:43:07 +0530 |
commit | 82890b0a753af50eb64271ba633e8da5527eb097 (patch) | |
tree | 5c673de50f29d39b48e9e9b1b897ef0ec9e3d812 | |
parent | d7b3ab5b5d17427bef5012ab72086e2b44ba1364 (diff) |
glusterd, cli: Provide status of quotad in 'volume status'
Change-Id: I5e90376ecfe11ae5a3bca936d9d9acdd54c337d7
BUG: 969461
Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com>
-rw-r--r-- | cli/src/cli-cmd-parser.c | 13 | ||||
-rw-r--r-- | cli/src/cli-cmd-volume.c | 2 | ||||
-rw-r--r-- | cli/src/cli-rpc-ops.c | 6 | ||||
-rw-r--r-- | glusterfsd/src/glusterfsd-mgmt.c | 5 | ||||
-rw-r--r-- | rpc/xdr/src/cli1-xdr.h | 1 | ||||
-rw-r--r-- | rpc/xdr/src/cli1-xdr.x | 25 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-handler.c | 11 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-op-sm.c | 74 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-rpc-ops.c | 3 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-syncop.c | 4 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 7 |
11 files changed, 117 insertions, 34 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index 78f680da..98ed0fdd 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -2263,6 +2263,8 @@ cli_cmd_volume_status_parse (const char **words, int wordcount, cmd |= GF_CLI_STATUS_NFS; } else if (!strcmp (words[3], "shd")) { cmd |= GF_CLI_STATUS_SHD; + } else if (!strcmp (words[3], "quotad")) { + cmd |= GF_CLI_STATUS_QUOTAD; } else { cmd = GF_CLI_STATUS_BRICK; ret = dict_set_str (dict, "brick", @@ -2316,6 +2318,17 @@ cli_cmd_volume_status_parse (const char **words, int wordcount, goto out; } cmd |= GF_CLI_STATUS_SHD; + } else if (!strcmp (words[3], "quotad")) { + if (cmd == GF_CLI_STATUS_FD || + cmd == GF_CLI_STATUS_CLIENTS || + cmd == GF_CLI_STATUS_DETAIL || + cmd == GF_CLI_STATUS_INODE) { + cli_err ("Detail/FD/Clients/Inode status not " + "available for Quota Daemon"); + ret = -1; + goto out; + } + cmd |= GF_CLI_STATUS_QUOTAD; } else { cmd |= GF_CLI_STATUS_BRICK; ret = dict_set_str (dict, "brick", (char *)words[3]); diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index 6465d577..f10df335 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -1908,7 +1908,7 @@ struct cli_cmd volume_cmds[] = { cli_cmd_volume_top_cbk, "volume top operations"}, - { "volume status [all | <VOLNAME> [nfs|shd|<BRICK>]]" + { "volume status [all | <VOLNAME> [nfs|shd|<BRICK>|quotad]]" " [detail|clients|mem|inode|fd|callpool]", cli_cmd_volume_status_cbk, "display status of all or specified volume(s)/brick"}, diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 05f2e957..008b74c4 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -5987,7 +5987,8 @@ gf_cli_status_cbk (struct rpc_req *req, struct iovec *iov, goto out; } - if ((cmd & GF_CLI_STATUS_NFS) || (cmd & GF_CLI_STATUS_SHD)) + if ((cmd & GF_CLI_STATUS_NFS) || (cmd & GF_CLI_STATUS_SHD) || + (cmd & GF_CLI_STATUS_QUOTAD)) notbrick = _gf_true; ret = dict_get_int32 (dict, "count", &count); @@ -6094,7 +6095,8 @@ gf_cli_status_cbk (struct rpc_req *req, struct iovec *iov, */ memset (status.brick, 0, PATH_MAX + 255); if (!strcmp (hostname, "NFS Server") || - !strcmp (hostname, "Self-heal Daemon")) + !strcmp (hostname, "Self-heal Daemon") || + !strcmp (hostname, "Quota Daemon")) snprintf (status.brick, PATH_MAX + 255, "%s on %s", hostname, path); else diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c index e26bf5a2..967a01bd 100644 --- a/glusterfsd/src/glusterfsd-mgmt.c +++ b/glusterfsd/src/glusterfsd-mgmt.c @@ -912,6 +912,9 @@ glusterfs_handle_node_status (rpcsvc_request_t *req) ret = gf_asprintf (&node_name, "%s", "nfs-server"); else if ((cmd & GF_CLI_STATUS_SHD) != 0) ret = gf_asprintf (&node_name, "%s", "glustershd"); + else if ((cmd & GF_CLI_STATUS_QUOTAD) != 0) + ret = gf_asprintf (&node_name, "%s", "quotad"); + else { ret = -1; goto out; @@ -934,6 +937,8 @@ glusterfs_handle_node_status (rpcsvc_request_t *req) ret = gf_asprintf (&subvol_name, "%s", volname); else if ((cmd & GF_CLI_STATUS_SHD) != 0) ret = gf_asprintf (&subvol_name, "%s-replicate-0", volname); + else if ((cmd & GF_CLI_STATUS_QUOTAD) != 0) + ret = gf_asprintf (&subvol_name, "%s", volname); else { ret = -1; goto out; diff --git a/rpc/xdr/src/cli1-xdr.h b/rpc/xdr/src/cli1-xdr.h index edbfddba..476ba594 100644 --- a/rpc/xdr/src/cli1-xdr.h +++ b/rpc/xdr/src/cli1-xdr.h @@ -164,6 +164,7 @@ enum gf_cli_status_type { GF_CLI_STATUS_BRICK = 0x0400, GF_CLI_STATUS_NFS = 0x0800, GF_CLI_STATUS_SHD = 0x1000, + GF_CLI_STATUS_QUOTAD = 0x2000, }; typedef enum gf_cli_status_type gf_cli_status_type; diff --git a/rpc/xdr/src/cli1-xdr.x b/rpc/xdr/src/cli1-xdr.x index 1585fb86..e58329a3 100644 --- a/rpc/xdr/src/cli1-xdr.x +++ b/rpc/xdr/src/cli1-xdr.x @@ -105,18 +105,19 @@ enum gf1_cli_top_op { bit-wise operations which reduces complexity */ enum gf_cli_status_type { GF_CLI_STATUS_NONE = 0x0000, - GF_CLI_STATUS_MEM = 0x0001, /*0000000000001*/ - GF_CLI_STATUS_CLIENTS = 0x0002, /*0000000000010*/ - GF_CLI_STATUS_INODE = 0x0004, /*0000000000100*/ - GF_CLI_STATUS_FD = 0x0008, /*0000000001000*/ - GF_CLI_STATUS_CALLPOOL = 0x0010, /*0000000010000*/ - GF_CLI_STATUS_DETAIL = 0x0020, /*0000000100000*/ - GF_CLI_STATUS_MASK = 0x00FF, /*0000011111111 Used to get the op*/ - GF_CLI_STATUS_VOL = 0x0100, /*0000100000000*/ - GF_CLI_STATUS_ALL = 0x0200, /*0001000000000*/ - GF_CLI_STATUS_BRICK = 0x0400, /*0010000000000*/ - GF_CLI_STATUS_NFS = 0x0800, /*0100000000000*/ - GF_CLI_STATUS_SHD = 0x1000 /*1000000000000*/ + GF_CLI_STATUS_MEM = 0x0001, /*00000000000001*/ + GF_CLI_STATUS_CLIENTS = 0x0002, /*00000000000010*/ + GF_CLI_STATUS_INODE = 0x0004, /*00000000000100*/ + GF_CLI_STATUS_FD = 0x0008, /*00000000001000*/ + GF_CLI_STATUS_CALLPOOL = 0x0010, /*00000000010000*/ + GF_CLI_STATUS_DETAIL = 0x0020, /*00000000100000*/ + GF_CLI_STATUS_MASK = 0x00FF, /*00000011111111 Used to get the op*/ + GF_CLI_STATUS_VOL = 0x0100, /*00000100000000*/ + GF_CLI_STATUS_ALL = 0x0200, /*00001000000000*/ + GF_CLI_STATUS_BRICK = 0x0400, /*00010000000000*/ + GF_CLI_STATUS_NFS = 0x0800, /*00100000000000*/ + GF_CLI_STATUS_SHD = 0x1000, /*01000000000000*/ + GF_CLI_STATUS_QUOTAD = 0x2000 /*10000000000000*/ }; struct gf_cli_req { diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c index fbc48001..274ea09f 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-handler.c @@ -3450,10 +3450,13 @@ __glusterd_handle_status_volume (rpcsvc_request_t *req) glusterd_op_t cli_op = GD_OP_STATUS_VOLUME; char err_str[2048] = {0,}; xlator_t *this = NULL; + glusterd_conf_t *conf = NULL; GF_ASSERT (req); this = THIS; GF_ASSERT (this); + conf = this->private; + GF_ASSERT (conf); ret = xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf_cli_req); if (ret < 0) { @@ -3494,6 +3497,14 @@ __glusterd_handle_status_volume (rpcsvc_request_t *req) "Received status volume req for volume %s", volname); } + if ((cmd & GF_CLI_STATUS_QUOTAD) && + (conf->op_version == GD_OP_VERSION_MIN)) { + snprintf (err_str, sizeof (err_str), "The cluster is operating " + "at version 1. Getting the status of quotad is not " + "allowed in this state."); + ret = -1; + goto out; + } ret = glusterd_op_begin_synctask (req, GD_OP_STATUS_VOLUME, dict); diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index fb8d1f17..4b66ca3b 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -901,18 +901,24 @@ glusterd_op_stage_status_volume (dict_t *dict, char **op_errstr) if (cmd & GF_CLI_STATUS_ALL) goto out; + if ((cmd & GF_CLI_STATUS_QUOTAD) && + (priv->op_version == GD_OP_VERSION_MIN)) { + snprintf (msg, sizeof (msg), "The cluster is operating at " + "version 1. Getting the status of quotad is not " + "allowed in this state."); + ret = -1; + goto out; + } + ret = dict_get_str (dict, "volname", &volname); if (ret) { - gf_log (THIS->name, GF_LOG_ERROR, - "Unable to get volume name"); + gf_log (this->name, GF_LOG_ERROR, "Unable to get volume name"); goto out; } ret = glusterd_volinfo_find (volname, &volinfo); if (ret) { - snprintf (msg, sizeof(msg), "Volume %s does not exist", - volname); - gf_log (THIS->name, GF_LOG_ERROR, "%s", msg); + snprintf (msg, sizeof(msg), FMTSTR_CHECK_VOL_EXISTS, volname); ret = -1; goto out; } @@ -925,7 +931,6 @@ glusterd_op_stage_status_volume (dict_t *dict, char **op_errstr) if (!ret) { snprintf (msg, sizeof (msg), "Volume %s is not started", volname); - gf_log (THIS->name, GF_LOG_ERROR, "%s", msg); ret = -1; goto out; } @@ -940,7 +945,6 @@ glusterd_op_stage_status_volume (dict_t *dict, char **op_errstr) snprintf (msg, sizeof (msg), "NFS server is disabled for volume %s", volname); - gf_log (THIS->name, GF_LOG_ERROR, "%s", msg); goto out; } } else if ((cmd & GF_CLI_STATUS_SHD) != 0) { @@ -949,7 +953,6 @@ glusterd_op_stage_status_volume (dict_t *dict, char **op_errstr) snprintf (msg, sizeof (msg), "Volume %s is not of type replicate", volname); - gf_log (THIS->name, GF_LOG_ERROR, "%s", msg); goto out; } @@ -961,10 +964,15 @@ glusterd_op_stage_status_volume (dict_t *dict, char **op_errstr) snprintf (msg, sizeof (msg), "Self-heal Daemon is disabled for volume %s", volname); - gf_log (THIS->name, GF_LOG_ERROR, "%s", msg); goto out; } - + } else if ((cmd & GF_CLI_STATUS_QUOTAD) != 0) { + if (!glusterd_is_volume_quota_enabled (volinfo)) { + ret = -1; + snprintf (msg, sizeof (msg), "Volume %s does not have " + "quota enabled", volname); + goto out; + } } else if ((cmd & GF_CLI_STATUS_BRICK) != 0) { ret = dict_get_str (dict, "brick", &brick); if (ret) @@ -975,8 +983,6 @@ glusterd_op_stage_status_volume (dict_t *dict, char **op_errstr) if (ret) { snprintf (msg, sizeof(msg), "No brick %s in" " volume %s", brick, volname); - gf_log (THIS->name, GF_LOG_ERROR, "%s", msg); - ret = -1; goto out; } @@ -992,7 +998,7 @@ glusterd_op_stage_status_volume (dict_t *dict, char **op_errstr) *op_errstr = gf_strdup ("Validation Failed for Status"); } - gf_log (THIS->name, GF_LOG_DEBUG, "Returning: %d", ret); + gf_log (this->name, GF_LOG_DEBUG, "Returning: %d", ret); return ret; } @@ -2055,6 +2061,14 @@ glusterd_op_status_volume (dict_t *dict, char **op_errstr, other_count++; node_count++; + } else if ((cmd & GF_CLI_STATUS_QUOTAD) != 0) { + ret = glusterd_add_node_to_dict ("quotad", rsp_dict, 0, + vol_opts); + if (ret) + goto out; + other_count++; + node_count++; + } else if ((cmd & GF_CLI_STATUS_BRICK) != 0) { ret = dict_get_str (dict, "brick", &brick); if (ret) @@ -2126,6 +2140,17 @@ glusterd_op_status_volume (dict_t *dict, char **op_errstr, goto out; other_count++; node_count++; + other_index++; + } + if (glusterd_is_volume_quota_enabled (volinfo)) { + ret = glusterd_add_node_to_dict ("quotad", + rsp_dict, + other_index, + vol_opts); + if (ret) + goto out; + other_count++; + node_count++; } } } @@ -4541,9 +4566,6 @@ out: return ret; } - - - static int glusterd_bricks_select_status_volume (dict_t *dict, char **op_errstr, struct list_head *selected) @@ -4583,6 +4605,7 @@ glusterd_bricks_select_status_volume (dict_t *dict, char **op_errstr, case GF_CLI_STATUS_CALLPOOL: case GF_CLI_STATUS_NFS: case GF_CLI_STATUS_SHD: + case GF_CLI_STATUS_QUOTAD: break; default: goto out; @@ -4664,6 +4687,25 @@ glusterd_bricks_select_status_volume (dict_t *dict, char **op_errstr, list_add_tail (&pending_node->list, selected); ret = 0; + } else if ((cmd & GF_CLI_STATUS_QUOTAD) != 0) { + if (!glusterd_is_nodesvc_online ("quotad")) { + gf_log (this->name, GF_LOG_ERROR, "Quotad is not " + "running"); + ret = -1; + goto out; + } + pending_node = GF_CALLOC (1, sizeof (*pending_node), + gf_gld_mt_pending_node_t); + if (!pending_node) { + ret = -1; + goto out; + } + pending_node->node = priv->quotad; + pending_node->type = GD_NODE_QUOTAD; + pending_node->index = 0; + list_add_tail (&pending_node->list, selected); + + ret = 0; } else { list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) { brick_index++; diff --git a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c index 18a74349..38231b11 100644 --- a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c @@ -1506,8 +1506,9 @@ glusterd_brick_op (call_frame_t *frame, xlator_t *this, continue; if ((pending_node->type == GD_NODE_NFS) || + (pending_node->type == GD_NODE_QUOTAD) || ((pending_node->type == GD_NODE_SHD) && - (req_ctx->op == GD_OP_STATUS_VOLUME))) + (req_ctx->op == GD_OP_STATUS_VOLUME))) ret = glusterd_node_op_build_payload (req_ctx->op, (gd1_mgmt_brick_op_req **)&req, diff --git a/xlators/mgmt/glusterd/src/glusterd-syncop.c b/xlators/mgmt/glusterd/src/glusterd-syncop.c index 7b0c28ba..af299afa 100644 --- a/xlators/mgmt/glusterd/src/glusterd-syncop.c +++ b/xlators/mgmt/glusterd/src/glusterd-syncop.c @@ -538,8 +538,8 @@ gd_syncop_mgmt_brick_op (struct rpc_clnt *rpc, glusterd_pending_node_t *pnode, args.op_errno = ENOTCONN; if ((pnode->type == GD_NODE_NFS) || - ((pnode->type == GD_NODE_SHD) && - (op == GD_OP_STATUS_VOLUME))) { + (pnode->type == GD_NODE_QUOTAD) || + ((pnode->type == GD_NODE_SHD) && (op == GD_OP_STATUS_VOLUME))) { ret = glusterd_node_op_build_payload (op, &req, dict_out); diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 023568f6..5b69316b 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -3232,6 +3232,7 @@ glusterd_pending_node_get_rpc (glusterd_pending_node_t *pending_node) nodesrv_t *shd = NULL; glusterd_volinfo_t *volinfo = NULL; nodesrv_t *nfs = NULL; + nodesrv_t *quotad = NULL; GF_VALIDATE_OR_GOTO (THIS->name, pending_node, out); GF_VALIDATE_OR_GOTO (THIS->name, pending_node->node, out); @@ -3253,6 +3254,10 @@ glusterd_pending_node_get_rpc (glusterd_pending_node_t *pending_node) nfs = pending_node->node; rpc = nfs->rpc; + } else if (pending_node->type == GD_NODE_QUOTAD) { + quotad = pending_node->node; + rpc = quotad->rpc; + } else { GF_ASSERT (0); } @@ -3623,6 +3628,8 @@ glusterd_add_node_to_dict (char *server, dict_t *dict, int count, ret = dict_set_str (dict, key, "NFS Server"); else if (!strcmp (server, "glustershd")) ret = dict_set_str (dict, key, "Self-heal Daemon"); + else if (!strcmp (server, "quotad")) + ret = dict_set_str (dict, key, "Quota Daemon"); if (ret) goto out; |