Re: nfs MAP_SHARED corruption fix

2001-05-10 Thread Trond Myklebust
> " " == Marcelo Tosatti <[EMAIL PROTECTED]> writes: > I suggested the removal of I_DIRTY_PAGES check because the > current behaviour of munmap seems to be synchronous (1), so I > guess you _always_ want it to be synchronous. Revised patch (+ necessary change in ksyms.c) follo

Re: nfs MAP_SHARED corruption fix

2001-05-10 Thread Trond Myklebust
> " " == Marcelo Tosatti <[EMAIL PROTECTED]> writes: > I suggested the removal of I_DIRTY_PAGES check because the > current behaviour of munmap seems to be synchronous (1), so I > guess you _always_ want it to be synchronous. Yes. The NFS concept of close-to-open cache consist

Re: nfs MAP_SHARED corruption fix

2001-05-09 Thread Marcelo Tosatti
On Thu, 10 May 2001, Andrea Arcangeli wrote: > If some page wasn't yet visible in the dirty_pages list by the time > __sync_one started, we'll find I_DIRTY_PAGES set. This is enforced by > the locking order (sync_one first clears the I_DIRTY_PAGES and then > it starts browsing the dirty_pages l

Re: nfs MAP_SHARED corruption fix

2001-05-09 Thread Andrea Arcangeli
On Wed, May 09, 2001 at 07:38:01PM -0300, Marcelo Tosatti wrote: > > > On Thu, 10 May 2001, Andrea Arcangeli wrote: > > > On Wed, May 09, 2001 at 07:02:16PM -0300, Marcelo Tosatti wrote: > > > Why don't you clean I_DIRTY_PAGES ? > > > > we don't have visibilty on the inode_lock from there, we

Re: nfs MAP_SHARED corruption fix

2001-05-09 Thread Marcelo Tosatti
On Thu, 10 May 2001, Andrea Arcangeli wrote: > On Wed, May 09, 2001 at 07:02:16PM -0300, Marcelo Tosatti wrote: > > Why don't you clean I_DIRTY_PAGES ? > > we don't have visibilty on the inode_lock from there, we could make a > function in fs/inode.c or export the inode_lock to do that, but t

Re: nfs MAP_SHARED corruption fix

2001-05-09 Thread Andrea Arcangeli
On Wed, May 09, 2001 at 07:02:16PM -0300, Marcelo Tosatti wrote: > Why don't you clean I_DIRTY_PAGES ? we don't have visibilty on the inode_lock from there, we could make a function in fs/inode.c or export the inode_lock to do that, but the flag will be collected when the inode is released anywa

Re: nfs MAP_SHARED corruption fix

2001-05-09 Thread Marcelo Tosatti
On Wed, 9 May 2001, Trond Myklebust wrote: > > In addition to the two changes I proposed to Andrea's new patch, I > also realized we might want to do a fdatasync() when locking files. If > we don't, then locking won't be atomic on mmap()... > > Here therefore is Andrea's patch with the changes

Re: nfs MAP_SHARED corruption fix

2001-05-09 Thread Andrea Arcangeli
On Wed, May 09, 2001 at 09:30:18AM +0200, Trond Myklebust wrote: > Here therefore is Andrea's patch with the changes I propose. Opinions? flushing the dirty pages before locks is probably not required, a dirty page in the dirty_pages list is no different than a mapped page not in the dirty_pages

Re: nfs MAP_SHARED corruption fix

2001-05-09 Thread Kurt Garloff
Hi Andrea, Trond, the demo for the NFS SHARED_MAP corruption: garloff@daubechies:~/C $ uname -sr Linux 2.4.4 garloff@daubechies:~/C $ ./test_nfs_shared_map ; head -1 ./testfile; sleep 10; head -1 ./testfile Linux NFS rocks. Linux NFS sucks. Sources attached. I still have to test your fix, Tron

Re: nfs MAP_SHARED corruption fix

2001-05-09 Thread Trond Myklebust
In addition to the two changes I proposed to Andrea's new patch, I also realized we might want to do a fdatasync() when locking files. If we don't, then locking won't be atomic on mmap()... Here therefore is Andrea's patch with the changes I propose. Opinions? Cheers, Trond diff -u --recursi

Re: nfs MAP_SHARED corruption fix

2001-05-08 Thread Trond Myklebust
> " " == Andrea Arcangeli <[EMAIL PROTECTED]> writes: > On Tue, May 08, 2001 at 05:21:02PM +0200, Trond Myklebust > wrote: >> AFAICs this fix will clearly deadlock... > yeah, it didn't triggered because it probably needs to be the > same page writepaged and in the dir

Re: nfs MAP_SHARED corruption fix

2001-05-08 Thread Andrea Arcangeli
On Tue, May 08, 2001 at 05:21:02PM +0200, Trond Myklebust wrote: > AFAICs this fix will clearly deadlock... yeah, it didn't triggered because it probably needs to be the same page writepaged and in the dirty list at the same time. I hooked it very deep into the writeback logic to keep it generic

Re: nfs MAP_SHARED corruption fix

2001-05-08 Thread Kurt Garloff
On Tue, May 08, 2001 at 05:21:02PM +0200, Trond Myklebust wrote: > Could you instead detail exactly which corruption problem you are > trying to fix? int fd = open (name, O_RDWR); char* adr = (char*) mmap (0, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); /* write to *adr through *(ard+len-1) *

Re: nfs MAP_SHARED corruption fix

2001-05-08 Thread Trond Myklebust
> " " == Andrea Arcangeli <[EMAIL PROTECTED]> writes: > This fixes corruption with MAP_SHARED on top of nfs filesystem > in 2.4: > --- 2.4.5pre1aa2/fs/nfs/write.c.~1~ Tue May 1 19:35:29 2001 > +++ 2.4.5pre1aa2/fs/nfs/write.c Tue May 8 02:04:15 2001 > @@ -1533,6 +1533,

nfs MAP_SHARED corruption fix

2001-05-08 Thread Andrea Arcangeli
This fixes corruption with MAP_SHARED on top of nfs filesystem in 2.4: --- 2.4.5pre1aa2/fs/nfs/write.c.~1~ Tue May 1 19:35:29 2001 +++ 2.4.5pre1aa2/fs/nfs/write.c Tue May 8 02:04:15 2001 @@ -1533,6 +1533,7 @@ if (!inode && file) inode = file->f_dentry->d_inode; +