Re: SMP read() stopping at memory page boundaries

2007-06-20 Thread Jiri Kosina
On Wed, 20 Jun 2007, Timo Sirainen wrote: > > It will occur if you are reading as someone else changes the file size. > > Use file locking, it exists for a reason ;) > Annoying extra overhead. Especially with NFS, when nowadays you can't > even use flock() to create local locks.. It's not only "n

Re: SMP read() stopping at memory page boundaries

2007-06-20 Thread Timo Sirainen
On Wed, 2007-06-20 at 18:05 +0100, Alan Cox wrote: > > I thought this wouldn't happen when reading from local filesystems. > > Anyway, my real program was doing that, and it was still seeing partial > > data. But looks like I can't reproduce it in my test program with two > > pread()s, so I'll have

Re: SMP read() stopping at memory page boundaries

2007-06-20 Thread Alan Cox
> I thought this wouldn't happen when reading from local filesystems. > Anyway, my real program was doing that, and it was still seeing partial > data. But looks like I can't reproduce it in my test program with two > pread()s, so I'll have to do some more debugging. It will occur if you are readi

Re: SMP read() stopping at memory page boundaries

2007-06-20 Thread Timo Sirainen
On Wed, 2007-06-20 at 09:22 -0700, Ray Lee wrote: > On 6/20/07, Timo Sirainen <[EMAIL PROTECTED]> wrote: > > 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? > > man

Re: SMP read() stopping at memory page boundaries

2007-06-20 Thread Ray Lee
On 6/20/07, Timo Sirainen <[EMAIL PROTECTED]> wrote: 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? man 2 read read() is always allowed to return less than you asked fo

Re: SMP read() stopping at memory page boundaries

2007-06-20 Thread Timo Sirainen
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 w

SMP read() stopping at memory page boundaries

2007-06-20 Thread Timo Sirainen
Tested with various 2.6.x i386/x86-64 SMP kernels and CPUs, for example 2.6.21.3/x86-64. Process 1: - lock file - write(4096 + 16 bytes) - unlock file Process 2: - lock file - read(8192 bytes) - unlock file Sometimes read() returns only 4096 bytes. I'm locking the file, so I don't think