[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1182354493.3768.80.camel@hurina>
Date: Wed, 20 Jun 2007 18:48:13 +0300
From: Timo Sirainen <tss@....fi>
To: linux-kernel@...r.kernel.org
Subject: Re: SMP read() stopping at memory page boundaries
On Wed, 2007-06-20 at 17:52 +0300, Timo Sirainen wrote:
> Sometimes read() returns only 4096 bytes. I'm locking the file, so I
> don't think this should ever happen, right?
Sorry, the problem was with file truncating so there's no bug with
locking. I didn't notice it first because it happened to work with
FreeBSD and Solaris.
Without locking there's a problem that I'd want to avoid, but I guess
it's not necessarily a bug (although it doesn't seem to happen with
FreeBSD or Solaris):
Process 1:
- create "foo2"
- rename() to "foo"
- lock
- write(4096 + 16 bytes)
- [fsync() here doesn't change anything]
- pwrite("1111" to offset=4096-4)
- unlock
Process 2:
- open("foo")
- read(8192 bytes)
read() sometimes returns 4096 bytes but with the "1111" already included
in the data. Is there a way to avoid this without locking the file while
reading? The "1111" tries to act as a kind of a lock.
Again attached a test program, which should really do what I
intended. :)
View attachment "concurrency.c" of type "text/x-csrc" (1718 bytes)
Download attachment "signature.asc" of type "application/pgp-signature" (190 bytes)
Powered by blists - more mailing lists