It works like this because the "cluster layer" in Mac OS X really wants to work in units of page size (or multiples). By default, MacFUSE also sends all writes to the user-space file system synchronously. (There are good reasons for why this is so, but the margin of this post is too small to describe them.) The user-space file system is free to deal with the writes itself, but it must respond to MacFUSE synchronously. Because of the two aforementioned reasons, you see patterns that look like "overwrites".
If you disable the buffer cache (not a good thing in general) though the -onoubc mount-time option, you should see the pattern that you were expecting (5 writes of 1024 bytes each). If you enable asynchronous writes (not at all a good thing in general) through the -onosyncwrites mount-time option, you should see a different pattern: in your example, a write of 4096 bytes followed by a 1024-byte write. This isn't problematic under normal I/O cases though, because normally things will try to keep the cluster layer happy. In your file system, you shouldn't be returning 'size' just because it works--you should be returning whatever you actually did. Rule of thumb: if you are writing a file system that supports writing, being able to deal with 4K writes at a time (even better: multiples of 4K) would lead to the best performance. Amit On Dec 8, 11:45 pm, Jason8 <[EMAIL PROTECTED]> wrote: > Hi: > > I'm working with writeFileAtPath and testing using small files to help > me debug (and implement). I'm simulating small files with dd using > this command (incrementing count as needed): > > dd if=/dev/zero of=/Volumes/myfancyfusefs/j10 bs=1024 count=5 > > Here is some info from writeFileAtPath for the 5 iterations: > > Iteration 1: size = 1024, offset=0, return=1024 (I write all data OK). > Iteration 2: size = 2048, offset=0, return=2048 (I write all data OK). > Iteration 3: size = 3072, offset=0, return=3072 (I write all data OK). > Iteration 4: size = 4096, offset=0, return=4096 (I write all data OK). > Iteration 5: size = 1024, offset=4096, return=1024 (I write all data > OK). > > My question is why does this behave like this? I'm returning 'size' > because it works, and I do write that data out. But I'm probably > overwriting it 3 of the 4 times until I get the full 4k and my offset > increases. > > Thanks, > Jason. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "MacFUSE" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/macfuse?hl=en -~----------~----~----~----~------~----~------~--~---
