Re: nfs question - ftruncate vs pwrite

From: Peter Staubach
Date: Wed Dec 07 2005 - 16:13:34 EST


Kenny Simpson wrote:

Sorry about the previous partial message...

If a file is extended via ftruncate, the new empty pages are read in before the the ftruncate
returns (taking 64mS on my machine), but if the file is extended via pwrite, nothing is read in
and the system call is very quick (34uS).

Why is there such a difference? Is there another cheap way to grow a file and map in its new
pages? Am I missing some other semantic difference between ftruncate and a pwrite past the end of
the file?


You might use tcpdump or etherreal to see what the different traffic looks
like. I suspect that ftruncate() leads a SETATTR operation while pwrite()
leads to a WRITE operation.

ps
-
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/