Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gluster-block: adopt to targetclid usage #203

Merged
merged 1 commit into from
Dec 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions daemon/gluster-blockd.c
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,9 @@ static int
blockNodeSanityCheck(void)
{
int ret;
bool use_targetclid = true;
char *global_opts;
char *tmp;


/*
Expand Down Expand Up @@ -516,6 +518,35 @@ blockNodeSanityCheck(void)
if (GB_ASPRINTF(&global_opts, GB_TGCLI_GLOBALS, gbConf->configShellLogFile) == -1) {
return ENOMEM;
}

tmp = gbRunnerGetOutput(TARGETCLI_VERSION);
if (!gbDependencyVersionCompare(TARGETCLI_DAEMON, tmp)) {
use_targetclid = false;
LOG("mgmt", GB_LOG_WARNING,
"targetclid required: %s, current version: %s, using cli mode",
GB_MIN_TARGETCLI_DAEMON_VERSION, tmp);
}
GB_FREE(tmp);

if (use_targetclid) {
tmp = global_opts;
/* Check if targetclid is running */
ret = gbRunner("ps aux ww | grep -w '[t]argetclid' > /dev/null");
if (ret) {
LOG("mgmt", GB_LOG_WARNING, "targetclid not running, using targetcli");
if (GB_ASPRINTF(&global_opts, "targetcli --disable-daemon; %s", tmp) == -1) {
GB_FREE(tmp);
return ENOMEM;
}
} else {
if (GB_ASPRINTF(&global_opts, "%s auto_use_daemon=true", tmp) == -1) {
GB_FREE(tmp);
return ENOMEM;
}
}
GB_FREE(tmp);
}

/* Set targetcli globals */
ret = gbRunner(global_opts);
GB_FREE(global_opts);
Expand Down
2 changes: 1 addition & 1 deletion rpc/block_create.c
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ block_create_common(blockCreate *blk, char *control, char *volServer,
goto out;
}

if (GB_ASPRINTF(&exec, "targetcli <<EOF\n%s\n%s\nEOF", tmp, save) == -1) {
if (GB_ASPRINTF(&exec, "targetcli <<EOF\n%s\n%s\nexit\nEOF", tmp, save) == -1) {
goto out;
}
GB_FREE(tmp);
Expand Down
2 changes: 1 addition & 1 deletion rpc/block_delete.c
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ block_delete_1_svc_st(blockDelete *blk, struct svc_req *rqstp)
goto out;
}

if (GB_ASPRINTF(&exec, "targetcli <<EOF\n%s\n%s\nEOF", backstore, iqn) == -1) {
if (GB_ASPRINTF(&exec, "targetcli <<EOF\n%s\n%s\nexit\nEOF", backstore, iqn) == -1) {
goto out;
}

Expand Down
4 changes: 2 additions & 2 deletions rpc/block_modify.c
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@ block_modify_1_svc_st(blockModify *blk, struct svc_req *rqstp)
goto out;
}

if (GB_ASPRINTF(&exec, "targetcli <<EOF\n%s\n%s\nEOF", tmp, save) == -1) {
if (GB_ASPRINTF(&exec, "targetcli <<EOF\n%s\n%s\nexit\nEOF", tmp, save) == -1) {
goto out;
}

Expand Down Expand Up @@ -1084,7 +1084,7 @@ block_modify_size_1_svc_st(blockModifySize *blk, struct svc_req *rqstp)
goto out;
}

if (GB_ASPRINTF(&exec, "targetcli <<EOF\n%s\n%s\nEOF", tmp, save) == -1) {
if (GB_ASPRINTF(&exec, "targetcli <<EOF\n%s\n%s\nexit\nEOF", tmp, save) == -1) {
goto out;
}

Expand Down
2 changes: 1 addition & 1 deletion rpc/block_replace.c
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ block_replace_1_svc_st(blockReplace *blk, struct svc_req *rqstp)
}

if (GB_ASPRINTF(&exec,
"targetcli <<EOF\n%s delete %s ip_port=3260\n%s create %s\n%s\nEOF",
"targetcli <<EOF\n%s delete %s ip_port=3260\n%s create %s\n%s\nexit\nEOF",
path, blk->ripaddr, path, blk->ipaddr, save) == -1) {
goto out;
}
Expand Down
2 changes: 1 addition & 1 deletion systemd/gluster-block-target.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Conflicts=target.service
Requisite=glusterd.service
BindsTo=tcmu-runner.service
After=glusterd.service tcmu-runner.service
After=glusterd.service tcmu-runner.service targetclid.service

[Service]
ExecStop=
Expand Down
1 change: 1 addition & 0 deletions systemd/gluster-blockd.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Description=Gluster block storage utility
Requisite=glusterd.service
Requires=rpcbind.service
BindsTo=gluster-block-target.service
Wants=targetclid.service
After=gluster-block-target.service rpcbind.service

[Service]
Expand Down
5 changes: 5 additions & 0 deletions utils/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,11 @@ gbDependencyVersionCompare(int dependencyName, char *version)
ret = true;
}
break;
case TARGETCLI_DAEMON:
if (DEPENDENCY_VERSION(vNum[0], vNum[1], vNum[2]) >= GB_MIN_TARGETCLI_DAEMON_VERSION_CODE) {
ret = true;
}
break;
}

GB_FREE(verStr);
Expand Down
1 change: 1 addition & 0 deletions utils/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,7 @@ typedef enum gbDependencies {
RTSLIB_RELOAD = 5,
CONFIGSHELL_SEMICOLON = 6,
TCMURUNNER_IO_TIMEOUT = 7,
TARGETCLI_DAEMON = 8,
} gbDependencies;

int initGbConfig(void);
Expand Down
2 changes: 2 additions & 0 deletions version.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
# define GB_MIN_RTSLIB_RELOAD_VERSION "2.1.71"
# define GB_MIN_CONFIGSHELL_SEM_VERSION "1.1.25"
# define GB_MIN_TCMURUNNER_IO_TIMEOUT_VERSION "1.5.0"
# define GB_MIN_TARGETCLI_DAEMON_VERSION "2.1.fb51"

# define GB_MIN_TCMURUNNER_VERSION_CODE DEPENDENCY_VERSION(1, 1, 3)
# define GB_MIN_TARGETCLI_VERSION_CODE DEPENDENCY_VERSION(2, 1, 49)
Expand All @@ -42,5 +43,6 @@
# define GB_MIN_RTSLIB_RELOAD_VERSION_CODE DEPENDENCY_VERSION(2, 1, 71)
# define GB_MIN_CONFIGSHELL_SEM_VERSION_CODE DEPENDENCY_VERSION(1, 1, 25)
# define GB_MIN_TCMURUNNER_IO_TIMEOUT_VERSION_CODE DEPENDENCY_VERSION(1, 5, 0)
# define GB_MIN_TARGETCLI_DAEMON_VERSION_CODE DEPENDENCY_VERSION(2, 1, 51)

# endif /* _VERSION_H */