Re: stat64 for over 2TB file returned invalid st_blocks

From: Jörn Engel
Date: Thu Dec 01 2005 - 07:39:17 EST


On Thu, 1 December 2005 21:00:26 +0900, Takashi Sato wrote:
>
> I found a problem at stat64 on 32bit architecture.
>
> When I called stat64 for a file which is larger than 2TB, stat64
> returned an invalid number of blocks at st_blocks on 32bit
> architecture, although it returned a valid number of blocks on 64bit
> architecture(ia64).

My take was to simply hold a u64 in the fs-private inode structure and
use ULONG_MAX for inode->i_blocks in case of an overflow. Also has
the nice advantage of working with fs-sized blocks, not 512-byte ones:
inode->i_blocks = ULONG_MAX;
if (li->li_blocks<<3 < ULONG_MAX)
inode->i_blocks = li->li_blocks<<3;

That said, your solution appears to be much better, as long as it
doesnt subtly break binary compatibility.

Jörn

--
ticks = jiffies;
while (ticks == jiffies);
ticks = jiffies;
-- /usr/src/linux/init/main.c
-
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/