From: Anton Altaparmakov <aia21@cam.ac.uk>
To: Badari Pulavarty <pbadari@us.ibm.com>
Cc: Arjan van de Ven <arjan@infradead.org>,
akpm@osdl.org, andrea@suse.de, hugh@veritas.com,
lkml <linux-kernel@vger.kernel.org>,
linux-mm <linux-mm@kvack.org>
Subject: Re: [RFC] sys_punchhole()
Date: Wed, 16 Nov 2005 16:38:49 +0000 (GMT) [thread overview]
Message-ID: <Pine.LNX.4.64.0511161630190.6470@hermes-1.csi.cam.ac.uk> (raw)
In-Reply-To: <1132157106.24066.61.camel@localhost.localdomain>
On Wed, 16 Nov 2005, Badari Pulavarty wrote:
> 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 :(
So why not tell the fs to perform the "punch" before dealing with the page
cache? If you do it in that order, a racing read(2) (or a racing mmapped
access for that matter) will see the hole, not the old data.
btw. I sometimes wonder whether it is correct for truncate to do the page
cache update before calling down into the fs for simillar reasons but I
think that it is ok after all because truncate only ever converts between
(exists/hole -> does not exist) or (does not exist -> exists as
zeroes/hole) but it never deals with (exists A -> exists B/hole) which is
what sys_punchhole does. I just had to adapt the address space operations
readpage and writepage in ntfs to cope with a read/write request outside
the end of the file which does happen when a racing truncate has extended
the file's i_size but the fs has not done the necessary metadata updates
yet...
Best regards,
Anton
--
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
prev parent reply other threads:[~2005-11-16 16:38 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-10 23:23 Badari Pulavarty
2005-11-10 23:32 ` Andrew Morton
2005-11-10 23:41 ` Badari Pulavarty
2005-11-10 23:55 ` Anton Altaparmakov
2005-11-11 8:25 ` Ingo Oeser
2005-11-11 19:07 ` Christoph Lameter
2005-11-16 12:08 ` Rob Landley
2005-11-16 12:20 ` Andrea Arcangeli
2005-11-13 15:09 ` Pavel Machek
2005-11-16 22:01 ` Badari Pulavarty
2005-11-16 23:37 ` Ric Wheeler
2005-11-21 6:46 ` Rob Landley
2005-11-18 16:42 ` Ragnar Kjørstad
2005-11-18 16:54 ` Badari Pulavarty
2005-11-11 5:18 ` Arjan van de Ven
2005-11-16 16:05 ` Badari Pulavarty
2005-11-16 16:38 ` Anton Altaparmakov [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.64.0511161630190.6470@hermes-1.csi.cam.ac.uk \
--to=aia21@cam.ac.uk \
--cc=akpm@osdl.org \
--cc=andrea@suse.de \
--cc=arjan@infradead.org \
--cc=hugh@veritas.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=pbadari@us.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox