From owner-svn-src-head@FreeBSD.ORG Mon Sep 23 19:54:45 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 40A17B55; Mon, 23 Sep 2013 19:54:45 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 1EA352514; Mon, 23 Sep 2013 19:54:45 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8NJsiFk027250; Mon, 23 Sep 2013 19:54:44 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r8NJsixj027245; Mon, 23 Sep 2013 19:54:44 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201309231954.r8NJsixj027245@svn.freebsd.org> From: Edward Tomasz Napierala Date: Mon, 23 Sep 2013 19:54:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r255824 - in head/sys: cam/ctl dev/iscsi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Sep 2013 19:54:45 -0000 Author: trasz Date: Mon Sep 23 19:54:44 2013 New Revision: 255824 URL: http://svnweb.freebsd.org/changeset/base/255824 Log: Don't use M_WAITOK when running from context where sleeping is prohibited, such as callout or a geom thread. Approved by: re (marius) Sponsored by: FreeBSD Foundation Modified: head/sys/cam/ctl/ctl_frontend_iscsi.c head/sys/dev/iscsi/iscsi.c Modified: head/sys/cam/ctl/ctl_frontend_iscsi.c ============================================================================== --- head/sys/cam/ctl/ctl_frontend_iscsi.c Mon Sep 23 18:53:48 2013 (r255823) +++ head/sys/cam/ctl/ctl_frontend_iscsi.c Mon Sep 23 19:54:44 2013 (r255824) @@ -930,7 +930,11 @@ cfiscsi_callout(void *context) if (cs->cs_timeout < 2) return; - cp = icl_pdu_new_bhs(cs->cs_conn, M_WAITOK); + cp = icl_pdu_new_bhs(cs->cs_conn, M_NOWAIT); + if (cp == NULL) { + CFISCSI_SESSION_WARN(cs, "failed to allocate PDU"); + return; + } bhsni = (struct iscsi_bhs_nop_in *)cp->ip_bhs; bhsni->bhsni_opcode = ISCSI_BHS_OPCODE_NOP_IN; bhsni->bhsni_flags = 0x80; @@ -2245,7 +2249,7 @@ cfiscsi_datamove(union ctl_io *io) struct ctl_sg_entry ctl_sg_entry, *ctl_sglist; size_t copy_len, len, off; const char *addr; - int ctl_sg_count, i; + int ctl_sg_count, error, i; uint32_t target_transfer_tag; bool done; @@ -2298,7 +2302,13 @@ cfiscsi_datamove(union ctl_io *io) KASSERT(i < ctl_sg_count, ("i >= ctl_sg_count")); if (response == NULL) { response = - cfiscsi_pdu_new_response(request, M_WAITOK); + cfiscsi_pdu_new_response(request, M_NOWAIT); + if (response == NULL) { + CFISCSI_SESSION_WARN(cs, "failed to " + "allocate memory; dropping connection"); + cfiscsi_session_terminate(cs); + return; + } bhsdi = (struct iscsi_bhs_data_in *) response->ip_bhs; bhsdi->bhsdi_opcode = @@ -2323,7 +2333,14 @@ cfiscsi_datamove(union ctl_io *io) copy_len = cs->cs_max_data_segment_length - response->ip_data_len; KASSERT(copy_len <= len, ("copy_len > len")); - icl_pdu_append_data(response, addr, copy_len, M_WAITOK); + error = icl_pdu_append_data(response, addr, copy_len, M_NOWAIT); + if (error != 0) { + CFISCSI_SESSION_WARN(cs, "failed to " + "allocate memory; dropping connection"); + icl_pdu_free(response); + cfiscsi_session_terminate(cs); + return; + } addr += copy_len; len -= copy_len; off += copy_len; Modified: head/sys/dev/iscsi/iscsi.c ============================================================================== --- head/sys/dev/iscsi/iscsi.c Mon Sep 23 18:53:48 2013 (r255823) +++ head/sys/dev/iscsi/iscsi.c Mon Sep 23 19:54:44 2013 (r255824) @@ -558,7 +558,11 @@ iscsi_callout(void *context) if (is->is_timeout < 2) return; - request = icl_pdu_new_bhs(is->is_conn, M_WAITOK); + request = icl_pdu_new_bhs(is->is_conn, M_NOWAIT); + if (request == NULL) { + ISCSI_SESSION_WARN(is, "failed to allocate PDU"); + return; + } bhsno = (struct iscsi_bhs_nop_out *)request->ip_bhs; bhsno->bhsno_opcode = ISCSI_BHS_OPCODE_NOP_OUT | ISCSI_BHS_OPCODE_IMMEDIATE;