Re: fsync while appending to a file
Re: fsync while appending to a file
- Subject: Re: fsync while appending to a file
- From: Terry Lambert <email@hidden>
- Date: Mon, 25 Oct 2010 12:58:18 -0700
On Oct 25, 2010, at 10:53 AM, Joel Reymont wrote:
> Will fsync stall appending to a file, assuming both operations run concurrently and use different fds that point to the same file?
>
> Thanks, Joel
It depends on the file system. For non-multithreaded filesystems, which are deprecated and unavailable on 64 bit kernels, yes.
Otherwise, it's implementation defined on a per-file system basis. For HFS, also yes, since hfs_vnop_fsync() takes an hfs_lock() exclusive on the cnode while performing the operation. For UFS, the answer would have been no. I don't have an exact survey of answers for all the file systems supported by Mac OS X.
That doesn't mean that if you are naturally racing that the append won't get in first, so if you need to ensure order of operation, for example, to ensure a database record gets written before a database index entry gets written as part of the standard two stage commit process, you should do locking anyway, rather than relying on implementation details of a particular FS.
-- Terry _______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden