[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1228213651.7133.12.camel@twins>
Date: Tue, 02 Dec 2008 11:27:31 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: Miquel van Smoorenburg <miquels@...tron.nl>
Cc: linux-kernel@...r.kernel.org, Chris Mason <chris.mason@...cle.com>
Subject: Re: MAP_PRIVATE that stays private even on external write
On Tue, 2008-12-02 at 10:06 +0000, Miquel van Smoorenburg wrote:
> I have an application that mmaps blocks from a file and then
> sends it out over a TCP socket.
>
> The contents of the file may be overwritten while the blocks
> are sent out, but there is a very low chance of that.
>
> To prevent this, I can ofcourse just use read() all blocks into
> memory in advance, check consistency, and go ahead .. but since
> there may be a lot of network connections active this might cost
> a lot of memory.
>
> What I am looking for is a MAP_PRIVATE type flag that, when another
> process modifies pages of the file (through mmap() or write())
> makes sure that my mapping never sees that.
>
> I found out that mmap(MAP_PRIVATE|MAP_POPULATE) does exactly what
> I want, but ofcourse it reads in the entire mapping all at once,
> which is equivalent to plain read().
>
> There has been talk of a MAP_SNAPSHOT flag before, e.g.
> http://lkml.indiana.edu/hypermail/linux/kernel/0407.1/0416.htm
>
> Has anyone ever looked at implementing something like this ?
I suppose that needs a snapshot filesystem for backing, and we don't
have such a creature (yet). I suppose BTRFS might be able to pull that
off.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists