Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 263298
b: refs/heads/master
c: 525a48a
h: refs/heads/master
v: v3
  • Loading branch information
Nicholas Bellinger committed Aug 22, 2011
1 parent bb523f6 commit 8c47f17
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 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: 01cde4d54327884a0b61ce8666092f5703557d4b
refs/heads/master: 525a48a21da259d00d6ebc5b60563b5bcf022c26
28 changes: 28 additions & 0 deletions trunk/drivers/target/target_core_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,24 @@ int se_dev_check_shutdown(struct se_device *dev)
return ret;
}

u32 se_dev_align_max_sectors(u32 max_sectors, u32 block_size)
{
u32 tmp, aligned_max_sectors;
/*
* Limit max_sectors to a PAGE_SIZE aligned value for modern
* transport_allocate_data_tasks() operation.
*/
tmp = rounddown((max_sectors * block_size), PAGE_SIZE);
aligned_max_sectors = (tmp / block_size);
if (max_sectors != aligned_max_sectors) {
printk(KERN_INFO "Rounding down aligned max_sectors from %u"
" to %u\n", max_sectors, aligned_max_sectors);
return aligned_max_sectors;
}

return max_sectors;
}

void se_dev_set_default_attribs(
struct se_device *dev,
struct se_dev_limits *dev_limits)
Expand Down Expand Up @@ -878,6 +896,11 @@ void se_dev_set_default_attribs(
* max_sectors is based on subsystem plugin dependent requirements.
*/
dev->se_sub_dev->se_dev_attrib.hw_max_sectors = limits->max_hw_sectors;
/*
* Align max_sectors down to PAGE_SIZE to follow transport_allocate_data_tasks()
*/
limits->max_sectors = se_dev_align_max_sectors(limits->max_sectors,
limits->logical_block_size);
dev->se_sub_dev->se_dev_attrib.max_sectors = limits->max_sectors;
/*
* Set optimal_sectors from max_sectors, which can be lowered via
Expand Down Expand Up @@ -1242,6 +1265,11 @@ int se_dev_set_max_sectors(struct se_device *dev, u32 max_sectors)
return -EINVAL;
}
}
/*
* Align max_sectors down to PAGE_SIZE to follow transport_allocate_data_tasks()
*/
max_sectors = se_dev_align_max_sectors(max_sectors,
dev->se_sub_dev->se_dev_attrib.block_size);

dev->se_sub_dev->se_dev_attrib.max_sectors = max_sectors;
pr_debug("dev[%p]: SE Device max_sectors changed to %u\n",
Expand Down
7 changes: 5 additions & 2 deletions trunk/drivers/target/target_core_transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -4126,7 +4126,11 @@ static int transport_allocate_data_tasks(

/* Update new cdb with updated lba/sectors */
cmd->transport_split_cdb(task->task_lba, task->task_sectors, cdb);

/*
* This now assumes that passed sg_ents are in PAGE_SIZE chunks
* in order to calculate the number per task SGL entries
*/
task->task_sg_nents = DIV_ROUND_UP(task->task_size, PAGE_SIZE);
/*
* Check if the fabric module driver is requesting that all
* struct se_task->task_sg[] be chained together.. If so,
Expand All @@ -4136,7 +4140,6 @@ static int transport_allocate_data_tasks(
* It's so much easier and only a waste when task_count > 1.
* That is extremely rare.
*/
task->task_sg_nents = sgl_nents;
if (cmd->se_tfo->task_sg_chaining) {
task->task_sg_nents++;
task->task_padded_sg = 1;
Expand Down

0 comments on commit 8c47f17

Please sign in to comment.