[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20101026222612.GB3194@thunk.org>
Date: Tue, 26 Oct 2010 18:26:12 -0400
From: Ted Ts'o <tytso@....edu>
To: Filipe David Manana <fdmanana@...che.org>
Cc: linux-ext4@...r.kernel.org
Subject: Re: question about fsync
On Mon, Oct 25, 2010 at 11:10:15PM +0100, Filipe David Manana wrote:
> Theodore, thanks for your answer.
>
> A similar question:
>
> I have 2 threads. Both open the same file, but each using its own
> (different) file descriptor.
>
> If one thread writes data past the eof (appends data), will the other
> one be able to read it with pread call (an offset past the eof it
> found when it opened the file)?
>
> I would just like to know if it's something safe to do on Linux and
> all Posix compliant platforms (and eventually Windows). (I tested this
> with non C code and it worked)
Race conditions aside, yes.
However, note that large writes are not necessarily guaranteed to be
atomic. Yes, the other thread will be able to read it with a pread
call, but if there is a race between the write() and pread(), it's
possible that pread will only read part of what has been written so
far by the write system call.
- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists