Hi Linus,
On 22 Sep 2014, at 16:33, Linus Torvalds <[email protected]> wrote:
> On Mon, Sep 22, 2014 at 8:29 AM, Anton Altaparmakov <[email protected]> wrote:
>>
>> You could do "block & ~(sector_t)(size - 1)" instead of "(sector_t)index <<
>> sizebits" if you prefer but not sure that is an improvement!
>
> No, it would be even worse. Something like
>
> block & ~(sector_t)((size >> 9) - 1)
>
> because block is the sector number (ie 512-byte) and size is in bytes.
Oops, sorry. But I think you got it wrong, too as you are ignoring the
PAGE_SIZE - as was I but it is what we need to align to in addition to the
problem of "size" being in bytes. So I think the correct mask is actually
based on sizebits which reflects the number of blocks per page thus:
block & ~(sector_t)((1 << sizebits) - 1)
In any case the shift is the lesser evil I think as it is at least obviously
correct whilst getting the right mask has taken us a few iterations of
correcting each other! (-:
PS. Thank you for taking my patch and correcting the misleading description!
Best regards,
Anton
> Linus
--
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
University of Cambridge Information Services, Roger Needham Building
7 JJ Thomson Avenue, Cambridge, CB3 0RB, UK
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/