Re: [PATCH] sector_t overflow in block layer
From: Linus Torvalds
Date: Thu May 18 2006 - 17:06:05 EST
On Thu, 18 May 2006, Andreas Dilger wrote:
> struct bio *bio;
> + unsigned long long sector;
> int ret = 0;
> + /* Check if we overflow sector_t when computing the sector offset. */
> + sector = (unsigned long long)bh->b_blocknr * (bh->b_size >> 9);
Ok so far, looks fine.
But what the heck is this:
> +#if !defined(CONFIG_LBD) && BITS_PER_LONG == 32
> + if (unlikely(sector != (sector_t)sector))
> + if (unlikely(((bh->b_blocknr >> 32) * (bh->b_size >> 9)) >=
> + 0xffffffff00000000ULL))
I don't understand the #ifdef at all.
Why isn't that just a
if (unlikely(sector != (sector_t)sector))
and that's it? What does this have to do with CONFIG_LBD or BITS_PER_LONG,
or anything at all?
If the sector number fits in a sector_t, we're all good.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/