Re: 2.3 SMP overlapping writes and NFS

Alexander Viro (viro@math.psu.edu)
Thu, 5 Aug 1999 10:19:43 -0400 (EDT)


On Thu, 5 Aug 1999, Jamie Lokier wrote:

> If two processes write to an overlapping region of a file at the same
> time, current 2.3 SMP kernels may mix the data from the two writes.
> This is a consequence of the 2.3 SMP scalability changes, am I right?

Yes, you are.

> I just spotted this in the NFSv2 spec (rfc1094)
>
> Writes "data" beginning "offset" bytes from the beginning of "file".
> The first byte of the file is at offset zero. If the reply "status"
> is NFS_OK, then the reply "attributes" contains the attributes of the
> file after the write has completed. The write operation is atomic.
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> Data from this "WRITE" will not be mixed with data from another
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> client's "WRITE".
> ^^^^^^^^^^^^^^^^
>
> NFSv2's requirements are stricter -- so I guess knfsd has to handle this
> by locking the inode during an NFSv2 write. Is this done and does
> anyone care?

It isn't done and any locking works only if everybody use it.
Probably using rwlock-style semantics (modulo sleeping, indeed - you don't
want spinlocks here) would be the right thing. Then we have write() as
reader, knfsd write() as writer and quite probably truncate() as writer
too.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/