Messages in this thread | | | From | sct@dcs ... | Date | Fri, 15 Mar 96 14:17 GMT | Subject | Re: imapd and synchronous writes |
| |
Hi,
On Thu, 14 Mar 1996 08:33:22 +0100, Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de> said:
> On 13 Mar 96 at 20:49, sct@dcs.ed.ac.uk wrote:
>> You really can't just blindly assume synchronous directory updates. >> Even on systems using ffs, where directories are updated synchronously >> (currently), it is not a wise assumption, for things may change in the >> future. FreeBSD's ffs already has an option to disable sync writes, >> and the authors are looking at alternatives to sync writes which >> preserve the metadata consistency (by using either ordered async >> writes or rollback mechanisms).
> I seems that we'll need something like "opendir(..., O_SYNC)", or at > least a new mount option to default to synchronous directory (only) > writes.
Why? Not even BSD does this. If you want consistency *guarantees*, then you can enable it for the whole filesystem. If you only want it for selected inodes, then the existing ext2fs sync flag gives you this. If you want it at the application level, fsync() on a directory file descriptor works fine.
> BTW: Does "open("file", O_CREAT|O_SYNC, ...)" cause the directory > entry be written immediately, or is O_SYNC only related to the file > descriptor?
O_SYNC only affects the file descriptor, and makes no guarantees about any associated directory entries.
> Maybe the POSIX team assumed what I always thought, and therefore > forgot to specify directory writes.
No. POSIX.1 doesn't specify synchronisation to the disk at all. POSIX.4 does, but only on a per-inode basis, not extending to directory entries. The directory is a different inode, and if you want to synchronise it, the same rules apply --- you have to fd = opendir("."); fsync(fd); closedir(fd); to request an explicit sync from the application, unless the (implementation-defined) local filesystem semantics specify synchronous directory updates. AFAIK, POSIX.4 does not require fsync() to be supported for directory fd's, but it certainly doesn't forbid it.
Cheers, Stephen. -- Stephen Tweedie <sct@dcs.ed.ac.uk> Department of Computer Science, Edinburgh University, Scotland.
| |