From 1c5a7f4dc33bbb1738b66dd73aa281c78aa0c326 Mon Sep 17 00:00:00 2001 From: Prasanna Kumar Kalever Date: Mon, 20 Feb 2017 16:09:15 +0530 Subject: gluster-blockd: treat delete success if block doesn't exist problem: say because of some reasons create failed to config on node, so it will log CONFIGFAIL in the metafile. At the time of delete since config failed it is obvious that block will not exist. since delete cannot find it now it fails to delete hence returning -1. solution: treat delete success if there is no block with given name on that node. Signed-off-by: Prasanna Kumar Kalever --- rpc/block_svc_routines.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/rpc/block_svc_routines.c b/rpc/block_svc_routines.c index f755ee9..175372a 100644 --- a/rpc/block_svc_routines.c +++ b/rpc/block_svc_routines.c @@ -25,6 +25,7 @@ # define GB_TGCLI_GLFS_PATH "/backstores/user:glfs" # define GB_TGCLI_GLFS "targetcli " GB_TGCLI_GLFS_PATH +# define GB_TGCLI_CHECK GB_TGCLI_GLFS " ls | grep ' %s ' > " DEVNULLPATH # define GB_TGCLI_ISCSI "targetcli /iscsi" # define GB_TGCLI_GLOBALS "targetcli set global auto_add_default_portal=false > " DEVNULLPATH # define GB_TGCLI_SAVE "targetcli / saveconfig > " DEVNULLPATH @@ -919,6 +920,20 @@ block_delete_1_svc(blockDelete *blk, struct svc_req *rqstp) } reply->exit = -1; + if (asprintf(&exec, GB_TGCLI_CHECK, blk->block_name) == -1) { + goto out; + } + + /* Check if block exist on this node ? */ + if (WEXITSTATUS(system(exec))== 1) { + reply->exit = 0; + if (asprintf(&reply->out, "No %s.", blk->block_name) == -1) { + goto out; + } + goto out; + } + GB_FREE(exec); + if (asprintf(&iqn, "%s %s %s%s", GB_TGCLI_ISCSI, GB_DELETE, GB_TGCLI_IQN_PREFIX, blk->gbid) == -1) { goto out; -- cgit