bdev/iscsi: save string url rather than struct iscsi_url
iscsi_url is not need after bdev creation. Also implementing get_config RPC call in next patches is quite problematic as information how bdev is created using iSCSI URL is lost (eg username). Change-Id: I8b097617c09bd4636c28531ca20a59919b2b4f84 Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com> Reviewed-on: https://review.gerrithub.io/407769 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ziye Yang <optimistyzy@gmail.com>
This commit is contained in:
parent
81866c26d8
commit
5f2ad2620b
@ -73,7 +73,7 @@ struct bdev_iscsi_lun {
|
|||||||
struct spdk_bdev bdev;
|
struct spdk_bdev bdev;
|
||||||
struct iscsi_context *context;
|
struct iscsi_context *context;
|
||||||
char *initiator_iqn;
|
char *initiator_iqn;
|
||||||
struct iscsi_url *url;
|
char *url;
|
||||||
pthread_mutex_t mutex;
|
pthread_mutex_t mutex;
|
||||||
uint32_t ch_count;
|
uint32_t ch_count;
|
||||||
struct bdev_iscsi_io_channel *master_ch;
|
struct bdev_iscsi_io_channel *master_ch;
|
||||||
@ -87,7 +87,7 @@ struct bdev_iscsi_io_channel {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct bdev_iscsi_conn_req {
|
struct bdev_iscsi_conn_req {
|
||||||
struct iscsi_url *url;
|
char *url;
|
||||||
char *bdev_name;
|
char *bdev_name;
|
||||||
struct iscsi_context *context;
|
struct iscsi_context *context;
|
||||||
TAILQ_ENTRY(bdev_iscsi_conn_req) link;
|
TAILQ_ENTRY(bdev_iscsi_conn_req) link;
|
||||||
@ -125,6 +125,7 @@ static void iscsi_free_lun(struct bdev_iscsi_lun *lun)
|
|||||||
{
|
{
|
||||||
assert(lun != NULL);
|
assert(lun != NULL);
|
||||||
free(lun->bdev.name);
|
free(lun->bdev.name);
|
||||||
|
free(lun->url);
|
||||||
free(lun);
|
free(lun);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +134,6 @@ bdev_iscsi_lun_cleanup(struct bdev_iscsi_lun *lun)
|
|||||||
{
|
{
|
||||||
TAILQ_REMOVE(&g_iscsi_lun_head, lun, link);
|
TAILQ_REMOVE(&g_iscsi_lun_head, lun, link);
|
||||||
iscsi_destroy_context(lun->context);
|
iscsi_destroy_context(lun->context);
|
||||||
iscsi_destroy_url(lun->url);
|
|
||||||
iscsi_free_lun(lun);
|
iscsi_free_lun(lun);
|
||||||
if (TAILQ_EMPTY(&g_iscsi_lun_head)) {
|
if (TAILQ_EMPTY(&g_iscsi_lun_head)) {
|
||||||
bdev_iscsi_finish_done();
|
bdev_iscsi_finish_done();
|
||||||
@ -429,8 +429,8 @@ bdev_iscsi_dump_info_json(void *ctx, struct spdk_json_write_ctx *w)
|
|||||||
spdk_json_write_object_begin(w);
|
spdk_json_write_object_begin(w);
|
||||||
spdk_json_write_name(w, "initiator_name");
|
spdk_json_write_name(w, "initiator_name");
|
||||||
spdk_json_write_string(w, lun->initiator_iqn);
|
spdk_json_write_string(w, lun->initiator_iqn);
|
||||||
spdk_json_write_name(w, "target");
|
spdk_json_write_name(w, "url");
|
||||||
spdk_json_write_string(w, lun->url->target);
|
spdk_json_write_string(w, lun->url);
|
||||||
spdk_json_write_object_end(w);
|
spdk_json_write_object_end(w);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -445,7 +445,7 @@ static const struct spdk_bdev_fn_table iscsi_fn_table = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static struct spdk_bdev *
|
static struct spdk_bdev *
|
||||||
create_iscsi_lun(struct iscsi_context *context, struct iscsi_url *url,
|
create_iscsi_lun(struct iscsi_context *context, char *url,
|
||||||
const char *name, uint64_t num_blocks, uint32_t block_size)
|
const char *name, uint64_t num_blocks, uint32_t block_size)
|
||||||
{
|
{
|
||||||
struct bdev_iscsi_lun *lun;
|
struct bdev_iscsi_lun *lun;
|
||||||
@ -581,6 +581,7 @@ static int
|
|||||||
create_iscsi_disk(const char *bdev_name, const char *url, const char *initiator_iqn)
|
create_iscsi_disk(const char *bdev_name, const char *url, const char *initiator_iqn)
|
||||||
{
|
{
|
||||||
struct bdev_iscsi_conn_req *req;
|
struct bdev_iscsi_conn_req *req;
|
||||||
|
struct iscsi_url *iscsi_url = NULL;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if (!bdev_name || !url || !initiator_iqn || strlen(initiator_iqn) == 0) {
|
if (!bdev_name || !url || !initiator_iqn || strlen(initiator_iqn) == 0) {
|
||||||
@ -594,15 +595,16 @@ create_iscsi_disk(const char *bdev_name, const char *url, const char *initiator_
|
|||||||
}
|
}
|
||||||
|
|
||||||
req->bdev_name = strdup(bdev_name);
|
req->bdev_name = strdup(bdev_name);
|
||||||
|
req->url = strdup(url);
|
||||||
req->context = iscsi_create_context(initiator_iqn);
|
req->context = iscsi_create_context(initiator_iqn);
|
||||||
if (!req->bdev_name || !req->context) {
|
if (!req->bdev_name || !req->url || !req->context) {
|
||||||
SPDK_ERRLOG("Out of memory\n");
|
SPDK_ERRLOG("Out of memory\n");
|
||||||
rc = -ENOMEM;
|
rc = -ENOMEM;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
req->url = iscsi_parse_full_url(req->context, url);
|
iscsi_url = iscsi_parse_full_url(req->context, url);
|
||||||
if (url == NULL) {
|
if (iscsi_url == NULL) {
|
||||||
SPDK_ERRLOG("could not parse URL: %s\n", iscsi_get_error(req->context));
|
SPDK_ERRLOG("could not parse URL: %s\n", iscsi_get_error(req->context));
|
||||||
rc = -EINVAL;
|
rc = -EINVAL;
|
||||||
goto err;
|
goto err;
|
||||||
@ -610,20 +612,21 @@ create_iscsi_disk(const char *bdev_name, const char *url, const char *initiator_
|
|||||||
|
|
||||||
rc = iscsi_set_session_type(req->context, ISCSI_SESSION_NORMAL);
|
rc = iscsi_set_session_type(req->context, ISCSI_SESSION_NORMAL);
|
||||||
rc = rc ? rc : iscsi_set_header_digest(req->context, ISCSI_HEADER_DIGEST_NONE);
|
rc = rc ? rc : iscsi_set_header_digest(req->context, ISCSI_HEADER_DIGEST_NONE);
|
||||||
rc = rc ? rc : iscsi_full_connect_async(req->context, req->url->portal, req->url->lun,
|
rc = rc ? rc : iscsi_full_connect_async(req->context, iscsi_url->portal, iscsi_url->lun,
|
||||||
iscsi_connect_cb, req);
|
iscsi_connect_cb, req);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
SPDK_ERRLOG("Failed to connect provided URL=%s: %s\n", url, iscsi_get_error(req->context));
|
SPDK_ERRLOG("Failed to connect provided URL=%s: %s\n", url, iscsi_get_error(req->context));
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
iscsi_destroy_url(iscsi_url);
|
||||||
TAILQ_INSERT_TAIL(&g_iscsi_conn_req, req, link);
|
TAILQ_INSERT_TAIL(&g_iscsi_conn_req, req, link);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
/* iscsi_destroy_url() is not NULL-proof */
|
/* iscsi_destroy_url() is not NULL-proof */
|
||||||
if (req->url) {
|
if (iscsi_url) {
|
||||||
iscsi_destroy_url(req->url);
|
iscsi_destroy_url(iscsi_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req->context) {
|
if (req->context) {
|
||||||
@ -631,6 +634,7 @@ err:
|
|||||||
}
|
}
|
||||||
|
|
||||||
free(req->bdev_name);
|
free(req->bdev_name);
|
||||||
|
free(req->url);
|
||||||
free(req);
|
free(req);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user