diff options
author | trasz <trasz@FreeBSD.org> | 2013-09-23 19:54:44 +0000 |
---|---|---|
committer | trasz <trasz@FreeBSD.org> | 2013-09-23 19:54:44 +0000 |
commit | 883625cd6610a9c86c5a3f649bd38259ad602ad3 (patch) | |
tree | f57493f0e367656aa2d1545a0dbdd1b134a75d41 /sys/cam/ctl | |
parent | d232e740fa1fdf064d937d9d03973d715bcb27f7 (diff) | |
download | FreeBSD-src-883625cd6610a9c86c5a3f649bd38259ad602ad3.zip FreeBSD-src-883625cd6610a9c86c5a3f649bd38259ad602ad3.tar.gz |
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
Diffstat (limited to 'sys/cam/ctl')
-rw-r--r-- | sys/cam/ctl/ctl_frontend_iscsi.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/sys/cam/ctl/ctl_frontend_iscsi.c b/sys/cam/ctl/ctl_frontend_iscsi.c index 34e2ead..60204f5 100644 --- a/sys/cam/ctl/ctl_frontend_iscsi.c +++ b/sys/cam/ctl/ctl_frontend_iscsi.c @@ -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; |