blobcli: support for deleting blobs

Add a new option, -w for "whack", to delete a blob.

Signed-off-by: Mike Gerdts <mgerdts@nvidia.com>
Change-Id: Ic7650d9cb6d2aa1cdfa020ad6389c497a481409c
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11254
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Mike Gerdts 2021-11-18 19:15:37 +00:00 committed by Jim Harris
parent ff4fd58b95
commit 3453391baf

View File

@ -86,6 +86,7 @@ enum cli_action_type {
CLI_SHELL_EXIT,
CLI_HELP,
CLI_RECOVER,
CLI_DELETE_BLOB,
};
#define BUFSIZE 255
@ -165,6 +166,7 @@ print_cmds(void)
printf("\t-s <blobid> | bs - show blob info or blobstore info\n");
printf("\t-S - enter interactive shell mode\n");
printf("\t-T <filename> - automated script mode\n");
printf("\t-w <blobid> - delete (whack) a blob\n");
printf("\t-x <blobid> name value - set xattr name/value pair\n");
printf("\t-X - exit when in interactive shell mode\n");
printf("\n");
@ -802,6 +804,24 @@ fill_blob_cb(void *arg1, struct spdk_blob *blob, int bserrno)
STARTING_IO_UNIT, NUM_IO_UNITS, write_cb, cli_context);
}
/*
* Callback for deleting a blob
*/
static void
delete_blob_cb(void *arg1, int bserrno)
{
struct cli_context_t *cli_context = arg1;
if (bserrno) {
unload_bs(cli_context, "Error in delete_blob callback",
bserrno);
return;
}
printf("Blob 0x%lx has been deleted.\n", cli_context->blobid);
unload_bs(cli_context, "", 0);
}
/*
* Multiple actions require us to open the bs first so here we use
* a common callback to set a bunch of values and then move on to
@ -861,6 +881,10 @@ load_bs_cb(void *arg1, struct spdk_blob_store *bs, int bserrno)
case CLI_RECOVER:
unload_bs(cli_context, "", 0);
break;
case CLI_DELETE_BLOB:
spdk_bs_delete_blob(cli_context->bs, cli_context->blobid,
delete_blob_cb, cli_context);
break;
default:
/* should never get here */
@ -1054,7 +1078,7 @@ cmd_parser(int argc, char **argv, struct cli_context_t *cli_context)
int cmd_chosen = 0;
char resp;
while ((op = getopt(argc, argv, "b:d:f:hij:l:m:n:p:r:s:DRST:Xx:")) != -1) {
while ((op = getopt(argc, argv, "b:d:f:hij:l:m:n:p:r:s:w:DRST:Xx:")) != -1) {
switch (op) {
case 'b':
if (strcmp(cli_context->bdev_name, "") == 0) {
@ -1197,6 +1221,11 @@ cmd_parser(int argc, char **argv, struct cli_context_t *cli_context)
cli_context->action = CLI_NONE;
}
break;
case 'w':
cmd_chosen++;
cli_context->action = CLI_DELETE_BLOB;
cli_context->blobid = spdk_strtoll(optarg, 0);
break;
case 'X':
cmd_chosen++;
cli_context->action = CLI_SHELL_EXIT;
@ -1471,6 +1500,7 @@ cli_start(void *arg1)
case CLI_IMPORT_BLOB:
case CLI_FILL:
case CLI_RECOVER:
case CLI_DELETE_BLOB:
load_bs(cli_context);
break;
case CLI_INIT_BS: