diff options
author | Prasanna Kumar Kalever <prasanna.kalever@redhat.com> | 2017-01-25 16:09:12 +0530 |
---|---|---|
committer | Prasanna Kumar Kalever <prasanna.kalever@redhat.com> | 2017-01-30 19:31:50 +0530 |
commit | d65f7b890a2554c9e3d0cafdb58ac257d4f26ab3 (patch) | |
tree | 32fb92ab62279ea56e1ada3d496b950d467b4cbc /gluster-block.c | |
parent | b58e4765ed7e232f638ceb764b8ef1210bb43ff9 (diff) |
gluster-blockd: implement transaction framework
This patch introduce the transaction locking also, start maintaining
meta data journaling per block
Every request is follows transaction, at the start of any transaction
we take blocking lock on "/block-meta/meta.lock" file and at the end
we unlock.
Meanwhile while, when the transaction is in progress we do
journaling, while performing series of operations, used for future
purposes and roll backing.
A sample journal file looks like:
$ cat /mnt/block-meta/LUN1
GBID: xyz-abc
SIZE : 5GiB
HA: 3
ENTRYCREATE: INPROGRESS
ENTRYCREATE: SUCCESS
NODE1: INPROGRESS
NODE2: INPROGRESS
NODE3: INPROGRESS
NODE2: SUCCESS
NODE3: FAIL
NODE1: SUCCESS
NODE4: INPROGRESS
NODE4: SUCCESS
NODE3: CLEANUPSUCCESS
<EOF>
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Diffstat (limited to 'gluster-block.c')
-rw-r--r-- | gluster-block.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/gluster-block.c b/gluster-block.c index ef2ba1b..b8e64b9 100644 --- a/gluster-block.c +++ b/gluster-block.c @@ -23,6 +23,7 @@ # define INFO "info" # define MODIFY "modify" # define BLOCKHOST "block-host" +# define VOLUME "volume" # define HELP "help" @@ -112,7 +113,6 @@ glusterBlockHelp(void) MSG("%s", "gluster-block (Version 0.1) \n" " -c, --create <name> Create the gluster block\n" - " -v, --volume <vol> gluster volume name\n" " -h, --host <gluster-node> node addr from gluster pool\n" " -s, --size <size> block storage size in KiB|MiB|GiB|TiB..\n" "\n" @@ -124,7 +124,8 @@ glusterBlockHelp(void) "\n" " -d, --delete <name> Delete the gluster block\n" "\n" - " [-b, --block-host <IP1,IP2,IP3...>] block servers, clubbed with any option\n"); + " -v, --volume <vol> gluster volume name\n" + " [-b, --block-host <IP1,IP2,IP3...>] block servers, clubbed with any option\n"); } @@ -230,12 +231,13 @@ glusterBlockCreate(int count, char **options, char *name) static int -glusterBlockList(char *blkServers) +glusterBlockList(char *volume, char *blkServers) { static blockListCli cobj; char *out = NULL; int ret = -1; + strcpy(cobj.volume, volume); if (GB_STRDUP(cobj.block_hosts, blkServers) < 0) { return -1; } @@ -251,13 +253,14 @@ glusterBlockList(char *blkServers) static int -glusterBlockDelete(char* name, char *blkServers) +glusterBlockDelete(char* name, char* volume, char *blkServers) { static blockDeleteCli cobj; char *out = NULL; int ret = -1; strcpy(cobj.block_name, name); + strcpy(cobj.volume, volume); if (GB_STRDUP(cobj.block_hosts, blkServers) < 0) { return -1; } @@ -273,13 +276,14 @@ glusterBlockDelete(char* name, char *blkServers) static int -glusterBlockInfo(char* name, char *blkServers) +glusterBlockInfo(char* name, char* volume, char *blkServers) { static blockInfoCli cobj; char *out = NULL; int ret = -1; strcpy(cobj.block_name, name); + strcpy(cobj.volume, volume); if (GB_STRDUP(cobj.block_hosts, blkServers) < 0) { return -1; } @@ -302,6 +306,7 @@ glusterBlockParseArgs(int count, char **options) int optFlag = 0; char *block = NULL; char *blkServers = NULL; + char *volume = NULL; while (1) { static const struct option long_options[] = { @@ -311,6 +316,7 @@ glusterBlockParseArgs(int count, char **options) {LIST, no_argument, 0, 'l'}, {INFO, required_argument, 0, 'i'}, {MODIFY, required_argument, 0, 'm'}, + {VOLUME, required_argument, 0, 'v'}, {BLOCKHOST, required_argument, 0, 'b'}, {0, 0, 0, 0} }; @@ -332,9 +338,13 @@ glusterBlockParseArgs(int count, char **options) goto opt; break; + case 'v': + volume = optarg; + break; + case 'c': ret = glusterBlockCreate(count, options, optarg); - if (ret) { + if (ret && ret != EEXIST) { ERROR("%s", FAILED_CREATE); goto out; } @@ -368,17 +378,17 @@ glusterBlockParseArgs(int count, char **options) opt: switch (optFlag) { case 'l': - ret = glusterBlockList(blkServers); + ret = glusterBlockList(volume, blkServers); if (ret) ERROR("%s", FAILED_LIST); break; case 'i': - ret = glusterBlockInfo(block, blkServers); + ret = glusterBlockInfo(block, volume, blkServers); if (ret) ERROR("%s", FAILED_INFO); break; case 'd': - ret = glusterBlockDelete(block, blkServers); + ret = glusterBlockDelete(block, volume, blkServers); if (ret) ERROR("%s", FAILED_DELETE); break; |