summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--glfs-operations.c4
-rw-r--r--glfs-operations.h2
-rw-r--r--gluster-block.c65
-rw-r--r--gluster-blockd.c386
-rw-r--r--rpc/block.h62
-rw-r--r--rpc/block.x26
-rw-r--r--rpc/block_clnt.c75
-rw-r--r--rpc/block_svc.c35
-rw-r--r--rpc/block_xdr.c46
9 files changed, 645 insertions, 56 deletions
diff --git a/glfs-operations.c b/glfs-operations.c
index fecc315..7f76b23 100644
--- a/glfs-operations.c
+++ b/glfs-operations.c
@@ -74,7 +74,7 @@ glusterBlockCreateEntry(blockCreateCli *blk, char *gbid)
int
-glusterBlockDeleteEntry(blockCreateCli *blk, char *gbid)
+glusterBlockDeleteEntry(blockCreate *blk)
{
struct glfs *glfs;
int ret = 0;
@@ -103,7 +103,7 @@ glusterBlockDeleteEntry(blockCreateCli *blk, char *gbid)
goto out;
}
- ret = glfs_unlink(glfs, gbid);
+ ret = glfs_unlink(glfs, blk->gbid);
if (ret) {
ERROR("%s", "glfs_unlink: failed");
goto out;
diff --git a/glfs-operations.h b/glfs-operations.h
index 1a1208d..ceadcd7 100644
--- a/glfs-operations.h
+++ b/glfs-operations.h
@@ -35,6 +35,6 @@ typedef glusterBlockDef *glusterBlockDefPtr;
int glusterBlockCreateEntry(blockCreateCli *blk, char *gbid);
-int glusterBlockDeleteEntry(blockCreateCli *blk, char *gbid);
+int glusterBlockDeleteEntry(blockCreate *blk);
#endif /* _GLFS_OPERATIONS_H */
diff --git a/gluster-block.c b/gluster-block.c
index e6dc0fc..1339ca9 100644
--- a/gluster-block.c
+++ b/gluster-block.c
@@ -44,7 +44,12 @@
# define MSERVER_DELIMITER ","
-
+typedef enum opterations {
+ CREATE_CLI = 1,
+ LIST_CLI = 2,
+ INFO_CLI = 3,
+ DELETE_CLI = 4
+} opterations;
typedef struct blockServerDef {
size_t nhosts;
@@ -54,7 +59,7 @@ typedef blockServerDef *blockServerDefPtr;
static void
-gluster_block_cli_1(blockCreateCli cobj, blockResponse **reply)
+gluster_block_cli_1(void *cobj, opterations opt, blockResponse **reply)
{
CLIENT *clnt;
int sockfd, len;
@@ -80,12 +85,23 @@ gluster_block_cli_1(blockCreateCli cobj, blockResponse **reply)
clnt_pcreateerror ("localhost");
exit (1);
}
-
- *reply = block_create_cli_1(&cobj, clnt);
- if (*reply == NULL) {
- clnt_perror (clnt, "call failed gluster-block");
- }
-
+switch(opt) {
+ case CREATE_CLI:
+ *reply = block_create_cli_1((blockCreateCli *)cobj, clnt);
+ if (*reply == NULL) {
+ clnt_perror (clnt, "call failed gluster-block");
+ }
+ break;
+ case DELETE_CLI:
+ *reply = block_delete_cli_1((blockDeleteCli *)cobj, clnt);
+ if (*reply == NULL) {
+ clnt_perror (clnt, "call failed gluster-block");
+ }
+ break;
+ case LIST_CLI:
+ case INFO_CLI:
+ break;
+}
printf("%s\n", (*reply)->out);
clnt_destroy (clnt);
@@ -379,7 +395,7 @@ glusterBlockCreate(int count, char **options, char *name)
goto out;
}
- gluster_block_cli_1(cobj, &reply);
+ gluster_block_cli_1(&cobj, CREATE_CLI, &reply);
@@ -466,7 +482,7 @@ glusterBlockCreate(int count, char **options, char *name)
*/
out:
- return 0;
+ return reply->exit;
}
@@ -659,16 +675,17 @@ glusterBlockList(blockServerDefPtr blkServers)
static int
-glusterBlockDelete(char* name, blockServerDefPtr blkServers)
+glusterBlockDelete(char* name, char *blkServers)
{
- size_t i;
- int ret;
- char *cmd;
- char *exec = NULL;
- char *cfgstring = NULL;
- char *iqn = NULL;
- glusterBlockDefPtr blk = NULL;
- blockResponse *reply = NULL;
+ static blockDeleteCli cobj;
+ blockResponse *reply;
+
+ strcpy(cobj.block_name, name);
+ GB_STRDUP(cobj.block_hosts, blkServers);
+
+ gluster_block_cli_1(&cobj, DELETE_CLI, &reply);
+
+ /*
asprintf(&cmd, "%s %s %s", TARGETCLI_GLFS, DELETE, name);
@@ -691,7 +708,6 @@ glusterBlockDelete(char* name, blockServerDefPtr blkServers)
goto fail;
}
MSG("%s", reply->out);
- /* cfgstring is constant across all tcmu nodes */
if (!blk) {
if (GB_ALLOC(blk) < 0)
goto fail;
@@ -738,8 +754,8 @@ glusterBlockDelete(char* name, blockServerDefPtr blkServers)
GB_FREE(cfgstring);
GB_FREE(exec);
GB_FREE(cmd);
-
- return ret;
+*/
+ return reply->exit;
}
@@ -782,6 +798,7 @@ glusterBlockParseArgs(int count, char **options)
char *block = NULL;
char *blkServers = NULL;
blockServerDefPtr list = NULL;
+ char *liststr;
while (1) {
static const struct option long_options[] = {
@@ -848,8 +865,10 @@ glusterBlockParseArgs(int count, char **options)
opt:
if (blkServers) {
list = blockServerParse(blkServers);
+ liststr = blkServers;
} else {
list = blockServerParse("localhost");
+ liststr = "localhost";
}
switch (optFlag) {
@@ -864,7 +883,7 @@ glusterBlockParseArgs(int count, char **options)
ERROR("%s", FAILED_INFO);
break;
case 'd':
- ret = glusterBlockDelete(block, list);
+ ret = glusterBlockDelete(block, liststr);
if (ret)
ERROR("%s", FAILED_DELETE);
break;
diff --git a/gluster-blockd.c b/gluster-blockd.c
index 6b73c8b..8807b19 100644
--- a/gluster-blockd.c
+++ b/gluster-blockd.c
@@ -1,6 +1,6 @@
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <stdio.h>
-#include <netdb.h>
+#include <netdb.h>
#include <sys/socket.h>
# include <uuid/uuid.h>
@@ -31,14 +31,103 @@
# define MSERVER_DELIMITER ","
-blockResponse *
-block_create_cli_1_svc(blockCreateCli *blk, struct svc_req *rqstp)
+typedef enum opterations {
+ CREATE_SRV = 1,
+ LIST_SRV = 2,
+ INFO_SRV = 3,
+ DELETE_SRV = 4,
+ EXEC_SRV = 5
+} opterations;
+
+static void
+gluster_block_1(char *host, void *cobj, opterations opt, blockResponse **reply)
{
- //FILE *fp;
CLIENT *clnt;
int sockfd;
struct hostent *server;
struct sockaddr_in sain;
+
+ if ((sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
+ perror("gluster-blockd: socket");
+ exit(1);
+ }
+ server = gethostbyname(host);
+ if (server == NULL) {
+ fprintf(stderr,"ERROR, no such host\n");
+ exit(0);
+ }
+
+ bzero((char *) &sain, sizeof(sain));
+ sain.sin_family = AF_INET;
+ bcopy((char *)server->h_addr, (char *)&sain.sin_addr.s_addr, server->h_length);
+ sain.sin_port = htons(24006);
+
+ if (connect(sockfd, (struct sockaddr *) &sain, sizeof(sain)) < 0) {
+ perror("gluster-blockd: connect");
+ exit(1);
+ }
+
+ clnt = clnttcp_create ((struct sockaddr_in *) &sain, GLUSTER_BLOCK, GLUSTER_BLOCK_VERS, &sockfd, 0, 0);
+ if (clnt == NULL) {
+ clnt_pcreateerror ("localhost");
+ exit (1);
+ }
+
+ switch(opt) {
+ case CREATE_SRV:
+ *reply = block_create_1((blockCreate *)cobj, clnt);
+ if (*reply == NULL) {
+ clnt_perror (clnt, "call failed gluster-block");
+ }
+ break;
+ case DELETE_SRV:
+ *reply = block_delete_1((blockDelete *)cobj, clnt);
+ if (*reply == NULL) {
+ clnt_perror (clnt, "call failed gluster-block");
+ }
+ break;
+ case INFO_SRV:
+ case LIST_SRV:
+ break;
+ case EXEC_SRV:
+ *reply = block_exec_1((char **)&cobj, clnt);
+ if (*reply == NULL) {
+ clnt_perror (clnt, "call failed gluster-block");
+ }
+ break;
+ }
+ clnt_destroy (clnt);
+}
+
+static char *
+getCfgstring(char* name, char *blkServer)
+{
+ char *cmd;
+ char *exec;
+ char *buf = NULL;
+ blockResponse *reply = NULL;
+
+ asprintf(&cmd, "%s %s", TARGETCLI_GLFS, BACKEND_CFGSTR);
+ asprintf(&exec, cmd, name);
+
+ gluster_block_1(blkServer, exec, EXEC_SRV, &reply);
+ if (!reply || reply->exit) {
+ ERROR("%s on host: %s",
+ FAILED_GATHERING_CFGSTR, blkServer);
+ }
+
+ GB_FREE(cmd);
+ GB_FREE(exec);
+
+ if(reply->out)
+ buf = strdup(reply->out);
+
+ return buf;
+}
+
+blockResponse *
+block_create_cli_1_svc(blockCreateCli *blk, struct svc_req *rqstp)
+{
int ret;
uuid_t out;
static blockCreate *cobj;
@@ -66,43 +155,161 @@ block_create_cli_1_svc(blockCreateCli *blk, struct svc_req *rqstp)
//for
- if ((sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
- perror("gluster-blockd: socket");
- exit(1);
+ gluster_block_1(blk->block_hosts, cobj, CREATE_SRV, &reply);
+
+out:
+ return reply;
+}
+
+static size_t
+glusterBlockCreateParseSize(char *value)
+{
+ char *postfix;
+ char *tmp;
+ size_t sizef;
+
+ if (!value)
+ return -1;
+
+ sizef = strtod(value, &postfix);
+ if (sizef < 0) {
+ ERROR("%s", "size cannot be negative number\n");
+ return -1;
}
- server = gethostbyname(blk->block_hosts);
- if (server == NULL) {
- fprintf(stderr,"ERROR, no such host\n");
- exit(0);
+
+ tmp = postfix;
+ if (*postfix == ' ')
+ tmp = tmp + 1;
+
+ switch (*tmp) {
+ case 'Y':
+ sizef *= 1024;
+ /* fall through */
+ case 'Z':
+ sizef *= 1024;
+ /* fall through */
+ case 'E':
+ sizef *= 1024;
+ /* fall through */
+ case 'P':
+ sizef *= 1024;
+ /* fall through */
+ case 'T':
+ sizef *= 1024;
+ /* fall through */
+ case 'G':
+ sizef *= 1024;
+ /* fall through */
+ case 'M':
+ sizef *= 1024;
+ /* fall through */
+ case 'K':
+ case 'k':
+ sizef *= 1024;
+ /* fall through */
+ case 'b':
+ case '\0':
+ return sizef;
+ break;
+ default:
+ ERROR("%s", "You may use k/K, M, G or T suffixes for "
+ "kilobytes, megabytes, gigabytes and terabytes.");
+ return -1;
}
+}
- bzero((char *) &sain, sizeof(sain));
- sain.sin_family = AF_INET;
- bcopy((char *)server->h_addr, (char *)&sain.sin_addr.s_addr, server->h_length);
- sain.sin_port = htons(24006);
+static int
+glusterBlockParseCfgStringToDef(char* cfgstring,
+ blockCreate *blk)
+{
+ int ret = 0;
+ char *p, *sep;
+
+ /* part before '@' is the volume name */
+ p = cfgstring;
+ sep = strchr(p, '@');
+ if (!sep) {
+ ret = -1;
+ goto fail;
+ }
- if (connect(sockfd, (struct sockaddr *) &sain, sizeof(sain)) < 0) {
- perror("gluster-blockd: connect");
- exit(1);
+ *sep = '\0';
+ /*if (GB_STRDUP(blk->volume, p) < 0) {
+ ret = -1;
+ goto fail;
+ }
+ */
+ strcpy(blk->volume, p);
+
+ /* part between '@' and '/' is the server name */
+ p = sep + 1;
+ sep = strchr(p, '/');
+ if (!sep) {
+ ret = -1;
+ goto fail;
}
- clnt = clnttcp_create ((struct sockaddr_in *) &sain, GLUSTER_BLOCK, GLUSTER_BLOCK_VERS, &sockfd, 0, 0);
- if (clnt == NULL) {
- clnt_pcreateerror ("localhost");
- exit (1);
+ *sep = '\0';
+ /*if (GB_STRDUP(blk->volfileserver, p) < 0) {
+ ret = -1;
+ goto fail;
+ }
+ */
+ strcpy(blk->volfileserver, p);
+
+ /* part between '/' and '(' is the filename */
+ p = sep + 1;
+ sep = strchr(p, '(');
+ if (!sep) {
+ ret = -1;
+ goto fail;
}
- reply = block_create_1(cobj, clnt);
- if (reply == NULL) {
- clnt_perror (clnt, "call failed gluster-blockd");
+ *(sep - 1) = '\0'; /* discard extra space at end of filename */
+ /*if (GB_STRDUP(blk->gbid, p) < 0) {
+ ret = -1;
+ goto fail;
+ }
+ */
+ strcpy(blk->gbid, p);
+
+ /* part between '(' and ')' is the size */
+ p = sep + 1;
+ sep = strchr(p, ')');
+ if (!sep) {
+ ret = -1;
+ goto fail;
}
- clnt_destroy (clnt);
+ *sep = '\0';
+ blk->size = glusterBlockCreateParseSize(p);
+ if (blk->size < 0) {
+ ERROR("%s", "failed while parsing size");
+ ret = -1;
+ goto fail;
+ }
-out:
- return reply;
-}
+ /* part between ')' and '\n' is the status */
+/*
+ p = sep + 1;
+ sep = strchr(p, '\n');
+ if (!sep) {
+ ret = -1;
+ goto fail;
+ }
+
+ *sep = '\0';
+ if (!strcmp(p, " activated"))
+ blk->status = true;
+*/
+ return 0;
+
+ fail:
+// glusterBlockDefFree(blk);
+
+ return ret;
+}
blockResponse *
block_create_1_svc(blockCreate *blk, struct svc_req *rqstp)
@@ -153,3 +360,124 @@ block_create_1_svc(blockCreate *blk, struct svc_req *rqstp)
return obj;
}
+blockResponse *
+block_delete_cli_1_svc(blockDeleteCli *blk, struct svc_req *rqstp)
+{
+ char *cfgstring;
+ static blockCreate *blkcfg;
+ static blockDelete *cobj;
+ static blockResponse *reply;
+
+ if(GB_ALLOC(cobj) < 0)
+ goto out;
+
+ strcpy(cobj->block_name, blk->block_name);
+
+ //for
+ cfgstring = getCfgstring(blk->block_name, blk->block_hosts);
+ if (!cfgstring) {
+ ERROR("%s", "failed while gathering CfgString");
+ goto out;
+ }
+
+ if (GB_ALLOC(blkcfg) < 0)
+ goto out;
+
+ if(glusterBlockParseCfgStringToDef(cfgstring, blkcfg)) {
+ ERROR("%s", "failed while parsing CfgString to glusterBlockDef");
+ goto out;
+ }
+
+ strcpy(cobj->gbid, blkcfg->gbid);
+ gluster_block_1(blk->block_hosts, cobj, DELETE_SRV, &reply);
+
+ if (glusterBlockDeleteEntry(blkcfg)) {
+ ERROR("%s volume: %s host: %s",
+ FAILED_DELETING_FILE, blkcfg->volume, blkcfg->volfileserver);
+ }
+out:
+ return reply;
+}
+
+
+blockResponse *
+block_delete_1_svc(blockDelete *blk, struct svc_req *rqstp)
+{
+ FILE *fp;
+ char *backstore = NULL;
+ char *iqn = NULL;
+ char *exec = NULL;
+ blockResponse *obj = NULL;
+
+ asprintf(&iqn, "%s %s %s%s", TARGETCLI_ISCSI, DELETE, IQN_PREFIX, blk->gbid);
+
+ asprintf(&backstore, "%s %s %s", TARGETCLI_GLFS,
+ DELETE, blk->block_name);
+
+ asprintf(&exec, "%s && %s", backstore, iqn);
+
+ if(GB_ALLOC(obj) < 0)
+ return NULL;
+
+ if (GB_ALLOC_N(obj->out, 4096) < 0) {
+ GB_FREE(obj);
+ return NULL;
+ }
+
+ fp = popen(exec, "r");
+ if (fp != NULL) {
+ size_t newLen = fread(obj->out, sizeof(char), 4096, fp);
+ if (ferror( fp ) != 0) {
+ ERROR("%s", "Error reading command output\n");
+ } else {
+ obj->out[newLen++] = '\0';
+ }
+ obj->exit = WEXITSTATUS(pclose(fp));
+ }
+
+ return obj;
+}
+
+blockResponse *
+block_exec_1_svc(char **cmd, struct svc_req *rqstp)
+{
+ FILE *fp;
+ static blockResponse *obj;
+
+ if(GB_ALLOC(obj) < 0)
+ return NULL;
+
+ if (GB_ALLOC_N(obj->out, 4096) < 0) {
+ GB_FREE(obj);
+ return NULL;
+ }
+
+ fp = popen(*cmd, "r");
+ if (fp != NULL) {
+ size_t newLen = fread(obj->out, sizeof(char), 4996, fp);
+ if (ferror( fp ) != 0) {
+ ERROR("%s", "Error reading command output\n");
+ } else {
+ obj->out[newLen++] = '\0';
+ }
+ obj->exit = WEXITSTATUS(pclose(fp));
+ }
+
+ return obj;
+}
+
+blockResponse *
+block_list_cli_1_svc(blockListCli *blk, struct svc_req *rqstp)
+{
+
+
+ return NULL;
+}
+
+blockResponse *
+block_info_cli_1_svc(blockInfoCli *blk, struct svc_req *rqstp)
+{
+
+
+ return NULL;
+}
diff --git a/rpc/block.h b/rpc/block.h
index d939057..0ce4e33 100644
--- a/rpc/block.h
+++ b/rpc/block.h
@@ -33,6 +33,30 @@ struct blockCreateCli {
};
typedef struct blockCreateCli blockCreateCli;
+struct blockDeleteCli {
+ char block_name[255];
+ char *block_hosts;
+};
+typedef struct blockDeleteCli blockDeleteCli;
+
+struct blockDelete {
+ char block_name[255];
+ char gbid[127];
+};
+typedef struct blockDelete blockDelete;
+
+struct blockInfoCli {
+ char block_name[255];
+ char volume[255];
+};
+typedef struct blockInfoCli blockInfoCli;
+
+struct blockListCli {
+ char volume[255];
+ u_quad_t offset;
+};
+typedef struct blockListCli blockListCli;
+
struct blockResponse {
int exit;
char *out;
@@ -51,12 +75,30 @@ typedef struct blockResponse blockResponse;
#define BLOCK_CREATE_CLI 1
extern blockResponse * block_create_cli_1(blockCreateCli *, CLIENT *);
extern blockResponse * block_create_cli_1_svc(blockCreateCli *, struct svc_req *);
+#define BLOCK_LIST_CLI 2
+extern blockResponse * block_list_cli_1(blockListCli *, CLIENT *);
+extern blockResponse * block_list_cli_1_svc(blockListCli *, struct svc_req *);
+#define BLOCK_INFO_CLI 3
+extern blockResponse * block_info_cli_1(blockInfoCli *, CLIENT *);
+extern blockResponse * block_info_cli_1_svc(blockInfoCli *, struct svc_req *);
+#define BLOCK_DELETE_CLI 4
+extern blockResponse * block_delete_cli_1(blockDeleteCli *, CLIENT *);
+extern blockResponse * block_delete_cli_1_svc(blockDeleteCli *, struct svc_req *);
extern int gluster_block_cli_1_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
#else /* K&R C */
#define BLOCK_CREATE_CLI 1
extern blockResponse * block_create_cli_1();
extern blockResponse * block_create_cli_1_svc();
+#define BLOCK_LIST_CLI 2
+extern blockResponse * block_list_cli_1();
+extern blockResponse * block_list_cli_1_svc();
+#define BLOCK_INFO_CLI 3
+extern blockResponse * block_info_cli_1();
+extern blockResponse * block_info_cli_1_svc();
+#define BLOCK_DELETE_CLI 4
+extern blockResponse * block_delete_cli_1();
+extern blockResponse * block_delete_cli_1_svc();
extern int gluster_block_cli_1_freeresult ();
#endif /* K&R C */
@@ -67,12 +109,24 @@ extern int gluster_block_cli_1_freeresult ();
#define BLOCK_CREATE 1
extern blockResponse * block_create_1(blockCreate *, CLIENT *);
extern blockResponse * block_create_1_svc(blockCreate *, struct svc_req *);
+#define BLOCK_DELETE 2
+extern blockResponse * block_delete_1(blockDelete *, CLIENT *);
+extern blockResponse * block_delete_1_svc(blockDelete *, struct svc_req *);
+#define BLOCK_EXEC 3
+extern blockResponse * block_exec_1(char **, CLIENT *);
+extern blockResponse * block_exec_1_svc(char **, struct svc_req *);
extern int gluster_block_1_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
#else /* K&R C */
#define BLOCK_CREATE 1
extern blockResponse * block_create_1();
extern blockResponse * block_create_1_svc();
+#define BLOCK_DELETE 2
+extern blockResponse * block_delete_1();
+extern blockResponse * block_delete_1_svc();
+#define BLOCK_EXEC 3
+extern blockResponse * block_exec_1();
+extern blockResponse * block_exec_1_svc();
extern int gluster_block_1_freeresult ();
#endif /* K&R C */
@@ -81,11 +135,19 @@ extern int gluster_block_1_freeresult ();
#if defined(__STDC__) || defined(__cplusplus)
extern bool_t xdr_blockCreate (XDR *, blockCreate*);
extern bool_t xdr_blockCreateCli (XDR *, blockCreateCli*);
+extern bool_t xdr_blockDeleteCli (XDR *, blockDeleteCli*);
+extern bool_t xdr_blockDelete (XDR *, blockDelete*);
+extern bool_t xdr_blockInfoCli (XDR *, blockInfoCli*);
+extern bool_t xdr_blockListCli (XDR *, blockListCli*);
extern bool_t xdr_blockResponse (XDR *, blockResponse*);
#else /* K&R C */
extern bool_t xdr_blockCreate ();
extern bool_t xdr_blockCreateCli ();
+extern bool_t xdr_blockDeleteCli ();
+extern bool_t xdr_blockDelete ();
+extern bool_t xdr_blockInfoCli ();
+extern bool_t xdr_blockListCli ();
extern bool_t xdr_blockResponse ();
#endif /* K&R C */
diff --git a/rpc/block.x b/rpc/block.x
index b563c9e..aebe451 100644
--- a/rpc/block.x
+++ b/rpc/block.x
@@ -1,4 +1,3 @@
-
struct blockCreate {
char volume[255];
char volfileserver[255];
@@ -15,6 +14,26 @@ struct blockCreateCli {
string block_hosts<>;
};
+struct blockDeleteCli {
+ char block_name[255];
+ string block_hosts<>;
+};
+
+struct blockDelete {
+ char block_name[255];
+ char gbid[127];
+};
+
+struct blockInfoCli {
+ char block_name[255];
+ char volume[255];
+};
+
+struct blockListCli {
+ char volume[255];
+ u_quad_t offset; /* dentry d_name offset */
+};
+
struct blockResponse {
int exit; /* exit code of the command */
string out<>; /* json output */
@@ -25,11 +44,16 @@ struct blockResponse {
program GLUSTER_BLOCK_CLI {
version GLUSTER_BLOCK_CLI_VERS {
blockResponse BLOCK_CREATE_CLI(blockCreateCli) = 1;
+ blockResponse BLOCK_LIST_CLI(blockListCli) = 2;
+ blockResponse BLOCK_INFO_CLI(blockInfoCli) = 3;
+ blockResponse BLOCK_DELETE_CLI(blockDeleteCli) = 4;
} = 1;
} = 212153113; /* B2 L12 O15 C3 K11 C3 */
program GLUSTER_BLOCK {
version GLUSTER_BLOCK_VERS {
blockResponse BLOCK_CREATE(blockCreate) = 1;
+ blockResponse BLOCK_DELETE(blockDelete) = 2;
+ blockResponse BLOCK_EXEC(string) = 3;
} = 1;
} = 21215311; /* B2 L12 O15 C3 K11 */
diff --git a/rpc/block_clnt.c b/rpc/block_clnt.c
index ae95d9a..2e96709 100644
--- a/rpc/block_clnt.c
+++ b/rpc/block_clnt.c
@@ -25,6 +25,51 @@ block_create_cli_1(blockCreateCli *argp, CLIENT *clnt)
}
blockResponse *
+block_list_cli_1(blockListCli *argp, CLIENT *clnt)
+{
+ static blockResponse clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof(clnt_res));
+ if (clnt_call (clnt, BLOCK_LIST_CLI,
+ (xdrproc_t) xdr_blockListCli, (caddr_t) argp,
+ (xdrproc_t) xdr_blockResponse, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+blockResponse *
+block_info_cli_1(blockInfoCli *argp, CLIENT *clnt)
+{
+ static blockResponse clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof(clnt_res));
+ if (clnt_call (clnt, BLOCK_INFO_CLI,
+ (xdrproc_t) xdr_blockInfoCli, (caddr_t) argp,
+ (xdrproc_t) xdr_blockResponse, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+blockResponse *
+block_delete_cli_1(blockDeleteCli *argp, CLIENT *clnt)
+{
+ static blockResponse clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof(clnt_res));
+ if (clnt_call (clnt, BLOCK_DELETE_CLI,
+ (xdrproc_t) xdr_blockDeleteCli, (caddr_t) argp,
+ (xdrproc_t) xdr_blockResponse, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+blockResponse *
block_create_1(blockCreate *argp, CLIENT *clnt)
{
static blockResponse clnt_res;
@@ -38,3 +83,33 @@ block_create_1(blockCreate *argp, CLIENT *clnt)
}
return (&clnt_res);
}
+
+blockResponse *
+block_delete_1(blockDelete *argp, CLIENT *clnt)
+{
+ static blockResponse clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof(clnt_res));
+ if (clnt_call (clnt, BLOCK_DELETE,
+ (xdrproc_t) xdr_blockDelete, (caddr_t) argp,
+ (xdrproc_t) xdr_blockResponse, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+blockResponse *
+block_exec_1(char **argp, CLIENT *clnt)
+{
+ static blockResponse clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof(clnt_res));
+ if (clnt_call (clnt, BLOCK_EXEC,
+ (xdrproc_t) xdr_wrapstring, (caddr_t) argp,
+ (xdrproc_t) xdr_blockResponse, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
diff --git a/rpc/block_svc.c b/rpc/block_svc.c
index 4c054f5..345581f 100644
--- a/rpc/block_svc.c
+++ b/rpc/block_svc.c
@@ -28,6 +28,9 @@ gluster_block_cli_1(struct svc_req *rqstp, register SVCXPRT *transp)
{
union {
blockCreateCli block_create_cli_1_arg;
+ blockListCli block_list_cli_1_arg;
+ blockInfoCli block_info_cli_1_arg;
+ blockDeleteCli block_delete_cli_1_arg;
} argument;
char *result;
xdrproc_t _xdr_argument, _xdr_result;
@@ -44,6 +47,24 @@ gluster_block_cli_1(struct svc_req *rqstp, register SVCXPRT *transp)
local = (char *(*)(char *, struct svc_req *)) block_create_cli_1_svc;
break;
+ case BLOCK_LIST_CLI:
+ _xdr_argument = (xdrproc_t) xdr_blockListCli;
+ _xdr_result = (xdrproc_t) xdr_blockResponse;
+ local = (char *(*)(char *, struct svc_req *)) block_list_cli_1_svc;
+ break;
+
+ case BLOCK_INFO_CLI:
+ _xdr_argument = (xdrproc_t) xdr_blockInfoCli;
+ _xdr_result = (xdrproc_t) xdr_blockResponse;
+ local = (char *(*)(char *, struct svc_req *)) block_info_cli_1_svc;
+ break;
+
+ case BLOCK_DELETE_CLI:
+ _xdr_argument = (xdrproc_t) xdr_blockDeleteCli;
+ _xdr_result = (xdrproc_t) xdr_blockResponse;
+ local = (char *(*)(char *, struct svc_req *)) block_delete_cli_1_svc;
+ break;
+
default:
svcerr_noproc (transp);
return;
@@ -69,6 +90,8 @@ gluster_block_1(struct svc_req *rqstp, register SVCXPRT *transp)
{
union {
blockCreate block_create_1_arg;
+ blockDelete block_delete_1_arg;
+ char *block_exec_1_arg;
} argument;
char *result;
xdrproc_t _xdr_argument, _xdr_result;
@@ -85,6 +108,18 @@ gluster_block_1(struct svc_req *rqstp, register SVCXPRT *transp)
local = (char *(*)(char *, struct svc_req *)) block_create_1_svc;
break;
+ case BLOCK_DELETE:
+ _xdr_argument = (xdrproc_t) xdr_blockDelete;
+ _xdr_result = (xdrproc_t) xdr_blockResponse;
+ local = (char *(*)(char *, struct svc_req *)) block_delete_1_svc;
+ break;
+
+ case BLOCK_EXEC:
+ _xdr_argument = (xdrproc_t) xdr_wrapstring;
+ _xdr_result = (xdrproc_t) xdr_blockResponse;
+ local = (char *(*)(char *, struct svc_req *)) block_exec_1_svc;
+ break;
+
default:
svcerr_noproc (transp);
return;
diff --git a/rpc/block_xdr.c b/rpc/block_xdr.c
index 91775fa..1b9a4c6 100644
--- a/rpc/block_xdr.c
+++ b/rpc/block_xdr.c
@@ -45,6 +45,52 @@ xdr_blockCreateCli (XDR *xdrs, blockCreateCli *objp)
}
bool_t
+xdr_blockDeleteCli (XDR *xdrs, blockDeleteCli *objp)
+{
+ if (!xdr_vector (xdrs, (char *)objp->block_name, 255,
+ sizeof (char), (xdrproc_t) xdr_char))
+ return FALSE;
+ if (!xdr_string (xdrs, &objp->block_hosts, ~0))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_blockDelete (XDR *xdrs, blockDelete *objp)
+{
+ if (!xdr_vector (xdrs, (char *)objp->block_name, 255,
+ sizeof (char), (xdrproc_t) xdr_char))
+ return FALSE;
+ if (!xdr_vector (xdrs, (char *)objp->gbid, 127,
+ sizeof (char), (xdrproc_t) xdr_char))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_blockInfoCli (XDR *xdrs, blockInfoCli *objp)
+{
+ if (!xdr_vector (xdrs, (char *)objp->block_name, 255,
+ sizeof (char), (xdrproc_t) xdr_char))
+ return FALSE;
+ if (!xdr_vector (xdrs, (char *)objp->volume, 255,
+ sizeof (char), (xdrproc_t) xdr_char))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_blockListCli (XDR *xdrs, blockListCli *objp)
+{
+ if (!xdr_vector (xdrs, (char *)objp->volume, 255,
+ sizeof (char), (xdrproc_t) xdr_char))
+ return FALSE;
+ if (!xdr_u_quad_t (xdrs, &objp->offset))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
xdr_blockResponse (XDR *xdrs, blockResponse *objp)
{
if (!xdr_int (xdrs, &objp->exit))