lib/iscsi: Rename iSCSI global data from g_spdk_iscsi to g_iscsi
The following patch will remove the "spdk_" prefix from iSCSI internal APIs. The iSCSI global data g_spdk_iscsi is also local in SPDK iSCSI library. Hence rename it by g_iscsi for consistency. Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: If35e9d58b1388fd725a505ee9be870e414c37ba5 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1831 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Paul Luse <paul.e.luse@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
parent
11e25ed27e
commit
be1489b9b9
@ -220,9 +220,9 @@ spdk_iscsi_conn_construct(struct spdk_iscsi_portal *portal,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
pthread_mutex_lock(&g_iscsi.mutex);
|
||||||
conn->timeout = g_spdk_iscsi.timeout * spdk_get_ticks_hz(); /* seconds to TSC */
|
conn->timeout = g_iscsi.timeout * spdk_get_ticks_hz(); /* seconds to TSC */
|
||||||
conn->nopininterval = g_spdk_iscsi.nopininterval;
|
conn->nopininterval = g_iscsi.nopininterval;
|
||||||
conn->nopininterval *= spdk_get_ticks_hz(); /* seconds to TSC */
|
conn->nopininterval *= spdk_get_ticks_hz(); /* seconds to TSC */
|
||||||
conn->nop_outstanding = false;
|
conn->nop_outstanding = false;
|
||||||
conn->data_out_cnt = 0;
|
conn->data_out_cnt = 0;
|
||||||
@ -231,7 +231,7 @@ spdk_iscsi_conn_construct(struct spdk_iscsi_portal *portal,
|
|||||||
conn->require_chap = portal->group->require_chap;
|
conn->require_chap = portal->group->require_chap;
|
||||||
conn->mutual_chap = portal->group->mutual_chap;
|
conn->mutual_chap = portal->group->mutual_chap;
|
||||||
conn->chap_group = portal->group->chap_group;
|
conn->chap_group = portal->group->chap_group;
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
conn->MaxRecvDataSegmentLength = 8192; /* RFC3720(12.12) */
|
conn->MaxRecvDataSegmentLength = 8192; /* RFC3720(12.12) */
|
||||||
|
|
||||||
conn->portal = portal;
|
conn->portal = portal;
|
||||||
@ -294,7 +294,7 @@ spdk_iscsi_conn_construct(struct spdk_iscsi_portal *portal,
|
|||||||
conn->pending_task_cnt = 0;
|
conn->pending_task_cnt = 0;
|
||||||
|
|
||||||
/* Get the first poll group. */
|
/* Get the first poll group. */
|
||||||
pg = TAILQ_FIRST(&g_spdk_iscsi.poll_group_head);
|
pg = TAILQ_FIRST(&g_iscsi.poll_group_head);
|
||||||
if (pg == NULL) {
|
if (pg == NULL) {
|
||||||
SPDK_ERRLOG("There is no poll group.\n");
|
SPDK_ERRLOG("There is no poll group.\n");
|
||||||
assert(false);
|
assert(false);
|
||||||
@ -376,7 +376,7 @@ iscsi_conn_cleanup_backend(struct spdk_iscsi_conn *conn)
|
|||||||
|
|
||||||
if (conn->sess->connections > 1) {
|
if (conn->sess->connections > 1) {
|
||||||
/* connection specific cleanup */
|
/* connection specific cleanup */
|
||||||
} else if (!g_spdk_iscsi.AllowDuplicateIsid) {
|
} else if (!g_iscsi.AllowDuplicateIsid) {
|
||||||
/* clean up all tasks to all LUNs for session */
|
/* clean up all tasks to all LUNs for session */
|
||||||
target = conn->sess->target;
|
target = conn->sess->target;
|
||||||
if (target != NULL) {
|
if (target != NULL) {
|
||||||
@ -1579,7 +1579,7 @@ spdk_iscsi_conn_schedule(struct spdk_iscsi_conn *conn)
|
|||||||
* thread. */
|
* thread. */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
pthread_mutex_lock(&g_iscsi.mutex);
|
||||||
|
|
||||||
target = conn->sess->target;
|
target = conn->sess->target;
|
||||||
pthread_mutex_lock(&target->mutex);
|
pthread_mutex_lock(&target->mutex);
|
||||||
@ -1590,7 +1590,7 @@ spdk_iscsi_conn_schedule(struct spdk_iscsi_conn *conn)
|
|||||||
* Pick a poll group using round-robin.
|
* Pick a poll group using round-robin.
|
||||||
*/
|
*/
|
||||||
if (g_next_pg == NULL) {
|
if (g_next_pg == NULL) {
|
||||||
g_next_pg = TAILQ_FIRST(&g_spdk_iscsi.poll_group_head);
|
g_next_pg = TAILQ_FIRST(&g_iscsi.poll_group_head);
|
||||||
assert(g_next_pg != NULL);
|
assert(g_next_pg != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1607,7 +1607,7 @@ spdk_iscsi_conn_schedule(struct spdk_iscsi_conn *conn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&target->mutex);
|
pthread_mutex_unlock(&target->mutex);
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
|
|
||||||
assert(spdk_io_channel_get_thread(spdk_io_channel_from_ctx(conn->pg)) ==
|
assert(spdk_io_channel_get_thread(spdk_io_channel_from_ctx(conn->pg)) ==
|
||||||
spdk_get_thread());
|
spdk_get_thread());
|
||||||
|
@ -449,13 +449,13 @@ spdk_iscsi_init_grp_register(struct spdk_iscsi_init_grp *ig)
|
|||||||
|
|
||||||
assert(ig != NULL);
|
assert(ig != NULL);
|
||||||
|
|
||||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
pthread_mutex_lock(&g_iscsi.mutex);
|
||||||
tmp = spdk_iscsi_init_grp_find_by_tag(ig->tag);
|
tmp = spdk_iscsi_init_grp_find_by_tag(ig->tag);
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
TAILQ_INSERT_TAIL(&g_spdk_iscsi.ig_head, ig, tailq);
|
TAILQ_INSERT_TAIL(&g_iscsi.ig_head, ig, tailq);
|
||||||
rc = 0;
|
rc = 0;
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@ -525,10 +525,10 @@ spdk_iscsi_init_grp_add_initiators_from_initiator_list(int tag,
|
|||||||
"add initiator to initiator group: tag=%d, #initiators=%d, #masks=%d\n",
|
"add initiator to initiator group: tag=%d, #initiators=%d, #masks=%d\n",
|
||||||
tag, num_initiator_names, num_initiator_masks);
|
tag, num_initiator_names, num_initiator_masks);
|
||||||
|
|
||||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
pthread_mutex_lock(&g_iscsi.mutex);
|
||||||
ig = spdk_iscsi_init_grp_find_by_tag(tag);
|
ig = spdk_iscsi_init_grp_find_by_tag(tag);
|
||||||
if (!ig) {
|
if (!ig) {
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
SPDK_ERRLOG("initiator group (%d) is not found\n", tag);
|
SPDK_ERRLOG("initiator group (%d) is not found\n", tag);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@ -549,7 +549,7 @@ spdk_iscsi_init_grp_add_initiators_from_initiator_list(int tag,
|
|||||||
}
|
}
|
||||||
|
|
||||||
error:
|
error:
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -567,10 +567,10 @@ spdk_iscsi_init_grp_delete_initiators_from_initiator_list(int tag,
|
|||||||
"delete initiator from initiator group: tag=%d, #initiators=%d, #masks=%d\n",
|
"delete initiator from initiator group: tag=%d, #initiators=%d, #masks=%d\n",
|
||||||
tag, num_initiator_names, num_initiator_masks);
|
tag, num_initiator_names, num_initiator_masks);
|
||||||
|
|
||||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
pthread_mutex_lock(&g_iscsi.mutex);
|
||||||
ig = spdk_iscsi_init_grp_find_by_tag(tag);
|
ig = spdk_iscsi_init_grp_find_by_tag(tag);
|
||||||
if (!ig) {
|
if (!ig) {
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
SPDK_ERRLOG("initiator group (%d) is not found\n", tag);
|
SPDK_ERRLOG("initiator group (%d) is not found\n", tag);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@ -592,7 +592,7 @@ spdk_iscsi_init_grp_delete_initiators_from_initiator_list(int tag,
|
|||||||
}
|
}
|
||||||
|
|
||||||
error:
|
error:
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -613,7 +613,7 @@ spdk_iscsi_init_grp_find_by_tag(int tag)
|
|||||||
{
|
{
|
||||||
struct spdk_iscsi_init_grp *ig;
|
struct spdk_iscsi_init_grp *ig;
|
||||||
|
|
||||||
TAILQ_FOREACH(ig, &g_spdk_iscsi.ig_head, tailq) {
|
TAILQ_FOREACH(ig, &g_iscsi.ig_head, tailq) {
|
||||||
if (ig->tag == tag) {
|
if (ig->tag == tag) {
|
||||||
return ig;
|
return ig;
|
||||||
}
|
}
|
||||||
@ -652,12 +652,12 @@ spdk_iscsi_init_grps_destroy(void)
|
|||||||
struct spdk_iscsi_init_grp *ig, *tmp;
|
struct spdk_iscsi_init_grp *ig, *tmp;
|
||||||
|
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "spdk_iscsi_init_grp_array_destroy\n");
|
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "spdk_iscsi_init_grp_array_destroy\n");
|
||||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
pthread_mutex_lock(&g_iscsi.mutex);
|
||||||
TAILQ_FOREACH_SAFE(ig, &g_spdk_iscsi.ig_head, tailq, tmp) {
|
TAILQ_FOREACH_SAFE(ig, &g_iscsi.ig_head, tailq, tmp) {
|
||||||
TAILQ_REMOVE(&g_spdk_iscsi.ig_head, ig, tailq);
|
TAILQ_REMOVE(&g_iscsi.ig_head, ig, tailq);
|
||||||
spdk_iscsi_init_grp_destroy(ig);
|
spdk_iscsi_init_grp_destroy(ig);
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct spdk_iscsi_init_grp *
|
struct spdk_iscsi_init_grp *
|
||||||
@ -665,15 +665,15 @@ spdk_iscsi_init_grp_unregister(int tag)
|
|||||||
{
|
{
|
||||||
struct spdk_iscsi_init_grp *ig;
|
struct spdk_iscsi_init_grp *ig;
|
||||||
|
|
||||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
pthread_mutex_lock(&g_iscsi.mutex);
|
||||||
TAILQ_FOREACH(ig, &g_spdk_iscsi.ig_head, tailq) {
|
TAILQ_FOREACH(ig, &g_iscsi.ig_head, tailq) {
|
||||||
if (ig->tag == tag) {
|
if (ig->tag == tag) {
|
||||||
TAILQ_REMOVE(&g_spdk_iscsi.ig_head, ig, tailq);
|
TAILQ_REMOVE(&g_iscsi.ig_head, ig, tailq);
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
return ig;
|
return ig;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -706,7 +706,7 @@ spdk_iscsi_init_grps_config_text(FILE *fp)
|
|||||||
fprintf(fp, "%s", initiator_group_section);
|
fprintf(fp, "%s", initiator_group_section);
|
||||||
|
|
||||||
/* Dump initiator groups */
|
/* Dump initiator groups */
|
||||||
TAILQ_FOREACH(ig, &g_spdk_iscsi.ig_head, tailq) {
|
TAILQ_FOREACH(ig, &g_iscsi.ig_head, tailq) {
|
||||||
if (NULL == ig) { continue; }
|
if (NULL == ig) { continue; }
|
||||||
fprintf(fp, INITIATOR_GROUP_TMPL, ig->tag, ig->tag);
|
fprintf(fp, INITIATOR_GROUP_TMPL, ig->tag, ig->tag);
|
||||||
|
|
||||||
@ -771,7 +771,7 @@ spdk_iscsi_init_grps_info_json(struct spdk_json_write_ctx *w)
|
|||||||
{
|
{
|
||||||
struct spdk_iscsi_init_grp *ig;
|
struct spdk_iscsi_init_grp *ig;
|
||||||
|
|
||||||
TAILQ_FOREACH(ig, &g_spdk_iscsi.ig_head, tailq) {
|
TAILQ_FOREACH(ig, &g_iscsi.ig_head, tailq) {
|
||||||
iscsi_init_grp_info_json(ig, w);
|
iscsi_init_grp_info_json(ig, w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -781,7 +781,7 @@ spdk_iscsi_init_grps_config_json(struct spdk_json_write_ctx *w)
|
|||||||
{
|
{
|
||||||
struct spdk_iscsi_init_grp *ig;
|
struct spdk_iscsi_init_grp *ig;
|
||||||
|
|
||||||
TAILQ_FOREACH(ig, &g_spdk_iscsi.ig_head, tailq) {
|
TAILQ_FOREACH(ig, &g_iscsi.ig_head, tailq) {
|
||||||
iscsi_init_grp_config_json(ig, w);
|
iscsi_init_grp_config_json(ig, w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,14 +67,14 @@
|
|||||||
#define HAVE_ARC4RANDOM 1
|
#define HAVE_ARC4RANDOM 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct spdk_iscsi_globals g_spdk_iscsi = {
|
struct spdk_iscsi_globals g_iscsi = {
|
||||||
.mutex = PTHREAD_MUTEX_INITIALIZER,
|
.mutex = PTHREAD_MUTEX_INITIALIZER,
|
||||||
.portal_head = TAILQ_HEAD_INITIALIZER(g_spdk_iscsi.portal_head),
|
.portal_head = TAILQ_HEAD_INITIALIZER(g_iscsi.portal_head),
|
||||||
.pg_head = TAILQ_HEAD_INITIALIZER(g_spdk_iscsi.pg_head),
|
.pg_head = TAILQ_HEAD_INITIALIZER(g_iscsi.pg_head),
|
||||||
.ig_head = TAILQ_HEAD_INITIALIZER(g_spdk_iscsi.ig_head),
|
.ig_head = TAILQ_HEAD_INITIALIZER(g_iscsi.ig_head),
|
||||||
.target_head = TAILQ_HEAD_INITIALIZER(g_spdk_iscsi.target_head),
|
.target_head = TAILQ_HEAD_INITIALIZER(g_iscsi.target_head),
|
||||||
.auth_group_head = TAILQ_HEAD_INITIALIZER(g_spdk_iscsi.auth_group_head),
|
.auth_group_head = TAILQ_HEAD_INITIALIZER(g_iscsi.auth_group_head),
|
||||||
.poll_group_head = TAILQ_HEAD_INITIALIZER(g_spdk_iscsi.poll_group_head),
|
.poll_group_head = TAILQ_HEAD_INITIALIZER(g_iscsi.poll_group_head),
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MATCH_DIGEST_WORD(BUF, CRC32C) \
|
#define MATCH_DIGEST_WORD(BUF, CRC32C) \
|
||||||
@ -546,7 +546,7 @@ void spdk_free_sess(struct spdk_iscsi_sess *sess)
|
|||||||
spdk_iscsi_param_free(sess->params);
|
spdk_iscsi_param_free(sess->params);
|
||||||
free(sess->conns);
|
free(sess->conns);
|
||||||
spdk_scsi_port_free(&sess->initiator_port);
|
spdk_scsi_port_free(&sess->initiator_port);
|
||||||
spdk_mempool_put(g_spdk_iscsi.session_pool, (void *)sess);
|
spdk_mempool_put(g_iscsi.session_pool, (void *)sess);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -557,30 +557,30 @@ create_iscsi_sess(struct spdk_iscsi_conn *conn,
|
|||||||
struct spdk_iscsi_sess *sess;
|
struct spdk_iscsi_sess *sess;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
sess = spdk_mempool_get(g_spdk_iscsi.session_pool);
|
sess = spdk_mempool_get(g_iscsi.session_pool);
|
||||||
if (!sess) {
|
if (!sess) {
|
||||||
SPDK_ERRLOG("Unable to get session object\n");
|
SPDK_ERRLOG("Unable to get session object\n");
|
||||||
SPDK_ERRLOG("MaxSessions set to %d\n", g_spdk_iscsi.MaxSessions);
|
SPDK_ERRLOG("MaxSessions set to %d\n", g_iscsi.MaxSessions);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* configuration values */
|
/* configuration values */
|
||||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
pthread_mutex_lock(&g_iscsi.mutex);
|
||||||
|
|
||||||
sess->MaxConnections = g_spdk_iscsi.MaxConnectionsPerSession;
|
sess->MaxConnections = g_iscsi.MaxConnectionsPerSession;
|
||||||
sess->MaxOutstandingR2T = DEFAULT_MAXOUTSTANDINGR2T;
|
sess->MaxOutstandingR2T = DEFAULT_MAXOUTSTANDINGR2T;
|
||||||
|
|
||||||
sess->DefaultTime2Wait = g_spdk_iscsi.DefaultTime2Wait;
|
sess->DefaultTime2Wait = g_iscsi.DefaultTime2Wait;
|
||||||
sess->DefaultTime2Retain = g_spdk_iscsi.DefaultTime2Retain;
|
sess->DefaultTime2Retain = g_iscsi.DefaultTime2Retain;
|
||||||
sess->FirstBurstLength = g_spdk_iscsi.FirstBurstLength;
|
sess->FirstBurstLength = g_iscsi.FirstBurstLength;
|
||||||
sess->MaxBurstLength = SPDK_ISCSI_MAX_BURST_LENGTH;
|
sess->MaxBurstLength = SPDK_ISCSI_MAX_BURST_LENGTH;
|
||||||
sess->InitialR2T = DEFAULT_INITIALR2T;
|
sess->InitialR2T = DEFAULT_INITIALR2T;
|
||||||
sess->ImmediateData = g_spdk_iscsi.ImmediateData;
|
sess->ImmediateData = g_iscsi.ImmediateData;
|
||||||
sess->DataPDUInOrder = DEFAULT_DATAPDUINORDER;
|
sess->DataPDUInOrder = DEFAULT_DATAPDUINORDER;
|
||||||
sess->DataSequenceInOrder = DEFAULT_DATASEQUENCEINORDER;
|
sess->DataSequenceInOrder = DEFAULT_DATASEQUENCEINORDER;
|
||||||
sess->ErrorRecoveryLevel = g_spdk_iscsi.ErrorRecoveryLevel;
|
sess->ErrorRecoveryLevel = g_iscsi.ErrorRecoveryLevel;
|
||||||
|
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
|
|
||||||
sess->tag = conn->pg_tag;
|
sess->tag = conn->pg_tag;
|
||||||
|
|
||||||
@ -708,11 +708,11 @@ get_iscsi_sess_by_tsih(uint16_t tsih)
|
|||||||
{
|
{
|
||||||
struct spdk_iscsi_sess *session;
|
struct spdk_iscsi_sess *session;
|
||||||
|
|
||||||
if (tsih == 0 || tsih > g_spdk_iscsi.MaxSessions) {
|
if (tsih == 0 || tsih > g_iscsi.MaxSessions) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
session = g_spdk_iscsi.session[tsih - 1];
|
session = g_iscsi.session[tsih - 1];
|
||||||
assert(tsih == session->tsih);
|
assert(tsih == session->tsih);
|
||||||
|
|
||||||
return session;
|
return session;
|
||||||
@ -1073,9 +1073,9 @@ iscsi_check_values(struct spdk_iscsi_conn *conn)
|
|||||||
conn->sess->MaxBurstLength);
|
conn->sess->MaxBurstLength);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (conn->sess->FirstBurstLength > g_spdk_iscsi.FirstBurstLength) {
|
if (conn->sess->FirstBurstLength > g_iscsi.FirstBurstLength) {
|
||||||
SPDK_ERRLOG("FirstBurstLength(%d) > iSCSI target restriction(%d)\n",
|
SPDK_ERRLOG("FirstBurstLength(%d) > iSCSI target restriction(%d)\n",
|
||||||
conn->sess->FirstBurstLength, g_spdk_iscsi.FirstBurstLength);
|
conn->sess->FirstBurstLength, g_iscsi.FirstBurstLength);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (conn->sess->MaxBurstLength > 0x00ffffff) {
|
if (conn->sess->MaxBurstLength > 0x00ffffff) {
|
||||||
@ -1514,7 +1514,7 @@ iscsi_op_login_check_session(struct spdk_iscsi_conn *conn,
|
|||||||
rsph->status_detail = rc;
|
rsph->status_detail = rc;
|
||||||
return SPDK_ISCSI_LOGIN_ERROR_RESPONSE;
|
return SPDK_ISCSI_LOGIN_ERROR_RESPONSE;
|
||||||
}
|
}
|
||||||
} else if (!g_spdk_iscsi.AllowDuplicateIsid) {
|
} else if (!g_iscsi.AllowDuplicateIsid) {
|
||||||
/* new session, drop old sess by the initiator */
|
/* new session, drop old sess by the initiator */
|
||||||
spdk_iscsi_drop_conns(conn, initiator_port_name, 0 /* drop old */);
|
spdk_iscsi_drop_conns(conn, initiator_port_name, 0 /* drop old */);
|
||||||
}
|
}
|
||||||
@ -1687,9 +1687,9 @@ iscsi_op_login_session_normal(struct spdk_iscsi_conn *conn,
|
|||||||
target_short_name);
|
target_short_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
pthread_mutex_lock(&g_iscsi.mutex);
|
||||||
rc = iscsi_op_login_check_target(conn, rsp_pdu, target_name, &target);
|
rc = iscsi_op_login_check_target(conn, rsp_pdu, target_name, &target);
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
|
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
return rc;
|
return rc;
|
||||||
@ -1914,9 +1914,9 @@ iscsi_op_login_phase_none(struct spdk_iscsi_conn *conn,
|
|||||||
rsph->tsih = 0;
|
rsph->tsih = 0;
|
||||||
|
|
||||||
/* force target flags */
|
/* force target flags */
|
||||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
pthread_mutex_lock(&g_iscsi.mutex);
|
||||||
rc = iscsi_op_login_session_discovery_chap(conn);
|
rc = iscsi_op_login_session_discovery_chap(conn);
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@ -4737,10 +4737,10 @@ iscsi_read_pdu(struct spdk_iscsi_conn *conn)
|
|||||||
|
|
||||||
if (data_len != 0 && pdu->data_buf == NULL) {
|
if (data_len != 0 && pdu->data_buf == NULL) {
|
||||||
if (data_len <= spdk_get_max_immediate_data_size()) {
|
if (data_len <= spdk_get_max_immediate_data_size()) {
|
||||||
pool = g_spdk_iscsi.pdu_immediate_data_pool;
|
pool = g_iscsi.pdu_immediate_data_pool;
|
||||||
pdu->data_buf_len = SPDK_BDEV_BUF_SIZE_WITH_MD(spdk_get_max_immediate_data_size());
|
pdu->data_buf_len = SPDK_BDEV_BUF_SIZE_WITH_MD(spdk_get_max_immediate_data_size());
|
||||||
} else if (data_len <= SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH) {
|
} else if (data_len <= SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH) {
|
||||||
pool = g_spdk_iscsi.pdu_data_out_pool;
|
pool = g_iscsi.pdu_data_out_pool;
|
||||||
pdu->data_buf_len = SPDK_BDEV_BUF_SIZE_WITH_MD(SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH);
|
pdu->data_buf_len = SPDK_BDEV_BUF_SIZE_WITH_MD(SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH);
|
||||||
} else {
|
} else {
|
||||||
SPDK_ERRLOG("Data(%d) > MaxSegment(%d)\n",
|
SPDK_ERRLOG("Data(%d) > MaxSegment(%d)\n",
|
||||||
|
@ -389,7 +389,7 @@ enum spdk_error_codes {
|
|||||||
|
|
||||||
#define xstrdup(s) (s ? strdup(s) : (char *)NULL)
|
#define xstrdup(s) (s ? strdup(s) : (char *)NULL)
|
||||||
|
|
||||||
extern struct spdk_iscsi_globals g_spdk_iscsi;
|
extern struct spdk_iscsi_globals g_iscsi;
|
||||||
extern struct spdk_iscsi_opts *g_spdk_iscsi_opts;
|
extern struct spdk_iscsi_opts *g_spdk_iscsi_opts;
|
||||||
|
|
||||||
struct spdk_iscsi_task;
|
struct spdk_iscsi_task;
|
||||||
@ -457,7 +457,7 @@ spdk_get_max_immediate_data_size(void)
|
|||||||
* take up much space and we need to make sure the worst-case scenario
|
* take up much space and we need to make sure the worst-case scenario
|
||||||
* can be satisified by the size returned here.
|
* can be satisified by the size returned here.
|
||||||
*/
|
*/
|
||||||
return g_spdk_iscsi.FirstBurstLength +
|
return g_iscsi.FirstBurstLength +
|
||||||
ISCSI_DIGEST_LEN + /* data digest */
|
ISCSI_DIGEST_LEN + /* data digest */
|
||||||
ISCSI_DIGEST_LEN + /* header digest */
|
ISCSI_DIGEST_LEN + /* header digest */
|
||||||
8 + /* bidirectional AHS */
|
8 + /* bidirectional AHS */
|
||||||
|
@ -923,7 +923,7 @@ spdk_rpc_iscsi_portal_group_set_auth(struct spdk_jsonrpc_request *request,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
pthread_mutex_lock(&g_iscsi.mutex);
|
||||||
|
|
||||||
pg = spdk_iscsi_portal_grp_find_by_tag(req.tag);
|
pg = spdk_iscsi_portal_grp_find_by_tag(req.tag);
|
||||||
if (pg == NULL) {
|
if (pg == NULL) {
|
||||||
@ -940,7 +940,7 @@ spdk_rpc_iscsi_portal_group_set_auth(struct spdk_jsonrpc_request *request,
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
|
|
||||||
w = spdk_jsonrpc_begin_result(request);
|
w = spdk_jsonrpc_begin_result(request);
|
||||||
spdk_json_write_bool(w, true);
|
spdk_json_write_bool(w, true);
|
||||||
@ -949,7 +949,7 @@ spdk_rpc_iscsi_portal_group_set_auth(struct spdk_jsonrpc_request *request,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
}
|
}
|
||||||
SPDK_RPC_REGISTER("iscsi_portal_group_set_auth", spdk_rpc_iscsi_portal_group_set_auth,
|
SPDK_RPC_REGISTER("iscsi_portal_group_set_auth", spdk_rpc_iscsi_portal_group_set_auth,
|
||||||
SPDK_RPC_RUNTIME)
|
SPDK_RPC_RUNTIME)
|
||||||
@ -1009,7 +1009,7 @@ spdk_rpc_iscsi_get_connections(struct spdk_jsonrpc_request *request,
|
|||||||
|
|
||||||
spdk_json_write_array_begin(ctx->w);
|
spdk_json_write_array_begin(ctx->w);
|
||||||
|
|
||||||
spdk_for_each_channel(&g_spdk_iscsi,
|
spdk_for_each_channel(&g_iscsi,
|
||||||
rpc_iscsi_get_connections,
|
rpc_iscsi_get_connections,
|
||||||
ctx,
|
ctx,
|
||||||
rpc_iscsi_get_connections_done);
|
rpc_iscsi_get_connections_done);
|
||||||
@ -1308,11 +1308,11 @@ spdk_rpc_iscsi_create_auth_group(struct spdk_jsonrpc_request *request,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
pthread_mutex_lock(&g_iscsi.mutex);
|
||||||
|
|
||||||
rc = spdk_iscsi_add_auth_group(req.tag, &group);
|
rc = spdk_iscsi_add_auth_group(req.tag, &group);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
|
|
||||||
spdk_jsonrpc_send_error_response_fmt(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
spdk_jsonrpc_send_error_response_fmt(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
||||||
"Could not add auth group (%d), %s",
|
"Could not add auth group (%d), %s",
|
||||||
@ -1327,7 +1327,7 @@ spdk_rpc_iscsi_create_auth_group(struct spdk_jsonrpc_request *request,
|
|||||||
_secret->muser, _secret->msecret);
|
_secret->muser, _secret->msecret);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
spdk_iscsi_delete_auth_group(group);
|
spdk_iscsi_delete_auth_group(group);
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
|
|
||||||
spdk_jsonrpc_send_error_response_fmt(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
spdk_jsonrpc_send_error_response_fmt(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
||||||
"Could not add secret to auth group (%d), %s",
|
"Could not add secret to auth group (%d), %s",
|
||||||
@ -1337,7 +1337,7 @@ spdk_rpc_iscsi_create_auth_group(struct spdk_jsonrpc_request *request,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
|
|
||||||
free_rpc_auth_group(&req);
|
free_rpc_auth_group(&req);
|
||||||
|
|
||||||
@ -1372,11 +1372,11 @@ spdk_rpc_iscsi_delete_auth_group(struct spdk_jsonrpc_request *request,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
pthread_mutex_lock(&g_iscsi.mutex);
|
||||||
|
|
||||||
group = spdk_iscsi_find_auth_group_by_tag(req.tag);
|
group = spdk_iscsi_find_auth_group_by_tag(req.tag);
|
||||||
if (group == NULL) {
|
if (group == NULL) {
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
|
|
||||||
spdk_jsonrpc_send_error_response_fmt(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
spdk_jsonrpc_send_error_response_fmt(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
||||||
"Could not find auth group (%d)", req.tag);
|
"Could not find auth group (%d)", req.tag);
|
||||||
@ -1385,7 +1385,7 @@ spdk_rpc_iscsi_delete_auth_group(struct spdk_jsonrpc_request *request,
|
|||||||
|
|
||||||
spdk_iscsi_delete_auth_group(group);
|
spdk_iscsi_delete_auth_group(group);
|
||||||
|
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
|
|
||||||
w = spdk_jsonrpc_begin_result(request);
|
w = spdk_jsonrpc_begin_result(request);
|
||||||
spdk_json_write_bool(w, true);
|
spdk_json_write_bool(w, true);
|
||||||
@ -1437,11 +1437,11 @@ spdk_rpc_iscsi_auth_group_add_secret(struct spdk_jsonrpc_request *request,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
pthread_mutex_lock(&g_iscsi.mutex);
|
||||||
|
|
||||||
group = spdk_iscsi_find_auth_group_by_tag(req.tag);
|
group = spdk_iscsi_find_auth_group_by_tag(req.tag);
|
||||||
if (group == NULL) {
|
if (group == NULL) {
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
|
|
||||||
spdk_jsonrpc_send_error_response_fmt(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
spdk_jsonrpc_send_error_response_fmt(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
||||||
"Could not find auth group (%d)", req.tag);
|
"Could not find auth group (%d)", req.tag);
|
||||||
@ -1451,7 +1451,7 @@ spdk_rpc_iscsi_auth_group_add_secret(struct spdk_jsonrpc_request *request,
|
|||||||
|
|
||||||
rc = spdk_iscsi_auth_group_add_secret(group, req.user, req.secret, req.muser, req.msecret);
|
rc = spdk_iscsi_auth_group_add_secret(group, req.user, req.secret, req.muser, req.msecret);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
|
|
||||||
spdk_jsonrpc_send_error_response_fmt(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
spdk_jsonrpc_send_error_response_fmt(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
||||||
"Could not add secret to auth group (%d), %s",
|
"Could not add secret to auth group (%d), %s",
|
||||||
@ -1460,7 +1460,7 @@ spdk_rpc_iscsi_auth_group_add_secret(struct spdk_jsonrpc_request *request,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
|
|
||||||
free_rpc_add_auth_secret(&req);
|
free_rpc_add_auth_secret(&req);
|
||||||
|
|
||||||
@ -1507,11 +1507,11 @@ spdk_rpc_iscsi_auth_group_remove_secret(struct spdk_jsonrpc_request *request,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
pthread_mutex_lock(&g_iscsi.mutex);
|
||||||
|
|
||||||
group = spdk_iscsi_find_auth_group_by_tag(req.tag);
|
group = spdk_iscsi_find_auth_group_by_tag(req.tag);
|
||||||
if (group == NULL) {
|
if (group == NULL) {
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
|
|
||||||
spdk_jsonrpc_send_error_response_fmt(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
spdk_jsonrpc_send_error_response_fmt(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
||||||
"Could not find auth group (%d)", req.tag);
|
"Could not find auth group (%d)", req.tag);
|
||||||
@ -1521,7 +1521,7 @@ spdk_rpc_iscsi_auth_group_remove_secret(struct spdk_jsonrpc_request *request,
|
|||||||
|
|
||||||
rc = spdk_iscsi_auth_group_delete_secret(group, req.user);
|
rc = spdk_iscsi_auth_group_delete_secret(group, req.user);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
|
|
||||||
spdk_jsonrpc_send_error_response_fmt(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
spdk_jsonrpc_send_error_response_fmt(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
||||||
"Could not delete secret from CHAP group (%d), %s",
|
"Could not delete secret from CHAP group (%d), %s",
|
||||||
@ -1530,7 +1530,7 @@ spdk_rpc_iscsi_auth_group_remove_secret(struct spdk_jsonrpc_request *request,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
|
|
||||||
free_rpc_remove_auth_secret(&req);
|
free_rpc_remove_auth_secret(&req);
|
||||||
|
|
||||||
|
@ -98,30 +98,30 @@ iscsi_globals_config_text(FILE *fp)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_spdk_iscsi.require_chap) {
|
if (g_iscsi.require_chap) {
|
||||||
authmethod = "CHAP";
|
authmethod = "CHAP";
|
||||||
} else if (g_spdk_iscsi.mutual_chap) {
|
} else if (g_iscsi.mutual_chap) {
|
||||||
authmethod = "CHAP Mutual";
|
authmethod = "CHAP Mutual";
|
||||||
} else if (!g_spdk_iscsi.disable_chap) {
|
} else if (!g_iscsi.disable_chap) {
|
||||||
authmethod = "Auto";
|
authmethod = "Auto";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_spdk_iscsi.chap_group) {
|
if (g_iscsi.chap_group) {
|
||||||
snprintf(authgroup, sizeof(authgroup), "AuthGroup%d", g_spdk_iscsi.chap_group);
|
snprintf(authgroup, sizeof(authgroup), "AuthGroup%d", g_iscsi.chap_group);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(fp, ISCSI_CONFIG_TMPL,
|
fprintf(fp, ISCSI_CONFIG_TMPL,
|
||||||
g_spdk_iscsi.nodebase,
|
g_iscsi.nodebase,
|
||||||
g_spdk_iscsi.authfile ? "AuthFile" : "",
|
g_iscsi.authfile ? "AuthFile" : "",
|
||||||
g_spdk_iscsi.authfile ? g_spdk_iscsi.authfile : "",
|
g_iscsi.authfile ? g_iscsi.authfile : "",
|
||||||
g_spdk_iscsi.timeout, authmethod, authgroup,
|
g_iscsi.timeout, authmethod, authgroup,
|
||||||
g_spdk_iscsi.MaxSessions, g_spdk_iscsi.MaxConnectionsPerSession,
|
g_iscsi.MaxSessions, g_iscsi.MaxConnectionsPerSession,
|
||||||
g_spdk_iscsi.MaxConnections,
|
g_iscsi.MaxConnections,
|
||||||
g_spdk_iscsi.MaxQueueDepth,
|
g_iscsi.MaxQueueDepth,
|
||||||
g_spdk_iscsi.DefaultTime2Wait, g_spdk_iscsi.DefaultTime2Retain,
|
g_iscsi.DefaultTime2Wait, g_iscsi.DefaultTime2Retain,
|
||||||
g_spdk_iscsi.FirstBurstLength,
|
g_iscsi.FirstBurstLength,
|
||||||
(g_spdk_iscsi.ImmediateData) ? "Yes" : "No",
|
(g_iscsi.ImmediateData) ? "Yes" : "No",
|
||||||
g_spdk_iscsi.ErrorRecoveryLevel);
|
g_iscsi.ErrorRecoveryLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ISCSI_DATA_BUFFER_ALIGNMENT (0x1000)
|
#define ISCSI_DATA_BUFFER_ALIGNMENT (0x1000)
|
||||||
@ -147,7 +147,7 @@ mobj_ctor(struct spdk_mempool *mp, __attribute__((unused)) void *arg,
|
|||||||
static int
|
static int
|
||||||
iscsi_initialize_pdu_pool(void)
|
iscsi_initialize_pdu_pool(void)
|
||||||
{
|
{
|
||||||
struct spdk_iscsi_globals *iscsi = &g_spdk_iscsi;
|
struct spdk_iscsi_globals *iscsi = &g_iscsi;
|
||||||
int imm_mobj_size = SPDK_BDEV_BUF_SIZE_WITH_MD(spdk_get_max_immediate_data_size()) +
|
int imm_mobj_size = SPDK_BDEV_BUF_SIZE_WITH_MD(spdk_get_max_immediate_data_size()) +
|
||||||
sizeof(struct spdk_mobj) + ISCSI_DATA_BUFFER_ALIGNMENT;
|
sizeof(struct spdk_mobj) + ISCSI_DATA_BUFFER_ALIGNMENT;
|
||||||
int dout_mobj_size = SPDK_BDEV_BUF_SIZE_WITH_MD(SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH) +
|
int dout_mobj_size = SPDK_BDEV_BUF_SIZE_WITH_MD(SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH) +
|
||||||
@ -204,7 +204,7 @@ iscsi_sess_ctor(struct spdk_mempool *pool, void *arg, void *session_buf,
|
|||||||
static int
|
static int
|
||||||
iscsi_initialize_task_pool(void)
|
iscsi_initialize_task_pool(void)
|
||||||
{
|
{
|
||||||
struct spdk_iscsi_globals *iscsi = &g_spdk_iscsi;
|
struct spdk_iscsi_globals *iscsi = &g_iscsi;
|
||||||
|
|
||||||
/* create scsi_task pool */
|
/* create scsi_task pool */
|
||||||
iscsi->task_pool = spdk_mempool_create("SCSI_TASK_Pool",
|
iscsi->task_pool = spdk_mempool_create("SCSI_TASK_Pool",
|
||||||
@ -223,7 +223,7 @@ iscsi_initialize_task_pool(void)
|
|||||||
static int
|
static int
|
||||||
iscsi_initialize_session_pool(void)
|
iscsi_initialize_session_pool(void)
|
||||||
{
|
{
|
||||||
struct spdk_iscsi_globals *iscsi = &g_spdk_iscsi;
|
struct spdk_iscsi_globals *iscsi = &g_iscsi;
|
||||||
|
|
||||||
iscsi->session_pool = spdk_mempool_create_ctor("Session_Pool",
|
iscsi->session_pool = spdk_mempool_create_ctor("Session_Pool",
|
||||||
SESSION_POOL_SIZE(iscsi),
|
SESSION_POOL_SIZE(iscsi),
|
||||||
@ -268,7 +268,7 @@ iscsi_check_pool(struct spdk_mempool *pool, size_t count)
|
|||||||
static void
|
static void
|
||||||
iscsi_check_pools(void)
|
iscsi_check_pools(void)
|
||||||
{
|
{
|
||||||
struct spdk_iscsi_globals *iscsi = &g_spdk_iscsi;
|
struct spdk_iscsi_globals *iscsi = &g_iscsi;
|
||||||
|
|
||||||
iscsi_check_pool(iscsi->pdu_pool, PDU_POOL_SIZE(iscsi));
|
iscsi_check_pool(iscsi->pdu_pool, PDU_POOL_SIZE(iscsi));
|
||||||
iscsi_check_pool(iscsi->session_pool, SESSION_POOL_SIZE(iscsi));
|
iscsi_check_pool(iscsi->session_pool, SESSION_POOL_SIZE(iscsi));
|
||||||
@ -280,7 +280,7 @@ iscsi_check_pools(void)
|
|||||||
static void
|
static void
|
||||||
iscsi_free_pools(void)
|
iscsi_free_pools(void)
|
||||||
{
|
{
|
||||||
struct spdk_iscsi_globals *iscsi = &g_spdk_iscsi;
|
struct spdk_iscsi_globals *iscsi = &g_iscsi;
|
||||||
|
|
||||||
spdk_mempool_free(iscsi->pdu_pool);
|
spdk_mempool_free(iscsi->pdu_pool);
|
||||||
spdk_mempool_free(iscsi->session_pool);
|
spdk_mempool_free(iscsi->session_pool);
|
||||||
@ -307,7 +307,7 @@ void spdk_put_pdu(struct spdk_iscsi_pdu *pdu)
|
|||||||
free(pdu->data);
|
free(pdu->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
spdk_mempool_put(g_spdk_iscsi.pdu_pool, (void *)pdu);
|
spdk_mempool_put(g_iscsi.pdu_pool, (void *)pdu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,7 +316,7 @@ struct spdk_iscsi_pdu *spdk_get_pdu(struct spdk_iscsi_conn *conn)
|
|||||||
struct spdk_iscsi_pdu *pdu;
|
struct spdk_iscsi_pdu *pdu;
|
||||||
|
|
||||||
assert(conn != NULL);
|
assert(conn != NULL);
|
||||||
pdu = spdk_mempool_get(g_spdk_iscsi.pdu_pool);
|
pdu = spdk_mempool_get(g_iscsi.pdu_pool);
|
||||||
if (!pdu) {
|
if (!pdu) {
|
||||||
SPDK_ERRLOG("Unable to get PDU\n");
|
SPDK_ERRLOG("Unable to get PDU\n");
|
||||||
abort();
|
abort();
|
||||||
@ -334,47 +334,47 @@ static void
|
|||||||
iscsi_log_globals(void)
|
iscsi_log_globals(void)
|
||||||
{
|
{
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "AuthFile %s\n",
|
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "AuthFile %s\n",
|
||||||
g_spdk_iscsi.authfile ? g_spdk_iscsi.authfile : "(none)");
|
g_iscsi.authfile ? g_iscsi.authfile : "(none)");
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "NodeBase %s\n", g_spdk_iscsi.nodebase);
|
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "NodeBase %s\n", g_iscsi.nodebase);
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "MaxSessions %d\n", g_spdk_iscsi.MaxSessions);
|
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "MaxSessions %d\n", g_iscsi.MaxSessions);
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "MaxConnectionsPerSession %d\n",
|
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "MaxConnectionsPerSession %d\n",
|
||||||
g_spdk_iscsi.MaxConnectionsPerSession);
|
g_iscsi.MaxConnectionsPerSession);
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "MaxQueueDepth %d\n", g_spdk_iscsi.MaxQueueDepth);
|
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "MaxQueueDepth %d\n", g_iscsi.MaxQueueDepth);
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "DefaultTime2Wait %d\n",
|
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "DefaultTime2Wait %d\n",
|
||||||
g_spdk_iscsi.DefaultTime2Wait);
|
g_iscsi.DefaultTime2Wait);
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "DefaultTime2Retain %d\n",
|
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "DefaultTime2Retain %d\n",
|
||||||
g_spdk_iscsi.DefaultTime2Retain);
|
g_iscsi.DefaultTime2Retain);
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "FirstBurstLength %d\n",
|
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "FirstBurstLength %d\n",
|
||||||
g_spdk_iscsi.FirstBurstLength);
|
g_iscsi.FirstBurstLength);
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "ImmediateData %s\n",
|
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "ImmediateData %s\n",
|
||||||
g_spdk_iscsi.ImmediateData ? "Yes" : "No");
|
g_iscsi.ImmediateData ? "Yes" : "No");
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "AllowDuplicateIsid %s\n",
|
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "AllowDuplicateIsid %s\n",
|
||||||
g_spdk_iscsi.AllowDuplicateIsid ? "Yes" : "No");
|
g_iscsi.AllowDuplicateIsid ? "Yes" : "No");
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "ErrorRecoveryLevel %d\n",
|
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "ErrorRecoveryLevel %d\n",
|
||||||
g_spdk_iscsi.ErrorRecoveryLevel);
|
g_iscsi.ErrorRecoveryLevel);
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "Timeout %d\n", g_spdk_iscsi.timeout);
|
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "Timeout %d\n", g_iscsi.timeout);
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "NopInInterval %d\n",
|
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "NopInInterval %d\n",
|
||||||
g_spdk_iscsi.nopininterval);
|
g_iscsi.nopininterval);
|
||||||
if (g_spdk_iscsi.disable_chap) {
|
if (g_iscsi.disable_chap) {
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI,
|
SPDK_DEBUGLOG(SPDK_LOG_ISCSI,
|
||||||
"DiscoveryAuthMethod None\n");
|
"DiscoveryAuthMethod None\n");
|
||||||
} else if (!g_spdk_iscsi.require_chap) {
|
} else if (!g_iscsi.require_chap) {
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI,
|
SPDK_DEBUGLOG(SPDK_LOG_ISCSI,
|
||||||
"DiscoveryAuthMethod Auto\n");
|
"DiscoveryAuthMethod Auto\n");
|
||||||
} else {
|
} else {
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI,
|
SPDK_DEBUGLOG(SPDK_LOG_ISCSI,
|
||||||
"DiscoveryAuthMethod %s %s\n",
|
"DiscoveryAuthMethod %s %s\n",
|
||||||
g_spdk_iscsi.require_chap ? "CHAP" : "",
|
g_iscsi.require_chap ? "CHAP" : "",
|
||||||
g_spdk_iscsi.mutual_chap ? "Mutual" : "");
|
g_iscsi.mutual_chap ? "Mutual" : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_spdk_iscsi.chap_group == 0) {
|
if (g_iscsi.chap_group == 0) {
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI,
|
SPDK_DEBUGLOG(SPDK_LOG_ISCSI,
|
||||||
"DiscoveryAuthGroup None\n");
|
"DiscoveryAuthGroup None\n");
|
||||||
} else {
|
} else {
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI,
|
SPDK_DEBUGLOG(SPDK_LOG_ISCSI,
|
||||||
"DiscoveryAuthGroup AuthGroup%d\n",
|
"DiscoveryAuthGroup AuthGroup%d\n",
|
||||||
g_spdk_iscsi.chap_group);
|
g_iscsi.chap_group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -739,34 +739,34 @@ iscsi_set_global_params(struct spdk_iscsi_opts *opts)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (opts->authfile != NULL) {
|
if (opts->authfile != NULL) {
|
||||||
g_spdk_iscsi.authfile = strdup(opts->authfile);
|
g_iscsi.authfile = strdup(opts->authfile);
|
||||||
if (!g_spdk_iscsi.authfile) {
|
if (!g_iscsi.authfile) {
|
||||||
SPDK_ERRLOG("failed to strdup for auth file %s\n", opts->authfile);
|
SPDK_ERRLOG("failed to strdup for auth file %s\n", opts->authfile);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_spdk_iscsi.nodebase = strdup(opts->nodebase);
|
g_iscsi.nodebase = strdup(opts->nodebase);
|
||||||
if (!g_spdk_iscsi.nodebase) {
|
if (!g_iscsi.nodebase) {
|
||||||
SPDK_ERRLOG("failed to strdup for nodebase %s\n", opts->nodebase);
|
SPDK_ERRLOG("failed to strdup for nodebase %s\n", opts->nodebase);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_spdk_iscsi.MaxSessions = opts->MaxSessions;
|
g_iscsi.MaxSessions = opts->MaxSessions;
|
||||||
g_spdk_iscsi.MaxConnectionsPerSession = opts->MaxConnectionsPerSession;
|
g_iscsi.MaxConnectionsPerSession = opts->MaxConnectionsPerSession;
|
||||||
g_spdk_iscsi.MaxQueueDepth = opts->MaxQueueDepth;
|
g_iscsi.MaxQueueDepth = opts->MaxQueueDepth;
|
||||||
g_spdk_iscsi.DefaultTime2Wait = opts->DefaultTime2Wait;
|
g_iscsi.DefaultTime2Wait = opts->DefaultTime2Wait;
|
||||||
g_spdk_iscsi.DefaultTime2Retain = opts->DefaultTime2Retain;
|
g_iscsi.DefaultTime2Retain = opts->DefaultTime2Retain;
|
||||||
g_spdk_iscsi.FirstBurstLength = opts->FirstBurstLength;
|
g_iscsi.FirstBurstLength = opts->FirstBurstLength;
|
||||||
g_spdk_iscsi.ImmediateData = opts->ImmediateData;
|
g_iscsi.ImmediateData = opts->ImmediateData;
|
||||||
g_spdk_iscsi.AllowDuplicateIsid = opts->AllowDuplicateIsid;
|
g_iscsi.AllowDuplicateIsid = opts->AllowDuplicateIsid;
|
||||||
g_spdk_iscsi.ErrorRecoveryLevel = opts->ErrorRecoveryLevel;
|
g_iscsi.ErrorRecoveryLevel = opts->ErrorRecoveryLevel;
|
||||||
g_spdk_iscsi.timeout = opts->timeout;
|
g_iscsi.timeout = opts->timeout;
|
||||||
g_spdk_iscsi.nopininterval = opts->nopininterval;
|
g_iscsi.nopininterval = opts->nopininterval;
|
||||||
g_spdk_iscsi.disable_chap = opts->disable_chap;
|
g_iscsi.disable_chap = opts->disable_chap;
|
||||||
g_spdk_iscsi.require_chap = opts->require_chap;
|
g_iscsi.require_chap = opts->require_chap;
|
||||||
g_spdk_iscsi.mutual_chap = opts->mutual_chap;
|
g_iscsi.mutual_chap = opts->mutual_chap;
|
||||||
g_spdk_iscsi.chap_group = opts->chap_group;
|
g_iscsi.chap_group = opts->chap_group;
|
||||||
|
|
||||||
iscsi_log_globals();
|
iscsi_log_globals();
|
||||||
|
|
||||||
@ -783,12 +783,12 @@ spdk_iscsi_set_discovery_auth(bool disable_chap, bool require_chap, bool mutual_
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
pthread_mutex_lock(&g_iscsi.mutex);
|
||||||
g_spdk_iscsi.disable_chap = disable_chap;
|
g_iscsi.disable_chap = disable_chap;
|
||||||
g_spdk_iscsi.require_chap = require_chap;
|
g_iscsi.require_chap = require_chap;
|
||||||
g_spdk_iscsi.mutual_chap = mutual_chap;
|
g_iscsi.mutual_chap = mutual_chap;
|
||||||
g_spdk_iscsi.chap_group = chap_group;
|
g_iscsi.chap_group = chap_group;
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -899,7 +899,7 @@ spdk_iscsi_add_auth_group(int32_t tag, struct spdk_iscsi_auth_group **_group)
|
|||||||
{
|
{
|
||||||
struct spdk_iscsi_auth_group *group;
|
struct spdk_iscsi_auth_group *group;
|
||||||
|
|
||||||
TAILQ_FOREACH(group, &g_spdk_iscsi.auth_group_head, tailq) {
|
TAILQ_FOREACH(group, &g_iscsi.auth_group_head, tailq) {
|
||||||
if (group->tag == tag) {
|
if (group->tag == tag) {
|
||||||
SPDK_ERRLOG("Auth group (%d) already exists\n", tag);
|
SPDK_ERRLOG("Auth group (%d) already exists\n", tag);
|
||||||
return -EEXIST;
|
return -EEXIST;
|
||||||
@ -915,7 +915,7 @@ spdk_iscsi_add_auth_group(int32_t tag, struct spdk_iscsi_auth_group **_group)
|
|||||||
TAILQ_INIT(&group->secret_head);
|
TAILQ_INIT(&group->secret_head);
|
||||||
group->tag = tag;
|
group->tag = tag;
|
||||||
|
|
||||||
TAILQ_INSERT_TAIL(&g_spdk_iscsi.auth_group_head, group, tailq);
|
TAILQ_INSERT_TAIL(&g_iscsi.auth_group_head, group, tailq);
|
||||||
|
|
||||||
*_group = group;
|
*_group = group;
|
||||||
return 0;
|
return 0;
|
||||||
@ -926,7 +926,7 @@ spdk_iscsi_delete_auth_group(struct spdk_iscsi_auth_group *group)
|
|||||||
{
|
{
|
||||||
struct spdk_iscsi_auth_secret *_secret, *tmp;
|
struct spdk_iscsi_auth_secret *_secret, *tmp;
|
||||||
|
|
||||||
TAILQ_REMOVE(&g_spdk_iscsi.auth_group_head, group, tailq);
|
TAILQ_REMOVE(&g_iscsi.auth_group_head, group, tailq);
|
||||||
|
|
||||||
TAILQ_FOREACH_SAFE(_secret, &group->secret_head, tailq, tmp) {
|
TAILQ_FOREACH_SAFE(_secret, &group->secret_head, tailq, tmp) {
|
||||||
TAILQ_REMOVE(&group->secret_head, _secret, tailq);
|
TAILQ_REMOVE(&group->secret_head, _secret, tailq);
|
||||||
@ -940,7 +940,7 @@ spdk_iscsi_find_auth_group_by_tag(int32_t tag)
|
|||||||
{
|
{
|
||||||
struct spdk_iscsi_auth_group *group;
|
struct spdk_iscsi_auth_group *group;
|
||||||
|
|
||||||
TAILQ_FOREACH(group, &g_spdk_iscsi.auth_group_head, tailq) {
|
TAILQ_FOREACH(group, &g_iscsi.auth_group_head, tailq) {
|
||||||
if (group->tag == tag) {
|
if (group->tag == tag) {
|
||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
@ -954,7 +954,7 @@ iscsi_auth_groups_destroy(void)
|
|||||||
{
|
{
|
||||||
struct spdk_iscsi_auth_group *group, *tmp;
|
struct spdk_iscsi_auth_group *group, *tmp;
|
||||||
|
|
||||||
TAILQ_FOREACH_SAFE(group, &g_spdk_iscsi.auth_group_head, tailq, tmp) {
|
TAILQ_FOREACH_SAFE(group, &g_iscsi.auth_group_head, tailq, tmp) {
|
||||||
spdk_iscsi_delete_auth_group(group);
|
spdk_iscsi_delete_auth_group(group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1016,7 +1016,7 @@ iscsi_parse_auth_info(void)
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = spdk_conf_read(config, g_spdk_iscsi.authfile);
|
rc = spdk_conf_read(config, g_iscsi.authfile);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
SPDK_INFOLOG(SPDK_LOG_ISCSI, "Failed to load auth file\n");
|
SPDK_INFOLOG(SPDK_LOG_ISCSI, "Failed to load auth file\n");
|
||||||
spdk_conf_free(config);
|
spdk_conf_free(config);
|
||||||
@ -1054,7 +1054,7 @@ iscsi_find_auth_secret(const char *authuser, int ag_tag)
|
|||||||
struct spdk_iscsi_auth_group *group;
|
struct spdk_iscsi_auth_group *group;
|
||||||
struct spdk_iscsi_auth_secret *_secret;
|
struct spdk_iscsi_auth_secret *_secret;
|
||||||
|
|
||||||
TAILQ_FOREACH(group, &g_spdk_iscsi.auth_group_head, tailq) {
|
TAILQ_FOREACH(group, &g_iscsi.auth_group_head, tailq) {
|
||||||
if (group->tag == ag_tag) {
|
if (group->tag == ag_tag) {
|
||||||
TAILQ_FOREACH(_secret, &group->secret_head, tailq) {
|
TAILQ_FOREACH(_secret, &group->secret_head, tailq) {
|
||||||
if (strcmp(_secret->user, authuser) == 0) {
|
if (strcmp(_secret->user, authuser) == 0) {
|
||||||
@ -1084,11 +1084,11 @@ spdk_iscsi_chap_get_authinfo(struct iscsi_chap_auth *auth, const char *authuser,
|
|||||||
memset(auth->msecret, 0, sizeof(auth->msecret));
|
memset(auth->msecret, 0, sizeof(auth->msecret));
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
pthread_mutex_lock(&g_iscsi.mutex);
|
||||||
|
|
||||||
_secret = iscsi_find_auth_secret(authuser, ag_tag);
|
_secret = iscsi_find_auth_secret(authuser, ag_tag);
|
||||||
if (_secret == NULL) {
|
if (_secret == NULL) {
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
|
|
||||||
SPDK_ERRLOG("CHAP secret is not found: user:%s, tag:%d\n",
|
SPDK_ERRLOG("CHAP secret is not found: user:%s, tag:%d\n",
|
||||||
authuser, ag_tag);
|
authuser, ag_tag);
|
||||||
@ -1103,7 +1103,7 @@ spdk_iscsi_chap_get_authinfo(struct iscsi_chap_auth *auth, const char *authuser,
|
|||||||
memcpy(auth->msecret, _secret->msecret, sizeof(auth->msecret));
|
memcpy(auth->msecret, _secret->msecret, sizeof(auth->msecret));
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1165,15 +1165,15 @@ iscsi_parse_configuration(void)
|
|||||||
SPDK_ERRLOG("spdk_iscsi_parse_tgt_nodes() failed\n");
|
SPDK_ERRLOG("spdk_iscsi_parse_tgt_nodes() failed\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_spdk_iscsi.authfile != NULL) {
|
if (g_iscsi.authfile != NULL) {
|
||||||
if (access(g_spdk_iscsi.authfile, R_OK) == 0) {
|
if (access(g_iscsi.authfile, R_OK) == 0) {
|
||||||
rc = iscsi_parse_auth_info();
|
rc = iscsi_parse_auth_info();
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
SPDK_ERRLOG("spdk_iscsi_parse_auth_info() failed\n");
|
SPDK_ERRLOG("spdk_iscsi_parse_auth_info() failed\n");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SPDK_INFOLOG(SPDK_LOG_ISCSI, "CHAP secret file is not found in the path %s\n",
|
SPDK_INFOLOG(SPDK_LOG_ISCSI, "CHAP secret file is not found in the path %s\n",
|
||||||
g_spdk_iscsi.authfile);
|
g_iscsi.authfile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1262,8 +1262,8 @@ _iscsi_init_thread_done(void *ctx)
|
|||||||
{
|
{
|
||||||
struct spdk_iscsi_poll_group *pg = ctx;
|
struct spdk_iscsi_poll_group *pg = ctx;
|
||||||
|
|
||||||
TAILQ_INSERT_TAIL(&g_spdk_iscsi.poll_group_head, pg, link);
|
TAILQ_INSERT_TAIL(&g_iscsi.poll_group_head, pg, link);
|
||||||
if (--g_spdk_iscsi.refcnt == 0) {
|
if (--g_iscsi.refcnt == 0) {
|
||||||
iscsi_parse_configuration();
|
iscsi_parse_configuration();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1274,7 +1274,7 @@ _iscsi_init_thread(void *ctx)
|
|||||||
struct spdk_io_channel *ch;
|
struct spdk_io_channel *ch;
|
||||||
struct spdk_iscsi_poll_group *pg;
|
struct spdk_iscsi_poll_group *pg;
|
||||||
|
|
||||||
ch = spdk_get_io_channel(&g_spdk_iscsi);
|
ch = spdk_get_io_channel(&g_iscsi);
|
||||||
pg = spdk_io_channel_get_ctx(ch);
|
pg = spdk_io_channel_get_ctx(ch);
|
||||||
|
|
||||||
spdk_thread_send_msg(g_init_thread, _iscsi_init_thread_done, pg);
|
spdk_thread_send_msg(g_init_thread, _iscsi_init_thread_done, pg);
|
||||||
@ -1288,7 +1288,7 @@ initialize_iscsi_poll_group(void)
|
|||||||
char thread_name[32];
|
char thread_name[32];
|
||||||
struct spdk_thread *thread;
|
struct spdk_thread *thread;
|
||||||
|
|
||||||
spdk_io_device_register(&g_spdk_iscsi, iscsi_poll_group_create, iscsi_poll_group_destroy,
|
spdk_io_device_register(&g_iscsi, iscsi_poll_group_create, iscsi_poll_group_destroy,
|
||||||
sizeof(struct spdk_iscsi_poll_group), "iscsi_tgt");
|
sizeof(struct spdk_iscsi_poll_group), "iscsi_tgt");
|
||||||
|
|
||||||
/* Create threads for CPU cores active for this application, and send a
|
/* Create threads for CPU cores active for this application, and send a
|
||||||
@ -1296,7 +1296,7 @@ initialize_iscsi_poll_group(void)
|
|||||||
*/
|
*/
|
||||||
g_init_thread = spdk_get_thread();
|
g_init_thread = spdk_get_thread();
|
||||||
assert(g_init_thread != NULL);
|
assert(g_init_thread != NULL);
|
||||||
assert(g_spdk_iscsi.refcnt == 0);
|
assert(g_iscsi.refcnt == 0);
|
||||||
|
|
||||||
SPDK_ENV_FOREACH_CORE(i) {
|
SPDK_ENV_FOREACH_CORE(i) {
|
||||||
spdk_cpuset_zero(&tmp_cpumask);
|
spdk_cpuset_zero(&tmp_cpumask);
|
||||||
@ -1306,7 +1306,7 @@ initialize_iscsi_poll_group(void)
|
|||||||
thread = spdk_thread_create(thread_name, &tmp_cpumask);
|
thread = spdk_thread_create(thread_name, &tmp_cpumask);
|
||||||
assert(thread != NULL);
|
assert(thread != NULL);
|
||||||
|
|
||||||
g_spdk_iscsi.refcnt++;
|
g_iscsi.refcnt++;
|
||||||
spdk_thread_send_msg(thread, _iscsi_init_thread, NULL);
|
spdk_thread_send_msg(thread, _iscsi_init_thread, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1322,8 +1322,8 @@ iscsi_parse_globals(void)
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_spdk_iscsi.session = calloc(1, sizeof(struct spdk_iscsi_sess *) * g_spdk_iscsi.MaxSessions);
|
g_iscsi.session = calloc(1, sizeof(struct spdk_iscsi_sess *) * g_iscsi.MaxSessions);
|
||||||
if (!g_spdk_iscsi.session) {
|
if (!g_iscsi.session) {
|
||||||
SPDK_ERRLOG("calloc() failed for session array\n");
|
SPDK_ERRLOG("calloc() failed for session array\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1334,21 +1334,21 @@ iscsi_parse_globals(void)
|
|||||||
* handling for low resource conditions from our various buffer
|
* handling for low resource conditions from our various buffer
|
||||||
* pools, we can bump this up to support more connections.
|
* pools, we can bump this up to support more connections.
|
||||||
*/
|
*/
|
||||||
g_spdk_iscsi.MaxConnections = g_spdk_iscsi.MaxSessions;
|
g_iscsi.MaxConnections = g_iscsi.MaxSessions;
|
||||||
|
|
||||||
rc = iscsi_initialize_all_pools();
|
rc = iscsi_initialize_all_pools();
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
SPDK_ERRLOG("spdk_initialize_all_pools() failed\n");
|
SPDK_ERRLOG("spdk_initialize_all_pools() failed\n");
|
||||||
free(g_spdk_iscsi.session);
|
free(g_iscsi.session);
|
||||||
g_spdk_iscsi.session = NULL;
|
g_iscsi.session = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = spdk_initialize_iscsi_conns();
|
rc = spdk_initialize_iscsi_conns();
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
SPDK_ERRLOG("spdk_initialize_iscsi_conns() failed\n");
|
SPDK_ERRLOG("spdk_initialize_iscsi_conns() failed\n");
|
||||||
free(g_spdk_iscsi.session);
|
free(g_iscsi.session);
|
||||||
g_spdk_iscsi.session = NULL;
|
g_iscsi.session = NULL;
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1391,10 +1391,10 @@ spdk_iscsi_fini(spdk_iscsi_fini_cb cb_fn, void *cb_arg)
|
|||||||
static void
|
static void
|
||||||
iscsi_fini_done(void *io_device)
|
iscsi_fini_done(void *io_device)
|
||||||
{
|
{
|
||||||
free(g_spdk_iscsi.authfile);
|
free(g_iscsi.authfile);
|
||||||
free(g_spdk_iscsi.nodebase);
|
free(g_iscsi.nodebase);
|
||||||
|
|
||||||
pthread_mutex_destroy(&g_spdk_iscsi.mutex);
|
pthread_mutex_destroy(&g_iscsi.mutex);
|
||||||
g_fini_cb_fn(g_fini_cb_arg);
|
g_fini_cb_fn(g_fini_cb_arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1403,16 +1403,16 @@ _iscsi_fini_dev_unreg(struct spdk_io_channel_iter *i, int status)
|
|||||||
{
|
{
|
||||||
iscsi_check_pools();
|
iscsi_check_pools();
|
||||||
iscsi_free_pools();
|
iscsi_free_pools();
|
||||||
free(g_spdk_iscsi.session);
|
free(g_iscsi.session);
|
||||||
|
|
||||||
assert(TAILQ_EMPTY(&g_spdk_iscsi.poll_group_head));
|
assert(TAILQ_EMPTY(&g_iscsi.poll_group_head));
|
||||||
|
|
||||||
spdk_iscsi_shutdown_tgt_nodes();
|
spdk_iscsi_shutdown_tgt_nodes();
|
||||||
spdk_iscsi_init_grps_destroy();
|
spdk_iscsi_init_grps_destroy();
|
||||||
spdk_iscsi_portal_grps_destroy();
|
spdk_iscsi_portal_grps_destroy();
|
||||||
iscsi_auth_groups_destroy();
|
iscsi_auth_groups_destroy();
|
||||||
|
|
||||||
spdk_io_device_unregister(&g_spdk_iscsi, iscsi_fini_done);
|
spdk_io_device_unregister(&g_iscsi, iscsi_fini_done);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1424,9 +1424,9 @@ _iscsi_fini_thread(struct spdk_io_channel_iter *i)
|
|||||||
ch = spdk_io_channel_iter_get_channel(i);
|
ch = spdk_io_channel_iter_get_channel(i);
|
||||||
pg = spdk_io_channel_get_ctx(ch);
|
pg = spdk_io_channel_get_ctx(ch);
|
||||||
|
|
||||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
pthread_mutex_lock(&g_iscsi.mutex);
|
||||||
TAILQ_REMOVE(&g_spdk_iscsi.poll_group_head, pg, link);
|
TAILQ_REMOVE(&g_iscsi.poll_group_head, pg, link);
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
|
|
||||||
spdk_put_io_channel(ch);
|
spdk_put_io_channel(ch);
|
||||||
|
|
||||||
@ -1436,7 +1436,7 @@ _iscsi_fini_thread(struct spdk_io_channel_iter *i)
|
|||||||
void
|
void
|
||||||
spdk_shutdown_iscsi_conns_done(void)
|
spdk_shutdown_iscsi_conns_done(void)
|
||||||
{
|
{
|
||||||
spdk_for_each_channel(&g_spdk_iscsi, _iscsi_fini_thread, NULL, _iscsi_fini_dev_unreg);
|
spdk_for_each_channel(&g_iscsi, _iscsi_fini_thread, NULL, _iscsi_fini_dev_unreg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1453,35 +1453,35 @@ spdk_iscsi_opts_info_json(struct spdk_json_write_ctx *w)
|
|||||||
{
|
{
|
||||||
spdk_json_write_object_begin(w);
|
spdk_json_write_object_begin(w);
|
||||||
|
|
||||||
if (g_spdk_iscsi.authfile != NULL) {
|
if (g_iscsi.authfile != NULL) {
|
||||||
spdk_json_write_named_string(w, "auth_file", g_spdk_iscsi.authfile);
|
spdk_json_write_named_string(w, "auth_file", g_iscsi.authfile);
|
||||||
}
|
}
|
||||||
spdk_json_write_named_string(w, "node_base", g_spdk_iscsi.nodebase);
|
spdk_json_write_named_string(w, "node_base", g_iscsi.nodebase);
|
||||||
|
|
||||||
spdk_json_write_named_uint32(w, "max_sessions", g_spdk_iscsi.MaxSessions);
|
spdk_json_write_named_uint32(w, "max_sessions", g_iscsi.MaxSessions);
|
||||||
spdk_json_write_named_uint32(w, "max_connections_per_session",
|
spdk_json_write_named_uint32(w, "max_connections_per_session",
|
||||||
g_spdk_iscsi.MaxConnectionsPerSession);
|
g_iscsi.MaxConnectionsPerSession);
|
||||||
|
|
||||||
spdk_json_write_named_uint32(w, "max_queue_depth", g_spdk_iscsi.MaxQueueDepth);
|
spdk_json_write_named_uint32(w, "max_queue_depth", g_iscsi.MaxQueueDepth);
|
||||||
|
|
||||||
spdk_json_write_named_uint32(w, "default_time2wait", g_spdk_iscsi.DefaultTime2Wait);
|
spdk_json_write_named_uint32(w, "default_time2wait", g_iscsi.DefaultTime2Wait);
|
||||||
spdk_json_write_named_uint32(w, "default_time2retain", g_spdk_iscsi.DefaultTime2Retain);
|
spdk_json_write_named_uint32(w, "default_time2retain", g_iscsi.DefaultTime2Retain);
|
||||||
|
|
||||||
spdk_json_write_named_uint32(w, "first_burst_length", g_spdk_iscsi.FirstBurstLength);
|
spdk_json_write_named_uint32(w, "first_burst_length", g_iscsi.FirstBurstLength);
|
||||||
|
|
||||||
spdk_json_write_named_bool(w, "immediate_data", g_spdk_iscsi.ImmediateData);
|
spdk_json_write_named_bool(w, "immediate_data", g_iscsi.ImmediateData);
|
||||||
|
|
||||||
spdk_json_write_named_bool(w, "allow_duplicated_isid", g_spdk_iscsi.AllowDuplicateIsid);
|
spdk_json_write_named_bool(w, "allow_duplicated_isid", g_iscsi.AllowDuplicateIsid);
|
||||||
|
|
||||||
spdk_json_write_named_uint32(w, "error_recovery_level", g_spdk_iscsi.ErrorRecoveryLevel);
|
spdk_json_write_named_uint32(w, "error_recovery_level", g_iscsi.ErrorRecoveryLevel);
|
||||||
|
|
||||||
spdk_json_write_named_int32(w, "nop_timeout", g_spdk_iscsi.timeout);
|
spdk_json_write_named_int32(w, "nop_timeout", g_iscsi.timeout);
|
||||||
spdk_json_write_named_int32(w, "nop_in_interval", g_spdk_iscsi.nopininterval);
|
spdk_json_write_named_int32(w, "nop_in_interval", g_iscsi.nopininterval);
|
||||||
|
|
||||||
spdk_json_write_named_bool(w, "disable_chap", g_spdk_iscsi.disable_chap);
|
spdk_json_write_named_bool(w, "disable_chap", g_iscsi.disable_chap);
|
||||||
spdk_json_write_named_bool(w, "require_chap", g_spdk_iscsi.require_chap);
|
spdk_json_write_named_bool(w, "require_chap", g_iscsi.require_chap);
|
||||||
spdk_json_write_named_bool(w, "mutual_chap", g_spdk_iscsi.mutual_chap);
|
spdk_json_write_named_bool(w, "mutual_chap", g_iscsi.mutual_chap);
|
||||||
spdk_json_write_named_int32(w, "chap_group", g_spdk_iscsi.chap_group);
|
spdk_json_write_named_int32(w, "chap_group", g_iscsi.chap_group);
|
||||||
|
|
||||||
spdk_json_write_object_end(w);
|
spdk_json_write_object_end(w);
|
||||||
}
|
}
|
||||||
@ -1534,7 +1534,7 @@ spdk_iscsi_auth_groups_info_json(struct spdk_json_write_ctx *w)
|
|||||||
{
|
{
|
||||||
struct spdk_iscsi_auth_group *group;
|
struct spdk_iscsi_auth_group *group;
|
||||||
|
|
||||||
TAILQ_FOREACH(group, &g_spdk_iscsi.auth_group_head, tailq) {
|
TAILQ_FOREACH(group, &g_iscsi.auth_group_head, tailq) {
|
||||||
iscsi_auth_group_info_json(group, w);
|
iscsi_auth_group_info_json(group, w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1544,7 +1544,7 @@ iscsi_auth_groups_config_json(struct spdk_json_write_ctx *w)
|
|||||||
{
|
{
|
||||||
struct spdk_iscsi_auth_group *group;
|
struct spdk_iscsi_auth_group *group;
|
||||||
|
|
||||||
TAILQ_FOREACH(group, &g_spdk_iscsi.auth_group_head, tailq) {
|
TAILQ_FOREACH(group, &g_iscsi.auth_group_head, tailq) {
|
||||||
iscsi_auth_group_config_json(group, w);
|
iscsi_auth_group_config_json(group, w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ iscsi_portal_find_by_addr(const char *host, const char *port)
|
|||||||
{
|
{
|
||||||
struct spdk_iscsi_portal *p;
|
struct spdk_iscsi_portal *p;
|
||||||
|
|
||||||
TAILQ_FOREACH(p, &g_spdk_iscsi.portal_head, g_tailq) {
|
TAILQ_FOREACH(p, &g_iscsi.portal_head, g_tailq) {
|
||||||
if (!strcmp(p->host, host) && !strcmp(p->port, port)) {
|
if (!strcmp(p->host, host) && !strcmp(p->port, port)) {
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
@ -136,16 +136,16 @@ spdk_iscsi_portal_create(const char *host, const char *port)
|
|||||||
p->group = NULL; /* set at a later time by caller */
|
p->group = NULL; /* set at a later time by caller */
|
||||||
p->acceptor_poller = NULL;
|
p->acceptor_poller = NULL;
|
||||||
|
|
||||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
pthread_mutex_lock(&g_iscsi.mutex);
|
||||||
tmp = iscsi_portal_find_by_addr(host, port);
|
tmp = iscsi_portal_find_by_addr(host, port);
|
||||||
if (tmp != NULL) {
|
if (tmp != NULL) {
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
SPDK_ERRLOG("portal (%s, %s) already exists\n", host, port);
|
SPDK_ERRLOG("portal (%s, %s) already exists\n", host, port);
|
||||||
goto error_out;
|
goto error_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
TAILQ_INSERT_TAIL(&g_spdk_iscsi.portal_head, p, g_tailq);
|
TAILQ_INSERT_TAIL(&g_iscsi.portal_head, p, g_tailq);
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
|
|
||||||
@ -162,9 +162,9 @@ spdk_iscsi_portal_destroy(struct spdk_iscsi_portal *p)
|
|||||||
|
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "spdk_iscsi_portal_destroy\n");
|
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "spdk_iscsi_portal_destroy\n");
|
||||||
|
|
||||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
pthread_mutex_lock(&g_iscsi.mutex);
|
||||||
TAILQ_REMOVE(&g_spdk_iscsi.portal_head, p, g_tailq);
|
TAILQ_REMOVE(&g_iscsi.portal_head, p, g_tailq);
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
|
|
||||||
free(p);
|
free(p);
|
||||||
|
|
||||||
@ -298,12 +298,12 @@ spdk_iscsi_portal_grp_create(int tag)
|
|||||||
pg->ref = 0;
|
pg->ref = 0;
|
||||||
pg->tag = tag;
|
pg->tag = tag;
|
||||||
|
|
||||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
pthread_mutex_lock(&g_iscsi.mutex);
|
||||||
pg->disable_chap = g_spdk_iscsi.disable_chap;
|
pg->disable_chap = g_iscsi.disable_chap;
|
||||||
pg->require_chap = g_spdk_iscsi.require_chap;
|
pg->require_chap = g_iscsi.require_chap;
|
||||||
pg->mutual_chap = g_spdk_iscsi.mutual_chap;
|
pg->mutual_chap = g_iscsi.mutual_chap;
|
||||||
pg->chap_group = g_spdk_iscsi.chap_group;
|
pg->chap_group = g_iscsi.chap_group;
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
|
|
||||||
TAILQ_INIT(&pg->head);
|
TAILQ_INIT(&pg->head);
|
||||||
|
|
||||||
@ -334,13 +334,13 @@ spdk_iscsi_portal_grp_register(struct spdk_iscsi_portal_grp *pg)
|
|||||||
|
|
||||||
assert(pg != NULL);
|
assert(pg != NULL);
|
||||||
|
|
||||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
pthread_mutex_lock(&g_iscsi.mutex);
|
||||||
tmp = spdk_iscsi_portal_grp_find_by_tag(pg->tag);
|
tmp = spdk_iscsi_portal_grp_find_by_tag(pg->tag);
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
TAILQ_INSERT_TAIL(&g_spdk_iscsi.pg_head, pg, tailq);
|
TAILQ_INSERT_TAIL(&g_iscsi.pg_head, pg, tailq);
|
||||||
rc = 0;
|
rc = 0;
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -441,7 +441,7 @@ spdk_iscsi_portal_grp_find_by_tag(int tag)
|
|||||||
{
|
{
|
||||||
struct spdk_iscsi_portal_grp *pg;
|
struct spdk_iscsi_portal_grp *pg;
|
||||||
|
|
||||||
TAILQ_FOREACH(pg, &g_spdk_iscsi.pg_head, tailq) {
|
TAILQ_FOREACH(pg, &g_iscsi.pg_head, tailq) {
|
||||||
if (pg->tag == tag) {
|
if (pg->tag == tag) {
|
||||||
return pg;
|
return pg;
|
||||||
}
|
}
|
||||||
@ -482,15 +482,15 @@ spdk_iscsi_portal_grps_destroy(void)
|
|||||||
struct spdk_iscsi_portal_grp *pg;
|
struct spdk_iscsi_portal_grp *pg;
|
||||||
|
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "spdk_iscsi_portal_grps_destroy\n");
|
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "spdk_iscsi_portal_grps_destroy\n");
|
||||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
pthread_mutex_lock(&g_iscsi.mutex);
|
||||||
while (!TAILQ_EMPTY(&g_spdk_iscsi.pg_head)) {
|
while (!TAILQ_EMPTY(&g_iscsi.pg_head)) {
|
||||||
pg = TAILQ_FIRST(&g_spdk_iscsi.pg_head);
|
pg = TAILQ_FIRST(&g_iscsi.pg_head);
|
||||||
TAILQ_REMOVE(&g_spdk_iscsi.pg_head, pg, tailq);
|
TAILQ_REMOVE(&g_iscsi.pg_head, pg, tailq);
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
spdk_iscsi_portal_grp_destroy(pg);
|
spdk_iscsi_portal_grp_destroy(pg);
|
||||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
pthread_mutex_lock(&g_iscsi.mutex);
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -524,11 +524,11 @@ spdk_iscsi_portal_grp_close_all(void)
|
|||||||
struct spdk_iscsi_portal_grp *pg;
|
struct spdk_iscsi_portal_grp *pg;
|
||||||
|
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "spdk_iscsi_portal_grp_close_all\n");
|
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "spdk_iscsi_portal_grp_close_all\n");
|
||||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
pthread_mutex_lock(&g_iscsi.mutex);
|
||||||
TAILQ_FOREACH(pg, &g_spdk_iscsi.pg_head, tailq) {
|
TAILQ_FOREACH(pg, &g_iscsi.pg_head, tailq) {
|
||||||
iscsi_portal_grp_close(pg);
|
iscsi_portal_grp_close(pg);
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct spdk_iscsi_portal_grp *
|
struct spdk_iscsi_portal_grp *
|
||||||
@ -536,15 +536,15 @@ spdk_iscsi_portal_grp_unregister(int tag)
|
|||||||
{
|
{
|
||||||
struct spdk_iscsi_portal_grp *pg;
|
struct spdk_iscsi_portal_grp *pg;
|
||||||
|
|
||||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
pthread_mutex_lock(&g_iscsi.mutex);
|
||||||
TAILQ_FOREACH(pg, &g_spdk_iscsi.pg_head, tailq) {
|
TAILQ_FOREACH(pg, &g_iscsi.pg_head, tailq) {
|
||||||
if (pg->tag == tag) {
|
if (pg->tag == tag) {
|
||||||
TAILQ_REMOVE(&g_spdk_iscsi.pg_head, pg, tailq);
|
TAILQ_REMOVE(&g_iscsi.pg_head, pg, tailq);
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
return pg;
|
return pg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -586,7 +586,7 @@ spdk_iscsi_portal_grps_config_text(FILE *fp)
|
|||||||
fprintf(fp, "%s", portal_group_section);
|
fprintf(fp, "%s", portal_group_section);
|
||||||
|
|
||||||
/* Dump portal groups */
|
/* Dump portal groups */
|
||||||
TAILQ_FOREACH(pg, &g_spdk_iscsi.pg_head, tailq) {
|
TAILQ_FOREACH(pg, &g_iscsi.pg_head, tailq) {
|
||||||
if (NULL == pg) { continue; }
|
if (NULL == pg) { continue; }
|
||||||
fprintf(fp, PORTAL_GROUP_TMPL, pg->tag, pg->tag);
|
fprintf(fp, PORTAL_GROUP_TMPL, pg->tag, pg->tag);
|
||||||
/* Dump portals */
|
/* Dump portals */
|
||||||
@ -640,7 +640,7 @@ spdk_iscsi_portal_grps_info_json(struct spdk_json_write_ctx *w)
|
|||||||
{
|
{
|
||||||
struct spdk_iscsi_portal_grp *pg;
|
struct spdk_iscsi_portal_grp *pg;
|
||||||
|
|
||||||
TAILQ_FOREACH(pg, &g_spdk_iscsi.pg_head, tailq) {
|
TAILQ_FOREACH(pg, &g_iscsi.pg_head, tailq) {
|
||||||
iscsi_portal_grp_info_json(pg, w);
|
iscsi_portal_grp_info_json(pg, w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -650,7 +650,7 @@ spdk_iscsi_portal_grps_config_json(struct spdk_json_write_ctx *w)
|
|||||||
{
|
{
|
||||||
struct spdk_iscsi_portal_grp *pg;
|
struct spdk_iscsi_portal_grp *pg;
|
||||||
|
|
||||||
TAILQ_FOREACH(pg, &g_spdk_iscsi.pg_head, tailq) {
|
TAILQ_FOREACH(pg, &g_iscsi.pg_head, tailq) {
|
||||||
iscsi_portal_grp_config_json(pg, w);
|
iscsi_portal_grp_config_json(pg, w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ iscsi_task_free(struct spdk_scsi_task *scsi_task)
|
|||||||
spdk_iscsi_task_disassociate_pdu(task);
|
spdk_iscsi_task_disassociate_pdu(task);
|
||||||
assert(task->conn->pending_task_cnt > 0);
|
assert(task->conn->pending_task_cnt > 0);
|
||||||
task->conn->pending_task_cnt--;
|
task->conn->pending_task_cnt--;
|
||||||
spdk_mempool_put(g_spdk_iscsi.task_pool, (void *)task);
|
spdk_mempool_put(g_iscsi.task_pool, (void *)task);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct spdk_iscsi_task *
|
struct spdk_iscsi_task *
|
||||||
@ -64,7 +64,7 @@ spdk_iscsi_task_get(struct spdk_iscsi_conn *conn, struct spdk_iscsi_task *parent
|
|||||||
{
|
{
|
||||||
struct spdk_iscsi_task *task;
|
struct spdk_iscsi_task *task;
|
||||||
|
|
||||||
task = spdk_mempool_get(g_spdk_iscsi.task_pool);
|
task = spdk_mempool_get(g_iscsi.task_pool);
|
||||||
if (!task) {
|
if (!task) {
|
||||||
SPDK_ERRLOG("Unable to get task\n");
|
SPDK_ERRLOG("Unable to get task\n");
|
||||||
abort();
|
abort();
|
||||||
|
@ -330,8 +330,8 @@ spdk_iscsi_send_tgts(struct spdk_iscsi_conn *conn, const char *iiqn,
|
|||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
pthread_mutex_lock(&g_iscsi.mutex);
|
||||||
TAILQ_FOREACH(target, &g_spdk_iscsi.target_head, tailq) {
|
TAILQ_FOREACH(target, &g_iscsi.target_head, tailq) {
|
||||||
if (strcasecmp(tiqn, "ALL") != 0
|
if (strcasecmp(tiqn, "ALL") != 0
|
||||||
&& strcasecmp(tiqn, target->name) != 0) {
|
&& strcasecmp(tiqn, target->name) != 0) {
|
||||||
continue;
|
continue;
|
||||||
@ -351,7 +351,7 @@ spdk_iscsi_send_tgts(struct spdk_iscsi_conn *conn, const char *iiqn,
|
|||||||
pg = pg_map->pg;
|
pg = pg_map->pg;
|
||||||
TAILQ_FOREACH(p, &pg->head, per_pg_tailq) {
|
TAILQ_FOREACH(p, &pg->head, per_pg_tailq) {
|
||||||
if (alloc_len - total < 1) {
|
if (alloc_len - total < 1) {
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
SPDK_ERRLOG("data space small %d\n", alloc_len);
|
SPDK_ERRLOG("data space small %d\n", alloc_len);
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
@ -383,7 +383,7 @@ spdk_iscsi_send_tgts(struct spdk_iscsi_conn *conn, const char *iiqn,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
|
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
@ -396,7 +396,7 @@ spdk_iscsi_find_tgt_node(const char *target_name)
|
|||||||
if (target_name == NULL) {
|
if (target_name == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
TAILQ_FOREACH(target, &g_spdk_iscsi.target_head, tailq) {
|
TAILQ_FOREACH(target, &g_iscsi.target_head, tailq) {
|
||||||
if (strcasecmp(target_name, target->name) == 0) {
|
if (strcasecmp(target_name, target->name) == 0) {
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
@ -408,16 +408,16 @@ spdk_iscsi_find_tgt_node(const char *target_name)
|
|||||||
static int
|
static int
|
||||||
iscsi_tgt_node_register(struct spdk_iscsi_tgt_node *target)
|
iscsi_tgt_node_register(struct spdk_iscsi_tgt_node *target)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
pthread_mutex_lock(&g_iscsi.mutex);
|
||||||
|
|
||||||
if (spdk_iscsi_find_tgt_node(target->name) != NULL) {
|
if (spdk_iscsi_find_tgt_node(target->name) != NULL) {
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
return -EEXIST;
|
return -EEXIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
TAILQ_INSERT_TAIL(&g_spdk_iscsi.target_head, target, tailq);
|
TAILQ_INSERT_TAIL(&g_iscsi.target_head, target, tailq);
|
||||||
|
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -426,9 +426,9 @@ iscsi_tgt_node_unregister(struct spdk_iscsi_tgt_node *target)
|
|||||||
{
|
{
|
||||||
struct spdk_iscsi_tgt_node *t;
|
struct spdk_iscsi_tgt_node *t;
|
||||||
|
|
||||||
TAILQ_FOREACH(t, &g_spdk_iscsi.target_head, tailq) {
|
TAILQ_FOREACH(t, &g_iscsi.target_head, tailq) {
|
||||||
if (t == target) {
|
if (t == target) {
|
||||||
TAILQ_REMOVE(&g_spdk_iscsi.target_head, t, tailq);
|
TAILQ_REMOVE(&g_iscsi.target_head, t, tailq);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -638,9 +638,9 @@ _iscsi_tgt_node_destruct(void *cb_arg, int rc)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
pthread_mutex_lock(&g_iscsi.mutex);
|
||||||
iscsi_tgt_node_delete_all_pg_maps(target);
|
iscsi_tgt_node_delete_all_pg_maps(target);
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
|
|
||||||
pthread_mutex_destroy(&target->mutex);
|
pthread_mutex_destroy(&target->mutex);
|
||||||
free(target);
|
free(target);
|
||||||
@ -793,7 +793,7 @@ spdk_iscsi_target_node_add_pg_ig_maps(struct spdk_iscsi_tgt_node *target,
|
|||||||
uint16_t i;
|
uint16_t i;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
pthread_mutex_lock(&g_iscsi.mutex);
|
||||||
for (i = 0; i < num_maps; i++) {
|
for (i = 0; i < num_maps; i++) {
|
||||||
rc = iscsi_tgt_node_add_pg_ig_map(target, pg_tag_list[i],
|
rc = iscsi_tgt_node_add_pg_ig_map(target, pg_tag_list[i],
|
||||||
ig_tag_list[i]);
|
ig_tag_list[i]);
|
||||||
@ -802,7 +802,7 @@ spdk_iscsi_target_node_add_pg_ig_maps(struct spdk_iscsi_tgt_node *target,
|
|||||||
goto invalid;
|
goto invalid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
invalid:
|
invalid:
|
||||||
@ -810,7 +810,7 @@ invalid:
|
|||||||
iscsi_tgt_node_delete_pg_ig_map(target, pg_tag_list[i - 1],
|
iscsi_tgt_node_delete_pg_ig_map(target, pg_tag_list[i - 1],
|
||||||
ig_tag_list[i - 1]);
|
ig_tag_list[i - 1]);
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -821,7 +821,7 @@ spdk_iscsi_target_node_remove_pg_ig_maps(struct spdk_iscsi_tgt_node *target,
|
|||||||
uint16_t i;
|
uint16_t i;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
pthread_mutex_lock(&g_iscsi.mutex);
|
||||||
for (i = 0; i < num_maps; i++) {
|
for (i = 0; i < num_maps; i++) {
|
||||||
rc = iscsi_tgt_node_delete_pg_ig_map(target, pg_tag_list[i],
|
rc = iscsi_tgt_node_delete_pg_ig_map(target, pg_tag_list[i],
|
||||||
ig_tag_list[i]);
|
ig_tag_list[i]);
|
||||||
@ -830,7 +830,7 @@ spdk_iscsi_target_node_remove_pg_ig_maps(struct spdk_iscsi_tgt_node *target,
|
|||||||
goto invalid;
|
goto invalid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
invalid:
|
invalid:
|
||||||
@ -842,7 +842,7 @@ invalid:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -947,7 +947,7 @@ struct spdk_iscsi_tgt_node *spdk_iscsi_tgt_node_construct(int target_index,
|
|||||||
if (strncasecmp(name, "iqn.", 4) != 0
|
if (strncasecmp(name, "iqn.", 4) != 0
|
||||||
&& strncasecmp(name, "eui.", 4) != 0
|
&& strncasecmp(name, "eui.", 4) != 0
|
||||||
&& strncasecmp(name, "naa.", 4) != 0) {
|
&& strncasecmp(name, "naa.", 4) != 0) {
|
||||||
snprintf(fullname, sizeof(fullname), "%s:%s", g_spdk_iscsi.nodebase, name);
|
snprintf(fullname, sizeof(fullname), "%s:%s", g_iscsi.nodebase, name);
|
||||||
} else {
|
} else {
|
||||||
snprintf(fullname, sizeof(fullname), "%s", name);
|
snprintf(fullname, sizeof(fullname), "%s", name);
|
||||||
}
|
}
|
||||||
@ -1007,12 +1007,12 @@ struct spdk_iscsi_tgt_node *spdk_iscsi_tgt_node_construct(int target_index,
|
|||||||
target->header_digest = header_digest;
|
target->header_digest = header_digest;
|
||||||
target->data_digest = data_digest;
|
target->data_digest = data_digest;
|
||||||
|
|
||||||
if (queue_depth > 0 && ((uint32_t)queue_depth <= g_spdk_iscsi.MaxQueueDepth)) {
|
if (queue_depth > 0 && ((uint32_t)queue_depth <= g_iscsi.MaxQueueDepth)) {
|
||||||
target->queue_depth = queue_depth;
|
target->queue_depth = queue_depth;
|
||||||
} else {
|
} else {
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "QueueDepth %d is invalid and %d is used instead.\n",
|
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "QueueDepth %d is invalid and %d is used instead.\n",
|
||||||
queue_depth, g_spdk_iscsi.MaxQueueDepth);
|
queue_depth, g_iscsi.MaxQueueDepth);
|
||||||
target->queue_depth = g_spdk_iscsi.MaxQueueDepth;
|
target->queue_depth = g_iscsi.MaxQueueDepth;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = iscsi_tgt_node_register(target);
|
rc = iscsi_tgt_node_register(target);
|
||||||
@ -1198,7 +1198,7 @@ iscsi_parse_tgt_node(struct spdk_conf_section *sp)
|
|||||||
|
|
||||||
val = spdk_conf_section_get_val(sp, "QueueDepth");
|
val = spdk_conf_section_get_val(sp, "QueueDepth");
|
||||||
if (val == NULL) {
|
if (val == NULL) {
|
||||||
queue_depth = g_spdk_iscsi.MaxQueueDepth;
|
queue_depth = g_iscsi.MaxQueueDepth;
|
||||||
} else {
|
} else {
|
||||||
queue_depth = (int) strtol(val, NULL, 10);
|
queue_depth = (int) strtol(val, NULL, 10);
|
||||||
}
|
}
|
||||||
@ -1279,18 +1279,18 @@ spdk_iscsi_shutdown_tgt_nodes(void)
|
|||||||
{
|
{
|
||||||
struct spdk_iscsi_tgt_node *target;
|
struct spdk_iscsi_tgt_node *target;
|
||||||
|
|
||||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
pthread_mutex_lock(&g_iscsi.mutex);
|
||||||
while (!TAILQ_EMPTY(&g_spdk_iscsi.target_head)) {
|
while (!TAILQ_EMPTY(&g_iscsi.target_head)) {
|
||||||
target = TAILQ_FIRST(&g_spdk_iscsi.target_head);
|
target = TAILQ_FIRST(&g_iscsi.target_head);
|
||||||
TAILQ_REMOVE(&g_spdk_iscsi.target_head, target, tailq);
|
TAILQ_REMOVE(&g_iscsi.target_head, target, tailq);
|
||||||
|
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
|
|
||||||
iscsi_tgt_node_destruct(target, NULL, NULL);
|
iscsi_tgt_node_destruct(target, NULL, NULL);
|
||||||
|
|
||||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
pthread_mutex_lock(&g_iscsi.mutex);
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1299,17 +1299,17 @@ spdk_iscsi_shutdown_tgt_node_by_name(const char *target_name,
|
|||||||
{
|
{
|
||||||
struct spdk_iscsi_tgt_node *target;
|
struct spdk_iscsi_tgt_node *target;
|
||||||
|
|
||||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
pthread_mutex_lock(&g_iscsi.mutex);
|
||||||
target = spdk_iscsi_find_tgt_node(target_name);
|
target = spdk_iscsi_find_tgt_node(target_name);
|
||||||
if (target != NULL) {
|
if (target != NULL) {
|
||||||
iscsi_tgt_node_unregister(target);
|
iscsi_tgt_node_unregister(target);
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
|
|
||||||
iscsi_tgt_node_destruct(target, cb_fn, cb_arg);
|
iscsi_tgt_node_destruct(target, cb_fn, cb_arg);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
|
|
||||||
if (cb_fn) {
|
if (cb_fn) {
|
||||||
cb_fn(cb_arg, -ENOENT);
|
cb_fn(cb_arg, -ENOENT);
|
||||||
@ -1358,8 +1358,8 @@ void spdk_iscsi_tgt_node_delete_map(struct spdk_iscsi_portal_grp *portal_group,
|
|||||||
{
|
{
|
||||||
struct spdk_iscsi_tgt_node *target;
|
struct spdk_iscsi_tgt_node *target;
|
||||||
|
|
||||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
pthread_mutex_lock(&g_iscsi.mutex);
|
||||||
TAILQ_FOREACH(target, &g_spdk_iscsi.target_head, tailq) {
|
TAILQ_FOREACH(target, &g_iscsi.target_head, tailq) {
|
||||||
if (portal_group) {
|
if (portal_group) {
|
||||||
iscsi_tgt_node_delete_pg_map(target, portal_group);
|
iscsi_tgt_node_delete_pg_map(target, portal_group);
|
||||||
}
|
}
|
||||||
@ -1367,7 +1367,7 @@ void spdk_iscsi_tgt_node_delete_map(struct spdk_iscsi_portal_grp *portal_group,
|
|||||||
iscsi_tgt_node_delete_ig_maps(target, initiator_group);
|
iscsi_tgt_node_delete_ig_maps(target, initiator_group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_iscsi.mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -1461,7 +1461,7 @@ spdk_iscsi_tgt_nodes_config_text(FILE *fp)
|
|||||||
/* Create target nodes section */
|
/* Create target nodes section */
|
||||||
fprintf(fp, "%s", target_nodes_section);
|
fprintf(fp, "%s", target_nodes_section);
|
||||||
|
|
||||||
TAILQ_FOREACH(target, &g_spdk_iscsi.target_head, tailq) {
|
TAILQ_FOREACH(target, &g_iscsi.target_head, tailq) {
|
||||||
int idx;
|
int idx;
|
||||||
const char *authmethod = "None";
|
const char *authmethod = "None";
|
||||||
char authgroup[32] = "None";
|
char authgroup[32] = "None";
|
||||||
@ -1593,7 +1593,7 @@ spdk_iscsi_tgt_nodes_info_json(struct spdk_json_write_ctx *w)
|
|||||||
{
|
{
|
||||||
struct spdk_iscsi_tgt_node *target;
|
struct spdk_iscsi_tgt_node *target;
|
||||||
|
|
||||||
TAILQ_FOREACH(target, &g_spdk_iscsi.target_head, tailq) {
|
TAILQ_FOREACH(target, &g_iscsi.target_head, tailq) {
|
||||||
iscsi_tgt_node_info_json(target, w);
|
iscsi_tgt_node_info_json(target, w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1603,7 +1603,7 @@ spdk_iscsi_tgt_nodes_config_json(struct spdk_json_write_ctx *w)
|
|||||||
{
|
{
|
||||||
struct spdk_iscsi_tgt_node *target;
|
struct spdk_iscsi_tgt_node *target;
|
||||||
|
|
||||||
TAILQ_FOREACH(target, &g_spdk_iscsi.target_head, tailq) {
|
TAILQ_FOREACH(target, &g_iscsi.target_head, tailq) {
|
||||||
iscsi_tgt_node_config_json(target, w);
|
iscsi_tgt_node_config_json(target, w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ struct spdk_scsi_lun {
|
|||||||
uint8_t reserved;
|
uint8_t reserved;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct spdk_iscsi_globals g_spdk_iscsi;
|
struct spdk_iscsi_globals g_iscsi;
|
||||||
static TAILQ_HEAD(read_tasks_head, spdk_iscsi_task) g_ut_read_tasks =
|
static TAILQ_HEAD(read_tasks_head, spdk_iscsi_task) g_ut_read_tasks =
|
||||||
TAILQ_HEAD_INITIALIZER(g_ut_read_tasks);
|
TAILQ_HEAD_INITIALIZER(g_ut_read_tasks);
|
||||||
static struct spdk_iscsi_task *g_new_task = NULL;
|
static struct spdk_iscsi_task *g_new_task = NULL;
|
||||||
|
@ -40,14 +40,14 @@
|
|||||||
|
|
||||||
SPDK_LOG_REGISTER_COMPONENT("iscsi", SPDK_LOG_ISCSI)
|
SPDK_LOG_REGISTER_COMPONENT("iscsi", SPDK_LOG_ISCSI)
|
||||||
|
|
||||||
struct spdk_iscsi_globals g_spdk_iscsi;
|
struct spdk_iscsi_globals g_iscsi;
|
||||||
|
|
||||||
const char *config_file;
|
const char *config_file;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
test_setup(void)
|
test_setup(void)
|
||||||
{
|
{
|
||||||
TAILQ_INIT(&g_spdk_iscsi.ig_head);
|
TAILQ_INIT(&g_iscsi.ig_head);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,9 +229,9 @@ op_login_session_normal_test(void)
|
|||||||
CU_ASSERT(rsph->status_detail == ISCSI_LOGIN_CONN_ADD_FAIL);
|
CU_ASSERT(rsph->status_detail == ISCSI_LOGIN_CONN_ADD_FAIL);
|
||||||
|
|
||||||
/* expect failure: session found while tag is wrong */
|
/* expect failure: session found while tag is wrong */
|
||||||
g_spdk_iscsi.MaxSessions = UT_ISCSI_TSIH * 2;
|
g_iscsi.MaxSessions = UT_ISCSI_TSIH * 2;
|
||||||
g_spdk_iscsi.session = calloc(1, sizeof(void *) * g_spdk_iscsi.MaxSessions);
|
g_iscsi.session = calloc(1, sizeof(void *) * g_iscsi.MaxSessions);
|
||||||
g_spdk_iscsi.session[UT_ISCSI_TSIH - 1] = &sess;
|
g_iscsi.session[UT_ISCSI_TSIH - 1] = &sess;
|
||||||
sess.tsih = UT_ISCSI_TSIH;
|
sess.tsih = UT_ISCSI_TSIH;
|
||||||
rsph->tsih = UT_ISCSI_TSIH >> 8; /* to append the session */
|
rsph->tsih = UT_ISCSI_TSIH >> 8; /* to append the session */
|
||||||
sess.tag = 1;
|
sess.tag = 1;
|
||||||
@ -244,19 +244,19 @@ op_login_session_normal_test(void)
|
|||||||
|
|
||||||
/* expect suceess: drop the session */
|
/* expect suceess: drop the session */
|
||||||
rsph->tsih = 0; /* to create the session */
|
rsph->tsih = 0; /* to create the session */
|
||||||
g_spdk_iscsi.AllowDuplicateIsid = false;
|
g_iscsi.AllowDuplicateIsid = false;
|
||||||
rc = iscsi_op_login_session_normal(&conn, &rsp_pdu, UT_INITIATOR_NAME1,
|
rc = iscsi_op_login_session_normal(&conn, &rsp_pdu, UT_INITIATOR_NAME1,
|
||||||
¶m, 0);
|
¶m, 0);
|
||||||
CU_ASSERT(rc == 0);
|
CU_ASSERT(rc == 0);
|
||||||
|
|
||||||
/* expect suceess: create the session */
|
/* expect suceess: create the session */
|
||||||
rsph->tsih = 0; /* to create the session */
|
rsph->tsih = 0; /* to create the session */
|
||||||
g_spdk_iscsi.AllowDuplicateIsid = true;
|
g_iscsi.AllowDuplicateIsid = true;
|
||||||
rc = iscsi_op_login_session_normal(&conn, &rsp_pdu, UT_INITIATOR_NAME1,
|
rc = iscsi_op_login_session_normal(&conn, &rsp_pdu, UT_INITIATOR_NAME1,
|
||||||
¶m, 0);
|
¶m, 0);
|
||||||
CU_ASSERT(rc == 0);
|
CU_ASSERT(rc == 0);
|
||||||
|
|
||||||
free(g_spdk_iscsi.session);
|
free(g_iscsi.session);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
#include "spdk_internal/mock.h"
|
#include "spdk_internal/mock.h"
|
||||||
|
|
||||||
struct spdk_iscsi_globals g_spdk_iscsi;
|
struct spdk_iscsi_globals g_iscsi;
|
||||||
|
|
||||||
DEFINE_STUB(spdk_iscsi_find_tgt_node, struct spdk_iscsi_tgt_node *,
|
DEFINE_STUB(spdk_iscsi_find_tgt_node, struct spdk_iscsi_tgt_node *,
|
||||||
(const char *target_name), NULL);
|
(const char *target_name), NULL);
|
||||||
|
@ -49,14 +49,14 @@ DEFINE_STUB(spdk_iscsi_conn_construct, int,
|
|||||||
(struct spdk_iscsi_portal *portal, struct spdk_sock *sock),
|
(struct spdk_iscsi_portal *portal, struct spdk_sock *sock),
|
||||||
0);
|
0);
|
||||||
|
|
||||||
struct spdk_iscsi_globals g_spdk_iscsi;
|
struct spdk_iscsi_globals g_iscsi;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
test_setup(void)
|
test_setup(void)
|
||||||
{
|
{
|
||||||
TAILQ_INIT(&g_spdk_iscsi.portal_head);
|
TAILQ_INIT(&g_iscsi.portal_head);
|
||||||
TAILQ_INIT(&g_spdk_iscsi.pg_head);
|
TAILQ_INIT(&g_iscsi.pg_head);
|
||||||
pthread_mutex_init(&g_spdk_iscsi.mutex, NULL);
|
pthread_mutex_init(&g_iscsi.mutex, NULL);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ portal_create_ipv4_normal_case(void)
|
|||||||
CU_ASSERT(p != NULL);
|
CU_ASSERT(p != NULL);
|
||||||
|
|
||||||
spdk_iscsi_portal_destroy(p);
|
spdk_iscsi_portal_destroy(p);
|
||||||
CU_ASSERT(TAILQ_EMPTY(&g_spdk_iscsi.portal_head));
|
CU_ASSERT(TAILQ_EMPTY(&g_iscsi.portal_head));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -87,7 +87,7 @@ portal_create_ipv6_normal_case(void)
|
|||||||
CU_ASSERT(p != NULL);
|
CU_ASSERT(p != NULL);
|
||||||
|
|
||||||
spdk_iscsi_portal_destroy(p);
|
spdk_iscsi_portal_destroy(p);
|
||||||
CU_ASSERT(TAILQ_EMPTY(&g_spdk_iscsi.portal_head));
|
CU_ASSERT(TAILQ_EMPTY(&g_iscsi.portal_head));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -102,7 +102,7 @@ portal_create_ipv4_wildcard_case(void)
|
|||||||
CU_ASSERT(p != NULL);
|
CU_ASSERT(p != NULL);
|
||||||
|
|
||||||
spdk_iscsi_portal_destroy(p);
|
spdk_iscsi_portal_destroy(p);
|
||||||
CU_ASSERT(TAILQ_EMPTY(&g_spdk_iscsi.portal_head));
|
CU_ASSERT(TAILQ_EMPTY(&g_iscsi.portal_head));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -117,7 +117,7 @@ portal_create_ipv6_wildcard_case(void)
|
|||||||
CU_ASSERT(p != NULL);
|
CU_ASSERT(p != NULL);
|
||||||
|
|
||||||
spdk_iscsi_portal_destroy(p);
|
spdk_iscsi_portal_destroy(p);
|
||||||
CU_ASSERT(TAILQ_EMPTY(&g_spdk_iscsi.portal_head));
|
CU_ASSERT(TAILQ_EMPTY(&g_iscsi.portal_head));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -135,7 +135,7 @@ portal_create_twice_case(void)
|
|||||||
CU_ASSERT(p2 == NULL);
|
CU_ASSERT(p2 == NULL);
|
||||||
|
|
||||||
spdk_iscsi_portal_destroy(p1);
|
spdk_iscsi_portal_destroy(p1);
|
||||||
CU_ASSERT(TAILQ_EMPTY(&g_spdk_iscsi.portal_head));
|
CU_ASSERT(TAILQ_EMPTY(&g_iscsi.portal_head));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -154,7 +154,7 @@ parse_portal_ipv4_normal_case(void)
|
|||||||
CU_ASSERT(strcmp(p->port, port_str) == 0);
|
CU_ASSERT(strcmp(p->port, port_str) == 0);
|
||||||
|
|
||||||
spdk_iscsi_portal_destroy(p);
|
spdk_iscsi_portal_destroy(p);
|
||||||
CU_ASSERT(TAILQ_EMPTY(&g_spdk_iscsi.portal_head));
|
CU_ASSERT(TAILQ_EMPTY(&g_iscsi.portal_head));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ parse_portal_ipv6_normal_case(void)
|
|||||||
CU_ASSERT(strcmp(p->port, port_str) == 0);
|
CU_ASSERT(strcmp(p->port, port_str) == 0);
|
||||||
|
|
||||||
spdk_iscsi_portal_destroy(p);
|
spdk_iscsi_portal_destroy(p);
|
||||||
CU_ASSERT(TAILQ_EMPTY(&g_spdk_iscsi.portal_head));
|
CU_ASSERT(TAILQ_EMPTY(&g_iscsi.portal_head));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -193,7 +193,7 @@ parse_portal_ipv4_skip_port_case(void)
|
|||||||
CU_ASSERT(strcmp(p->port, port_str) == 0);
|
CU_ASSERT(strcmp(p->port, port_str) == 0);
|
||||||
|
|
||||||
spdk_iscsi_portal_destroy(p);
|
spdk_iscsi_portal_destroy(p);
|
||||||
CU_ASSERT(TAILQ_EMPTY(&g_spdk_iscsi.portal_head));
|
CU_ASSERT(TAILQ_EMPTY(&g_iscsi.portal_head));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -212,7 +212,7 @@ parse_portal_ipv6_skip_port_case(void)
|
|||||||
CU_ASSERT(strcmp(p->port, port_str) == 0);
|
CU_ASSERT(strcmp(p->port, port_str) == 0);
|
||||||
|
|
||||||
spdk_iscsi_portal_destroy(p);
|
spdk_iscsi_portal_destroy(p);
|
||||||
CU_ASSERT(TAILQ_EMPTY(&g_spdk_iscsi.portal_head));
|
CU_ASSERT(TAILQ_EMPTY(&g_iscsi.portal_head));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -239,11 +239,11 @@ portal_grp_register_unregister_case(void)
|
|||||||
CU_ASSERT(pg2 != NULL);
|
CU_ASSERT(pg2 != NULL);
|
||||||
CU_ASSERT(pg1 == pg2);
|
CU_ASSERT(pg1 == pg2);
|
||||||
|
|
||||||
CU_ASSERT(TAILQ_EMPTY(&g_spdk_iscsi.pg_head));
|
CU_ASSERT(TAILQ_EMPTY(&g_iscsi.pg_head));
|
||||||
|
|
||||||
spdk_iscsi_portal_grp_destroy(pg1);
|
spdk_iscsi_portal_grp_destroy(pg1);
|
||||||
|
|
||||||
CU_ASSERT(TAILQ_EMPTY(&g_spdk_iscsi.portal_head));
|
CU_ASSERT(TAILQ_EMPTY(&g_iscsi.portal_head));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -273,11 +273,11 @@ portal_grp_register_twice_case(void)
|
|||||||
CU_ASSERT(pg2 != NULL);
|
CU_ASSERT(pg2 != NULL);
|
||||||
CU_ASSERT(pg1 == pg2);
|
CU_ASSERT(pg1 == pg2);
|
||||||
|
|
||||||
CU_ASSERT(TAILQ_EMPTY(&g_spdk_iscsi.pg_head));
|
CU_ASSERT(TAILQ_EMPTY(&g_iscsi.pg_head));
|
||||||
|
|
||||||
spdk_iscsi_portal_grp_destroy(pg1);
|
spdk_iscsi_portal_grp_destroy(pg1);
|
||||||
|
|
||||||
CU_ASSERT(TAILQ_EMPTY(&g_spdk_iscsi.portal_head));
|
CU_ASSERT(TAILQ_EMPTY(&g_iscsi.portal_head));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -320,8 +320,8 @@ portal_grp_add_delete_case(void)
|
|||||||
|
|
||||||
poll_thread(0);
|
poll_thread(0);
|
||||||
|
|
||||||
CU_ASSERT(TAILQ_EMPTY(&g_spdk_iscsi.portal_head));
|
CU_ASSERT(TAILQ_EMPTY(&g_iscsi.portal_head));
|
||||||
CU_ASSERT(TAILQ_EMPTY(&g_spdk_iscsi.pg_head));
|
CU_ASSERT(TAILQ_EMPTY(&g_iscsi.pg_head));
|
||||||
|
|
||||||
free_threads();
|
free_threads();
|
||||||
}
|
}
|
||||||
@ -379,8 +379,8 @@ portal_grp_add_delete_twice_case(void)
|
|||||||
|
|
||||||
spdk_iscsi_portal_grps_destroy();
|
spdk_iscsi_portal_grps_destroy();
|
||||||
|
|
||||||
CU_ASSERT(TAILQ_EMPTY(&g_spdk_iscsi.portal_head));
|
CU_ASSERT(TAILQ_EMPTY(&g_iscsi.portal_head));
|
||||||
CU_ASSERT(TAILQ_EMPTY(&g_spdk_iscsi.pg_head));
|
CU_ASSERT(TAILQ_EMPTY(&g_iscsi.pg_head));
|
||||||
|
|
||||||
MOCK_CLEAR_P(spdk_sock_listen);
|
MOCK_CLEAR_P(spdk_sock_listen);
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
#include "unit/lib/json_mock.c"
|
#include "unit/lib/json_mock.c"
|
||||||
#include "common/lib/test_env.c"
|
#include "common/lib/test_env.c"
|
||||||
|
|
||||||
struct spdk_iscsi_globals g_spdk_iscsi;
|
struct spdk_iscsi_globals g_iscsi;
|
||||||
|
|
||||||
const char *config_file;
|
const char *config_file;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user