On 01/07/2011 01:37 AM, Max Matveev wrote:
I'm working with a customer who's getting the famous "scheduling while atomic" noise in the logs when using his tape library connected via iSCSI. The task is always an iscsi_q_31 and they're getting a lot of those BUG messages. I have the backtrace but it's almost useless - the code path is unbelievable: the only reliable bit is [<f8acca0e>] iscsi_tcp_segment_done+0x1c7/0x2a7 [libiscsi_tcp] [<c05b7f45>] kernel_sendmsg+0x27/0x35 [<f8ad33e8>] iscsi_sw_tcp_pdu_xmit+0x9e/0x1e8 [iscsi_tcp] [<f8acc246>] iscsi_tcp_task_xmit+0x25/0x204 [libiscsi_tcp] [<f8d9b622>] iscsi_xmit_task+0x24/0x4b [libiscsi2] [<f8d9c190>] iscsi_xmitworker+0x122/0x202 [libiscsi2]
If other people are hitting this try the attached patch. -- You received this message because you are subscribed to the Google Groups "open-iscsi" group. To post to this group, send email to open-iscsi@googlegroups.com. To unsubscribe from this group, send email to open-iscsi+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.
diff --git a/drivers/scsi/libiscsi_tcp.c b/drivers/scsi/libiscsi_tcp.c index 8eeb39f..e98ae33 100644 --- a/drivers/scsi/libiscsi_tcp.c +++ b/drivers/scsi/libiscsi_tcp.c @@ -132,14 +132,25 @@ static void iscsi_tcp_segment_map(struct iscsi_segment *segment, int recv) if (page_count(sg_page(sg)) >= 1 && !recv) return; - segment->sg_mapped = kmap_atomic(sg_page(sg), KM_SOFTIRQ0); + if (recv) { + segment->atomic_mapped = true; + segment->sg_mapped = kmap_atomic(sg_page(sg), KM_SOFTIRQ0); + } else { + segment->atomic_mapped = false; + /* the xmit path can sleep with the page mapped so use kmap */ + segment->sg_mapped = kmap(sg_page(sg)); + } + segment->data = segment->sg_mapped + sg->offset + segment->sg_offset; } void iscsi_tcp_segment_unmap(struct iscsi_segment *segment) { if (segment->sg_mapped) { - kunmap_atomic(segment->sg_mapped, KM_SOFTIRQ0); + if (segment->atomic_mapped) + kunmap_atomic(segment->sg_mapped, KM_SOFTIRQ0); + else + kunmap(sg_page(segment->sg)); segment->sg_mapped = NULL; segment->data = NULL; } diff --git a/include/scsi/libiscsi_tcp.h b/include/scsi/libiscsi_tcp.h index 741ae7e..e6b9fd2 100644 --- a/include/scsi/libiscsi_tcp.h +++ b/include/scsi/libiscsi_tcp.h @@ -47,6 +47,7 @@ struct iscsi_segment { struct scatterlist *sg; void *sg_mapped; unsigned int sg_offset; + bool atomic_mapped; iscsi_segment_done_fn_t *done; };