iscsi.c (256058) | iscsi.c (256187) |
---|---|
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/dev/iscsi/iscsi.c 256058 2013-10-04 19:31:41Z trasz $ | 29 * $FreeBSD: head/sys/dev/iscsi/iscsi.c 256187 2013-10-09 12:03:04Z trasz $ |
30 */ 31 32#include <sys/param.h> 33#include <sys/condvar.h> 34#include <sys/conf.h> 35#include <sys/eventhandler.h> 36#include <sys/file.h> 37#include <sys/kernel.h> --- 683 unchanged lines hidden (view full) --- 721 722 ISCSI_SESSION_WARN(is, "connection error; reconnecting"); 723 iscsi_session_reconnect(is); 724} 725 726static void 727iscsi_pdu_handle_nop_in(struct icl_pdu *response) 728{ | 30 */ 31 32#include <sys/param.h> 33#include <sys/condvar.h> 34#include <sys/conf.h> 35#include <sys/eventhandler.h> 36#include <sys/file.h> 37#include <sys/kernel.h> --- 683 unchanged lines hidden (view full) --- 721 722 ISCSI_SESSION_WARN(is, "connection error; reconnecting"); 723 iscsi_session_reconnect(is); 724} 725 726static void 727iscsi_pdu_handle_nop_in(struct icl_pdu *response) 728{ |
729 struct iscsi_session *is; |
|
729 struct iscsi_bhs_nop_out *bhsno; 730 struct iscsi_bhs_nop_in *bhsni; 731 struct icl_pdu *request; | 730 struct iscsi_bhs_nop_out *bhsno; 731 struct iscsi_bhs_nop_in *bhsni; 732 struct icl_pdu *request; |
733 void *data = NULL; 734 size_t datasize; 735 int error; |
|
732 | 736 |
737 is = PDU_SESSION(response); |
|
733 bhsni = (struct iscsi_bhs_nop_in *)response->ip_bhs; 734 735 if (bhsni->bhsni_target_transfer_tag == 0xffffffff) { 736 /* 737 * Nothing to do; iscsi_pdu_update_statsn() already 738 * zeroed the timeout. 739 */ 740 icl_pdu_free(response); 741 return; 742 } 743 | 738 bhsni = (struct iscsi_bhs_nop_in *)response->ip_bhs; 739 740 if (bhsni->bhsni_target_transfer_tag == 0xffffffff) { 741 /* 742 * Nothing to do; iscsi_pdu_update_statsn() already 743 * zeroed the timeout. 744 */ 745 icl_pdu_free(response); 746 return; 747 } 748 |
749 datasize = icl_pdu_data_segment_length(response); 750 if (datasize > 0) { 751 data = malloc(datasize, M_ISCSI, M_NOWAIT | M_ZERO); 752 if (data == NULL) { 753 ISCSI_SESSION_WARN(is, "failed to allocate memory; " 754 "reconnecting"); 755 icl_pdu_free(response); 756 iscsi_session_reconnect(is); 757 return; 758 } 759 icl_pdu_get_data(response, 0, data, datasize); 760 } 761 |
|
744 request = icl_pdu_new_bhs(response->ip_conn, M_NOWAIT); 745 if (request == NULL) { | 762 request = icl_pdu_new_bhs(response->ip_conn, M_NOWAIT); 763 if (request == NULL) { |
764 ISCSI_SESSION_WARN(is, "failed to allocate memory; " 765 "reconnecting"); 766 free(data, M_ISCSI); |
|
746 icl_pdu_free(response); | 767 icl_pdu_free(response); |
768 iscsi_session_reconnect(is); |
|
747 return; 748 } 749 bhsno = (struct iscsi_bhs_nop_out *)request->ip_bhs; 750 bhsno->bhsno_opcode = ISCSI_BHS_OPCODE_NOP_OUT | 751 ISCSI_BHS_OPCODE_IMMEDIATE; 752 bhsno->bhsno_flags = 0x80; | 769 return; 770 } 771 bhsno = (struct iscsi_bhs_nop_out *)request->ip_bhs; 772 bhsno->bhsno_opcode = ISCSI_BHS_OPCODE_NOP_OUT | 773 ISCSI_BHS_OPCODE_IMMEDIATE; 774 bhsno->bhsno_flags = 0x80; |
753 bhsno->bhsno_initiator_task_tag = 0xffffffff; /* XXX */ | 775 bhsno->bhsno_initiator_task_tag = 0xffffffff; |
754 bhsno->bhsno_target_transfer_tag = bhsni->bhsni_target_transfer_tag; | 776 bhsno->bhsno_target_transfer_tag = bhsni->bhsni_target_transfer_tag; |
777 if (datasize > 0) { 778 error = icl_pdu_append_data(request, data, datasize, M_NOWAIT); 779 if (error != 0) { 780 ISCSI_SESSION_WARN(is, "failed to allocate memory; " 781 "reconnecting"); 782 free(data, M_ISCSI); 783 icl_pdu_free(request); 784 icl_pdu_free(response); 785 iscsi_session_reconnect(is); 786 return; 787 } 788 free(data, M_ISCSI); 789 } |
|
755 | 790 |
756 request->ip_data_len = response->ip_data_len; 757 request->ip_data_mbuf = response->ip_data_mbuf; 758 response->ip_data_len = 0; 759 response->ip_data_mbuf = NULL; 760 | |
761 icl_pdu_free(response); 762 iscsi_pdu_queue_locked(request); 763} 764 765static void 766iscsi_pdu_handle_scsi_response(struct icl_pdu *response) 767{ 768 struct iscsi_bhs_scsi_response *bhssr; --- 1357 unchanged lines hidden --- | 791 icl_pdu_free(response); 792 iscsi_pdu_queue_locked(request); 793} 794 795static void 796iscsi_pdu_handle_scsi_response(struct icl_pdu *response) 797{ 798 struct iscsi_bhs_scsi_response *bhssr; --- 1357 unchanged lines hidden --- |