ctl_frontend_iscsi.c (268691) | ctl_frontend_iscsi.c (268692) |
---|---|
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 268691 2014-07-15 17:13:49Z mav $ | 29 * $FreeBSD: stable/10/sys/cam/ctl/ctl_frontend_iscsi.c 268692 2014-07-15 17:14:53Z 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 268691 2014-07-15 17:13:49Z mav $"); | 37__FBSDID("$FreeBSD: stable/10/sys/cam/ctl/ctl_frontend_iscsi.c 268692 2014-07-15 17:14:53Z 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> --- 1099 unchanged lines hidden (view full) --- 1145#ifdef ICL_KERNEL_PROXY 1146 cv_signal(&cs->cs_login_cv); 1147#endif 1148} 1149 1150static int 1151cfiscsi_session_register_initiator(struct cfiscsi_session *cs) 1152{ | 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> --- 1099 unchanged lines hidden (view full) --- 1145#ifdef ICL_KERNEL_PROXY 1146 cv_signal(&cs->cs_login_cv); 1147#endif 1148} 1149 1150static int 1151cfiscsi_session_register_initiator(struct cfiscsi_session *cs) 1152{ |
1153 int error, i; 1154 struct cfiscsi_softc *softc; | 1153 struct cfiscsi_target *ct; 1154 char *name; 1155 int i; |
1155 1156 KASSERT(cs->cs_ctl_initid == -1, ("already registered")); 1157 | 1156 1157 KASSERT(cs->cs_ctl_initid == -1, ("already registered")); 1158 |
1158 softc = &cfiscsi_softc; 1159 1160 mtx_lock(&softc->lock); 1161 for (i = 0; i < softc->max_initiators; i++) { 1162 if (softc->ctl_initids[i] == 0) 1163 break; 1164 } 1165 if (i == softc->max_initiators) { 1166 CFISCSI_SESSION_WARN(cs, "too many concurrent sessions (%d)", 1167 softc->max_initiators); 1168 mtx_unlock(&softc->lock); | 1159 ct = cs->cs_target; 1160 name = strdup(cs->cs_initiator_id, M_CTL); 1161 i = ctl_add_initiator(&ct->ct_port, -1, 0, name); 1162 if (i < 0) { 1163 CFISCSI_SESSION_WARN(cs, "ctl_add_initiator failed with error %d", 1164 i); 1165 cs->cs_ctl_initid = -1; |
1169 return (1); 1170 } | 1166 return (1); 1167 } |
1171 softc->ctl_initids[i] = 1; 1172 mtx_unlock(&softc->lock); 1173 | 1168 cs->cs_ctl_initid = i; |
1174#if 0 | 1169#if 0 |
1175 CFISCSI_SESSION_DEBUG(cs, "adding initiator id %d, max %d", 1176 i, softc->max_initiators); | 1170 CFISCSI_SESSION_DEBUG(cs, "added initiator id %d", i); |
1177#endif | 1171#endif |
1178 cs->cs_ctl_initid = i; 1179 error = ctl_add_initiator(0x0, cs->cs_target->ct_port.targ_port, cs->cs_ctl_initid); 1180 if (error != 0) { 1181 CFISCSI_SESSION_WARN(cs, "ctl_add_initiator failed with error %d", error); 1182 mtx_lock(&softc->lock); 1183 softc->ctl_initids[cs->cs_ctl_initid] = 0; 1184 mtx_unlock(&softc->lock); 1185 cs->cs_ctl_initid = -1; 1186 return (1); 1187 } | |
1188 1189 return (0); 1190} 1191 1192static void 1193cfiscsi_session_unregister_initiator(struct cfiscsi_session *cs) 1194{ 1195 int error; | 1172 1173 return (0); 1174} 1175 1176static void 1177cfiscsi_session_unregister_initiator(struct cfiscsi_session *cs) 1178{ 1179 int error; |
1196 struct cfiscsi_softc *softc; | |
1197 1198 if (cs->cs_ctl_initid == -1) 1199 return; 1200 | 1180 1181 if (cs->cs_ctl_initid == -1) 1182 return; 1183 |
1201 softc = &cfiscsi_softc; 1202 1203 error = ctl_remove_initiator(cs->cs_target->ct_port.targ_port, cs->cs_ctl_initid); | 1184 error = ctl_remove_initiator(&cs->cs_target->ct_port, cs->cs_ctl_initid); |
1204 if (error != 0) { 1205 CFISCSI_SESSION_WARN(cs, "ctl_remove_initiator failed with error %d", 1206 error); 1207 } | 1185 if (error != 0) { 1186 CFISCSI_SESSION_WARN(cs, "ctl_remove_initiator failed with error %d", 1187 error); 1188 } |
1208 mtx_lock(&softc->lock); 1209 softc->ctl_initids[cs->cs_ctl_initid] = 0; 1210 mtx_unlock(&softc->lock); | |
1211 cs->cs_ctl_initid = -1; 1212} 1213 1214static struct cfiscsi_session * 1215cfiscsi_session_new(struct cfiscsi_softc *softc) 1216{ 1217 struct cfiscsi_session *cs; 1218 int error; --- 80 unchanged lines hidden (view full) --- 1299 mtx_init(&softc->lock, "cfiscsi", NULL, MTX_DEF); 1300 1301#ifdef ICL_KERNEL_PROXY 1302 cv_init(&softc->accept_cv, "cfiscsi_accept"); 1303#endif 1304 TAILQ_INIT(&softc->sessions); 1305 TAILQ_INIT(&softc->targets); 1306 | 1189 cs->cs_ctl_initid = -1; 1190} 1191 1192static struct cfiscsi_session * 1193cfiscsi_session_new(struct cfiscsi_softc *softc) 1194{ 1195 struct cfiscsi_session *cs; 1196 int error; --- 80 unchanged lines hidden (view full) --- 1277 mtx_init(&softc->lock, "cfiscsi", NULL, MTX_DEF); 1278 1279#ifdef ICL_KERNEL_PROXY 1280 cv_init(&softc->accept_cv, "cfiscsi_accept"); 1281#endif 1282 TAILQ_INIT(&softc->sessions); 1283 TAILQ_INIT(&softc->targets); 1284 |
1307 softc->max_initiators = CTL_MAX_INIT_PER_PORT; 1308 | |
1309 cfiscsi_data_wait_zone = uma_zcreate("cfiscsi_data_wait", 1310 sizeof(struct cfiscsi_data_wait), NULL, NULL, NULL, NULL, 1311 UMA_ALIGN_PTR, 0); 1312 1313 return (0); 1314} 1315 1316#ifdef ICL_KERNEL_PROXY --- 1577 unchanged lines hidden --- | 1285 cfiscsi_data_wait_zone = uma_zcreate("cfiscsi_data_wait", 1286 sizeof(struct cfiscsi_data_wait), NULL, NULL, NULL, NULL, 1287 UMA_ALIGN_PTR, 0); 1288 1289 return (0); 1290} 1291 1292#ifdef ICL_KERNEL_PROXY --- 1577 unchanged lines hidden --- |