Date: Mon, 23 Sep 2013 19:54:44 +0000 (UTC) From: Edward Tomasz Napierala <trasz@FreeBSD.org> 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 Message-ID: <201309231954.r8NJsixj027245@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201309231954.r8NJsixj027245>