lkml.org 
[lkml]   [1999]   [Jun]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: 2.3.7: generic_write_page(): O_APPEND & inode->i_size not SMP safe

On Tue, 22 Jun 1999, Andrea Arcangeli wrote:

> >1) if 2 threads write to an O_APPEND file, then they could write to the same
> >address:
>
> They can't write over the same page at the same time though. Anyway I am
> not sure if this is correct or not.
>
> I seen also another problem of this kind. We may have a reader that will
> read data in copy_to_user, while a writer is in the middle of the
> copy_from_user. To avoid this we need a kind of read locking over the page
> that may be shared by all readers.

this is the type of locking that the whole pagecache is _designed_ to
prevent. Why is it a problem that we see what another process writes? You
can see the same thing if you mmap() a page. _If_ user-space is not
coherent, the kernel doesnt have to be restrictive either. The page lock
only maintains page metadata coherency, not data coherency - that one is
fully up to user-space. [and read/write atomicity was never there and will
never be, just think what happens if a write() page-faults in the middle
of updating a pagecache page - this can happen on a UP box as well]

> >2) setting inode->i_size is not SMP safe.

Your fix looks good, there might be a couple of other places we missed. We
have to update filep either within the kernel lock or within the page
lock, both are sufficiently exclusive. [note that Alexander Viro is
working on SMP-threading the VFS, which will change those places that
update filep fields.]

-- mingo


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

\
 
 \ /
  Last update: 2005-03-22 13:52    [W:0.164 / U:0.200 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site