fsync() should only sync dirty blocks, and not re-write the whole directory.
> > To summarize: basically you want the directory to be synced inside the
> > fsync() of the filedescriptor (with the advantage of being able to optimize
> > the directory sync to be a partial directory sync), while others want you
> > to explicitly sync the directory filedescriptor afterwards.
>
> Which is non-portable and will not be done by many application
> programmers which just use chattr +S instead (makes things S)afe and
> S)low) - and spoil performance that way since it makes not only
> directory writes synchronous, but file (data) writes as well.
But chattr +S isn't portable either (probably a lot _less_ portable),
and as you say - a lot slower. The other issue is that even if a new
option is implemented, it will not exist for older kernels so fsync()
on the directory will be the only widely available solution for a long
time.
The other reason why "chattr +S" is so slow is that by default ext2
file attributes are inherited, so each file you create in such a
directory also has +S set, so has fully synchronous I/O. You _could_
fix this by calling the ext2 ioctl to remove the sync attribute on each
new file, but this again is _very_ non-portable and you may as well just
do fsync() on the directory at that point.
> The actual problem is the application programmer's unwillingness to
> adopt the Linux peculiarities of the file system -- chattr +S is slower
> than a dirsync mount option would be (and if it initially doesn't
> optimize directory syncs, that's fine, because chattr +S is still worse,
> and if we can get rid of chattr +S in the first place, without hacking
> up all applications that came from BSD, that's fine).
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
-- Andreas Dilger http://sourceforge.net/projects/ext2resize/ http://www-mddsp.enel.ucalgary.ca/People/adilger/- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/