Re: 2.3 SMP overlapping writes and NFS

David S. Miller (davem@redhat.com)
Wed, 4 Aug 1999 20:40:03 -0700


Date: Thu, 5 Aug 1999 05:27:20 +0200
From: Jamie Lokier <lkd@tantalophile.demon.co.uk>

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?

I don't see any similar wording in NFSv3 (rfc1813).

The writes are atomic at the page level, but no further.
When a write through the page cache occurs, pages are locked
while they are being updated, then the lock is released.

Essentially, if you take a gander at mm/filemap.c you'll see that the
bare-bones top-level algorithm of generic_file_write is:

for_each_page() {
page = find_page(...);
if (!page)
page = make_page_cache_entry();
/* One of the two above incremented the
* page reference count and also locked
* the page.
*/

write_one_page();
unlock(page);
page_cache_release(page);
}

So the answer is that we provide page-level atomicity at
the moment. And it's not just an SMP problem actually,
multiple threads of control can write to independant pages
at the "same time" even on uniprocessor.

Later,
David S. Miller
davem@redhat.com

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