Re: [PATCH 1/2] target/rd: simplify the page/offset computation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 25 November 2011 22:18:45 +0100, Sebastian Andrzej Siewior wrote:
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
> ---
>  drivers/target/target_core_rd.c |   10 ++++------
>  1 files changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/target/target_core_rd.c b/drivers/target/target_core_rd.c
> index 7a21cbe..d42cbec 100644
> --- a/drivers/target/target_core_rd.c
> +++ b/drivers/target/target_core_rd.c
> @@ -583,14 +583,12 @@ static int rd_MEMCPY_do_task(struct se_task *task)
>  {
>  	struct se_device *dev = task->task_se_cmd->se_dev;
>  	struct rd_request *req = RD_REQ(task);
> -	unsigned long long lba;
> +	u64 tmp;
>  	int ret;
>  
> -	req->rd_page = (task->task_lba * dev->se_sub_dev->se_dev_attrib.block_size) / PAGE_SIZE;
> -	lba = task->task_lba;
> -	req->rd_offset = (do_div(lba,
> -			  (PAGE_SIZE / dev->se_sub_dev->se_dev_attrib.block_size))) *
> -			   dev->se_sub_dev->se_dev_attrib.block_size;
> +	tmp = task->task_lba * dev->se_sub_dev->se_dev_attrib.block_size;
> +	req->rd_offset = do_div(tmp, PAGE_SIZE);
> +	req->rd_page = tmp;

How about:
	byte_offset = task->task_lba * dev->se_sub_dev->se_dev_attrib.block_size;
	req->rd_offset = byte_offset & ~PAGE_MASK;
	req->rd_page = byte_offset >> PAGE_SHIFT;

>  	req->rd_size = task->task_size;
>  
>  	if (task->task_data_direction == DMA_FROM_DEVICE)

Jörn

-- 
There's nothing that will change someone's moral outlook quicker
than cash in large sums.
-- Larry Flynt
--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux SCSI]     [Kernel Newbies]     [Linux SCSI Target Infrastructure]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Device Mapper]

  Powered by Linux