ctl_frontend_iscsi.c (273319) | ctl_frontend_iscsi.c (275203) |
---|---|
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 273319 2014-10-20 07:59:29Z mav $ | 29 * $FreeBSD: stable/10/sys/cam/ctl/ctl_frontend_iscsi.c 275203 2014-11-28 08:56:37Z 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 273319 2014-10-20 07:59:29Z mav $"); | 37__FBSDID("$FreeBSD: stable/10/sys/cam/ctl/ctl_frontend_iscsi.c 275203 2014-11-28 08:56:37Z 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> --- 1011 unchanged lines hidden (view full) --- 1057 cfiscsi_pdu_queue(cp); 1058} 1059 1060static void 1061cfiscsi_session_terminate_tasks(struct cfiscsi_session *cs) 1062{ 1063 struct cfiscsi_data_wait *cdw; 1064 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> --- 1011 unchanged lines hidden (view full) --- 1057 cfiscsi_pdu_queue(cp); 1058} 1059 1060static void 1061cfiscsi_session_terminate_tasks(struct cfiscsi_session *cs) 1062{ 1063 struct cfiscsi_data_wait *cdw; 1064 union ctl_io *io; |
1065 int error, last; | 1065 int error, last, wait; |
1066 1067 io = ctl_alloc_io(cs->cs_target->ct_port.ctl_pool_ref); 1068 if (io == NULL) { 1069 CFISCSI_SESSION_WARN(cs, "can't allocate ctl_io"); 1070 return; 1071 } 1072 ctl_zero_io(io); 1073 io->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptr = cs; 1074 io->io_hdr.io_type = CTL_IO_TASK; 1075 io->io_hdr.nexus.initid.id = cs->cs_ctl_initid; 1076 io->io_hdr.nexus.targ_port = cs->cs_target->ct_port.targ_port; 1077 io->io_hdr.nexus.targ_target.id = 0; 1078 io->io_hdr.nexus.targ_lun = 0; 1079 io->taskio.tag_type = CTL_TAG_SIMPLE; /* XXX */ 1080 io->taskio.task_action = CTL_TASK_I_T_NEXUS_RESET; | 1066 1067 io = ctl_alloc_io(cs->cs_target->ct_port.ctl_pool_ref); 1068 if (io == NULL) { 1069 CFISCSI_SESSION_WARN(cs, "can't allocate ctl_io"); 1070 return; 1071 } 1072 ctl_zero_io(io); 1073 io->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptr = cs; 1074 io->io_hdr.io_type = CTL_IO_TASK; 1075 io->io_hdr.nexus.initid.id = cs->cs_ctl_initid; 1076 io->io_hdr.nexus.targ_port = cs->cs_target->ct_port.targ_port; 1077 io->io_hdr.nexus.targ_target.id = 0; 1078 io->io_hdr.nexus.targ_lun = 0; 1079 io->taskio.tag_type = CTL_TAG_SIMPLE; /* XXX */ 1080 io->taskio.task_action = CTL_TASK_I_T_NEXUS_RESET; |
1081 wait = cs->cs_outstanding_ctl_pdus; |
|
1081 refcount_acquire(&cs->cs_outstanding_ctl_pdus); 1082 error = ctl_queue(io); 1083 if (error != CTL_RETVAL_COMPLETE) { 1084 CFISCSI_SESSION_WARN(cs, "ctl_queue() failed; error %d", error); 1085 refcount_release(&cs->cs_outstanding_ctl_pdus); 1086 ctl_free_io(io); 1087 } 1088 --- 11 unchanged lines hidden (view full) --- 1100 uma_zfree(cfiscsi_data_wait_zone, cdw); 1101 CFISCSI_SESSION_LOCK(cs); 1102 } 1103 CFISCSI_SESSION_UNLOCK(cs); 1104 1105 /* 1106 * Wait for CTL to terminate all the tasks. 1107 */ | 1082 refcount_acquire(&cs->cs_outstanding_ctl_pdus); 1083 error = ctl_queue(io); 1084 if (error != CTL_RETVAL_COMPLETE) { 1085 CFISCSI_SESSION_WARN(cs, "ctl_queue() failed; error %d", error); 1086 refcount_release(&cs->cs_outstanding_ctl_pdus); 1087 ctl_free_io(io); 1088 } 1089 --- 11 unchanged lines hidden (view full) --- 1101 uma_zfree(cfiscsi_data_wait_zone, cdw); 1102 CFISCSI_SESSION_LOCK(cs); 1103 } 1104 CFISCSI_SESSION_UNLOCK(cs); 1105 1106 /* 1107 * Wait for CTL to terminate all the tasks. 1108 */ |
1109 if (wait > 0) 1110 CFISCSI_SESSION_WARN(cs, 1111 "waiting for CTL to terminate %d tasks", wait); |
|
1108 for (;;) { 1109 refcount_acquire(&cs->cs_outstanding_ctl_pdus); 1110 last = refcount_release(&cs->cs_outstanding_ctl_pdus); 1111 if (last != 0) 1112 break; | 1112 for (;;) { 1113 refcount_acquire(&cs->cs_outstanding_ctl_pdus); 1114 last = refcount_release(&cs->cs_outstanding_ctl_pdus); 1115 if (last != 0) 1116 break; |
1113 CFISCSI_SESSION_WARN(cs, "waiting for CTL to terminate tasks, " 1114 "%d remaining", cs->cs_outstanding_ctl_pdus); | |
1115 tsleep(__DEVOLATILE(void *, &cs->cs_outstanding_ctl_pdus), 1116 0, "cfiscsi_terminate", hz / 100); 1117 } | 1117 tsleep(__DEVOLATILE(void *, &cs->cs_outstanding_ctl_pdus), 1118 0, "cfiscsi_terminate", hz / 100); 1119 } |
1120 if (wait > 0) 1121 CFISCSI_SESSION_WARN(cs, "tasks terminated"); |
|
1118} 1119 1120static void 1121cfiscsi_maintenance_thread(void *arg) 1122{ 1123 struct cfiscsi_session *cs; 1124 1125 cs = arg; --- 1810 unchanged lines hidden --- | 1122} 1123 1124static void 1125cfiscsi_maintenance_thread(void *arg) 1126{ 1127 struct cfiscsi_session *cs; 1128 1129 cs = arg; --- 1810 unchanged lines hidden --- |