From e6ed5b53cf33b4315ee2846a9f773cd672a5de8c Mon Sep 17 00:00:00 2001 From: Prasanna Kumar Kalever Date: Thu, 3 Aug 2017 14:35:37 +0530 Subject: delete/rollback: check for matching gbid before deleting a block Currently we are just checking for blockname in targetcli list output, if it exist we will delete the backend. We do not check if block belongs to a given volume (say vol1), because of which a rollback on a failure to create block with same name, on same node but on a different volume (say vol2) deletes block backend belonging to vol1. Solution: only if blockname + gbid matches continue delete. Change-Id: I396c228dad3cf4f51cc6676a266b837bdf6040c7 Signed-off-by: Prasanna Kumar Kalever --- rpc/block_svc_routines.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/rpc/block_svc_routines.c b/rpc/block_svc_routines.c index c8fb18d..c0c437f 100644 --- a/rpc/block_svc_routines.c +++ b/rpc/block_svc_routines.c @@ -27,7 +27,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_CHECK GB_TGCLI_GLFS " ls | grep ' %s ' | grep '/%s ' > " DEVNULLPATH # define GB_TGCLI_ISCSI_PATH "/iscsi" # define GB_TGCLI_SAVE "/ saveconfig" # define GB_TGCLI_ATTRIBUTES "generate_node_acls=1 demo_mode_write_protect=0" @@ -2410,7 +2410,10 @@ block_delete_1_svc_st(blockDelete *blk, struct svc_req *rqstp) } reply->exit = -1; - if (GB_ASPRINTF(&exec, GB_TGCLI_CHECK, blk->block_name) == -1) { + if (GB_ASPRINTF(&exec, GB_TGCLI_CHECK, blk->block_name, blk->gbid) == -1) { + LOG("mgmt", GB_LOG_WARNING, + "block backend with name '%s' doesn't exist with matching gbid %s", + blk->block_name, blk->gbid); goto out; } @@ -2483,7 +2486,10 @@ block_modify_1_svc_st(blockModify *blk, struct svc_req *rqstp) } reply->exit = -1; - if (GB_ASPRINTF(&exec, GB_TGCLI_CHECK, blk->block_name) == -1) { + if (GB_ASPRINTF(&exec, GB_TGCLI_CHECK, blk->block_name, blk->gbid) == -1) { + LOG("mgmt", GB_LOG_WARNING, + "block backend with name '%s' doesn't exist with matching gbid %s, volume '%s'", + blk->block_name, blk->gbid, blk->volume); goto out; } -- cgit