Re: Concurrent read/writes on the same file

Jamie Lokier (lkd@tantalophile.demon.co.uk)
Fri, 11 Dec 1998 08:52:06 +0000


On Wed, Dec 09, 1998 at 11:50:02AM +0000, Stephen C. Tweedie wrote:
> On Wed, 9 Dec 1998 16:55:30 +1300, Chris Wedgwood <cw@ix.net.nz> said:
> > What about one reader and one writer -- here I assume the read is
> > locked, or do we just get trashed data? (Assuming we do, its still
> > OK, it really up to an application to not read/write to a file at the
> > same time and expect consistency).
>
> No automatic locking is done in the kernel for this case. Use kernel
> record locking with flock/fcntl if you want that: that's what it's
> there for!
>
> I've considered it more than once, but the performance penalty of
> doing range locking is too high --- it pollutes the fast path of
> accessing data in the cache --- and locking the entire inode destroys
> parallelism.

I thought one of the fundamentals was that read/write were atomic, if
they're not interrupted.

Wouldn't a per-inode rwlock_t be efficient for this? (Instead of the
current per-inode writer semaphore).

-- Jamie

-
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/