Skip to content

Commit

Permalink
[SCSI] libiscsi_tcp: use kmap in xmit path
Browse files Browse the repository at this point in the history
The xmit path can sleep with a page kmapped in the network
xmit code while it waits for space to open up, so we have to use
kmap instead of kmap atomic in that path.

Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
  • Loading branch information
Mike Christie authored and James Bottomley committed Mar 23, 2011
1 parent e8b12f0 commit 70c7c88
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
15 changes: 13 additions & 2 deletions drivers/scsi/libiscsi_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions include/scsi/libiscsi_tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down

0 comments on commit 70c7c88

Please sign in to comment.