Re: [RFC] sys_punchhole()

From: Badari Pulavarty
Date: Wed Nov 16 2005 - 11:05:01 EST

On Fri, 2005-11-11 at 06:18 +0100, Arjan van de Ven wrote:
> On Thu, 2005-11-10 at 15:23 -0800, Badari Pulavarty wrote:
> >
> > We discussed this in madvise(REMOVE) thread - to add support
> > for sys_punchhole(fd, offset, len) to complete the functionality
> > (in the future).
> in the past always this was said to be "really hard" in linux locking
> wise, esp. the locking with respect to truncate...
> did you find a solution to this problem ?

I have been thinking about some of the race condition we might run into.
Its hard to think all of them, when I really don't have any code to play
with :(

Anyway, I think race against truncate is fine. We hold i_alloc_sem -
which should serialize against truncates. This should also serialize
against DIO. Holding i_sem should take care of writers.

One concern I can think of is, racing with read(2). While we are
thrashing pagecache and calling filesystem to free up the blocks -
a read(2) could read old disk block and give old data (since it won't
find it in pagecache). This could become a security hole :(


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at