ctl_frontend_iscsi.c (268258) | ctl_frontend_iscsi.c (268259) |
---|---|
1/*- 2 * Copyright (c) 2012 The FreeBSD Foundation 3 * All rights reserved. 4 * 5 * This software was developed by Edward Tomasz Napierala under sponsorship 6 * from the FreeBSD Foundation. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 12 unchanged lines hidden (view full) --- 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * | 1/*- 2 * Copyright (c) 2012 The FreeBSD Foundation 3 * All rights reserved. 4 * 5 * This software was developed by Edward Tomasz Napierala under sponsorship 6 * from the FreeBSD Foundation. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 12 unchanged lines hidden (view full) --- 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * |
29 * $FreeBSD: stable/10/sys/cam/ctl/ctl_frontend_iscsi.c 268258 2014-07-04 16:07:57Z mav $ | 29 * $FreeBSD: stable/10/sys/cam/ctl/ctl_frontend_iscsi.c 268259 2014-07-04 16:09:09Z mav $ |
30 */ 31 32/* 33 * CTL frontend for the iSCSI protocol. 34 */ 35 36#include <sys/cdefs.h> | 30 */ 31 32/* 33 * CTL frontend for the iSCSI protocol. 34 */ 35 36#include <sys/cdefs.h> |
37__FBSDID("$FreeBSD: stable/10/sys/cam/ctl/ctl_frontend_iscsi.c 268258 2014-07-04 16:07:57Z mav $"); | 37__FBSDID("$FreeBSD: stable/10/sys/cam/ctl/ctl_frontend_iscsi.c 268259 2014-07-04 16:09:09Z mav $"); |
38 39#include <sys/param.h> 40#include <sys/capability.h> 41#include <sys/condvar.h> 42#include <sys/file.h> 43#include <sys/kernel.h> 44#include <sys/kthread.h> 45#include <sys/lock.h> --- 993 unchanged lines hidden (view full) --- 1039 cfiscsi_pdu_queue(cp); 1040} 1041 1042static void 1043cfiscsi_session_terminate_tasks(struct cfiscsi_session *cs) 1044{ 1045 struct cfiscsi_data_wait *cdw, *tmpcdw; 1046 union ctl_io *io; | 38 39#include <sys/param.h> 40#include <sys/capability.h> 41#include <sys/condvar.h> 42#include <sys/file.h> 43#include <sys/kernel.h> 44#include <sys/kthread.h> 45#include <sys/lock.h> --- 993 unchanged lines hidden (view full) --- 1039 cfiscsi_pdu_queue(cp); 1040} 1041 1042static void 1043cfiscsi_session_terminate_tasks(struct cfiscsi_session *cs) 1044{ 1045 struct cfiscsi_data_wait *cdw, *tmpcdw; 1046 union ctl_io *io; |
1047 int error; | 1047 int error, last; |
1048 1049#ifdef notyet 1050 io = ctl_alloc_io(cs->cs_target->ct_softc->fe.ctl_pool_ref); 1051 if (io == NULL) { 1052 CFISCSI_SESSION_WARN(cs, "can't allocate ctl_io"); 1053 return; 1054 } 1055 ctl_zero_io(io); --- 40 unchanged lines hidden (view full) --- 1096 CFISCSI_SESSION_WARN(cs, "ctl_queue() failed; error %d", error); 1097 ctl_free_io(io); 1098 return; 1099 } 1100#if 0 1101 CFISCSI_SESSION_DEBUG(cs, "removing csw for initiator task tag " 1102 "0x%x", cdw->cdw_initiator_task_tag); 1103#endif | 1048 1049#ifdef notyet 1050 io = ctl_alloc_io(cs->cs_target->ct_softc->fe.ctl_pool_ref); 1051 if (io == NULL) { 1052 CFISCSI_SESSION_WARN(cs, "can't allocate ctl_io"); 1053 return; 1054 } 1055 ctl_zero_io(io); --- 40 unchanged lines hidden (view full) --- 1096 CFISCSI_SESSION_WARN(cs, "ctl_queue() failed; error %d", error); 1097 ctl_free_io(io); 1098 return; 1099 } 1100#if 0 1101 CFISCSI_SESSION_DEBUG(cs, "removing csw for initiator task tag " 1102 "0x%x", cdw->cdw_initiator_task_tag); 1103#endif |
1104 /* 1105 * Set nonzero port status; this prevents backends from 1106 * assuming that the data transfer actually succeeded 1107 * and writing uninitialized data to disk. 1108 */ 1109 cdw->cdw_ctl_io->scsiio.io_hdr.port_status = 42; |
|
1104 cdw->cdw_ctl_io->scsiio.be_move_done(cdw->cdw_ctl_io); 1105 TAILQ_REMOVE(&cs->cs_waiting_for_data_out, cdw, cdw_next); 1106 uma_zfree(cfiscsi_data_wait_zone, cdw); 1107 } 1108 CFISCSI_SESSION_UNLOCK(cs); 1109#endif | 1110 cdw->cdw_ctl_io->scsiio.be_move_done(cdw->cdw_ctl_io); 1111 TAILQ_REMOVE(&cs->cs_waiting_for_data_out, cdw, cdw_next); 1112 uma_zfree(cfiscsi_data_wait_zone, cdw); 1113 } 1114 CFISCSI_SESSION_UNLOCK(cs); 1115#endif |
1116 1117 /* 1118 * Wait for CTL to terminate all the tasks. 1119 */ 1120 for (;;) { 1121 refcount_acquire(&cs->cs_outstanding_ctl_pdus); 1122 last = refcount_release(&cs->cs_outstanding_ctl_pdus); 1123 if (last != 0) 1124 break; 1125 CFISCSI_SESSION_WARN(cs, "waiting for CTL to terminate tasks, " 1126 "%d remaining", cs->cs_outstanding_ctl_pdus); 1127 pause("cfiscsi_terminate", 1); 1128 } |
|
1110} 1111 1112static void 1113cfiscsi_maintenance_thread(void *arg) 1114{ 1115 struct cfiscsi_session *cs; 1116 1117 cs = arg; 1118 1119 for (;;) { 1120 CFISCSI_SESSION_LOCK(cs); 1121 if (cs->cs_terminating == false) 1122 cv_wait(&cs->cs_maintenance_cv, &cs->cs_lock); 1123 CFISCSI_SESSION_UNLOCK(cs); 1124 1125 if (cs->cs_terminating) { | 1129} 1130 1131static void 1132cfiscsi_maintenance_thread(void *arg) 1133{ 1134 struct cfiscsi_session *cs; 1135 1136 cs = arg; 1137 1138 for (;;) { 1139 CFISCSI_SESSION_LOCK(cs); 1140 if (cs->cs_terminating == false) 1141 cv_wait(&cs->cs_maintenance_cv, &cs->cs_lock); 1142 CFISCSI_SESSION_UNLOCK(cs); 1143 1144 if (cs->cs_terminating) { |
1126 cfiscsi_session_terminate_tasks(cs); 1127 callout_drain(&cs->cs_callout); | |
1128 | 1145 |
1146 /* 1147 * We used to wait up to 30 seconds to deliver queued 1148 * PDUs to the initiator. We also tried hard to deliver 1149 * SCSI Responses for the aborted PDUs. We don't do 1150 * that anymore. We might need to revisit that. 1151 */ 1152 callout_drain(&cs->cs_callout); |
|
1129 icl_conn_shutdown(cs->cs_conn); 1130 icl_conn_close(cs->cs_conn); 1131 1132 /* | 1153 icl_conn_shutdown(cs->cs_conn); 1154 icl_conn_close(cs->cs_conn); 1155 1156 /* |
1133 * XXX: We used to wait up to 30 seconds to deliver queued PDUs 1134 * to the initiator. We also tried hard to deliver SCSI Responses 1135 * for the aborted PDUs. We don't do that anymore. We might need 1136 * to revisit that. | 1157 * At this point ICL receive thread is no longer 1158 * running; no new tasks can be queued. |
1137 */ | 1159 */ |
1138 | 1160 cfiscsi_session_terminate_tasks(cs); |
1139 cfiscsi_session_delete(cs); 1140 kthread_exit(); 1141 return; 1142 } 1143 CFISCSI_SESSION_DEBUG(cs, "nothing to do"); 1144 } 1145} 1146 --- 1771 unchanged lines hidden --- | 1161 cfiscsi_session_delete(cs); 1162 kthread_exit(); 1163 return; 1164 } 1165 CFISCSI_SESSION_DEBUG(cs, "nothing to do"); 1166 } 1167} 1168 --- 1771 unchanged lines hidden --- |