tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: zero-filed page on VOP_PUTPAGES



On Fri, Aug 19, 2011 at 06:47:51AM +0000, YAMAMOTO Takashi wrote:
> what does FUSE protocol do to prevent unsafe reordering?
> i guess we can learn from it.

I am not sure it does anything about it. But unfortunately that bug is
not about reordering. Here is my complete anlysis of the problem:

1. file is created. Process writes to it, but thanks to page cache, no data
   gets pushed to the filesystem yet.

2. Our process uses stat(2), which sends a GETATTR. 

3. puffs_vnode_fsync strikes. It calls flushvncache/dosetattr, 
   which causes a SETATTR to be sent with the file size for the first time.
   kernal idea of the file size was set.

4. stat's GETATTR resturns before fscyn's SETATTR completes. It reports 
   the size being zero. puffs_vnop_getattr() calls uvm_vnp_setsize/vn_put.
   The filesystem reported a smaller size than kernel value, the kernel 
   therefore assume the file was truncated. vnode pages are discarded.

5. SETATTR completes for puffs_vnode_fsync. It then attemps a PUTPAGES
   which will write nothing, since data was discarded.

6. Next write find a clean vnode with no page in memory. It will cause
   a page fault, and modified page will be reloaded from filesystem using
   GETPAGE. The filesystems hands us what it has for the data that was
   never previously written: a chunk of zeroes. 

-- 
Emmanuel Dreyfus
manu%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index