Re: Understanding max_sectors

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

 



On Wed, Mar 21, 2012 at 5:34 PM, Nicholas A. Bellinger
<nab@xxxxxxxxxxxxxxx> wrote:
> -       tmp = rounddown((max_sectors * block_size), PAGE_SIZE);
> -       aligned_max_sectors = (tmp / block_size);
> +       aligned_max_sectors = rounddown(max_sectors, PAGE_SIZE / block_size);
>
> The PAGE_SIZE / block_size calculation looks bogus to me here..

What's bogus about it?  As long as block_size is a power of 2 (which I believe
we assume many other places), it should be fine.

As a concrete example, if block_size is 512, instead of multiplying max_sectors
by 512, rounding down to the nearest 4096 and then dividing by 512 again, we
just round down to the nearest (4096/512) == 8 directly.

Basically if we want to limit the size of the IO to a PAGE_SIZE multiple, and we
are dealing in block_size sectors, we should make sure that the IO
size is limited
to be a multiple of PAGE_SIZE/block_size sectors.

It's hard to explain but I if you think about it, it becomes pretty
clear.  Clearer to
me than a 64-bit multiple followed by do_div, at least.

 - R.
--
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