summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorVijay Bellur <vijay@gluster.com>2010-09-02 04:02:52 +0000
committerVijay Bellur <vijay@dev.gluster.com>2010-09-02 03:28:42 -0700
commitfabe6417986dedd92adc2ac5d8d71cfd4dd918da (patch)
tree4c515d2c449fc6f5535033ac18047f0c66d7ff49 /xlators
parentea86a09143c5c59349ca82ddcbc2178a84cccde7 (diff)
mgmt/glusterd: support for GET_NEXT volume info
Signed-off-by: Vijay Bellur <vijay@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 1255 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1255
Diffstat (limited to 'xlators')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c45
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c13
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c6
3 files changed, 54 insertions, 10 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index 1c0d1ee6f..c55de40b1 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -2832,6 +2832,7 @@ glusterd_get_volumes (rpcsvc_request_t *req, dict_t *dict, int32_t flags)
int32_t count = 0;
dict_t *volumes = NULL;
gf1_cli_get_vol_rsp rsp = {0,};
+ char *volname = NULL;
priv = THIS->private;
GF_ASSERT (priv);
@@ -2848,21 +2849,53 @@ glusterd_get_volumes (rpcsvc_request_t *req, dict_t *dict, int32_t flags)
}
if (flags == GF_CLI_GET_VOLUME_ALL) {
- list_for_each_entry (entry, &priv->volumes, vol_list) {
- count++;
- ret = glusterd_add_volume_detail_to_dict (entry,
- volumes, count);
- if (ret)
- goto out;
+ list_for_each_entry (entry, &priv->volumes, vol_list) {
+ count++;
+ ret = glusterd_add_volume_detail_to_dict (entry,
+ volumes, count);
+ if (ret)
+ goto out;
+
+ }
+
+ ret = dict_set_int32 (volumes, "count", count);
+
+ if (ret)
+ goto out;
+ } else if (flags == GF_CLI_GET_NEXT_VOLUME) {
+ ret = dict_get_str (dict, "volname", &volname);
+ if (ret) {
+ if (priv->volumes.next) {
+ entry = list_entry (priv->volumes.next,
+ typeof (*entry),
+ vol_list);
}
+ } else {
+ ret = glusterd_volinfo_find (volname, &entry);
+ if (ret)
+ goto out;
+ entry = list_entry (entry->vol_list.next, typeof (*entry),
+ vol_list);
+ }
+ if (&entry->vol_list == &priv->volumes) {
ret = dict_set_int32 (volumes, "count", count);
+ } else {
+ count++;
+ ret = glusterd_add_volume_detail_to_dict (entry,
+ volumes, count);
+ if (ret)
+ goto out;
+ ret = dict_set_int32 (volumes, "count", count);
if (ret)
goto out;
+
+ }
}
+
ret = dict_allocate_and_serialize (volumes, &rsp.volumes.volumes_val,
(size_t *)&rsp.volumes.volumes_len);
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 59dae198c..b5cd26b8f 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -2936,6 +2936,10 @@ glusterd_op_txn_complete ()
int32_t ret = -1;
glusterd_conf_t *priv = NULL;
int32_t op = -1;
+ int32_t op_ret = 0;
+ int32_t op_errno = 0;
+ int32_t cli_op = 0;
+ rpcsvc_request_t *req = NULL;
priv = THIS->private;
GF_ASSERT (priv);
@@ -2950,8 +2954,11 @@ glusterd_op_txn_complete ()
gf_log ("glusterd", GF_LOG_NORMAL, "Cleared local lock");
- ret = glusterd_op_send_cli_response (opinfo.cli_op, opinfo.op_ret,
- opinfo.op_errno, opinfo.req);
+ op_ret = opinfo.op_ret;
+ op_errno = opinfo.op_errno;
+ cli_op = opinfo.cli_op;
+ req = opinfo.req;
+
opinfo.op_ret = 0;
opinfo.op_errno = 0;
@@ -2968,6 +2975,8 @@ glusterd_op_txn_complete ()
out:
pthread_mutex_unlock (&opinfo.lock);
+ ret = glusterd_op_send_cli_response (cli_op, op_ret,
+ op_errno, req);
gf_log ("glusterd", GF_LOG_NORMAL, "Returning %d", ret);
return ret;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index 5f65cf1cf..f3ef79cea 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -716,8 +716,8 @@ glusterd_store_iter_new (glusterd_store_handle_t *shandle,
fd = open (shandle->path, O_RDWR);
if (fd < 0) {
- gf_log ("", GF_LOG_ERROR, "Unable to open %s",
- shandle->path);
+ gf_log ("", GF_LOG_ERROR, "Unable to open %s, errno: %d",
+ shandle->path, errno);
goto out;
}
@@ -885,6 +885,8 @@ glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo)
}
out:
+ if (dir)
+ closedir (dir);
gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
return ret;