summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gluster-block.c78
-rw-r--r--gluster-blockd.c23
-rw-r--r--rpc/block.h2
-rw-r--r--rpc/block.x2
-rw-r--r--rpc/block_xdr.c4
5 files changed, 79 insertions, 30 deletions
diff --git a/gluster-block.c b/gluster-block.c
index 1339ca9..23e98f9 100644
--- a/gluster-block.c
+++ b/gluster-block.c
@@ -98,8 +98,17 @@ switch(opt) {
clnt_perror (clnt, "call failed gluster-block");
}
break;
- case LIST_CLI:
case INFO_CLI:
+ *reply = block_info_cli_1((blockInfoCli *)cobj, clnt);
+ if (*reply == NULL) {
+ clnt_perror (clnt, "call failed gluster-block");
+ }
+ break;
+ case LIST_CLI:
+ *reply = block_list_cli_1((blockListCli *)cobj, clnt);
+ if (*reply == NULL) {
+ clnt_perror (clnt, "call failed gluster-block");
+ }
break;
}
printf("%s\n", (*reply)->out);
@@ -144,7 +153,7 @@ blockServerDefFree(blockServerDefPtr blkServers)
GB_FREE(blkServers);
}
-
+/*
static void
glusterBlockDefFree(glusterBlockDefPtr blk)
{
@@ -156,7 +165,7 @@ glusterBlockDefFree(glusterBlockDefPtr blk)
GB_FREE(blk->filename);
GB_FREE(blk);
}
-
+*/
static blockServerDefPtr
blockServerParse(char *blkServers)
@@ -254,7 +263,7 @@ glusterBlockCreateParseSize(char *value)
}
}
-
+/*
static char *
glusterBlockListGetHumanReadableSize(size_t bytes)
{
@@ -278,7 +287,7 @@ glusterBlockListGetHumanReadableSize(size_t bytes)
return NULL;
}
-
+*/
static int
glusterBlockCreate(int count, char **options, char *name)
@@ -485,7 +494,7 @@ glusterBlockCreate(int count, char **options, char *name)
return reply->exit;
}
-
+/*
static int
glusterBlockParseCfgStringToDef(char* cfgstring,
glusterBlockDefPtr blk)
@@ -493,7 +502,7 @@ glusterBlockParseCfgStringToDef(char* cfgstring,
int ret = 0;
char *p, *sep;
- /* part before '@' is the volume name */
+ // part before '@' is the volume name
p = cfgstring;
sep = strchr(p, '@');
if (!sep) {
@@ -507,7 +516,7 @@ glusterBlockParseCfgStringToDef(char* cfgstring,
goto fail;
}
- /* part between '@' and '/' is the server name */
+ // part between '@' and '/' is the server name
p = sep + 1;
sep = strchr(p, '/');
if (!sep) {
@@ -521,7 +530,7 @@ glusterBlockParseCfgStringToDef(char* cfgstring,
goto fail;
}
- /* part between '/' and '(' is the filename */
+ // part between '/' and '(' is the filename
p = sep + 1;
sep = strchr(p, '(');
if (!sep) {
@@ -529,13 +538,13 @@ glusterBlockParseCfgStringToDef(char* cfgstring,
goto fail;
}
- *(sep - 1) = '\0'; /* discard extra space at end of filename */
+ *(sep - 1) = '\0'; // discard extra space at end of filename
if (GB_STRDUP(blk->filename, p) < 0) {
ret = -1;
goto fail;
}
- /* part between '(' and ')' is the size */
+ // part between '(' and ')' is the size
p = sep + 1;
sep = strchr(p, ')');
if (!sep) {
@@ -552,7 +561,7 @@ glusterBlockParseCfgStringToDef(char* cfgstring,
}
- /* part between ')' and '\n' is the status */
+ // part between ')' and '\n' is the status
p = sep + 1;
sep = strchr(p, '\n');
if (!sep) {
@@ -571,8 +580,9 @@ glusterBlockParseCfgStringToDef(char* cfgstring,
return ret;
}
+*/
-
+/*
static char *
getCfgstring(char* name, char *blkServer)
{
@@ -598,21 +608,28 @@ getCfgstring(char* name, char *blkServer)
return buf;
}
-
+*/
/* TODO: need to implement sessions [ list | detail ] [sid] */
static int
-glusterBlockList(blockServerDefPtr blkServers)
+glusterBlockList(char *blkServers)
{
- size_t i;
+ /*size_t i;
int ret;
char *cmd;
char *pos;
char *size;
char *cfgstring = NULL;
- glusterBlockDefPtr blk = NULL;
+ glusterBlockDefPtr blk = NULL;*/
+
+ static blockListCli cobj;
blockResponse *reply = NULL;
+ GB_STRDUP(cobj.block_hosts, blkServers);
+
+ gluster_block_cli_1(&cobj, LIST_CLI, &reply);
+
+ /*
MSG("%s", "BlockName Volname Host Size Status");
asprintf(&cmd, "%s %s", TARGETCLI_GLFS, LUNS_LIST);
@@ -671,6 +688,8 @@ glusterBlockList(blockServerDefPtr blkServers)
GB_FREE(cmd);
return -1;
+ */
+ return 0;
}
@@ -760,18 +779,21 @@ glusterBlockDelete(char* name, char *blkServers)
static int
-glusterBlockInfo(char* name, blockServerDefPtr blkServers)
+glusterBlockInfo(char* name, char *blkServers)
{
- size_t i;
- int ret = 0;
- char *cmd;
- blockResponse *reply = NULL;
+ static blockInfoCli cobj;
+ blockResponse *reply;
+
+ strcpy(cobj.block_name, name);
+ GB_STRDUP(cobj.block_hosts, blkServers);
+
+ gluster_block_cli_1(&cobj, INFO_CLI, &reply);
- asprintf(&cmd, "%s/%s %s", TARGETCLI_GLFS, name, INFO);
+ /*asprintf(&cmd, "%s/%s %s", TARGETCLI_GLFS, name, INFO);
for (i = 0; i < blkServers->nhosts; i++) {
MSG("[OnHost: %s]", blkServers->hosts[i]);
- //gluster_block_1(blkServers->hosts[i], cmd, &reply);
+ gluster_block_1(blkServers->hosts[i], cmd, &reply);
if (!reply || reply->exit) {
ret = -1;
ERROR("%s on host: %s",
@@ -784,8 +806,8 @@ glusterBlockInfo(char* name, blockServerDefPtr blkServers)
fail:
GB_FREE(cmd);
-
- return ret;
+*/
+ return 0;
}
@@ -873,12 +895,12 @@ glusterBlockParseArgs(int count, char **options)
switch (optFlag) {
case 'l':
- ret = glusterBlockList(list);
+ ret = glusterBlockList(liststr);
if (ret)
ERROR("%s", FAILED_LIST);
break;
case 'i':
- ret = glusterBlockInfo(block, list);
+ ret = glusterBlockInfo(block, liststr);
if (ret)
ERROR("%s", FAILED_INFO);
break;
diff --git a/gluster-blockd.c b/gluster-blockd.c
index 8807b19..48786ca 100644
--- a/gluster-blockd.c
+++ b/gluster-blockd.c
@@ -469,15 +469,34 @@ block_exec_1_svc(char **cmd, struct svc_req *rqstp)
blockResponse *
block_list_cli_1_svc(blockListCli *blk, struct svc_req *rqstp)
{
+ char *cmd;
+ blockResponse *reply;
+ asprintf(&cmd, "%s %s", TARGETCLI_GLFS, LUNS_LIST);
- return NULL;
+ gluster_block_1(blk->block_hosts, cmd, EXEC_SRV, &reply);
+ if (!reply || reply->exit) {
+ ERROR("%s on host: %s",
+ FAILED_GATHERING_CFGSTR, blk->block_hosts);
+ }
+
+ return reply;
}
blockResponse *
block_info_cli_1_svc(blockInfoCli *blk, struct svc_req *rqstp)
{
+ char *cmd;
+ blockResponse *reply;
+ asprintf(&cmd, "%s/%s %s", TARGETCLI_GLFS, blk->block_name, INFO);
- return NULL;
+ //for
+ gluster_block_1(blk->block_hosts, cmd, EXEC_SRV, &reply);
+ if (!reply || reply->exit) {
+ ERROR("%s on host: %s",
+ FAILED_GATHERING_CFGSTR, blk->block_hosts);
+ }
+
+ return reply;
}
diff --git a/rpc/block.h b/rpc/block.h
index 0ce4e33..8cd38fb 100644
--- a/rpc/block.h
+++ b/rpc/block.h
@@ -48,12 +48,14 @@ typedef struct blockDelete blockDelete;
struct blockInfoCli {
char block_name[255];
char volume[255];
+ char *block_hosts;
};
typedef struct blockInfoCli blockInfoCli;
struct blockListCli {
char volume[255];
u_quad_t offset;
+ char *block_hosts;
};
typedef struct blockListCli blockListCli;
diff --git a/rpc/block.x b/rpc/block.x
index aebe451..b90aa45 100644
--- a/rpc/block.x
+++ b/rpc/block.x
@@ -27,11 +27,13 @@ struct blockDelete {
struct blockInfoCli {
char block_name[255];
char volume[255];
+ string block_hosts<>;
};
struct blockListCli {
char volume[255];
u_quad_t offset; /* dentry d_name offset */
+ string block_hosts<>;
};
struct blockResponse {
diff --git a/rpc/block_xdr.c b/rpc/block_xdr.c
index 1b9a4c6..c0a5666 100644
--- a/rpc/block_xdr.c
+++ b/rpc/block_xdr.c
@@ -76,6 +76,8 @@ xdr_blockInfoCli (XDR *xdrs, blockInfoCli *objp)
if (!xdr_vector (xdrs, (char *)objp->volume, 255,
sizeof (char), (xdrproc_t) xdr_char))
return FALSE;
+ if (!xdr_string (xdrs, &objp->block_hosts, ~0))
+ return FALSE;
return TRUE;
}
@@ -87,6 +89,8 @@ xdr_blockListCli (XDR *xdrs, blockListCli *objp)
return FALSE;
if (!xdr_u_quad_t (xdrs, &objp->offset))
return FALSE;
+ if (!xdr_string (xdrs, &objp->block_hosts, ~0))
+ return FALSE;
return TRUE;
}