diff options
author | Edward Tomasz Napierala <trasz@FreeBSD.org> | 2014-04-16 10:06:37 +0000 |
---|---|---|
committer | Edward Tomasz Napierala <trasz@FreeBSD.org> | 2014-04-16 10:06:37 +0000 |
commit | ba3a2d31c810f11860330921fc4863274988172a (patch) | |
tree | 90ca69bfbb810a738dbe9edbe210611d69f49ba9 /sys/cam/ctl/ctl_frontend_iscsi.c | |
parent | 79bde95f51be75e30a1b26c1e6ed2cd07d889419 (diff) | |
download | src-ba3a2d31c810f11860330921fc4863274988172a.tar.gz src-ba3a2d31c810f11860330921fc4863274988172a.zip |
Make it possible for the iSCSI target side to operate in both normal
and ICL_KERNEL_PROXY mode, and fix some bit rot so the latter actually
works again.
Sponsored by: The FreeBSD Foundation
Notes
Notes:
svn path=/head/; revision=264524
Diffstat (limited to 'sys/cam/ctl/ctl_frontend_iscsi.c')
-rw-r--r-- | sys/cam/ctl/ctl_frontend_iscsi.c | 74 |
1 files changed, 45 insertions, 29 deletions
diff --git a/sys/cam/ctl/ctl_frontend_iscsi.c b/sys/cam/ctl/ctl_frontend_iscsi.c index 57517c3f08c2..411aafc748c7 100644 --- a/sys/cam/ctl/ctl_frontend_iscsi.c +++ b/sys/cam/ctl/ctl_frontend_iscsi.c @@ -1419,9 +1419,7 @@ cfiscsi_ioctl_handoff(struct ctl_iscsi *ci) struct cfiscsi_session *cs; struct cfiscsi_target *ct; struct ctl_iscsi_handoff_params *cihp; -#ifndef ICL_KERNEL_PROXY int error; -#endif cihp = (struct ctl_iscsi_handoff_params *)&(ci->data); softc = &cfiscsi_softc; @@ -1446,27 +1444,39 @@ cfiscsi_ioctl_handoff(struct ctl_iscsi *ci) } #ifdef ICL_KERNEL_PROXY - mtx_lock(&cfiscsi_softc.lock); - TAILQ_FOREACH(cs, &cfiscsi_softc.sessions, cs_next) { - if (cs->cs_id == cihp->socket) - break; - } - if (cs == NULL) { - mtx_unlock(&cfiscsi_softc.lock); - snprintf(ci->error_str, sizeof(ci->error_str), "connection not found"); + if (cihp->socket > 0 && cihp->connection_id > 0) { + snprintf(ci->error_str, sizeof(ci->error_str), + "both socket and connection_id set"); ci->status = CTL_ISCSI_ERROR; cfiscsi_target_release(ct); return; } - mtx_unlock(&cfiscsi_softc.lock); -#else - cs = cfiscsi_session_new(softc); - if (cs == NULL) { - ci->status = CTL_ISCSI_ERROR; - snprintf(ci->error_str, sizeof(ci->error_str), - "%s: cfiscsi_session_new failed", __func__); - cfiscsi_target_release(ct); - return; + if (cihp->socket == 0) { + mtx_lock(&cfiscsi_softc.lock); + TAILQ_FOREACH(cs, &cfiscsi_softc.sessions, cs_next) { + if (cs->cs_id == cihp->socket) + break; + } + if (cs == NULL) { + mtx_unlock(&cfiscsi_softc.lock); + snprintf(ci->error_str, sizeof(ci->error_str), + "connection not found"); + ci->status = CTL_ISCSI_ERROR; + cfiscsi_target_release(ct); + return; + } + mtx_unlock(&cfiscsi_softc.lock); + } else { +#endif + cs = cfiscsi_session_new(softc); + if (cs == NULL) { + ci->status = CTL_ISCSI_ERROR; + snprintf(ci->error_str, sizeof(ci->error_str), + "%s: cfiscsi_session_new failed", __func__); + cfiscsi_target_release(ct); + return; + } +#ifdef ICL_KERNEL_PROXY } #endif cs->cs_target = ct; @@ -1495,16 +1505,18 @@ cfiscsi_ioctl_handoff(struct ctl_iscsi *ci) cihp->initiator_alias, sizeof(cs->cs_initiator_alias)); #ifdef ICL_KERNEL_PROXY - cs->cs_login_phase = false; -#else - error = icl_conn_handoff(cs->cs_conn, cihp->socket); - if (error != 0) { - cfiscsi_session_delete(cs); - ci->status = CTL_ISCSI_ERROR; - snprintf(ci->error_str, sizeof(ci->error_str), - "%s: icl_conn_handoff failed with error %d", - __func__, error); - return; + if (cihp->socket > 0) { +#endif + error = icl_conn_handoff(cs->cs_conn, cihp->socket); + if (error != 0) { + cfiscsi_session_delete(cs); + ci->status = CTL_ISCSI_ERROR; + snprintf(ci->error_str, sizeof(ci->error_str), + "%s: icl_conn_handoff failed with error %d", + __func__, error); + return; + } +#ifdef ICL_KERNEL_PROXY } #endif @@ -1514,6 +1526,8 @@ cfiscsi_ioctl_handoff(struct ctl_iscsi *ci) cfiscsi_session_register_initiator(cs); #ifdef ICL_KERNEL_PROXY + cs->cs_login_phase = false; + /* * First PDU of the Full Feature phase has likely already arrived. * We have to pick it up and execute properly. @@ -1831,7 +1845,9 @@ cfiscsi_ioctl_send(struct ctl_iscsi *ci) icl_pdu_append_data(ip, data, datalen, M_WAITOK); free(data, M_CFISCSI); } + CFISCSI_SESSION_LOCK(cs); icl_pdu_queue(ip); + CFISCSI_SESSION_UNLOCK(cs); ci->status = CTL_ISCSI_OK; } |