Skip to content

Commit

Permalink
reload: add ability to reload a single block volume
Browse files Browse the repository at this point in the history
Problem:
-------
Right now, if any block volume is failed to load as part of service bringup
or node reboot, may be because of an issue from the backend, then there is
no way to reload that single block volume, we need to reload/restart all the\
block volumes present in the node just to load one block volume, this interrupts
ongoing  I/O (via this path) for all the volumes hosted within the node.

Solution:
--------
Add ability to reload a single block volume without touching other block volumes
in the node.

$ gluster-block help
usage:
  gluster-block [timeout <seconds>] <command> <volname[/blockname]> [<args>] [--json*]

commands:
[...]
  reload <volname/blockname>
        reload a block device.
[...]

Reviewed-by: Xiubo Li <[email protected]>
Signed-off-by: Prasanna Kumar Kalever <[email protected]>
  • Loading branch information
Prasanna Kumar Kalever authored and pkalever committed Oct 17, 2019
1 parent 77d8b69 commit 70165bd
Show file tree
Hide file tree
Showing 7 changed files with 532 additions and 3 deletions.
53 changes: 52 additions & 1 deletion cli/gluster-block.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"<HOST1[,HOST2,...]> [size] [--json*]"
# define GB_DELETE_HELP_STR "gluster-block delete <volname/blockname> " \
"[unlink-storage <yes|no>] [force] [--json*]"
# define GB_RELOAD_HELP_STR "gluster-block reload <volname/blockname> [--json*]"
# define GB_MODIFY_HELP_STR "gluster-block modify <volname/blockname> " \
"[auth <enable|disable>] [size <size> " \
"[force]] [--json*]"
Expand Down Expand Up @@ -57,7 +58,8 @@ typedef enum clioperations {
MODIFY_CLI = 5,
MODIFY_SIZE_CLI = 6,
REPLACE_CLI = 7,
GENCONF_CLI = 8
GENCONF_CLI = 8,
RELOAD_CLI = 9
} clioperations;


Expand Down Expand Up @@ -104,6 +106,7 @@ glusterBlockCliRPC_1(void *cobj, clioperations opt)
struct sockaddr_un saun = {0,};
blockCreateCli *create_obj;
blockDeleteCli *delete_obj;
blockReloadCli *reload_obj;
blockInfoCli *info_obj;
blockListCli *list_obj;
blockModifyCli *modify_obj;
Expand Down Expand Up @@ -193,6 +196,15 @@ glusterBlockCliRPC_1(void *cobj, clioperations opt)
goto out;
}
break;
case RELOAD_CLI:
reload_obj = cobj;
if (block_reload_cli_1(reload_obj, &reply, clnt) != RPC_SUCCESS) {
LOG("cli", GB_LOG_ERROR, "%s block %s reload on volume %s failed",
clnt_sperror(clnt, "block_reload_cli_1"),
reload_obj->block_name, reload_obj->volume);
goto out;
}
break;
case INFO_CLI:
info_obj = cobj;
if (block_info_cli_1(info_obj, &reply, clnt) != RPC_SUCCESS) {
Expand Down Expand Up @@ -318,6 +330,9 @@ glusterBlockHelp(void)
" replace <volname/blockname> <old-node> <new-node> [force]\n"
" replace operations.\n"
"\n"
" reload <volname/blockname>\n"
" reload a block device.\n"
"\n"
" genconfig <volname[,volume2,volume3,...]> enable-tpg <host>\n"
" generate the block volumes target configuration.\n"
"\n"
Expand Down Expand Up @@ -896,6 +911,35 @@ glusterBlockDelete(int argcount, char **options, int json)
return ret;
}

static int
glusterBlockReload(int argcount, char **options, int json)
{
blockReloadCli robj = {{0},};
int ret = -1;


GB_ARGCHECK_OR_RETURN(argcount, 2, "reload", GB_RELOAD_HELP_STR);
robj.json_resp = json;

if (glusterBlockParseVolumeBlock (options[1], robj.volume, robj.block_name,
sizeof(robj.volume), sizeof(robj.block_name),
GB_RELOAD_HELP_STR, "reload")) {
goto out;
}

getCommandString(&robj.cmd, argcount, options);

ret = glusterBlockCliRPC_1(&robj, RELOAD_CLI);
if (ret) {
LOG("cli", GB_LOG_ERROR,
"failed reload of block %s on volume %s",
robj.block_name, robj.volume);
}

out:

return ret;
}

static int
glusterBlockInfo(int argcount, char **options, int json)
Expand Down Expand Up @@ -1089,6 +1133,13 @@ glusterBlockParseArgs(int count, char **options, size_t opt, int json)
}
goto out;

case GB_CLI_RELOAD:
ret = glusterBlockReload(count, options, json);
if (ret) {
LOG("cli", GB_LOG_ERROR, FAILED_RELOAD);
}
goto out;

case GB_CLI_HELP:
case GB_CLI_HYPHEN_HELP:
case GB_CLI_USAGE:
Expand Down
2 changes: 1 addition & 1 deletion rpc/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ noinst_LTLIBRARIES = libgbrpc.la
libgbrpc_la_SOURCES = block_svc_routines.c block_info.c block_list.c \
block_create.c block_delete.c block_modify.c \
block_replace.c block_version.c block_genconfig.c \
block_common.h glfs-operations.c
block_reload.c block_common.h glfs-operations.c

noinst_HEADERS = glfs-operations.h

Expand Down
5 changes: 4 additions & 1 deletion rpc/block_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
# define GB_TGCLI_GLFS "targetcli " GB_TGCLI_GLFS_PATH
# define GB_TGCLI_CHECK GB_TGCLI_GLFS " ls | grep ' %s ' | grep '/%s ' > " DEVNULLPATH
# define GB_TGCLI_ISCSI_PATH "/iscsi"
# define GB_TGCLI_ISCSI "targetcli " GB_TGCLI_ISCSI_PATH
# define GB_TGCLI_ISCSI_CHECK GB_TGCLI_ISCSI " ls | grep ' %s%s ' > " DEVNULLPATH
# define GB_TGCLI_GLFS_SAVE GB_TGCLI_GLFS_PATH "/%s saveconfig"
# define GB_TGCLI_ATTRIBUTES "generate_node_acls=1 demo_mode_write_protect=0"
# define GB_TGCLI_IQN_PREFIX "iqn.2016-12.org.gluster-block:"
Expand Down Expand Up @@ -64,7 +66,8 @@ typedef enum operations {
LIST_SRV,
INFO_SRV,
VERSION_SRV,
GENCONFIG_SRV
GENCONFIG_SRV,
RELOAD_SRV
} operations;


Expand Down
Loading

0 comments on commit 70165bd

Please sign in to comment.