Race condition? while writing file without caching

66 views
Skip to first unread message

Florian Bogner

unread,
Jun 21, 2012, 5:06:57 PM6/21/12
to fus...@googlegroups.com
Hello Anatol, 
Hello everyone else ;-), 

I'm currently debugging a possible fuse4x kext bug. Maybe you can give me some hints.

We want to use the nolocalcaches option with bindfs. 
To verify the following problem I used the loopback FS from http://macfuse.googlecode.com/svn/trunk/filesystems/loopback/loopback.c

How to reproduce:
mkdir /Volumes/loop # create the mountpoint
mkdir /tmp/Test # create the test folder
sudo ./loopback /Volumes/loop -omodules=threadid:subdir,subdir=/tmp/ -oallow_other,native_xattr,volname=LoopbackFS,novncache  #mount the volume
dd if=/dev/zero of=/Volumes/loop/Test/test.img bs=8192 #write a file

Now open the folder /Volumes/loop/Test in Finder and select the file test.img (maybe you have to do it several times).
After a few tries dd stops with the following error message: Invalid argument

Conclusion
As far as I found out novncache is equivalent to noreadahead,noubc,novncache (http://linux.die.net/man/1/archivemount).
Therefore I used the following command:  
sudo ./loopback /Volumes/loop -omodules=threadid:subdir,subdir=/tmp/ -oallow_other,native_xattr,volname=LoopbackFS,noreadahead,noubc,novncache

After a few tests I found out, that novncache causes the problem. As soon as you remove it everything is working - But it's not directly causing it!
This command is working: sudo ./loopback /Volumes/loop -omodules=threadid:subdir,subdir=/tmp/ -oallow_other,native_xattr,volname=LoopbackFS,novncache

Then I looked at the fuse_isnovncache function in the fuse_internal.h file:
 /* In our model, direct_io implies no UBC. */
    return fuse_isdirectio(vp);

Using this information I changed the options to:
sudo ./loopback /Volumes/loop -omodules=threadid:subdir,subdir=/tmp/ -oallow_other,native_xattr,volname=LoopbackFS,noreadahead,noubc,direct_io

As far as I can tell it's also working! 


Do you have any hint? - What could cause this behaviour?


Kind Regards,
Florian Bogner

eMail: fbo...@gmail.com

Anatol Pomozov

unread,
Jun 21, 2012, 8:12:10 PM6/21/12
to fus...@googlegroups.com
Hi, Florian

Thanks a lot for this useful bug report. I was able to reproduce your issue easily.

Most likely it is inconsistent vncache handling in kext. There are few places where vncache is used but with different condition check (e.g. direct_io was checked if we pass vnode to the function, but did not check if mountpoint was passed).

I made several cleanup commits to vncache. I rebuilt kext and now I cannot repro the issue you have. Could you please build kext from here


and test it. Let me know the result and if you see any additional vncache issues.

Florian Bogner

unread,
Jun 22, 2012, 3:21:52 PM6/22/12
to fus...@googlegroups.com
Hello Anatol,

I'm still seeing the same issue with the newly compiled fuse4x version of the cleanup_vncache branch.

This mount still produces the Invalid argument error messages (using the same steps as below)
sudo ./loopback /Volumes/loop -omodules=threadid:subdir,subdir=/tmp/ -oallow_other,native_xattr,volname=LoopbackFS,nolocalcaches


Florian Bogner

Mobil: +43 664 82 000 30
eMail: fbo...@gmail.com
Reply all
Reply to author
Forward
0 new messages