Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 322918
b: refs/heads/master
c: 3717ef0
h: refs/heads/master
v: v3
  • Loading branch information
Paolo Bonzini authored and Nicholas Bellinger committed Sep 7, 2012
1 parent be9a19e commit 210c811
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9b16b9edb4fd0dc86ee0fbe1f7ede580e26e85f4
refs/heads/master: 3717ef0c63e90686d959158e9728a13a49229be6
13 changes: 9 additions & 4 deletions trunk/drivers/target/target_core_transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -2190,21 +2190,24 @@ void *transport_kmap_data_sg(struct se_cmd *cmd)
struct page **pages;
int i;

BUG_ON(!sg);
/*
* We need to take into account a possible offset here for fabrics like
* tcm_loop who may be using a contig buffer from the SCSI midlayer for
* control CDBs passed as SGLs via transport_generic_map_mem_to_cmd()
*/
if (!cmd->t_data_nents)
return NULL;
else if (cmd->t_data_nents == 1)

BUG_ON(!sg);
if (cmd->t_data_nents == 1)
return kmap(sg_page(sg)) + sg->offset;

/* >1 page. use vmap */
pages = kmalloc(sizeof(*pages) * cmd->t_data_nents, GFP_KERNEL);
if (!pages)
if (!pages) {
cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
return NULL;
}

/* convert sg[] to pages[] */
for_each_sg(cmd->t_data_sg, sg, cmd->t_data_nents, i) {
Expand All @@ -2213,8 +2216,10 @@ void *transport_kmap_data_sg(struct se_cmd *cmd)

cmd->t_data_vmap = vmap(pages, cmd->t_data_nents, VM_MAP, PAGE_KERNEL);
kfree(pages);
if (!cmd->t_data_vmap)
if (!cmd->t_data_vmap) {
cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
return NULL;
}

return cmd->t_data_vmap + cmd->t_data_sg[0].offset;
}
Expand Down

0 comments on commit 210c811

Please sign in to comment.