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 Sep 26, 2019
1 parent 08ebf97 commit 2605b43
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 6 deletions.
20 changes: 20 additions & 0 deletions daemon/gluster-blockd.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ blockNodeSanityCheck(void)
{
int ret;
char *global_opts;
char *tmp;


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

/* Check if targetclid is running */
tmp = global_opts;
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, "%s auto_use_daemon=false", 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

0 comments on commit 2605b43

Please sign in to comment.