Skip to content

Commit

Permalink
gluster-block: adopt to targetclid usage
Browse files Browse the repository at this point in the history
Requires: open-iscsi/targetcli-fb#132

Signed-off-by: Prasanna Kumar Kalever <[email protected]>
  • Loading branch information
Prasanna Kumar Kalever committed Nov 4, 2019
1 parent ec14ce7 commit b18d732
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 7 deletions.
31 changes: 31 additions & 0 deletions daemon/gluster-blockd.c
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,9 @@ static int
blockNodeSanityCheck(void)
{
int ret;
bool use_targetclid = true;
char *global_opts;
char *tmp;


/*
Expand Down Expand Up @@ -508,6 +510,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 @@ -672,7 +672,7 @@ block_create_common(blockCreate *blk, char *control, char *volServer, char *prio
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 @@ -817,7 +817,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
6 changes: 5 additions & 1 deletion utils/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,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 @@ -665,6 +665,7 @@ typedef enum gbDependencies {
RTSLIB_BLKSIZE = 3,
TARGETCLI_RELOAD = 4,
RTSLIB_RELOAD = 5,
TARGETCLI_DAEMON = 6,
} 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 @@ -31,11 +31,13 @@
# define GB_MIN_RTSLIB_BLKSIZE_VERSION "2.1.69"
# define GB_MIN_TARGETCLI_RELOAD_VERSION "2.1.fb50"
# define GB_MIN_RTSLIB_RELOAD_VERSION "2.1.71"
# 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)
# define GB_MIN_RTSLIB_BLKSIZE_VERSION_CODE DEPENDENCY_VERSION(2, 1, 69)
# define GB_MIN_TARGETCLI_RELOAD_VERSION_CODE DEPENDENCY_VERSION(2, 1, 50)
# define GB_MIN_RTSLIB_RELOAD_VERSION_CODE DEPENDENCY_VERSION(2, 1, 71)
# define GB_MIN_TARGETCLI_DAEMON_VERSION_CODE DEPENDENCY_VERSION(2, 1, 51)

# endif /* _VERSION_H */

0 comments on commit b18d732

Please sign in to comment.