ctl_frontend_iscsi.c (256065) | ctl_frontend_iscsi.c (256163) |
---|---|
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: head/sys/cam/ctl/ctl_frontend_iscsi.c 256065 2013-10-05 16:22:33Z trasz $ | 29 * $FreeBSD: head/sys/cam/ctl/ctl_frontend_iscsi.c 256163 2013-10-08 19:18:02Z trasz $ |
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: head/sys/cam/ctl/ctl_frontend_iscsi.c 256065 2013-10-05 16:22:33Z trasz $"); | 37__FBSDID("$FreeBSD: head/sys/cam/ctl/ctl_frontend_iscsi.c 256163 2013-10-08 19:18:02Z trasz $"); |
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> --- 8 unchanged lines hidden (view full) --- 54#include <sys/unistd.h> 55#include <vm/uma.h> 56 57#include <cam/scsi/scsi_all.h> 58#include <cam/scsi/scsi_da.h> 59#include <cam/ctl/ctl_io.h> 60#include <cam/ctl/ctl.h> 61#include <cam/ctl/ctl_backend.h> | 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> --- 8 unchanged lines hidden (view full) --- 54#include <sys/unistd.h> 55#include <vm/uma.h> 56 57#include <cam/scsi/scsi_all.h> 58#include <cam/scsi/scsi_da.h> 59#include <cam/ctl/ctl_io.h> 60#include <cam/ctl/ctl.h> 61#include <cam/ctl/ctl_backend.h> |
62#include <cam/ctl/ctl_error.h> |
|
62#include <cam/ctl/ctl_frontend.h> 63#include <cam/ctl/ctl_frontend_internal.h> 64#include <cam/ctl/ctl_debug.h> 65#include <cam/ctl/ctl_ha.h> 66#include <cam/ctl/ctl_ioctl.h> 67#include <cam/ctl/ctl_private.h> 68 69#include "../../dev/iscsi/icl.h" --- 2226 unchanged lines hidden (view full) --- 2296 bhsdi = NULL; 2297 for (;;) { 2298 KASSERT(i < ctl_sg_count, ("i >= ctl_sg_count")); 2299 if (response == NULL) { 2300 response = cfiscsi_pdu_new_response(request, M_NOWAIT); 2301 if (response == NULL) { 2302 CFISCSI_SESSION_WARN(cs, "failed to " 2303 "allocate memory; dropping connection"); | 63#include <cam/ctl/ctl_frontend.h> 64#include <cam/ctl/ctl_frontend_internal.h> 65#include <cam/ctl/ctl_debug.h> 66#include <cam/ctl/ctl_ha.h> 67#include <cam/ctl/ctl_ioctl.h> 68#include <cam/ctl/ctl_private.h> 69 70#include "../../dev/iscsi/icl.h" --- 2226 unchanged lines hidden (view full) --- 2297 bhsdi = NULL; 2298 for (;;) { 2299 KASSERT(i < ctl_sg_count, ("i >= ctl_sg_count")); 2300 if (response == NULL) { 2301 response = cfiscsi_pdu_new_response(request, M_NOWAIT); 2302 if (response == NULL) { 2303 CFISCSI_SESSION_WARN(cs, "failed to " 2304 "allocate memory; dropping connection"); |
2304 icl_pdu_free(request); | 2305 ctl_set_busy(&io->scsiio); 2306 io->scsiio.be_move_done(io); |
2305 cfiscsi_session_terminate(cs); 2306 return; 2307 } 2308 bhsdi = (struct iscsi_bhs_data_in *)response->ip_bhs; 2309 bhsdi->bhsdi_opcode = ISCSI_BHS_OPCODE_SCSI_DATA_IN; 2310 bhsdi->bhsdi_initiator_task_tag = 2311 bhssc->bhssc_initiator_task_tag; 2312 bhsdi->bhsdi_datasn = htonl(PDU_EXPDATASN(request)); --- 12 unchanged lines hidden (view full) --- 2325 cs->cs_max_data_segment_length) 2326 copy_len = cs->cs_max_data_segment_length - 2327 response->ip_data_len; 2328 KASSERT(copy_len <= len, ("copy_len > len")); 2329 error = icl_pdu_append_data(response, addr, copy_len, M_NOWAIT); 2330 if (error != 0) { 2331 CFISCSI_SESSION_WARN(cs, "failed to " 2332 "allocate memory; dropping connection"); | 2307 cfiscsi_session_terminate(cs); 2308 return; 2309 } 2310 bhsdi = (struct iscsi_bhs_data_in *)response->ip_bhs; 2311 bhsdi->bhsdi_opcode = ISCSI_BHS_OPCODE_SCSI_DATA_IN; 2312 bhsdi->bhsdi_initiator_task_tag = 2313 bhssc->bhssc_initiator_task_tag; 2314 bhsdi->bhsdi_datasn = htonl(PDU_EXPDATASN(request)); --- 12 unchanged lines hidden (view full) --- 2327 cs->cs_max_data_segment_length) 2328 copy_len = cs->cs_max_data_segment_length - 2329 response->ip_data_len; 2330 KASSERT(copy_len <= len, ("copy_len > len")); 2331 error = icl_pdu_append_data(response, addr, copy_len, M_NOWAIT); 2332 if (error != 0) { 2333 CFISCSI_SESSION_WARN(cs, "failed to " 2334 "allocate memory; dropping connection"); |
2333 icl_pdu_free(request); | |
2334 icl_pdu_free(response); | 2335 icl_pdu_free(response); |
2336 ctl_set_busy(&io->scsiio); 2337 io->scsiio.be_move_done(io); |
|
2335 cfiscsi_session_terminate(cs); 2336 return; 2337 } 2338 addr += copy_len; 2339 len -= copy_len; 2340 off += copy_len; 2341 io->scsiio.ext_data_filled += copy_len; 2342 --- 80 unchanged lines hidden (view full) --- 2423 CFISCSI_SESSION_DEBUG(cs, "expecting Data-Out with initiator " 2424 "task tag 0x%x, target transfer tag 0x%x", 2425 bhssc->bhssc_initiator_task_tag, target_transfer_tag); 2426#endif 2427 cdw = uma_zalloc(cfiscsi_data_wait_zone, M_NOWAIT | M_ZERO); 2428 if (cdw == NULL) { 2429 CFISCSI_SESSION_WARN(cs, "failed to " 2430 "allocate memory; dropping connection"); | 2338 cfiscsi_session_terminate(cs); 2339 return; 2340 } 2341 addr += copy_len; 2342 len -= copy_len; 2343 off += copy_len; 2344 io->scsiio.ext_data_filled += copy_len; 2345 --- 80 unchanged lines hidden (view full) --- 2426 CFISCSI_SESSION_DEBUG(cs, "expecting Data-Out with initiator " 2427 "task tag 0x%x, target transfer tag 0x%x", 2428 bhssc->bhssc_initiator_task_tag, target_transfer_tag); 2429#endif 2430 cdw = uma_zalloc(cfiscsi_data_wait_zone, M_NOWAIT | M_ZERO); 2431 if (cdw == NULL) { 2432 CFISCSI_SESSION_WARN(cs, "failed to " 2433 "allocate memory; dropping connection"); |
2431 icl_pdu_free(request); | 2434 ctl_set_busy(&io->scsiio); 2435 io->scsiio.be_move_done(io); |
2432 cfiscsi_session_terminate(cs); | 2436 cfiscsi_session_terminate(cs); |
2437 return; |
|
2433 } 2434 cdw->cdw_ctl_io = io; 2435 cdw->cdw_target_transfer_tag = htonl(target_transfer_tag); 2436 cdw->cdw_initiator_task_tag = bhssc->bhssc_initiator_task_tag; 2437 2438 if (cs->cs_immediate_data && icl_pdu_data_segment_length(request) > 0) { 2439 done = cfiscsi_handle_data_segment(request, cdw); 2440 if (done) { --- 16 unchanged lines hidden (view full) --- 2457 /* 2458 * XXX: We should limit the number of outstanding R2T PDUs 2459 * per task to MaxOutstandingR2T. 2460 */ 2461 response = cfiscsi_pdu_new_response(request, M_NOWAIT); 2462 if (response == NULL) { 2463 CFISCSI_SESSION_WARN(cs, "failed to " 2464 "allocate memory; dropping connection"); | 2438 } 2439 cdw->cdw_ctl_io = io; 2440 cdw->cdw_target_transfer_tag = htonl(target_transfer_tag); 2441 cdw->cdw_initiator_task_tag = bhssc->bhssc_initiator_task_tag; 2442 2443 if (cs->cs_immediate_data && icl_pdu_data_segment_length(request) > 0) { 2444 done = cfiscsi_handle_data_segment(request, cdw); 2445 if (done) { --- 16 unchanged lines hidden (view full) --- 2462 /* 2463 * XXX: We should limit the number of outstanding R2T PDUs 2464 * per task to MaxOutstandingR2T. 2465 */ 2466 response = cfiscsi_pdu_new_response(request, M_NOWAIT); 2467 if (response == NULL) { 2468 CFISCSI_SESSION_WARN(cs, "failed to " 2469 "allocate memory; dropping connection"); |
2465 icl_pdu_free(request); | 2470 ctl_set_busy(&io->scsiio); 2471 io->scsiio.be_move_done(io); |
2466 cfiscsi_session_terminate(cs); | 2472 cfiscsi_session_terminate(cs); |
2473 return; |
|
2467 } 2468 bhsr2t = (struct iscsi_bhs_r2t *)response->ip_bhs; 2469 bhsr2t->bhsr2t_opcode = ISCSI_BHS_OPCODE_R2T; 2470 bhsr2t->bhsr2t_flags = 0x80; 2471 bhsr2t->bhsr2t_lun = bhssc->bhssc_lun; 2472 bhsr2t->bhsr2t_initiator_task_tag = bhssc->bhssc_initiator_task_tag; 2473 bhsr2t->bhsr2t_target_transfer_tag = htonl(target_transfer_tag); 2474 /* --- 217 unchanged lines hidden --- | 2474 } 2475 bhsr2t = (struct iscsi_bhs_r2t *)response->ip_bhs; 2476 bhsr2t->bhsr2t_opcode = ISCSI_BHS_OPCODE_R2T; 2477 bhsr2t->bhsr2t_flags = 0x80; 2478 bhsr2t->bhsr2t_lun = bhssc->bhssc_lun; 2479 bhsr2t->bhsr2t_initiator_task_tag = bhssc->bhssc_initiator_task_tag; 2480 bhsr2t->bhsr2t_target_transfer_tag = htonl(target_transfer_tag); 2481 /* --- 217 unchanged lines hidden --- |