summaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorPrasanna Kumar Kalever <prasanna.kalever@redhat.com>2017-08-02 23:42:29 +0530
committerPrasanna Kumar Kalever <prasanna.kalever@redhat.com>2017-08-08 15:44:32 +0530
commitd723907c8eaa25f107c7fadd79ca5f9bc6596edf (patch)
treebfb9bcc9cbb1bdca3c66a497e319257818c31a91 /rpc
parent44f732d877743c692abb5d389ccda941b1fa4959 (diff)
gluster-block: support force delete option
$ gluster-block help gluster-block (0.2.1) usage: gluster-block <command> <volname[/blockname]> [<args>] [--json*] commands: [...] delete <volname/blockname> [force] delete block device. [...] Change-Id: I64ac01ec148e2e1d4d0ba0d4c5560df9334d58f5 Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Diffstat (limited to 'rpc')
-rw-r--r--rpc/block_svc_routines.c45
-rw-r--r--rpc/rpcl/block.x1
2 files changed, 27 insertions, 19 deletions
diff --git a/rpc/block_svc_routines.c b/rpc/block_svc_routines.c
index d04d2cf..b309e79 100644
--- a/rpc/block_svc_routines.c
+++ b/rpc/block_svc_routines.c
@@ -1131,7 +1131,7 @@ glusterBlockModifyRemoteAsync(MetaInfo *info,
static int
glusterBlockCleanUp(struct glfs *glfs, char *blockname,
- bool deleteall, blockRemoteDeleteResp *drobj)
+ bool deleteall, bool forcedel, blockRemoteDeleteResp *drobj)
{
int ret = -1;
size_t i;
@@ -1190,7 +1190,7 @@ glusterBlockCleanUp(struct glfs *glfs, char *blockname,
}
}
- if (cleanupsuccess == info->nhosts) {
+ if (forcedel || cleanupsuccess == info->nhosts) {
GB_METAUPDATE_OR_GOTO(lock, glfs, blockname, info->volume,
ret, errMsg, out, "ENTRYDELETE: INPROGRESS\n");
if (glusterBlockDeleteEntry(glfs, info->volume, info->gbid)) {
@@ -1216,6 +1216,11 @@ glusterBlockCleanUp(struct glfs *glfs, char *blockname,
blockFreeMetaInfo(info);
GB_FREE (errMsg);
+ /* ignore asyncret if force delete is used */
+ if (forcedel) {
+ asyncret = 0;
+ }
+
return asyncret?asyncret:ret;
}
@@ -1275,7 +1280,7 @@ glusterBlockAuditRequest(struct glfs *glfs,
"No Spare nodes to create (%s): rollingback creation of target"
" on volume %s with given hosts %s",
blk->block_name, blk->volume, blk->block_hosts);
- glusterBlockCleanUp(glfs, blk->block_name, TRUE, (*reply)->obj);
+ glusterBlockCleanUp(glfs, blk->block_name, TRUE, FALSE, (*reply)->obj);
needcleanup = FALSE; /* already clean attempted */
ret = -1;
goto out;
@@ -1284,7 +1289,7 @@ glusterBlockAuditRequest(struct glfs *glfs,
"Not enough Spare nodes for (%s): rollingback creation of target"
" on volume %s with given hosts %s",
blk->block_name, blk->volume, blk->block_hosts);
- glusterBlockCleanUp(glfs, blk->block_name, TRUE, (*reply)->obj);
+ glusterBlockCleanUp(glfs, blk->block_name, TRUE, FALSE, (*reply)->obj);
needcleanup = FALSE; /* already clean attempted */
ret = -1;
goto out;
@@ -1315,7 +1320,7 @@ glusterBlockAuditRequest(struct glfs *glfs,
out:
if (needcleanup) {
- glusterBlockCleanUp(glfs, blk->block_name, FALSE, (*reply)->obj);
+ glusterBlockCleanUp(glfs, blk->block_name, FALSE, FALSE, (*reply)->obj);
}
blockFreeMetaInfo(info);
@@ -1948,7 +1953,7 @@ block_create_cli_1_svc(blockCreateCli *blk, struct svc_req *rqstp)
" rollingback the create request for block %s on volume %s with hosts %s",
errCode, blk->block_name, blk->volume, blk->block_hosts);
- glusterBlockCleanUp(glfs, blk->block_name, TRUE, savereply->obj);
+ glusterBlockCleanUp(glfs, blk->block_name, TRUE, FALSE, savereply->obj);
goto exist;
}
@@ -2355,23 +2360,25 @@ block_delete_cli_1_svc(blockDeleteCli *blk, struct svc_req *rqstp)
goto out;
}
- if (GB_ALLOC(info) < 0) {
- goto out;
- }
+ if (!blk->force) {
+ if (GB_ALLOC(info) < 0) {
+ goto out;
+ }
- ret = blockGetMetaInfo(glfs, blk->block_name, info, NULL);
- if (ret) {
- goto out;
- }
+ ret = blockGetMetaInfo(glfs, blk->block_name, info, NULL);
+ if (ret) {
+ goto out;
+ }
- ret = glusterBlockConnectAsync(blk->block_name, info,
- glusterBlockDeleteFillArgs(info, true, NULL, NULL, NULL),
- &errMsg);
- if (ret) {
- goto out;
+ ret = glusterBlockConnectAsync(blk->block_name, info,
+ glusterBlockDeleteFillArgs(info, true, NULL, NULL, NULL),
+ &errMsg);
+ if (ret) {
+ goto out;
+ }
}
- errCode = glusterBlockCleanUp(glfs, blk->block_name, TRUE, savereply);
+ errCode = glusterBlockCleanUp(glfs, blk->block_name, TRUE, TRUE, savereply);
if (errCode) {
LOG("mgmt", GB_LOG_WARNING, "glusterBlockCleanUp: return %d "
"on block %s for volume %s", errCode, blk->block_name, blk->volume);
diff --git a/rpc/rpcl/block.x b/rpc/rpcl/block.x
index a47901a..66d1e32 100644
--- a/rpc/rpcl/block.x
+++ b/rpc/rpcl/block.x
@@ -47,6 +47,7 @@ struct blockCreateCli {
struct blockDeleteCli {
char block_name[255];
char volume[255];
+ bool force;
enum JsonResponseFormat json_resp;
};