• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: my filesystem vs Finder. "error -50" what does it mean?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: my filesystem vs Finder. "error -50" what does it mean?


  • Subject: Re: my filesystem vs Finder. "error -50" what does it mean?
  • From: Mark Day <email@hidden>
  • Date: Fri, 27 Apr 2012 15:05:13 -0700

On Apr 27, 2012, at 11:15 AM, Anatol Pomozov <email@hidden> wrote:

Anyway, the issue appeared in my fuse4x filesystem when I set VFS_TBLTHREADSAFE. After that I start seeing the issue I described in the original message. VFS_TBLTHREADSAFE effectively removes per vnode lock so VNOP operations might happens simultaneously.

If you set VFS_TBLTHREADSAFE, you must do your own locking.  You can receive multiple VNOPs for the same vnode at the same time.  You are responsible for making sure they all see a consistent state of your file system.

One thing to beware of with VFS_TBLTHREADSAFE is that operations that operate on multiple vnodes (like creating, deleting, renaming a file, directory or symlink) do not hold a lock between the time they look up the vnode(s) and the time they call the multi-vnode VNOP.  That means that other operations could have come after the lookup and before the last VNOP.

For example, VNOP_REMOVE gives you a parent vnode, child vnode, and the child's name.  By the time you get into VNOP_REMOVE, the child may no longer be a child of the given parent (i.e., it might have moved to some other directory).  The child may no longer have the same name (i.e. may have been renamed).  The child may have even been deleted since it was looked up.  So you have to check whether things are still the same as when they were looked up, and handle the case where things have changed.

It seems that after Finder copies a file it calls VNOP_GETATTR and checks the size vnop attribute. If this size does not match original size - Finder/Carbon fails with -50 error.

So why error happens with VFS_TBLTHREADSAFE flag but does not happen without it? It looks like if VFS_TBLTHREADSAFE is not set then VNOP_WRITE plus subsequent VNOP_STRATEGY executed as atomic operation, such as

VNOP_WRITE
VNOP_STRATEGY
VNOP_STRATEGY
..
VNOP_GETATTR   --- from Finder

It worth mention VNOP_STRATEGY does the actual data write to fuse filesystem. When VNOP_STRATEGY happens only then fuse filesystem is notified about the file change.

With VFS_TBLTHREADSAFE following sequence happens

VNOP_WRITE
VNOP_GETATTR   <-- return old file size
VNOP_STRATEGY
VNOP_STRATEGY

It looks like write returns to Finder but data is not written to fuse filesystem yet, data buffered in the kernel buffer cache. Then Finder checks the output file size and receives the old size - error! I was able to 'fix' the issue by caching the new file size and return in VNOP_GETATTR.

Your VNOP_WRITE handler is responsible for updating all of the metadata associated with the write.  That means making sure you have allocated enough space to store the data being written, updating the file's size (if needed), and marking the modification date for update.  At a minimum, you need to update your internal state for all of this metadata.  When you actually write this out to your underlying storage is up to you.

Your VNOP_STRATEGY handler is responsible for receiving the user data associated with a write (or returning user data associated with a read) and transferring it to your underlying storage.  Due to caching, the VNOP_STRATEGY can happen at some point after the VNOP_WRITE completes.

I'll bet you're updating the file's size in VNOP_STRATEGY, not in VNOP_WRITE.  You should update it in VNOP_WRITE instead; that sounds like what you called a 'fix'; it really is the correct fix for the problem.

-Mark

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Filesystem-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >my filesystem vs Finder. "error -50" what does it mean? (From: Anatol Pomozov <email@hidden>)
 >Re: my filesystem vs Finder. "error -50" what does it mean? (From: Jim Luther <email@hidden>)
 >Re: my filesystem vs Finder. "error -50" what does it mean? (From: Anatol Pomozov <email@hidden>)

  • Prev by Date: Re: my filesystem vs Finder. "error -50" what does it mean?
  • Previous by thread: Re: my filesystem vs Finder. "error -50" what does it mean?
  • Next by thread: Is there any way to setup a non-HFS volume sharing with AFP?
  • Index(es):
    • Date
    • Thread